Package com.treemap
Class AbstractTreeMapModel<N extends MutableTreeMapNode<N,Column,Color,Font>,Row,Column,Color,Font>
java.lang.Object
com.treemap.AbstractTreeMapModel<N,Row,Column,Color,Font>
- Type Parameters:
N
- the type of nodes
- All Implemented Interfaces:
TreeMapModel<N,
Row, Column, Color, Font>
- Direct Known Subclasses:
DefaultTreeMapModel
public abstract class AbstractTreeMapModel<N extends MutableTreeMapNode<N,Column,Color,Font>,Row,Column,Color,Font>
extends Object
implements TreeMapModel<N,Row,Column,Color,Font>
This class provides a skeletal implementation of the TreeMapModel interface to minimize the effort required to
implement this interface.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TreeMapSettings
protected final com.macrofocus.igraphics.CPColorFactory<Color>
protected final com.macrofocus.colormap.ColorMapFactory<Color>
protected final com.macrofocus.crossplatform.CPHelper
protected final com.macrofocus.igraphics.CPFontFactory<Font>
protected final com.macrofocus.format.FormatFactory
protected final com.macrofocus.igraphics.CPImageFactory
protected final Map<TreeMapField,
ParentTreeMapNode> Fields inherited from interface com.treemap.TreeMapModel
PROPERTY_CURRENT_ROOT, PROPERTY_PROGRESS
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractTreeMapModel
(com.macrofocus.crossplatform.CPFactory<?, Font, ?, Color> cpFactory, com.macrofocus.colormap.ColorMapFactory<Color> colorMapFactory, com.macrofocus.igraphics.CPImageFactory imageFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(TreeMapListener treeMapListener) Add a listener for receiving interesting events about changes in the model.breadthFirstIterator
(N parent) Creates and returns an iterable that traverses the subhierarchy rooted at the give node in breadth-first order.protected void
protected void
computeSize
(N node, TreeMapWorker worker) protected void
computeSizeLeafs
(N root, TreeMapWorker worker) protected void
computeSizeParents
(N node, TreeMapWorker worker) protected void
computeSumSize
(N node, TreeMapWorker worker) protected abstract com.macrofocus.colormap.MutableColorMap<Color>
createCategoricalColorMap
(TreeMapField<N, Column> field) protected abstract AbstractTreeMapNode
createRootNode
(TreeMapField<N, Column> groupByField) protected TreeMapSettings
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 currentRoot, TreeMapWorker worker) protected void
getAggregateValue
(N node, TreeMapField<N, Column> field) Returns the aggregated value of a variable for a given node.com.macrofocus.geom.Rectangle2D
Gets the bounding rectangle of the item in the map.com.macrofocus.colormap.MutableColorMap<Color>
getCategoricalColorMap
(Column columnIndex) getChildrenGroupByField
(N node) Gets the depth in hierarchy.com.macrofocus.igraphics.CPColor<Color>
Gets the color of the given node.com.macrofocus.igraphics.CPColorFactory<Color>
protected com.macrofocus.colormap.MutableColorMap
com.macrofocus.colormap.MutableColorMap<Color>
getColorMap
(TreeMapField<N, Column> field) Gets the currently selected root node from which the treemap should be displayed.com.macrofocus.colormap.MutableColorMap<Color>
getCustomColorMap
(Column columnIndex) Obtains the model used for filtering nodes in the treemap.getFormatPattern
(int columnIndex) getGroupByField
(N node) Gets the depth in hierarchy.Obtains the model used to highlight nodes in the treemap.com.macrofocus.igraphics.CPImageFactory
int
Gets the depth in hierarchy.double
Corresponds to area in map.com.macrofocus.geom.Shape
getNestedShape
(N node) Gets the shape after nesting of the item in the map.getNode
(com.macrofocus.geom.Point position) /** Gets the node at the specified positiondouble
Gets the the position of the light source along the X axis.double
Gets the the position of the light source along the Y axis.double
Gets the the position of the light source along the Z axis.com.macrofocus.colormap.MutableColorMap<Color>
getPredefinedColorMap
(Column columnIndex) Obtains the model used for probing (aka mouse over).getRoot()
Returns the root node of the treemap.Obtains the model used to carry out search in the treemap.Obtains the model used for selecting nodes in the treemap.Gets the settings currently selected.com.macrofocus.geom.Shape
Gets the shape of the item in the map.double
Corresponds to area in map.getStringValue
(N node, TreeMapField<N, Column> field, TreeMapFieldSettings<Color, Font> settings) Returns the string value for the cell atcolumnIndex
and ofnode
.double
getSumSize
(N node) protected Iterable<TreeMapField<N,
Column>> getTreeMapFields
(boolean includeNone) protected TreeMapField[]
getTreeMapFields
(int... columns) protected TreeMapField[]
getTreeMapFields
(Column... columns) protected TreeMapField[]
getTreeMapFields
(String... columnNames) protected com.macrofocus.geom.Rectangle2D
Gets the worker task updating the layout.Gets the worker task updating the layout.boolean
hasNoChildren
(N node) Tells whether the given node is a leaf node or not.protected void
boolean
isDirty()
Tells whether the current layout need to be reprocessed.boolean
boolean
isNumericType
(TreeMapField<N, Column> field) boolean
isTemporalType
(TreeMapField<N, Column> field) boolean
isVisualType
(TreeMapField<N, Column> field) parentPreorderEnumeration
(N parent) Creates and returns an iterable that traverses the subhierarchy rooted at the give node in preorder.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.protected void
protected void
protected void
void
Sets the color of the given node.void
setColorProvider
(com.macrofocus.igraphics.ColorProvider<N, Color> colorProvider) void
setCurrentRoot
(N currentRoot) Sets the currently selected root node from which the treemap should be displayed.void
setFormatPattern
(int columnIndex, String pattern) void
setNestedShape
(N node, com.macrofocus.geom.Shape shape) Sets the shape after nesting of the item in the map.void
setProgress
(int progress) void
Sets the shape of the item in the map.void
Wait until all processing are completed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.treemap.TreeMapModel
columns, createDefaultColorMap, getChildCount, getChildren, getChildrenOfTypeParent, getColumnClass, getColumnCount, getColumnName, getCushionColor, getCushionImage, getDataFrame, getLabelName, getNode, getNumericMax, getNumericMin, getParent, getRowCount, getTreeMapField, getTreeMapField, getTreeMapFieldByName, getValueAt, isEveryValueUnique, isRoot, setNumericMax, setNumericMin
-
Field Details
-
rowNode
-
rootNodes
-
_settings
-
cpHelper
protected final com.macrofocus.crossplatform.CPHelper cpHelper -
colorFactory
-
fontFactory
-
colorMapFactory
-
formatFactory
protected final com.macrofocus.format.FormatFactory formatFactory -
imageFactory
protected final com.macrofocus.igraphics.CPImageFactory imageFactory
-
-
Constructor Details
-
AbstractTreeMapModel
-
-
Method Details
-
getProperties
- Specified by:
getProperties
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getGroupByTreeMapFields
- Specified by:
getGroupByTreeMapFields
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getSizeTreeMapFields
- Specified by:
getSizeTreeMapFields
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getColorTreeMapFields
- Specified by:
getColorTreeMapFields
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getHeightTreeMapFields
- Specified by:
getHeightTreeMapFields
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getLabelsTreeMapFields
- Specified by:
getLabelsTreeMapFields
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getTooltipTreeMapFields
- Specified by:
getTooltipTreeMapFields
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getTreeMapFields
-
isNumericType
- Specified by:
isNumericType
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
isTemporalType
- Specified by:
isTemporalType
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
isVisualType
- Specified by:
isVisualType
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
initDefaults
protected void initDefaults() -
scheduleUpdateGroupBy
protected void scheduleUpdateGroupBy() -
createSettings
-
clearAggregationCache
protected void clearAggregationCache() -
createRootNode
-
scheduleUpdateColors
protected void scheduleUpdateColors() -
fireTableModelChanged
protected void fireTableModelChanged() -
getTreeMapFields
-
getTreeMapFields
-
getTreeMapFields
-
doGroupBy
-
doLayout
-
getViewport
protected com.macrofocus.geom.Rectangle2D getViewport() -
computeSize
-
computeSizeLeafs
-
computeSizeParents
-
computeSumSize
-
doLayoutChildren
-
getSumSize
- Specified by:
getSumSize
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
doColors
-
getColorMap
protected com.macrofocus.colormap.MutableColorMap getColorMap() -
getColorMap
- Specified by:
getColorMap
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getCategoricalColorMap
- Specified by:
getCategoricalColorMap
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
createCategoricalColorMap
protected abstract com.macrofocus.colormap.MutableColorMap<Color> createCategoricalColorMap(TreeMapField<N, Column> field) -
getPredefinedColorMap
- Specified by:
getPredefinedColorMap
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getCustomColorMap
- Specified by:
getCustomColorMap
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getSize
Corresponds to area in map. -
getMaximumSize
public double getMaximumSize()Description copied from interface:TreeMapModel
Corresponds to area in map.- Specified by:
getMaximumSize
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the maximum area
-
setShape
Sets the shape of the item in the map. -
getShape
Gets the shape of the item in the map. -
setNestedShape
Sets the shape after nesting of the item in the map.- Specified by:
setNestedShape
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
node
- the node.shape
- the shape of the item in the map.
-
getNestedShape
Gets the shape after nesting of the item in the map.- Specified by:
getNestedShape
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
node
- the node.- Returns:
- the shape of the item in the map.
-
getBounds
Gets the bounding rectangle of the item in the map. -
getLevel
Gets the depth in hierarchy. -
getGroupByField
Description copied from interface:TreeMapModel
Gets the depth in hierarchy.- Specified by:
getGroupByField
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
node
- the node.- Returns:
- the depth in hierarchy.
-
getChildrenGroupByField
Description copied from interface:TreeMapModel
Gets the depth in hierarchy.- Specified by:
getChildrenGroupByField
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
node
- the node.- Returns:
- the depth in hierarchy.
-
hasNoChildren
Tells whether the given node is a leaf node or not.- Specified by:
hasNoChildren
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
node
- the node- Returns:
- true if it is a leaf node, false otherwise.
-
isLeaf
-
parentPreorderEnumeration
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in preorder. Only non-leaf nodes are included. The first node returned by the iterator's next() method is the given node.- Specified by:
parentPreorderEnumeration
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
parent
- the root of the hierarchy to traverse- Returns:
- an iterable that traverses the subtree rooted at this node in preorder.
-
preorderEnumeration
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 interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
parent
- the root of the hierarchy to traverse- Returns:
- an iterable that traverses the subtree rooted at this node in preorder.
-
breadthFirstIterator
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 interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - 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
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 interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
parent
- the root of the hierarchy to traverse- Returns:
- an iterable that traverses the subtree rooted at this node in depth-first order.
-
getNormalizedLightSourceX
public double getNormalizedLightSourceX()Gets the the position of the light source along the X axis.- Specified by:
getNormalizedLightSourceX
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the position along the X axis.
-
getNormalizedLightSourceY
public double getNormalizedLightSourceY()Gets the the position of the light source along the Y axis.- Specified by:
getNormalizedLightSourceY
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the position along the Y axis.
-
getNormalizedLightSourceZ
public double getNormalizedLightSourceZ()Gets the the position of the light source along the Z axis.- Specified by:
getNormalizedLightSourceZ
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the position along the Z axis.
-
getAggregateValue
Returns the aggregated value of a variable for a given node.- Specified by:
getAggregateValue
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
node
- the node whose value is to be queriedfield
- the field whose value is to be queried- Returns:
- the value Object at the specified cell
-
getStringValue
public String getStringValue(N node, TreeMapField<N, Column> field, TreeMapFieldSettings<Color, Font> settings) Returns the string value for the cell atcolumnIndex
and ofnode
.- Specified by:
getStringValue
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
node
- the node whose value is to be queriedfield
- the field whose value is to be queried- Returns:
- the value Object at the specified cell
-
getRoot
Returns the root node of the treemap. -
getCurrentRoot
Gets the currently selected root node from which the treemap should be displayed.- Specified by:
getCurrentRoot
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the currently selected root node.
-
setCurrentRoot
Sets the currently selected root node from which the treemap should be displayed.- Specified by:
setCurrentRoot
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
currentRoot
- the root node to use for display.
-
scheduleUpdateLayout
protected void scheduleUpdateLayout() -
getProbing
Obtains the model used for probing (aka mouse over).- Specified by:
getProbing
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the model used for probing.
-
getHighlighting
Obtains the model used to highlight nodes in the treemap.- Specified by:
getHighlighting
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the model used for highlighting.
-
getSelection
Obtains the model used for selecting nodes in the treemap.- Specified by:
getSelection
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the model used for selection.
-
getFilter
Obtains the model used for filtering nodes in the treemap. -
getSearch
Obtains the model used to carry out search in the treemap. -
getSettings
Gets the settings currently selected.- Specified by:
getSettings
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the settings.
-
getWorker
Gets the worker task updating the layout. -
getWorkerFuture
Gets the worker task updating the layout.- Specified by:
getWorkerFuture
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Returns:
- the worker task
-
addListener
Add a listener for receiving interesting events about changes in the model.- Specified by:
addListener
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
treeMapListener
- the listener to add.
-
removeListener
Remove a listener from the list of listeners that should be notified about changes in the model.- Specified by:
removeListener
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font> - Parameters:
treeMapListener
- the listener to remove.
-
getNode
/** Gets the node at the specified position -
isDirty
public boolean isDirty()Tells whether the current layout need to be reprocessed. -
waitUntilReady
public void waitUntilReady()Wait until all processing are completed.- Specified by:
waitUntilReady
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getColorProvider
- Specified by:
getColorProvider
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
setColorProvider
- Specified by:
setColorProvider
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getColor
Description copied from interface:TreeMapModel
Gets the color of the given node. -
setColor
Sets the color of the given node. -
progressProperty
- Specified by:
progressProperty
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
setProgress
public void setProgress(int progress) -
getFormatPattern
- Specified by:
getFormatPattern
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
setFormatPattern
- Specified by:
setFormatPattern
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getColorFactory
- Specified by:
getColorFactory
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-
getImageFactory
public com.macrofocus.igraphics.CPImageFactory getImageFactory()- Specified by:
getImageFactory
in interfaceTreeMapModel<N extends MutableTreeMapNode<N,
Column, Color, Font>, Row, Column, Color, Font>
-