JIDE 3.5.15

com.jidesoft.treemap
Class AbstractTreeMapModel<N extends MutableTreeMapNode>

java.lang.Object
  extended by com.jidesoft.treemap.AbstractTreeMapModel<N>
Type Parameters:
N - the type of nodes
All Implemented Interfaces:
TreeMapModel<N>
Direct Known Subclasses:
DefaultTreeMapModel

public abstract class AbstractTreeMapModel<N extends MutableTreeMapNode>
extends Object
implements TreeMapModel<N>

This class provides a skeletal implementation of the TreeMapModel interface to minimize the effort required to implement this interface.


Nested Class Summary
 class AbstractTreeMapModel.Worker
           
 
Field Summary
protected  TreeMapSettings _settings
           
static String PROPERTY_HIGHLIGHTING
           
static String PROPERTY_PROBING
           
static String PROPERTY_SELECTION
           
 
Fields inherited from interface com.jidesoft.treemap.TreeMapModel
PROPERTY_PROGRESS
 
Constructor Summary
AbstractTreeMapModel()
           
 
Method Summary
 void addListener(TreeMapListener treeMapListener)
          Add a listener for receiving interesting events about changes in the model.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list for a specific property.
 Iterable<N> breadthFirstIterator(N parent)
          Creates and returns an iterable that traverses the subhierarchy rooted at the give node in breadth-first order.
protected  void computeSize(N node, TreeMapWorker worker)
           
protected abstract  N createRootNode(TreeMapField<N> groupByField)
           
protected  TreeMapSettings createSettings()
          
 Iterable<N> depthFirstIterator(N parent)
          Creates and returns an iterable that traverses the subhierarchy rooted at the give node in depth-first order.
protected  boolean doColors(N parent, TreeMapWorker worker)
          
protected abstract  boolean doGroupBy(N parent, TreeMapWorker worker)
           
protected  boolean doLayout(N parent, TreeMapWorker worker)
          
protected  boolean doLayoutChildren(N parent, TreeMapWorker worker)
           
protected  void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
          Support for reporting bound property changes for boolean properties.
protected  void firePropertyChange(String propertyName, int oldValue, int newValue)
          Support for reporting bound property changes for integer properties.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Support for reporting bound property changes for Object properties.
 ComboBoxModel getBackgroundModel()
           
 Rectangle2D getBounds(N node)
          Gets the bounding rectangle of the item in the map.
 TreeMapField<N> getChildrenGroupByField(N node)
          Gets the depth in hierarchy.
 ComboBoxModel getColorModel()
           
 N getCurrentRoot()
          Gets the currently selected root node from which the treemap should be displayed.
 MutableValueFilter<N> getFilter()
          Obtains the model used for filtering nodes in the treemap.
 TreeMapField<N> getGroupByField(N node)
          Gets the depth in hierarchy.
 ComboBoxModel getGroupByModel()
           
 ComboBoxModel getHeightModel()
           
 List<N> getHighlighting()
          Obtains the model used to highlight nodes in the treemap.
 ComboBoxModel getLabelModel()
           
 int getLevel(N node)
          Gets the depth in hierarchy.
 N getNode(Point p)
          
 double getNormalizedLightSourceX()
          Gets the the position of the light source along the X axis.
 double getNormalizedLightSourceY()
          Gets the the position of the light source along the Y axis.
 double getNormalizedLightSourceZ()
          Gets the the position of the light source along the Z axis.
 N getProbing()
          Obtains the model used for probing (aka mouse over).
 PropertyChangeListener[] getPropertyChangeListeners()
          Returns an array of all the property change listeners registered on this component.
 PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
          Returns an array of all the listeners which have been associated with the named property.
 N getRoot()
          Returns the root node of the treemap.
 MutableValueFilter<N> getSearch()
          Obtains the model used to carry out search in the treemap.
 List<N> getSelection()
          Obtains the model used for selecting nodes in the treemap.
 TreeMapSettings getSettings()
          Gets the settings currently selected.
 Shape getShape(N node)
          Gets the shape of the item in the map.
 double getSize(N node)
          Corresponds to area in map.
 ComboBoxModel getSizeModel()
           
 String getStringValue(N node, TreeMapField field)
          Returns the string value for the cell at columnIndex and of node.
