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

java.lang.Object
  extended by de.jaret.util.ui.timebars.model.AbstractTimeBarModel
All Implemented Interfaces:
TimeBarModel, TimeBarRowListener
Direct Known Subclasses:
DefaultTimeBarModel, StdHierarchicalTimeBarModel

public abstract class AbstractTimeBarModel
extends java.lang.Object
implements TimeBarModel, TimeBarRowListener

An abstract implementation of the TimeBarModel interface. The storage of the rows has to be added. Care has to be taken to register with the rows via the TimeBarRowListener interface. If this is ommited changes in the rows will not autmatic propagate to the TimeBarModelListeners registered with the model. The implementation must also care about the min/max fields and set them.

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

Field Summary
protected  java.util.List<TimeBarModelListener> _listenerList
          List of model listeners.
protected  de.jaret.util.date.JaretDate _maxDate
          Maximum date of the complete model.
protected  de.jaret.util.date.JaretDate _minDate
          Minimum date of the complete model.
 
Constructor Summary
AbstractTimeBarModel()
           
 
Method Summary
 void addTimeBarModelListener(TimeBarModelListener tbml)
          Add a listener to listen for changes in the model.
 void elementAdded(TimeBarRow row, de.jaret.util.date.Interval element)
          A new element was added to the row.
 void elementChanged(TimeBarRow row, de.jaret.util.date.Interval element)
          An element in the row has changed.
 void elementRemoved(TimeBarRow row, de.jaret.util.date.Interval element)
          An element was removed from the row.
protected  void fireElementAdded(TimeBarRow row, de.jaret.util.date.Interval element)
          Inform listeners about a new element in a specific row.
protected  void fireElementChanged(TimeBarRow row, de.jaret.util.date.Interval element)
          Inform listeners about a changed element in a specific row.
protected  void fireElementRemoved(TimeBarRow row, de.jaret.util.date.Interval element)
          Inform listeners about a removed element in a specific row.
protected  void fireHeaderChanged(TimeBarRow row, TimeBarRowHeader header)
          Inform listeners about a changed header.
protected  void fireModelDataChanged()
          Inform listeners about unspecific or multiple changes in the model.
protected  void fireRowAdded(TimeBarRow row)
          Inform listeners about a new row.
protected  void fireRowDataChanged(TimeBarRow row)
          Inform listeners about a changed row.
protected  void fireRowRemoved(TimeBarRow row)
          Inform listeners about a removed row.
 de.jaret.util.date.JaretDate getMaxDate()
          Retrieve tha latesr dat ein the model.
 de.jaret.util.date.JaretDate getMinDate()
          Retrieve the earliest date in the model.
 TimeBarRow getRowForInterval(de.jaret.util.date.Interval interval)
          Retrieve the TimeBarRow for a given interval.
 void headerChanged(TimeBarRow row, TimeBarRowHeader newHeader)
          The header of the row has changed.
 void remTimeBarModelListener(TimeBarModelListener tbml)
          Removes a previously added listener.
 void rowDataChanged(TimeBarRow row)
          Unspecific or multiple change of row data.
protected  void updateMinMax()
          Update the min/max date of the model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jaret.util.ui.timebars.model.TimeBarModel
getRow, getRowCount
 

Field Detail

_minDate

protected de.jaret.util.date.JaretDate _minDate
Minimum date of the complete model.


_maxDate

protected de.jaret.util.date.JaretDate _maxDate
Maximum date of the complete model.


_listenerList

protected java.util.List<TimeBarModelListener> _listenerList
List of model listeners.

Constructor Detail

AbstractTimeBarModel

public AbstractTimeBarModel()
Method Detail

getMinDate

public de.jaret.util.date.JaretDate getMinDate()
Retrieve the earliest date in the model.

Specified by:
getMinDate in interface TimeBarModel
Returns:
earliest date in the model

getMaxDate

