Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.treetable
Class UniqueTreeTableModel

java.lang.Object
  extended by com.citra.treetable.AbstractTreeTableModel
      extended by com.citra.treetable.MutableTreeTableModel
          extended by com.citra.treetable.ComparableTreeTableModel
              extended by com.citra.treetable.DefaultMutableTreeTableModel
                  extended by com.citra.treetable.UniqueTreeTableModel
All Implemented Interfaces:
ReorderModel, TreeTableModel, Serializable, TreeModel

public class UniqueTreeTableModel
extends DefaultMutableTreeTableModel

UniqueTreeTableModel is a TreeTableModel that builds a set of unique tree nodes at each tree level.

See Also:
Serialized Form

Field Summary
static int LEVEL_MODE
          the level mode
protected  int mode
          the mode that is used to build the unique structure by level
protected  TreeTableModel model
          the underlying treetable model
protected  Comparator nodeComparator
          the comparator that is used to compare tree nodes between them at each tree level
static int ROOT_MODE
          the root mode
protected  boolean sorted
          flag indicating whether the unique level values will be sorted
 
Fields inherited from class com.citra.treetable.DefaultMutableTreeTableModel
editable
 
Fields inherited from class com.citra.treetable.ComparableTreeTableModel
addChildForGroup, comparators, defaultComparatorsByColumnClass
 
Fields inherited from class com.citra.treetable.MutableTreeTableModel
classes, columns
 
Fields inherited from class com.citra.treetable.AbstractTreeTableModel
listenerList, root
 
Fields inherited from interface com.citra.treetable.TreeTableModel
CHANGE_COLUMN_SOURCE
 
Constructor Summary
UniqueTreeTableModel(TreeTableModel model, Comparator nodeComparator)
          Constructs a UniqueTreeTableModel that compares nodes with the supplied nodeComparator.
UniqueTreeTableModel(TreeTableModel model, int column)
          Constructs a UniqueTreeTableModel that compares nodes at a designated column with a GeneralComparator.
UniqueTreeTableModel(TreeTableModel model, int column, Comparator columnComparator)
          Constructs a UniqueTreeTableModel that compares nodes at a designated column and comparator.
 
Method Summary
 void clear()
          Removes all children from the root node and rebuilds the model.
 int getChildCount(Object parent)
          Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this data source.
 Class getColumnClass(int column)
          Returns the class of all the cells in the column.
 String getColumnName(int column)
          Returns the name of the column at columnIndex as it will be displayed by the table
 int getMode()
          Determines the mode that is used to build the level structure.
 String getStringForLevel(int level)
          Returns the string to return for the supplied level.
 TreeTableModel getTreeTableModel()
          Returns the underlying treetable model.
 boolean isSorted()
          Determines whether the unique level values will be sorted.
 void setMode(int mode)
          Determines the mode that is used to build the level structure.
 void setNodeComparator(Comparator nodeComparator)
          Assigns the comparator that will be used to make out the unique nodes at each tree level.
 void setSorted(boolean sorted)
          Determines whether the unique level values will be sorted.
 void setTreeTableModel(TreeTableModel model)
          Assigns a new underlying treetable model
 
Methods inherited from class com.citra.treetable.DefaultMutableTreeTableModel
createLeafNode, createNonLeafNode, getEditable, getValueAt, isCellEditable, replicateLeafNode, setEditable, setValueAt
 
Methods inherited from class com.citra.treetable.ComparableTreeTableModel
add, add, addNode, addRowComparator, clearComparators, comparatorsChanged, createDefaultComparators, findTreeNode, getAddChildForGroup, getDefaultComparator, getRowComparator, getRowComparators, getRowComparatorSize, insertRowComparator, loadComparators, refreshComparators, removeRowComparator, removeRowComparator, saveComparators, setAddChildForGroup, setDefaultComparator, setRowComparator
 
Methods inherited from class com.citra.treetable.MutableTreeTableModel
addColumn, addColumn, addReorderListener, fireRowsMapped, fireRowsReordered, getChild, getColumnCount, getIndexOfChild, getPathToRoot, getPathToRoot, insertNodeInto, isLeaf, moveNode, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, removeNodeFromParent, removeReorderListener, setColumnClasses, setColumnNames, valueForPathChanged
 