protected  double getSumSize(N node)
           
protected  TreeMapField[] getTreeMapFields(int... columns)
           
protected  TreeMapField[] getTreeMapFields(String... columnNames)
           
protected  Rectangle getViewport()
           
 TreeMapWorker getWorker()
          Gets the worker task updating the layout.
 Future<Void> getWorkerFuture()
          Gets the worker task updating the layout.
protected  void initDefaults()
           
 boolean isLeaf(N node)
          Tells whether the given node is a leaf node or not.
 Iterable<N> preorderEnumeration(N parent)
          Creates and returns an iterable that traverses the subhierarchy rooted at the give node in preorder.
 void removeListener(TreeMapListener treeMapListener)
          Remove a listener from the list of listeners that should be notified about changes in the model.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list for a specific property.
protected  void scheduleUpdateColors()
           
protected  void scheduleUpdateGroupBy()
           
protected  void scheduleUpdateLayout()
           
 void setColor(AbstractTreeMapNode node, Color color)
          
 void setCurrentRoot(N currentRoot)
          Sets the currently selected root node from which the treemap should be displayed.
 void setHighlighting(List<N> highlighting)
           
 void setProbing(N probing)
           
 void setSelection(List<N> selection)
           
 void setShape(N node, Shape shape)
          Sets the shape of the item in the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jidesoft.treemap.TreeMapModel
createDefaultColorMap, getChildCount, getChildren, getColor, getColumnClass, getColumnCount, getColumnName, getCushionColor, getCushionImage, getLabelName, getNumericMax, getNumericMin, getParent, getTreeMapField, getTreeMapField, getValueAt, isEveryValueUnique, isRoot, setColor, setNumericMax, setNumericMin
 

Field Detail

PROPERTY_PROBING

public static final String PROPERTY_PROBING
See Also:
Constant Field Values

PROPERTY_HIGHLIGHTING

public static final String PROPERTY_HIGHLIGHTING
See Also:
Constant Field Values

PROPERTY_SELECTION

public static final String PROPERTY_SELECTION
See Also:
Constant Field Values

_settings

protected final TreeMapSettings _settings
Constructor Detail

AbstractTreeMapModel

public AbstractTreeMapModel()
Method Detail

initDefaults

protected void initDefaults()

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list.

Specified by:
addPropertyChangeListener in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
listener - the PropertyChangeListener to be added
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(), addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Specified by:
removePropertyChangeListener in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(), removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.

Returns:
all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered
Since:
1.4
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), removePropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(java.lang.String), PropertyChangeSupport.getPropertyChangeListeners()

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property.

Specified by:
addPropertyChangeListener in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
propertyName - one of the property names listed above
listener - the PropertyChangeListener to be added
See Also:
removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), getPropertyChangeListeners(java.lang.String), addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

If listener is null, no exception is thrown and no action is performed.

Specified by:
removePropertyChangeListener in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
propertyName - a valid property name
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), getPropertyChangeListeners(java.lang.String), removePropertyChangeListener(java.beans.PropertyChangeListener)

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property.

Parameters:
propertyName - the property name
Returns:
all of the PropertyChangeListeners associated with the named property or an empty array if no listeners have been added
Since:
1.4
See Also:
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), getPropertyChangeListeners()

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  boolean oldValue,
                                  boolean newValue)
Support for reporting bound property changes for boolean properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  int oldValue,
                                  int newValue)
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

createSettings

protected TreeMapSettings createSettings()


getProbing

public N getProbing()
Description copied from interface: TreeMapModel
Obtains the model used for probing (aka mouse over).

Specified by:
getProbing in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the model used for probing.

setProbing

public void setProbing(N probing)
Specified by:
setProbing in interface TreeMapModel<N extends MutableTreeMapNode>

getHighlighting

public List<N> getHighlighting()
Description copied from interface: TreeMapModel
Obtains the model used to highlight nodes in the treemap.

Specified by:
getHighlighting in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the model used for highlighting.

setHighlighting