public de.jaret.util.date.JaretDate getMaxDate()
Retrieve tha latesr dat ein the model.

Specified by:
getMaxDate in interface TimeBarModel
Returns:
the latest date in the model

getRowForInterval

public TimeBarRow getRowForInterval(de.jaret.util.date.Interval interval)
Retrieve the TimeBarRow for a given interval. This default implementation is a brute force implementation. Real implementation should override the default implementation if the data model contains a reference to improve performance.

Specified by:
getRowForInterval in interface TimeBarModel
Parameters:
interval - interval to gt the row for.
Returns:
TimeBarRow that contains the interval or null if no row could be determined.

addTimeBarModelListener

public void addTimeBarModelListener(TimeBarModelListener tbml)
Add a listener to listen for changes in the model.

Specified by:
addTimeBarModelListener in interface TimeBarModel
Parameters:
tbml - TimeBarModelListener for watching the model

remTimeBarModelListener

public void remTimeBarModelListener(TimeBarModelListener tbml)
Removes a previously added listener.

Specified by:
remTimeBarModelListener in interface TimeBarModel
Parameters:
tbml - TimeBarModelListener to be removed

fireModelDataChanged

protected void fireModelDataChanged()
Inform listeners about unspecific or multiple changes in the model. Do use the more specific methods if possible.


fireRowAdded

protected void fireRowAdded(TimeBarRow row)
Inform listeners about a new row.

Parameters:
row - new row

fireRowRemoved

protected void fireRowRemoved(TimeBarRow row)
Inform listeners about a removed row.

Parameters:
row - removed row

fireRowDataChanged

protected void fireRowDataChanged(TimeBarRow row)
Inform listeners about a changed row.

Parameters:
row - changed row

fireHeaderChanged

protected void fireHeaderChanged(TimeBarRow row,
                                 TimeBarRowHeader header)
Inform listeners about a changed header.

Parameters:
row - row
header - header

fireElementChanged

protected void fireElementChanged(TimeBarRow row,
                                  de.jaret.util.date.Interval element)
Inform listeners about a changed element in a specific row.

Parameters:
row - row of the element
element - changed element

fireElementAdded

protected void fireElementAdded(TimeBarRow row,
                                de.jaret.util.date.Interval element)
Inform listeners about a new element in a specific row.

Parameters:
row - row of the element
element - new element

fireElementRemoved

protected void fireElementRemoved(TimeBarRow row,
                                  de.jaret.util.date.Interval element)
Inform listeners about a removed element in a specific row.

Parameters:
row - row of the element
element - removed element

elementAdded

public void elementAdded(TimeBarRow row,
                         de.jaret.util.date.Interval element)
A new element was added to the row.

Specified by:
elementAdded in interface TimeBarRowListener
Parameters:
row - the changed row
element - the new interval in the row

elementRemoved

public void elementRemoved(TimeBarRow row,
                           de.jaret.util.date.Interval element)
An element was removed from the row.

Specified by:
elementRemoved in interface TimeBarRowListener
Parameters:
row - the changed row
element - the removed element

elementChanged

public void elementChanged(TimeBarRow row,
                           de.jaret.util.date.Interval element)
An element in the row has changed.

Specified by:
elementChanged in interface TimeBarRowListener
Parameters:
row - the row of the changed element
element - the changed interval

headerChanged

public void headerChanged(TimeBarRow row,
                          TimeBarRowHeader newHeader)
The header of the row has changed.

Specified by:
headerChanged in interface TimeBarRowListener
Parameters:
row - the row containing the header.
newHeader - the new or updated header object

rowDataChanged

public void rowDataChanged(TimeBarRow row)
Unspecific or multiple change of row data. This method should not be used without the need for signalling an unspecific data change.

Specified by:
rowDataChanged in interface TimeBarRowListener
Parameters:
row - the changed row

updateMinMax

protected void updateMinMax()
Update the min/max date of the model.



Copyright © 2012. All Rights Reserved.