Package com.macrofocus.treemap
Class DefaultTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font>
- java.lang.Object
-
- com.macrofocus.treemap.AbstractTreeMapModel<N,Row,Column,Color,Font>
-
- com.macrofocus.treemap.DefaultTreeMapModel<N,Row,Column,Color,Font>
-
- Type Parameters:
N- the type of nodes
- All Implemented Interfaces:
TreeMapModel<N,Row,Column,Color,Font>
- Direct Known Subclasses:
SwingTreeMapModel
public class DefaultTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font> extends AbstractTreeMapModel<N,Row,Column,Color,Font>
Default implementation of a TreeMapModel. This class provides an easy way to integration with Swing's TableModel.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.macrofocus.treemap.AbstractTreeMapModel
AbstractTreeMapModel.Worker
-
-
Field Summary
Fields Modifier and Type Field Description protected com.macrofocus.molap.dataframe.DataFrame<Row,Column,?>dataFrame-
Fields inherited from class com.macrofocus.treemap.AbstractTreeMapModel
_settings, colorFactory, colorMapFactory, cpHelper, fontFactory, formatFactory, imageFactory, rowNode
-
Fields inherited from interface com.macrofocus.treemap.TreeMapModel
PROPERTY_CURRENT_ROOT, PROPERTY_PROGRESS
-
-
Constructor Summary
Constructors Constructor Description DefaultTreeMapModel(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame, com.macrofocus.crossplatform.CPFactory<?,Font,?,Color> cpFactory, com.macrofocus.colormap.ColorMapFactory<Color> colorMapFactory, com.macrofocus.igraphics.CPImageFactory imageFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddChild(N parent, AbstractTreeMapNode child)protected voidaddChild(N parent, java.util.List<java.lang.Object> path, java.util.List<TreeMapField> groupBy, java.util.List<TreeMapField> childrenGroupBy, Row row)Add a child according to its path in the hierarchy.java.lang.Iterable<Column>columns()protected com.macrofocus.colormap.MutableColorMap<Color>createCategoricalColorMap(TreeMapField<N,Column> field)com.macrofocus.colormap.MutableColorMapcreateDefaultColorMap(TreeMapField<N,Column> field)protected AbstractTreeMapNodecreateLeafNode(Row row)protected AbstractTreeMapNodecreateParentNode(java.lang.Object name, TreeMapField<N,Column> groupByField, TreeMapField<N,Column> childrenGroupByField)protected AbstractTreeMapNodecreateRootNode(TreeMapField<N,Column> childrenGroupByField)protected TreeMapFieldcreateTreeMapField(Column columnIndex)protected booleandoGroupBy(N parent, TreeMapWorker worker)protected AbstractTreeMapNodefindChild(AbstractTreeMapNode parent, java.lang.Object name)intgetChildCount(AbstractTreeMapNode node)Returns the number of children of a given node.java.lang.Iterable<N>getChildren(N parent)Returns an iterator of the children of the given node.java.lang.Iterable<N>getChildrenOfTypeParent(N parent)Returns an iterator of the children of the given node.java.lang.Class<?>getColumnClass(Column columnIndex)Returns the most specific superclass for all the cell values in the column.intgetColumnCount()Returns the number of columns in the model.java.lang.StringgetColumnName(Column columnIndex)Returns the name of the column atcolumnIndex.com.macrofocus.igraphics.CPColor<Color>getCushionColor(AbstractTreeMapNode node)Returns the color of the cushion.com.macrofocus.igraphics.CPImagegetCushionImage(AbstractTreeMapNode node)Returns the image used for painting the cushion.com.macrofocus.molap.dataframe.DataFrame<Row,Column,?>getDataFrame()java.lang.StringgetLabelName(AbstractTreeMapNode node)Gets the label of the given node.NgetNode(Row row)java.lang.DoublegetNumericMax(TreeMapField<N,Column> columnIndex)Gets the maximum value contained in the specified column.java.lang.DoublegetNumericMin(TreeMapField<N,Column> columnIndex)Gets the minimum value contained in the specified column.NgetParent(N node)Gets the parent node of the given node.intgetRowCount()Returns the number of columns in the model.TreeMapFieldgetTreeMapField(int columnIndex)Gets the field corresponding to the specified column index.TreeMapFieldgetTreeMapField(Column columnIndex)Gets the field corresponding to the specified column index.TreeMapFieldgetTreeMapFieldByName(java.lang.String columnName)Gets the field corresponding to the specified column name.java.lang.ObjectgetValueAt(N node, Column columnIndex)Returns the value for the cell atcolumnIndexand ofnode.booleanisEveryValueUnique(TreeMapField<N,Column> field)Indicates whether all the values in the given field are unique.booleanisRoot(AbstractTreeMapNode node)Tells whether the given node is the root node or not.voidsetDataFrame(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame)Change the underlying DataFrame.voidsetNumericMax(TreeMapField columnIndex, double max)Sets the maximum value contained in the specified column.voidsetNumericMin(TreeMapField columnIndex, double min)Sets the minimum value contained in the specified column.-
Methods inherited from class com.macrofocus.treemap.AbstractTreeMapModel
addListener, breadthFirstIterator, clearAggregationCache, computeSize, computeSizeLeafs, computeSizeParents, createSettings, depthFirstIterator, doColors, doLayout, doLayoutChildren, fireTableModelChanged, getAggregateValue, getBounds, getCategoricalColorMap, getChildrenGroupByField, getColor, getColorFactory, getColorMap, getColorMap, getColorProvider, getColorTreeMapFields, getCurrentRoot, getCustomColorMap, getFilter, getFormatPattern, getGroupByField, getGroupByTreeMapFields, getHeightTreeMapFields, getHighlighting, getImageFactory, getLabelsTreeMapFields, getLevel, getMaximumSize, getNestedShape, getNode, getNormalizedLightSourceX, getNormalizedLightSourceY, getNormalizedLightSourceZ, getPredefinedColorMap, getProbing, getProperties, getRoot, getSearch, getSelection, getSettings, getShape, getSize, getSizeTreeMapFields, getStringValue, getSumSize, getTooltipTreeMapFields, getTreeMapFields, getTreeMapFields, getTreeMapFields, getTreeMapFields, getViewport, getWorker, getWorkerFuture, hasNoChildren, initDefaults, isDirty, isLeaf, isNumericType, isTemporalType, isVisualType, parentPreorderEnumeration, preorderEnumeration, progressProperty, removeListener, scheduleUpdateColors, scheduleUpdateGroupBy, scheduleUpdateLayout, setColor, setColorProvider, setCurrentRoot, setFormatPattern, setNestedShape, setProgress, setShape, waitUntilReady
-
-
-
-
Constructor Detail
-
DefaultTreeMapModel
public DefaultTreeMapModel(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame, com.macrofocus.crossplatform.CPFactory<?,Font,?,Color> cpFactory, com.macrofocus.colormap.ColorMapFactory<Color> colorMapFactory, com.macrofocus.igraphics.CPImageFactory imageFactory)
-
-
Method Detail
-
setDataFrame
public void setDataFrame(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame)
Change the underlying DataFrame. It is currently assumed that the structure of the DataFrame doesn't change, i.e. that the number, name, and type of columns stay the same.- Parameters:
dataFrame- the new DataFrame
-
getLabelName
public java.lang.String getLabelName(AbstractTreeMapNode node)
Gets the label of the given node.- Parameters:
node- the node.- Returns:
- its label.
-
getParent
public N getParent(N node)
Gets the parent node of the given node.- Parameters:
node- the node- Returns:
- its parent
-
isRoot
public boolean isRoot(AbstractTreeMapNode node)
Tells whether the given node is the root node or not.- Parameters:
node- the node- Returns:
- true if it is the root node, false otherwise.
-
getChildCount
public int getChildCount(AbstractTreeMapNode node)
Returns the number of children of a given node.- Parameters:
node- the parent node.- Returns:
- the number of children
-
getChildren
public java.lang.Iterable<N> getChildren(N parent)
Returns an iterator of the children of the given node.- Parameters:
parent- the parent node- Returns:
- the children
-
getChildrenOfTypeParent
public java.lang.Iterable<N> getChildrenOfTypeParent(N parent)
Returns an iterator of the children of the given node.- Parameters:
parent- the parent node- Returns:
- the children
-
getCushionImage
public com.macrofocus.igraphics.CPImage getCushionImage(AbstractTreeMapNode node)
Returns the image used for painting the cushion.- Parameters:
node- the node- Returns:
- the cushion image
-
getCushionColor
public com.macrofocus.igraphics.CPColor<Color> getCushionColor(AbstractTreeMapNode node)
Returns the color of the cushion.- Parameters:
node- the node- Returns:
- the cushion color
-
createRootNode
protected AbstractTreeMapNode createRootNode(TreeMapField<N,Column> childrenGroupByField)
- Specified by:
createRootNodein classAbstractTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font>
-
createLeafNode
protected AbstractTreeMapNode createLeafNode(Row row)
-
createParentNode
protected AbstractTreeMapNode createParentNode(java.lang.Object name, TreeMapField<N,Column> groupByField, TreeMapField<N,Column> childrenGroupByField)
-
findChild
protected AbstractTreeMapNode findChild(AbstractTreeMapNode parent, java.lang.Object name)
-
addChild
protected void addChild(N parent, AbstractTreeMapNode child)
-
doGroupBy
protected boolean doGroupBy(N parent, TreeMapWorker worker)
-
addChild
protected void addChild(N parent, java.util.List<java.lang.Object> path, java.util.List<TreeMapField> groupBy, java.util.List<TreeMapField> childrenGroupBy, Row row)
Add a child according to its path in the hierarchy.- Parameters:
parent- the parent nodepath- the pathrow- the row of the child
-
getTreeMapField
public TreeMapField getTreeMapField(int columnIndex)
Description copied from interface:TreeMapModelGets the field corresponding to the specified column index.- Parameters:
columnIndex- the index of the column.- Returns:
- the field.
-
getTreeMapField
public TreeMapField getTreeMapField(Column columnIndex)
Description copied from interface:TreeMapModelGets the field corresponding to the specified column index.- Parameters:
columnIndex- the index of the column.- Returns:
- the field.
-
createTreeMapField
protected TreeMapField createTreeMapField(Column columnIndex)
-
getTreeMapFieldByName
public TreeMapField getTreeMapFieldByName(java.lang.String columnName)
Description copied from interface:TreeMapModelGets the field corresponding to the specified column name.- Parameters:
columnName- the name of the column.- Returns:
- the field.
-
getRowCount
public int getRowCount()
Description copied from interface:TreeMapModelReturns the number of columns in the model.- Returns:
- the number of columns in the model
-
getColumnCount
public int getColumnCount()
Description copied from interface:TreeMapModelReturns the number of columns in the model.- Returns:
- the number of columns in the model
-
columns
public java.lang.Iterable<Column> columns()
-
getColumnName
public java.lang.String getColumnName(Column columnIndex)
Description copied from interface:TreeMapModelReturns 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.- Parameters:
columnIndex- the index of the column- Returns:
- the name of the column
-
getColumnClass
public java.lang.Class<?> getColumnClass(Column columnIndex)
Description copied from interface:TreeMapModelReturns the most specific superclass for all the cell values in the column.- Parameters:
columnIndex- the index of the column- Returns:
- the common ancestor class of the object values in the model.
-
getValueAt
public java.lang.Object getValueAt(N node, Column columnIndex)
Description copied from interface:TreeMapModelReturns the value for the cell atcolumnIndexand ofnode.- 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
-
isEveryValueUnique
public boolean isEveryValueUnique(TreeMapField<N,Column> field)
Description copied from interface:TreeMapModelIndicates whether all the values in the given field are unique.- Parameters:
field- the field whose whose values are to be queried- Returns:
- true if every value is unique, false otherwise
-
getNumericMax
public java.lang.Double getNumericMax(TreeMapField<N,Column> columnIndex)
Description copied from interface:TreeMapModelGets the maximum value contained in the specified column.- Parameters:
columnIndex- the index of the column.- Returns:
- the maximum value.
-
getNumericMin
public java.lang.Double getNumericMin(TreeMapField<N,Column> columnIndex)
Description copied from interface:TreeMapModelGets the minimum value contained in the specified column.- Parameters:
columnIndex- the index of the column.- Returns:
- the minimum value.
-
setNumericMax
public void setNumericMax(TreeMapField columnIndex, double max)
Description copied from interface:TreeMapModelSets the maximum value contained in the specified column.- Parameters:
columnIndex- the index of the column.max- the maximum value.
-
setNumericMin
public void setNumericMin(TreeMapField columnIndex, double min)
Description copied from interface:TreeMapModelSets the minimum value contained in the specified column.- Parameters:
columnIndex- the index of the column.min- the minimum value.
-
createDefaultColorMap
public com.macrofocus.colormap.MutableColorMap createDefaultColorMap(TreeMapField<N,Column> field)
-
createCategoricalColorMap
protected com.macrofocus.colormap.MutableColorMap<Color> createCategoricalColorMap(TreeMapField<N,Column> field)
- Specified by:
createCategoricalColorMapin classAbstractTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font>
-
-