public void setHighlighting(List<N> highlighting)
Specified by:
setHighlighting in interface TreeMapModel<N extends MutableTreeMapNode>

getFilter

public MutableValueFilter<N> getFilter()
Description copied from interface: TreeMapModel
Obtains the model used for filtering nodes in the treemap.

Specified by:
getFilter in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the model used for filtering.

getSelection

public List<N> getSelection()
Description copied from interface: TreeMapModel
Obtains the model used for selecting nodes in the treemap.

Specified by:
getSelection in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the model used for selection.

setSelection

public void setSelection(List<N> selection)
Specified by:
setSelection in interface TreeMapModel<N extends MutableTreeMapNode>

getSearch

public MutableValueFilter<N> getSearch()
Description copied from interface: TreeMapModel
Obtains the model used to carry out search in the treemap.

Specified by:
getSearch in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the model used for searching.

getSettings

public TreeMapSettings getSettings()
Description copied from interface: TreeMapModel
Gets the settings currently selected.

Specified by:
getSettings in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the settings.

getStringValue

public String getStringValue(N node,
                             TreeMapField field)
Description copied from interface: TreeMapModel
Returns the string value for the cell at columnIndex and of node.

Specified by:
getStringValue in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node whose value is to be queried
field - the field whose value is to be queried
Returns:
the value Object at the specified cell

setCurrentRoot

public void setCurrentRoot(N currentRoot)
Description copied from interface: TreeMapModel
Sets the currently selected root node from which the treemap should be displayed.

Specified by:
setCurrentRoot in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
currentRoot - the root node to use for display.

getCurrentRoot

public N getCurrentRoot()
Description copied from interface: TreeMapModel
Gets the currently selected root node from which the treemap should be displayed.

Specified by:
getCurrentRoot in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the currently selected root node.

getRoot

public N getRoot()
Description copied from interface: TreeMapModel
Returns the root node of the treemap.

Specified by:
getRoot in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the root node.

createRootNode

protected abstract N createRootNode(TreeMapField<N> groupByField)

scheduleUpdateGroupBy

protected void scheduleUpdateGroupBy()

scheduleUpdateLayout

protected void scheduleUpdateLayout()

scheduleUpdateColors

protected void scheduleUpdateColors()

getNormalizedLightSourceX

public double getNormalizedLightSourceX()
Description copied from interface: TreeMapModel
Gets the the position of the light source along the X axis.

Specified by:
getNormalizedLightSourceX in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the position along the X axis.

getNormalizedLightSourceY

public double getNormalizedLightSourceY()
Description copied from interface: TreeMapModel
Gets the the position of the light source along the Y axis.

Specified by:
getNormalizedLightSourceY in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the position along the Y axis.

getNormalizedLightSourceZ

public double getNormalizedLightSourceZ()
Description copied from interface: TreeMapModel
Gets the the position of the light source along the Z axis.

Specified by:
getNormalizedLightSourceZ in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the position along the Z axis.

preorderEnumeration

public Iterable<N> preorderEnumeration(N parent)
Description copied from interface: TreeMapModel
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in preorder. The first node returned by the iterator's next() method is the given node.

Specified by:
preorderEnumeration in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
parent - the root of the hierarchy to traverse
Returns:
an iterable that traverses the subtree rooted at this node in preorder.

breadthFirstIterator

public Iterable<N> breadthFirstIterator(N parent)
Description copied from interface: TreeMapModel
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in breadth-first order. The first node returned by the iterator's next() method is the given node.

Specified by:
breadthFirstIterator in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
parent - the root of the hierarchy to traverse
Returns:
an iterable that traverses the subtree rooted at this node in breadth-first order.

depthFirstIterator

public Iterable<N> depthFirstIterator(N parent)
Description copied from interface: TreeMapModel
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in depth-first order. The first node returned by the iterator's next() method is the leftmost leaf.

Specified by:
depthFirstIterator in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
parent - the root of the hierarchy to traverse
Returns:
an iterable that traverses the subtree rooted at this node in depth-first order.

addListener

public void addListener(TreeMapListener treeMapListener)
Description copied from interface: TreeMapModel
Add a listener for receiving interesting events about changes in the model.

Specified by:
addListener in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
treeMapListener - the listener to add.

