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 TreeMapSettingsprotected final com.macrofocus.igraphics.CPColorFactory<Color> protected final com.macrofocus.colormap.ColorMapFactory<Color> protected final com.macrofocus.crossplatform.CPHelperprotected final com.macrofocus.igraphics.CPFontFactory<Font> protected final com.macrofocus.format.FormatFactoryprotected final com.macrofocus.igraphics.CPImageFactoryprotected 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 TypeMethodDescriptionvoidaddListener(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 voidprotected voidcomputeSize(N node, TreeMapWorker worker) protected voidcomputeSizeLeafs(N root, TreeMapWorker worker) protected voidcomputeSizeParents(N node, TreeMapWorker worker) protected voidcomputeSumSize(N node, TreeMapWorker worker) protected abstract com.macrofocus.colormap.MutableColorMap<Color> createCategoricalColorMap(TreeMapField<N, Column> field) protected abstract AbstractTreeMapNodecreateRootNode(TreeMapField<N, Column> groupByField) protected TreeMapSettingsdepthFirstIterator(N parent) Creates and returns an iterable that traverses the subhierarchy rooted at the give node in depth-first order.protected booleandoColors(N parent, TreeMapWorker worker) protected abstract booleandoGroupBy(N parent, TreeMapWorker worker) protected booleandoLayout(N parent, TreeMapWorker worker) protected booleandoLayoutChildren(N currentRoot, TreeMapWorker worker) protected voidgetAggregateValue(N node, TreeMapField<N, Column> field) Returns the aggregated value of a variable for a given node.com.macrofocus.geom.Rectangle2DGets 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.MutableColorMapcom.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.CPImageFactoryintGets the depth in hierarchy.doubleCorresponds to area in map.com.macrofocus.geom.ShapegetNestedShape(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 positiondoubleGets the the position of the light source along the X axis.doubleGets the the position of the light source along the Y axis.doubleGets 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.ShapeGets the shape of the item in the map.doubleCorresponds to area in map.getStringValue(N node, TreeMapField<N, Column> field, TreeMapFieldSettings<Color, Font> settings) Returns the string value for the cell atcolumnIndexand ofnode.doublegetSumSize(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.Rectangle2DGets the worker task updating the layout.Gets the worker task updating the layout.booleanhasNoChildren(N node) Tells whether the given node is a leaf node or not.protected voidbooleanisDirty()Tells whether the current layout need to be reprocessed.booleanbooleanisNumericType(TreeMapField<N, Column> field) booleanisTemporalType(TreeMapField<N, Column> field) booleanisVisualType(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.voidremoveListener(TreeMapListener treeMapListener) Remove a listener from the list of listeners that should be notified about changes in the model.protected voidprotected voidprotected voidvoidSets the color of the given node.voidsetColorProvider(com.macrofocus.igraphics.ColorProvider<N, Color> colorProvider) voidsetCurrentRoot(N currentRoot) Sets the currently selected root node from which the treemap should be displayed.voidsetFormatPattern(int columnIndex, String pattern) voidsetNestedShape(N node, com.macrofocus.geom.Shape shape) Sets the shape after nesting of the item in the map.voidsetProgress(int progress) voidSets the shape of the item in the map.voidWait until all processing are completed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getPropertiesin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getGroupByTreeMapFields
- Specified by:
getGroupByTreeMapFieldsin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getSizeTreeMapFields
- Specified by:
getSizeTreeMapFieldsin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getColorTreeMapFields
- Specified by:
getColorTreeMapFieldsin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getHeightTreeMapFields
- Specified by:
getHeightTreeMapFieldsin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getLabelsTreeMapFields
- Specified by:
getLabelsTreeMapFieldsin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getTooltipTreeMapFields
- Specified by:
getTooltipTreeMapFieldsin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getTreeMapFields
-
isNumericType
- Specified by:
isNumericTypein interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
isTemporalType
- Specified by:
isTemporalTypein interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
isVisualType
- Specified by:
isVisualTypein 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:
getSumSizein interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
doColors
-
getColorMap
protected com.macrofocus.colormap.MutableColorMap getColorMap() -
getColorMap
- Specified by:
getColorMapin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getCategoricalColorMap
- Specified by:
getCategoricalColorMapin 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:
getPredefinedColorMapin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getCustomColorMap
- Specified by:
getCustomColorMapin 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:TreeMapModelCorresponds to area in map.- Specified by:
getMaximumSizein 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:
setNestedShapein 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:
getNestedShapein 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:TreeMapModelGets the depth in hierarchy.- Specified by:
getGroupByFieldin 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:TreeMapModelGets the depth in hierarchy.- Specified by:
getChildrenGroupByFieldin 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:
hasNoChildrenin 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:
parentPreorderEnumerationin 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:
preorderEnumerationin 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:
breadthFirstIteratorin 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:
depthFirstIteratorin 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:
getNormalizedLightSourceXin 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:
getNormalizedLightSourceYin 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:
getNormalizedLightSourceZin 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:
getAggregateValuein 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 atcolumnIndexand ofnode.- Specified by:
getStringValuein 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:
getCurrentRootin 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:
setCurrentRootin 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:
getProbingin 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:
getHighlightingin 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:
getSelectionin 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:
getSettingsin 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:
getWorkerFuturein 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:
addListenerin 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:
removeListenerin 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:
waitUntilReadyin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getColorProvider
- Specified by:
getColorProviderin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
setColorProvider
- Specified by:
setColorProviderin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getColor
Description copied from interface:TreeMapModelGets the color of the given node. -
setColor
Sets the color of the given node. -
progressProperty
- Specified by:
progressPropertyin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
setProgress
public void setProgress(int progress) -
getFormatPattern
- Specified by:
getFormatPatternin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
setFormatPattern
- Specified by:
setFormatPatternin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getColorFactory
- Specified by:
getColorFactoryin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-
getImageFactory
public com.macrofocus.igraphics.CPImageFactory getImageFactory()- Specified by:
getImageFactoryin interfaceTreeMapModel<N extends MutableTreeMapNode<N,Column, Color, Font>, Row, Column, Color, Font>
-