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

java.lang.Object
  extended by de.jaret.util.ui.timebars.model.AbstractTimeBarModel
      extended by de.jaret.util.ui.timebars.model.StdHierarchicalTimeBarModel
All Implemented Interfaces:
HierarchicalViewStateListener, TimeBarModel, TimeBarNodeListener, TimeBarRowListener

public class StdHierarchicalTimeBarModel
extends AbstractTimeBarModel
implements HierarchicalViewStateListener, TimeBarNodeListener

An implementation of of a "normal" TimeBarModel based on a hierarchical model and a viewstate. Intended for internal use when using a hierarchical model. MAYBE Filter some of the events out of the node for visibility (will not hurt if not ...)

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

Field Summary
protected  boolean _hideRoot
          if set to true the roor node will be seen expanded and will not be represented by a row.
protected  HierarchicalTimeBarModel _hModel
          the underlying hierarchical model.
protected  HierarchicalViewState _hvs
          hierarchical viewstate holding the folded/unfolded information.
protected  java.util.List<TimeBarNode> _rows
          list of timebar nodes (that are the rows of the model).
 
Fields inherited from class de.jaret.util.ui.timebars.model.AbstractTimeBarModel
_listenerList, _maxDate, _minDate
 
Constructor Summary
StdHierarchicalTimeBarModel(HierarchicalTimeBarModel hModel, HierarchicalViewState hvs)
          Construct a new model.
 
Method Summary
 boolean getHideRoot()
          Retrieve whether the root node is included in the outgoing model.
 TimeBarNode getNextSibling(TimeBarNode node)
          Retrieve the next sibling of a given node.
 TimeBarRow getRow(int rowIdx)
          Return the row for the given index.
 int getRowCount()
          Get the number of rows in the model.
 boolean moreSiblings(TimeBarNode node, int level)
          Check whether there are sibling nodes for a given node on a specified level.
 void nodeAdded(TimeBarNode parent, TimeBarNode newChild)
          Called when a node has been added.
 void nodeExpanded(TimeBarNode node)
          Handle expansion of a node.
 int nodeExpanded2(TimeBarNode node)
          Handle expansion of a node.
 void nodeFolded(TimeBarNode node)
          Handle folding of a node.
 void nodeRemoved(TimeBarNode parent, TimeBarNode removedChild)
          Called whenever a node is removed.
 void setHideRoot(boolean hideRoot)
          Set whether the root node should be represented in the flat outgoing model.
 
Methods inherited from class de.jaret.util.ui.timebars.model.AbstractTimeBarModel
addTimeBarModelListener, elementAdded, elementChanged, elementRemoved, fireElementAdded, fireElementChanged, fireElementRemoved, fireHeaderChanged, fireModelDataChanged, fireRowAdded, fireRowDataChanged, fireRowRemoved, getMaxDate, getMinDate, getRowForInterval, headerChanged, remTimeBarModelListener, rowDataChanged, updateMinMax
 
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.TimeBarRowListener
elementAdded, elementChanged, elementRemoved, headerChanged, rowDataChanged
 

Field Detail

_rows

protected java.util.List<TimeBarNode> _rows
list of timebar nodes (that are the rows of the model). The list contains always only the visible nodes.


_hModel

protected HierarchicalTimeBarModel _hModel
the underlying hierarchical model.


_hvs

protected HierarchicalViewState _hvs
hierarchical viewstate holding the folded/unfolded information.


_hideRoot

protected boolean _hideRoot
if set to true the roor node will be seen expanded and will not be represented by a row.

Constructor Detail

StdHierarchicalTimeBarModel

public StdHierarchicalTimeBarModel(HierarchicalTimeBarModel hModel,
                                   HierarchicalViewState hvs)
Construct a new model.

Parameters:
hModel - hierachical model
hvs - hierarchical viewstate
Method Detail

moreSiblings

public boolean moreSiblings(TimeBarNode node,
                            int level)
Check whether there are sibling nodes for a given node on a specified level.

Parameters:
node - node to check
level - level
Returns:
true if the node itself has more siblings on the given level or if there are nodes on the given level

getNextSibling

public TimeBarNode getNextSibling(TimeBarNode node)
Retrieve the next sibling of a given node.

Parameters:
node - node to search sibling for
Returns:
next sibling or null if none could be found

getRow

public TimeBarRow getRow(int rowIdx)
Return the row for the given index.

Specified by:
getRow in interface TimeBarModel
Parameters:
rowIdx - index of the row
Returns:
the row for the given index

getRowCount

public int getRowCount()
Get the number of rows in the model.

Specified by:
getRowCount in interface TimeBarModel
Returns:
number of rows

nodeAdded

public void nodeAdded(TimeBarNode parent,
                      TimeBarNode newChild)
Called when a node has been added.

Specified by:
nodeAdded in interface TimeBarNodeListener
Parameters:
parent - Parent of the new node.
newChild - the new node.

nodeRemoved

public void nodeRemoved(TimeBarNode parent,
                        TimeBarNode removedChild)
Called whenever a node is removed.

Specified by:
nodeRemoved in interface TimeBarNodeListener
Parameters:
parent - parent of the removed node.
removedChild - the removed node.

nodeExpanded

public void nodeExpanded(TimeBarNode node)
Handle expansion of a node. This means adding all rows that become visible when expanding.

Specified by:
nodeExpanded in interface HierarchicalViewStateListener
Parameters:
node - the has been expanded

nodeExpanded2

public int nodeExpanded2(TimeBarNode node)
Handle expansion of a node. This means adding all rows that become visible when expanding.

Parameters:
node - the has been expanded
Returns:
number of added rows (that became visible)

nodeFolded

public void nodeFolded(TimeBarNode node)
Handle folding of a node. This means removing all rows that "disappear" with folding.

Specified by:
nodeFolded in interface HierarchicalViewStateListener
Parameters:
node - node that has been folded

getHideRoot

public boolean getHideRoot()
Retrieve whether the root node is included in the outgoing model.

Returns:
true when the root node is included in the resulting flat model

setHideRoot

public void setHideRoot(boolean hideRoot)
Set whether the root node should be represented in the flat outgoing model.

Parameters:
hideRoot - set to true if the root node should not be included in the outgoing flat model


Copyright © 2012. All Rights Reserved.