removeListener

public void removeListener(TreeMapListener treeMapListener)
Description copied from interface: TreeMapModel
Remove a listener from the list of listeners that should be notified about changes in the model.

Specified by:
removeListener in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
treeMapListener - the listener to remove.

getTreeMapFields

protected TreeMapField[] getTreeMapFields(int... columns)

getTreeMapFields

protected TreeMapField[] getTreeMapFields(String... columnNames)

doGroupBy

protected abstract boolean doGroupBy(N parent,
                                     TreeMapWorker worker)

doLayout

protected boolean doLayout(N parent,
                           TreeMapWorker worker)


getViewport

protected Rectangle getViewport()

computeSize

protected void computeSize(N node,
                           TreeMapWorker worker)

doLayoutChildren

protected boolean doLayoutChildren(N parent,
                                   TreeMapWorker worker)

getSumSize

protected double getSumSize(N node)

doColors

protected boolean doColors(N parent,
                           TreeMapWorker worker)


getSize

public double getSize(N node)
Corresponds to area in map.

Specified by:
getSize in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node.
Returns:
the area

setShape

public void setShape(N node,
                     Shape shape)
Sets the shape of the item in the map.

Specified by:
setShape in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node.
shape - the shape of the item in the map.

getShape

public Shape getShape(N node)
Gets the shape of the item in the map.

Specified by:
getShape in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node.
Returns:
the shape of the item in the map.

getBounds

public Rectangle2D getBounds(N node)
Gets the bounding rectangle of the item in the map.

Specified by:
getBounds in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node.
Returns:
the bounding rectangle of the item in the map.

getLevel

public int getLevel(N node)
Gets the depth in hierarchy.

Specified by:
getLevel in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node.
Returns:
the depth in hierarchy.

getGroupByField

public TreeMapField<N> getGroupByField(N node)
Description copied from interface: TreeMapModel
Gets the depth in hierarchy.

Specified by:
getGroupByField in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node.
Returns:
the depth in hierarchy.

getChildrenGroupByField

public TreeMapField<N> getChildrenGroupByField(N node)
Description copied from interface: TreeMapModel
Gets the depth in hierarchy.

Specified by:
getChildrenGroupByField in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node.
Returns:
the depth in hierarchy.

isLeaf

public boolean isLeaf(N node)
Tells whether the given node is a leaf node or not.

Specified by:
isLeaf in interface TreeMapModel<N extends MutableTreeMapNode>
Parameters:
node - the node
Returns:
true if it is a leaf node, false otherwise.

setColor

public void setColor(AbstractTreeMapNode node,
                     Color color)


getWorker

public TreeMapWorker getWorker()
Description copied from interface: TreeMapModel
Gets the worker task updating the layout.

Specified by:
getWorker in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the worker task

getWorkerFuture

public Future<Void> getWorkerFuture()
Description copied from interface: TreeMapModel
Gets the worker task updating the layout.

Specified by:
getWorkerFuture in interface TreeMapModel<N extends MutableTreeMapNode>
Returns:
the worker task

getGroupByModel

public ComboBoxModel getGroupByModel()
Specified by:
getGroupByModel in interface TreeMapModel<N extends MutableTreeMapNode>

getLabelModel

public ComboBoxModel getLabelModel()
Specified by:
getLabelModel in interface TreeMapModel<N extends MutableTreeMapNode>

getBackgroundModel

public ComboBoxModel getBackgroundModel()
Specified by:
getBackgroundModel in interface TreeMapModel<N extends MutableTreeMapNode>

getSizeModel

public ComboBoxModel getSizeModel()
Specified by:
getSizeModel in interface TreeMapModel<N extends MutableTreeMapNode>

getHeightModel

public ComboBoxModel getHeightModel()
Specified by:
getHeightModel in interface TreeMapModel<N extends MutableTreeMapNode>

getColorModel

public ComboBoxModel getColorModel()
Specified by:
getColorModel in interface TreeMapModel<N extends MutableTreeMapNode>

getNode

public N getNode(Point p)

Specified by:
getNode in interface TreeMapModel<N extends MutableTreeMapNode>

JIDE 3.5.15