Package com.macrofocus.treeplot
Class DefaultTreePlotModel<N,Row,Column,Color,Font>
- java.lang.Object
-
- com.macrofocus.treeplot.DefaultTreePlotModel<N,Row,Column,Color,Font>
-
- All Implemented Interfaces:
TreePlotModel<N,Row,Column,Color,Font>
- Direct Known Subclasses:
SwingTreePlotModel
public class DefaultTreePlotModel<N,Row,Column,Color,Font> extends java.lang.Object implements TreePlotModel<N,Row,Column,Color,Font>
-
-
Field Summary
Fields Modifier and Type Field Description protected MutableSingleSelection<TreeMapField<N,Column>>
xVariable
protected MutableSingleSelection<TreeMapField<N,Column>>
yVariable
-
Constructor Summary
Constructors Constructor Description DefaultTreePlotModel(TreeMapModel<N,Row,Column,Color,Font> tmm, com.macrofocus.igraphics.CPColorFactory<Color> colorFactory, com.macrofocus.igraphics.CPFontFactory<Font> fontFactory, com.macrofocus.crossplatform.CPHelper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<N>
depthFirstIterator(N parent)
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in depth-first order.java.lang.Object
getAggregateValue(N node, TreeMapField field)
Returns the aggregated value of a variable for a given node.java.awt.geom.GeneralPath
getCH(N node, TreeMapField xVariable, TreeMapField yVariable)
java.lang.Iterable<N>
getChildren(N parent)
Returns an iterator of the children of the given node.com.macrofocus.igraphics.CPColor<Color>
getColor(N node)
Gets the color of the given node.java.lang.Class<?>
getColumnClass(Column columnIndex)
Returns the most specific superclass for all the cell values in the column.int
getColumnCount()
Returns the number of columns in the model.java.lang.String
getColumnName(Column columnIndex)
Returns the name of the column atcolumnIndex
.N
getCurrentRoot()
Gets the currently selected root node from which the treemap should be displayed.MutableFilter<N>
getFilter()
Obtains the model used for filtering nodes in the treemap.Selection<N>
getHighlighting()
Obtains the model used to highlight nodes in the treemap.double
getMaximumSize()
Corresponds to area in map.double
getMaximumSize(N parent)
Corresponds to area in map.java.awt.geom.Ellipse2D
getMEC(N node, TreeMapField xVariable, TreeMapField yVariable)
java.lang.Double
getNumericMax(TreeMapField<N,Column> columnIndex)
Gets the maximum value contained in the specified column.java.lang.Double
getNumericMax(TreeMapField columnIndex, N parent)
Gets the maximum value contained in the specified column.java.lang.Double
getNumericMin(TreeMapField<N,Column> columnIndex)
Gets the minimum value contained in the specified column.java.lang.Double
getNumericMin(TreeMapField columnIndex, N parent)
Gets the minimum value contained in the specified column.N
getParent(N node)
Gets the parent node of the given node.MutableSingleSelection<N>
getProbing()
Obtains the model used for probing (aka mouse over).N
getRoot()
Returns the root node of the treemap.MutableFilter<N>
getSearch()
Obtains the model used to carry out search in the treemap.MutableSelection<N>
getSelection()
Obtains the model used for selecting nodes in the treemap.TreePlotSettings
getSettings()
Gets the settings currently selected.double
getSize(N node)
Corresponds to area in map.java.lang.String
getStringValue(N node, TreeMapField field)
Returns the string value for the cell atcolumnIndex
and ofnode
.TreeMapField<N,Column>
getTreeMapField(int columnIndex)
Gets the field corresponding to the specified column index.TreeMapField
getTreeMapField(java.lang.String columnName)
Gets the field corresponding to the specified column name.protected java.lang.Iterable<TreeMapField<N,Column>>
getTreeMapFields(boolean includeNone)
TreeMapModel<N,Row,Column,Color,Font>
getTreeMapModel()
java.lang.Object
getValueAt(N node, Column columnIndex)
Returns the value for the cell atcolumnIndex
and ofnode
.java.lang.Iterable<TreeMapField<N,Column>>
getXTreeMapFields()
MutableSingleSelection<TreeMapField<N,Column>>
getXVariable()
java.lang.Iterable<TreeMapField<N,Column>>
getYTreeMapFields()
MutableSingleSelection<TreeMapField<N,Column>>
getYVariable()
boolean
hasNoChildren(N node)
Tells whether the given node is a leaf node or not.boolean
isLeaf(N node)
boolean
isNumericType(TreeMapField<N,Column> field)
boolean
isRoot(N node)
Tells whether the given node is the root node or not.boolean
isTemporalType(TreeMapField<N,Column> field)
boolean
isVisualType(TreeMapField<N,Column> field)
void
setCurrentRoot(N currentRoot)
Sets the currently selected root node from which the treemap should be displayed.
-
-
-
Field Detail
-
xVariable
protected final MutableSingleSelection<TreeMapField<N,Column>> xVariable
-
yVariable
protected final MutableSingleSelection<TreeMapField<N,Column>> yVariable
-
-
Method Detail
-
isNumericType
public boolean isNumericType(TreeMapField<N,Column> field)
- Specified by:
isNumericType
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
isTemporalType
public boolean isTemporalType(TreeMapField<N,Column> field)
- Specified by:
isTemporalType
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
isVisualType
public boolean isVisualType(TreeMapField<N,Column> field)
- Specified by:
isVisualType
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
getSize
public double getSize(N node)
Corresponds to area in map.
-
getMaximumSize
public double getMaximumSize()
Corresponds to area in map.- Specified by:
getMaximumSize
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the maximum area
-
getMaximumSize
public double getMaximumSize(N parent)
Corresponds to area in map.- Specified by:
getMaximumSize
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the maximum area
-
getTreeMapModel
public TreeMapModel<N,Row,Column,Color,Font> getTreeMapModel()
- Specified by:
getTreeMapModel
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
getXVariable
public MutableSingleSelection<TreeMapField<N,Column>> getXVariable()
- Specified by:
getXVariable
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
getXTreeMapFields
public java.lang.Iterable<TreeMapField<N,Column>> getXTreeMapFields()
- Specified by:
getXTreeMapFields
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
getYVariable
public MutableSingleSelection<TreeMapField<N,Column>> getYVariable()
- Specified by:
getYVariable
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
getYTreeMapFields
public java.lang.Iterable<TreeMapField<N,Column>> getYTreeMapFields()
- Specified by:
getYTreeMapFields
in interfaceTreePlotModel<N,Row,Column,Color,Font>
-
getTreeMapFields
protected java.lang.Iterable<TreeMapField<N,Column>> getTreeMapFields(boolean includeNone)
-
getRoot
public N getRoot()
Returns the root node of the treemap.
-
getCurrentRoot
public N getCurrentRoot()
Gets the currently selected root node from which the treemap should be displayed.- Specified by:
getCurrentRoot
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the currently selected root node.
-
setCurrentRoot
public void setCurrentRoot(N currentRoot)
Sets the currently selected root node from which the treemap should be displayed.- Specified by:
setCurrentRoot
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
currentRoot
- the root node to use for display.
-
getProbing
public MutableSingleSelection<N> getProbing()
Obtains the model used for probing (aka mouse over).- Specified by:
getProbing
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the model used for probing.
-
getHighlighting
public Selection<N> getHighlighting()
Obtains the model used to highlight nodes in the treemap.- Specified by:
getHighlighting
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the model used for highlighting.
-
getSelection
public MutableSelection<N> getSelection()
Obtains the model used for selecting nodes in the treemap.- Specified by:
getSelection
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the model used for selection.
-
getFilter
public MutableFilter<N> getFilter()
Obtains the model used for filtering nodes in the treemap.
-
getSearch
public MutableFilter<N> getSearch()
Obtains the model used to carry out search in the treemap.
-
getSettings
public TreePlotSettings getSettings()
Gets the settings currently selected.- Specified by:
getSettings
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the settings.
-
getNumericMax
public java.lang.Double getNumericMax(TreeMapField<N,Column> columnIndex)
Gets the maximum value contained in the specified column.- Specified by:
getNumericMax
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnIndex
- the index of the column.- Returns:
- the maximum value.
-
getNumericMin
public java.lang.Double getNumericMin(TreeMapField<N,Column> columnIndex)
Gets the minimum value contained in the specified column.- Specified by:
getNumericMin
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnIndex
- the index of the column.- Returns:
- the minimum value.
-
getNumericMax
public java.lang.Double getNumericMax(TreeMapField columnIndex, N parent)
Description copied from interface:TreePlotModel
Gets the maximum value contained in the specified column.- Specified by:
getNumericMax
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnIndex
- the index of the column.- Returns:
- the maximum value.
-
getNumericMin
public java.lang.Double getNumericMin(TreeMapField columnIndex, N parent)
Description copied from interface:TreePlotModel
Gets the minimum value contained in the specified column.- Specified by:
getNumericMin
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnIndex
- the index of the column.- Returns:
- the minimum value.
-
depthFirstIterator
public java.lang.Iterable<N> depthFirstIterator(N parent)
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 interfaceTreePlotModel<N,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.
-
getTreeMapField
public TreeMapField<N,Column> getTreeMapField(int columnIndex)
Gets the field corresponding to the specified column index.- Specified by:
getTreeMapField
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnIndex
- the index of the column.- Returns:
- the field.
-
getTreeMapField
public TreeMapField getTreeMapField(java.lang.String columnName)
Gets the field corresponding to the specified column name.- Specified by:
getTreeMapField
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnName
- the name of the column.- Returns:
- the field.
-
hasNoChildren
public boolean hasNoChildren(N node)
Description copied from interface:TreePlotModel
Tells whether the given node is a leaf node or not.- Specified by:
hasNoChildren
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
node
- the node- Returns:
- true if it is a leaf node, false otherwise.
-
isLeaf
public boolean isLeaf(N node)
-
getColumnName
public java.lang.String getColumnName(Column columnIndex)
Returns the name of the column atcolumnIndex
. Note: this name does not need to be unique; two columns in a table can have the same name.- Specified by:
getColumnName
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnIndex
- the index of the column- Returns:
- the name of the column
-
getValueAt
public java.lang.Object getValueAt(N node, Column columnIndex)
Returns the value for the cell atcolumnIndex
and ofnode
.- Specified by:
getValueAt
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
node
- the node whose value is to be queriedcolumnIndex
- the column whose value is to be queried- Returns:
- the value Object at the specified cell
-
getAggregateValue
public java.lang.Object getAggregateValue(N node, TreeMapField field)
Returns the aggregated value of a variable for a given node.- Specified by:
getAggregateValue
in interfaceTreePlotModel<N,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
-
getChildren
public java.lang.Iterable<N> getChildren(N parent)
Returns an iterator of the children of the given node.- Specified by:
getChildren
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
parent
- the parent node- Returns:
- the children
-
getColor
public com.macrofocus.igraphics.CPColor<Color> getColor(N node)
Gets the color of the given node.
-
getStringValue
public java.lang.String getStringValue(N node, TreeMapField field)
Returns the string value for the cell atcolumnIndex
and ofnode
.- Specified by:
getStringValue
in interfaceTreePlotModel<N,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
-
isRoot
public boolean isRoot(N node)
Tells whether the given node is the root node or not.
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the model.- Specified by:
getColumnCount
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Returns:
- the number of columns in the model
-
getColumnClass
public java.lang.Class<?> getColumnClass(Column columnIndex)
Returns the most specific superclass for all the cell values in the column.- Specified by:
getColumnClass
in interfaceTreePlotModel<N,Row,Column,Color,Font>
- Parameters:
columnIndex
- the index of the column- Returns:
- the common ancestor class of the object values in the model.
-
getMEC
public java.awt.geom.Ellipse2D getMEC(N node, TreeMapField xVariable, TreeMapField yVariable)
-
getCH
public java.awt.geom.GeneralPath getCH(N node, TreeMapField xVariable, TreeMapField yVariable)
-
-