Methods inherited from class com.citra.treetable.AbstractTreeTableModel
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeTableStructureChanged, fireTreeTableStructureChanged, getRoot, isAggregate, isFooter, isHeader, removeTreeModelListener, setRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected TreeTableModel model
the underlying treetable model


mode

protected int mode
the mode that is used to build the unique structure by level


sorted

protected boolean sorted
flag indicating whether the unique level values will be sorted


nodeComparator

protected Comparator nodeComparator
the comparator that is used to compare tree nodes between them at each tree level


ROOT_MODE

public static final int ROOT_MODE
the root mode

See Also:
Constant Field Values

LEVEL_MODE

public static final int LEVEL_MODE
the level mode

See Also:
Constant Field Values
Constructor Detail

UniqueTreeTableModel

public UniqueTreeTableModel(TreeTableModel model,
                            int column)
Constructs a UniqueTreeTableModel that compares nodes at a designated column with a GeneralComparator.


UniqueTreeTableModel

public UniqueTreeTableModel(TreeTableModel model,
                            int column,
                            Comparator columnComparator)
Constructs a UniqueTreeTableModel that compares nodes at a designated column and comparator.


UniqueTreeTableModel

public UniqueTreeTableModel(TreeTableModel model,
                            Comparator nodeComparator)
Constructs a UniqueTreeTableModel that compares nodes with the supplied nodeComparator.

Method Detail

clear

public void clear()
Removes all children from the root node and rebuilds the model.

Overrides:
clear in class MutableTreeTableModel

getChildCount

public int getChildCount(Object parent)
Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this data source.

Specified by:
getChildCount in interface TreeModel
Overrides:
getChildCount in class MutableTreeTableModel
Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the number of children of the node parent

getColumnClass

public Class getColumnClass(int column)
Returns the class of all the cells in the column.

Specified by:
getColumnClass in interface TreeTableModel
Overrides:
getColumnClass in class MutableTreeTableModel
Parameters:
column - the index of the column
Returns:
the class of all the cells in the column.

getColumnName

public String getColumnName(int column)
Returns the name of the column at columnIndex as it will be displayed by the table

Specified by:
getColumnName in interface TreeTableModel
Overrides:
getColumnName in class MutableTreeTableModel
Parameters:
column - the index of the column
Returns:
the name of the column

getMode

public int getMode()
Determines the mode that is used to build the level structure. Valid modes are:
ROOT_MODE: each level is a child of the root and
LEVEL_MODE: each level is found after the last child of the previous level.

The default mode is ROOT_MODE.

Returns:
the mode used to build the tree structure

getStringForLevel

public String getStringForLevel(int level)
Returns the string to return for the supplied level. The default is 'Level '.

Parameters:
level - the node level

getTreeTableModel

public TreeTableModel getTreeTableModel()
Returns the underlying treetable model.

Returns:
the underlying treetable model

isSorted

public boolean isSorted()
Determines whether the unique level values will be sorted.

Returns:
true if the list of unique values is sorted, false otherwise.

setMode

public void setMode(int mode)
Determines the mode that is used to build the level structure. Valid modes are:
ROOT_MODE: each level is a child of the root and
LEVEL_MODE: each level is found after the last child of the previous level.

The default mode is ROOT_MODE.

Parameters:
mode - the mode used to build the tree structure

setNodeComparator

public void setNodeComparator(Comparator nodeComparator)
Assigns the comparator that will be used to make out the unique nodes at each tree level.

Parameters:
nodeComparator - the comparator to use

setSorted

public void setSorted(boolean sorted)
Determines whether the unique level values will be sorted.

Parameters:
sorted - true if the list of unique values is sorted, false otherwise.

setTreeTableModel

public void setTreeTableModel(TreeTableModel model)
Assigns a new underlying treetable model

Parameters:
model - the new treetablemodel to assign

Copyright © 2011 Citra Technologies. All Rights Reserved.