Package com.treemap

Class DefaultTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font>

java.lang.Object
com.treemap.AbstractTreeMapModel<N,Row,Column,Color,Font>
com.treemap.DefaultTreeMapModel<N,Row,Column,Color,Font>
Type Parameters:
N - the type of nodes
All Implemented Interfaces:
TreeMapModel<N,Row,Column,Color,Font>

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.
  • Field Details

    • dataFrame

      protected com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame
  • Constructor Details

    • 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 Details

    • 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 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 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 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:
      createRootNode in class AbstractTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font>
    • createLeafNode

      protected AbstractTreeMapNode createLeafNode(Row row)
    • getNode

      public N getNode(Row row)
    • createParentNode

      protected AbstractTreeMapNode createParentNode(Object name, TreeMapField<N,Column> groupByField, TreeMapField<N,Column> childrenGroupByField)
    • findChild

      protected AbstractTreeMapNode findChild(AbstractTreeMapNode parent, Object name)
    • addChild

      protected void addChild(N parent, AbstractTreeMapNode child)
    • doGroupBy

      protected boolean doGroupBy(N parent, TreeMapWorker worker)
      Specified by:
      doGroupBy in class AbstractTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font>
    • addChild

      protected void addChild(N parent, Iterable<Object> path, Iterable<TreeMapField> groupBy, Iterable<TreeMapField> childrenGroupBy, Row row)
      Add a child according to its path in the hierarchy.
      Parameters:
      parent - the parent node
      path - the path
      row - the row of the child
    • getTreeMapField

      public TreeMapField getTreeMapField(int columnIndex)
      Description copied from interface: TreeMapModel
      Gets 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: TreeMapModel
      Gets 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(String columnName)
      Description copied from interface: TreeMapModel
      Gets the field corresponding to the specified column name.
      Parameters:
      columnName - the name of the column.
      Returns:
      the field.
    • getDataFrame

      public com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> getDataFrame()
    • getRowCount

      public int getRowCount()
      Description copied from interface: TreeMapModel
      Returns the number of columns in the model.
      Returns:
      the number of columns in the model
    • getColumnCount

      public int getColumnCount()
      Description copied from interface: TreeMapModel
      Returns the number of columns in the model.
      Returns:
      the number of columns in the model
    • columns

      public Iterable<Column> columns()
    • getColumnName

      public String getColumnName(Column columnIndex)
      Description copied from interface: TreeMapModel
      Returns the name of the column at columnIndex. 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 Class<?> getColumnClass(Column columnIndex)
      Description copied from interface: TreeMapModel
      Returns 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 Object getValueAt(N node, Column columnIndex)
      Description copied from interface: TreeMapModel
      Returns the value for the cell at columnIndex and of node.
      Parameters:
      node - the node whose value is to be queried
      columnIndex - 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: TreeMapModel
      Indicates 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 Double getNumericMax(TreeMapField<N,Column> columnIndex)
      Description copied from interface: TreeMapModel
      Gets the maximum value contained in the specified column.
      Parameters:
      columnIndex - the index of the column.
      Returns:
      the maximum value.
    • getNumericMin

      public Double getNumericMin(TreeMapField<N,Column> columnIndex)
      Description copied from interface: TreeMapModel
      Gets 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: TreeMapModel
      Sets 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: TreeMapModel
      Sets 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:
      createCategoricalColorMap in class AbstractTreeMapModel<N extends AbstractTreeMapNode<N,Row,Column,Color,Font>,Row,Column,Color,Font>