de.jaret.util.ui.timebars.model
Class AbstractTimeBarRowModel

java.lang.Object
  extended by de.jaret.util.ui.timebars.model.AbstractTimeBarRowModel
All Implemented Interfaces:
TimeBarRow, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
AbstractTimeBarNode, AddingTimeBarRowModel, DefaultTimeBarRowModel

public abstract class AbstractTimeBarRowModel
extends java.lang.Object
implements TimeBarRow, java.beans.PropertyChangeListener

An abstract base implementation of the TimeBarRow interface. The part to implement is the storage and retrieval of the intervals in the row. Care has to be taken to update the min/max date fields with the intervals. Implementations for some additional methods are given, but are not guaranteed to be optimal (in fact they are not!).

Version:
$Id: AbstractTimeBarRowModel.java 800 2008-12-27 22:27:33Z kliem $
Author:
Peter Kliem

Field Summary
protected  TimeBarRowHeader _header
          the row header of the row.
protected  java.util.List<TimeBarRowListener> _listenerList
          the registered listeners.
protected  de.jaret.util.date.JaretDate _maxDate
          the maximum date of all intervals.
protected  de.jaret.util.date.JaretDate _minDate
          the minimum date of all intervals.
 
Constructor Summary
AbstractTimeBarRowModel()
          Default constructor.
AbstractTimeBarRowModel(TimeBarRowHeader header)
          onstructor supplying a header.
 
Method Summary
 void addTimeBarRowListener(TimeBarRowListener tbrl)
          Register a TimeBarRowListener for listening to changes in the row.
protected  void fireElementAdded(de.jaret.util.date.Interval element)
          Inform listeners that a new interval has been added.
protected  void fireElementChanged(de.jaret.util.date.Interval element)
          Inform listeners that an element has changed.
protected  void fireElementRemoved(de.jaret.util.date.Interval element)
          Inform listeners that an interval has been removed.
protected  void fireHeaderChanged()
          Inform listeners about a chnage of the header.
protected  void fireRowDataChanged()
          Inform listeners that all row data may have changed.
abstract  java.util.List<de.jaret.util.date.Interval> getIntervals()
          Provide the full ordered list of intervals.
 java.util.List<de.jaret.util.date.Interval> getIntervals(de.jaret.util.date.JaretDate date)
          Returns all intervals containing the given date.
 java.util.List<de.jaret.util.date.Interval> getIntervals(de.jaret.util.date.JaretDate beginDate, de.jaret.util.date.JaretDate endDate)
          Provide the intervals in beetween a given interval.
 de.jaret.util.date.JaretDate getMaxDate()
          Return the ending date of the latest interval in the row.
 de.jaret.util.date.JaretDate getMinDate()
          Return the beginning date of the earliest interval in the row.
 TimeBarRowHeader getRowHeader()
          Return the row header.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Handle property changes of the intervals in the row and of the header.
 void remTimeBarRowListener(TimeBarRowListener tbrl)
          Remove a previously added TimeBarRowListener.
 void setRowHeader(TimeBarRowHeader header)
          Set the row header.
protected  void updateMinMax()
          Updates the minimum and the maximum dates that may be queried by users of the row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_header

protected TimeBarRowHeader _header
the row header of the row.


_minDate

protected de.jaret.util.date.JaretDate _minDate
the minimum date of all intervals. This should always be up to date by updating.


_maxDate

protected de.jaret.util.date.JaretDate _maxDate
the maximum date of all intervals. This should always be up to date by updating.


_listenerList

protected java.util.List<TimeBarRowListener> _listenerList
the registered listeners.

Constructor Detail

AbstractTimeBarRowModel

public AbstractTimeBarRowModel()
Default constructor. Note that a header should be set.


AbstractTimeBarRowModel

public AbstractTimeBarRowModel(TimeBarRowHeader header)
onstructor supplying a header.

Parameters:
header - row header to be used
Method Detail

getIntervals

public abstract java.util.List<de.jaret.util.date.Interval> getIntervals()
Provide the full ordered list of intervals. Remains abstract and has to implemented.

Specified by:
getIntervals in interface TimeBarRow
Returns:
an ordered List of Intervals

getIntervals

public java.util.List<de.jaret.util.date.Interval> getIntervals(de.jaret.util.date.JaretDate beginDate,
                                                                de.jaret.util.date.JaretDate endDate)
Provide the intervals in beetween a given interval. An interval should be selected as inside the given bounds if it is in between the bounds or one of the bounds is in the interval in question. Very simple (imperformant) implementation.

Specified by:
getIntervals in interface TimeBarRow
Parameters:
beginDate - first date
endDate - last date
Returns:
ordered List of Intervals between the given dates

getIntervals

public java.util.List<de.jaret.util.date.Interval> getIntervals(de.jaret.util.date.JaretDate date)
Returns all intervals containing the given date.

Specified by:
getIntervals in interface TimeBarRow
Parameters:
date - the date to be included in the intervals
Returns:
List of intervals containing the given date

getRowHeader

public TimeBarRowHeader getRowHeader()
Return the row header.

Specified by:
getRowHeader in interface TimeBarRow
Returns:
row header

setRowHeader

public void setRowHeader(TimeBarRowHeader header)
Set the row header.

Parameters:
header - header to set

addTimeBarRowListener

public void addTimeBarRowListener(TimeBarRowListener tbrl)
Register a TimeBarRowListener for listening to changes in the row.

Specified by:
addTimeBarRowListener in interface TimeBarRow
Parameters:
tbrl - TimeBarRowListener to be added

remTimeBarRowListener

public void remTimeBarRowListener(TimeBarRowListener tbrl)
Remove a previously added TimeBarRowListener.

Specified by:
remTimeBarRowListener in interface TimeBarRow
Parameters:
tbrl - TimeBarRowListener to be removed

fireRowDataChanged

protected void fireRowDataChanged()
Inform listeners that all row data may have changed.


fireElementAdded

protected void fireElementAdded(de.jaret.util.date.Interval element)
Inform listeners that a new interval has been added.

Parameters:
element - added interval

fireElementRemoved

protected void fireElementRemoved(de.jaret.util.date.Interval element)
Inform listeners that an interval has been removed.

Parameters:
element - removed interval

fireElementChanged

protected void fireElementChanged(de.jaret.util.date.Interval element)
Inform listeners that an element has changed.

Parameters:
element - changed interval

fireHeaderChanged

protected void fireHeaderChanged()
Inform listeners about a chnage of the header.


getMaxDate

public de.jaret.util.date.JaretDate getMaxDate()
Description copied from interface: TimeBarRow
Return the ending date of the latest interval in the row. A row may return null if it contains no intervals. If a row supplies a max date it must always supply a min date.

Specified by:
getMaxDate in interface TimeBarRow
Returns:
Returns the maxDate.

getMinDate

public de.jaret.util.date.JaretDate getMinDate()
Description copied from interface: TimeBarRow
Return the beginning date of the earliest interval in the row. A row may return null if it contains no intervals. If a row supplies a min date it must always supply a max value.

Specified by:
getMinDate in interface TimeBarRow
Returns:
Returns the minDate.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Handle property changes of the intervals in the row and of the header.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - propChange event from the model elements

updateMinMax

protected void updateMinMax()
Updates the minimum and the maximum dates that may be queried by users of the row.



Copyright © 2012. All Rights Reserved.