T
- the object type of the user objectpublic class DefaultMutableTreeTableNode<T> extends DefaultMutableTreeNode implements IMutableTreeTableNode, Comparator
ITreeTableNode
interface.
A tree table node may have at most one parent and 0 or more children.
DefaultMutableTreeTableNode
provides operations for examining and
modifying a node's parent and children and also operations for examining the
tree that the node is a part of. A node's tree is the set of all nodes that
can be reached by starting at the node and following all the possible links
to parents and children. A node with no parent is the root of its tree; a
node with no children is a leaf. A tree may consist of many subtrees, each
node acting as the root for its own subtree.
This class provides enumerations for efficiently traversing a tree or subtree
in various orders or for following the path between two nodes. A
DefaultMutableTreeTableNode
may also hold a reference to a user
object, the use of which is left to the user. Asking a
DefaultMutableTreeTableNode
for its string representation with
DefaultMutableTreeNode.toString()
returns the string representation of its user object.
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
Constructor and Description |
---|
DefaultMutableTreeTableNode()
Creates a tree node that has no parent and no children, but which allows
children.
|
DefaultMutableTreeTableNode(boolean allowsChildren)
Creates a tree table node with no parent, no children, no user object,
which allows children only if specified.
|
DefaultMutableTreeTableNode(T userObject)
Creates a tree node with no parent, no children, but which allows
children, and initializes it with the specified user object.
|
DefaultMutableTreeTableNode(T userObject,
boolean allowsChildren)
Creates a tree table node with no parent, no children, initialized with
the specified user object, and that allows children only if specified.
|
Modifier and Type | Method and Description |
---|---|
void |
add(MutableTreeNode newChild) |
protected int |
compare(int modelIndex,
Object value1,
Object value2,
boolean ascending)
Compares two values with each other via this algorithm:
if value1 is NULL then return -1
if value2 is NULL then return +1
if getComparator(modelIndex) != null then return result of Comparator#compare(Object, Object)
if values implement
throw IllegalArgumentException -> unable to sort
|
int |
compare(Object o1,
Object o2) |
Object |
getColumnValue(int modelIndex)
Returns the value for the given model index.
|
Comparator |
getComparator(int modelIndex)
Returns a comparator for comparing values stored under the given model
index.
|
int |
getDragActions()
Returns the drag actions that can be performed on the tree table node.
|
int |
getDropActions(ITreeTableNode dropCandidate)
Returns the drop actions that can be performed on the node related to
another node.
|
Object |
getKey()
Returns the node's key object.
|
Comparator |
getKeyComparator()
Returns the comparator that will be used for comparing key values of tree
table nodes.
|
Object |
getPopupObject(boolean extended)
Returns the object for the popup window.
|
Object |
getPopupTitleObject()
Returns the object for the popup window title.
|
Object |
getRowHeaderValue()
Returns a value that can be used by the row header and the row header
renderer to control the rendering of the row header.
|
int |
getRowHeight()
Returns the current row height of the node.
|
int |
getRowHeightMaximum()
Returns the node's maximum row height.
|
int |
getRowHeightMinimum()
Returns the node's minimum row height.
|
String |
getToolTipText(TreeTableColumn modelIndex)
Returns the appropriate tooltip text for the given column.
|
T |
getTypedUserObject()
Returns the user object.
|
Object |
getUserObject()
Deprecated.
use
getTypedUserObject() instead |
void |
insert(MutableTreeNode newChild,
int childIndex) |
boolean |
isDeletable()
Returns TRUE if the whole node can be deleted.
|
boolean |
isKeyEditable()
Specifies whether or not the key value of the node can be edited /
replaced.
|
boolean |
isReassignable(Object parent)
Checks whether the node "could be" reassigned to the given potential
parent node.
|
boolean |
isResizable()
Returns TRUE if the tree node can be resized.
|
boolean |
isRowLineVisible(boolean expanded)
Returns TRUE if the horizontal grid line of the row in which the node is
displayed shall be drawn or not (the answer to this question of depends
on the state of the node, whether it is expanded or closed).
|
boolean |
isSelectable()
Returns TRUE if the tree node can be selected.
|
boolean |
isSorting()
Returns TRUE if the node sorts its children.
|
boolean |
isValueEditable(int modelIndex)
Returns TRUE if the column value at the given model index can be edited.
|
void |
setColumnValue(Object value,
int modelIndex)
Sets the value for the given model index.
|
void |
setComparator(int modelIndex,
Comparator comp)
Sets a comparator that will be used for comparing values stored under the
given model index.
|
static void |
setDefaultRowHeight(int height)
Sets the default row height for any new node.
|
void |
setDeletable(boolean b)
Specifies whether or not the entire node can be deleted from the tree
table model.
|
void |
setDragActions(int actions)
Sets the drag actions that can be performed on the tree table node.
|
void |
setKey(Object key)
Sets the node's key object.
|
void |
setKeyComparator(Comparator comparator)
Sets the comparator that will be used for comparing key values of tree
table nodes.
|
void |
setKeyEditable(boolean b)
Specifies whether or not the key value of the node can be edited /
replaced.
|
void |
setPopupObject(Object object,
boolean extended)
Sets an object on the tree node that will be used as input for the popup
renderer.
|
void |
setPopupTitleObject(Object object)
Sets the title object used for popup information windows.
|
void |
setResizable(boolean resizable)
Specifies whether the row height of the node is resizable.
|
void |
setRowHeaderValue(Object value)
Sets a row header value that can be used by the row ehader and the row
header renderer to control the rendering of the row header.
|
void |
setRowHeight(int rowHeight)
Specifies a new row height for the tree table node.
|
void |
setRowHeightMaximum(int max)
Sets the maximum height that the row showing this node may have.
|
void |
setRowHeightMinimum(int min)
Sets the minimum height that the row showing this node may have.
|
void |
setRowLineVisible(boolean visibleExpanded,
boolean visibleCollapsed)
Specifies whether the horizontal grid line of the row in which the node
gets displayed will be drawn or not.
|
void |
setSelectable(boolean b)
Specifies whether the node is selectable or not.
|
void |
setToolTipText(String ttt)
Sets a tooltip text on the node.
|
void |
setTypedUserObject(T userObject)
Sets a new user object on the node.
|
void |
setUserObject(Object userObject)
Deprecated.
use
setTypedUserObject(Object) instead |
void |
setValueEditable(int modelIndex,
boolean b)
Specifies which column values can be edited or not.
|
void |
sort(int[] modelIndices,
boolean[] sortDirections)
Invokes multi-column sorting on the tree table node.
|
breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, toString
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
remove, remove, removeFromParent, setParent
children, getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public DefaultMutableTreeTableNode(T userObject, boolean allowsChildren)
userObject
- an object provided by the user that constitutes the node's
dataallowsChildren
- if TRUE, the node is allowed to have child nodes -- otherwise,
it is always a leaf nodepublic DefaultMutableTreeTableNode(T userObject)
userObject
- an object provided by the user that constitutes the node's
datapublic DefaultMutableTreeTableNode(boolean allowsChildren)
allowsChildren
- if TRUE, the node is allowed to have child nodes -- otherwise,
it is always a leaf nodepublic DefaultMutableTreeTableNode()
public int getRowHeight()
ITreeTableNode
getRowHeight
in interface ITreeTableNode
ITreeTableNode.getRowHeightMaximum()
,
ITreeTableNode.getRowHeightMinimum()
,
IRowPolicy.getRowHeight(Object, ITreeTableModel)
,
IRowPolicy.getRowResizeCommand(Object, ITreeTableModel, int)
,
DefaultRowResizeCommand
public void setRowHeight(int rowHeight)
ITreeTableNode
setRowHeight
in interface ITreeTableNode
rowHeight
- the new row heightIRowPolicy.isRowResizable(Object, ITreeTableModel)
,
IRowPolicy.getRowResizeCommand(Object, ITreeTableModel, int)
,
DefaultRowPolicy
,
DefaultRowResizeCommand
public int getRowHeightMaximum()
ITreeTableNode
getRowHeightMaximum
in interface ITreeTableNode
ITreeTableNode.getRowHeight()
,
ITreeTableNode.getRowHeightMinimum()
,
IRowPolicy.getRowHeightMaximum(Object, ITreeTableModel)
,
IRowPolicy.getRowResizeCommand(Object, ITreeTableModel, int)
,
DefaultRowResizeCommand
public void setRowHeightMaximum(int max)
max
- the maximum row heightsetRowHeight(int)
,
setRowHeightMinimum(int)
public int getRowHeightMinimum()
ITreeTableNode
getRowHeightMinimum
in interface ITreeTableNode
ITreeTableNode.getRowHeight()
,
ITreeTableNode.getRowHeightMaximum()
,
IRowPolicy.getRowHeightMinimum(Object, ITreeTableModel)
,
IRowPolicy.getRowResizeCommand(Object, ITreeTableModel, int)
,
DefaultRowResizeCommand
public void setRowHeightMinimum(int min)
min
- the minimum row heightsetRowHeight(int)
,
setRowHeightMaximum(int)
public Object getColumnValue(int modelIndex)
ITreeTableNode
getColumnValue
in interface ITreeTableNode
modelIndex
- the model index provided by the columnTreeTableColumn.getModelIndex()
public void setColumnValue(Object value, int modelIndex)
ITreeTableNode
setColumnValue
in interface ITreeTableNode
value
- the new valuemodelIndex
- the model index provided by the columnTreeTableColumn.getModelIndex()
,
DefaultChangeValueCommand
,
INodeEditPolicy.getChangeValueCommand(Object, ITreeTableModel,
Object, int)
public boolean isSelectable()
ITreeTableNode
isSelectable
in interface ITreeTableNode
INodeEditPolicy.isSelectable(Object, ITreeTableModel)
public void setSelectable(boolean b)
b
- if TRUE the user will be able to add the node to the tree
table's current selectionisSelectable()
public boolean isResizable()
ITreeTableNode
isResizable
in interface ITreeTableNode
IRowPolicy.isRowResizable(Object, ITreeTableModel)
,
IRowPolicy.getRowResizeCommand(Object, ITreeTableModel, int)
,
DefaultRowResizeCommand
,
ITreeTableNode.getRowHeight()
,
ITreeTableNode.getRowHeightMaximum()
,
ITreeTableNode.getRowHeightMinimum()
public void setResizable(boolean resizable)
resizable
- if TRUE the user will be able to change the row heightisResizable()
public boolean isRowLineVisible(boolean expanded)
ITreeTableNode
isRowLineVisible
in interface ITreeTableNode
expanded
- if TRUE the tree table node is currently expandedIRowPolicy.isRowLineVisible(Object, boolean, ITreeTableModel)
public void setRowLineVisible(boolean visibleExpanded, boolean visibleCollapsed)
visibleExpanded
- if TRUE the horizontal grid line of the row will be visible
when the node is expandedvisibleCollapsed
- if TRUE the horizontal grid line of the row will be visible
when the node is collapsedIRowPolicy.isRowLineVisible(Object, boolean, ITreeTableModel)
public boolean isValueEditable(int modelIndex)
ITreeTableNode
isValueEditable
in interface ITreeTableNode
modelIndex
- the model indexINodeEditPolicy.isValueEditable(Object, ITreeTableModel, int)
,
INodeEditPolicy.getChangeValueCommand(Object, ITreeTableModel,
Object, int)
,
DefaultChangeValueCommand
public void setValueEditable(int modelIndex, boolean b)
modelIndex
- the model index for which editing will be enabled / disabledb
- if TRUE turns on value editing for the given model indexisValueEditable(int)
public boolean isKeyEditable()
isKeyEditable
in interface ITreeTableNode
setKeyEditable(boolean)
public void setKeyEditable(boolean b)
b
- if TRUE the key can be editedisKeyEditable()
public void setToolTipText(String ttt)
ttt
- the tooltip text to usegetToolTipText(TreeTableColumn)
public String getToolTipText(TreeTableColumn modelIndex)
ITreeTableNode
getToolTipText
in interface ITreeTableNode
modelIndex
- the column for which to return a tooltip textIRowPolicy.getRowToolTip(Object, ITreeTableModel, TreeTableColumn)
,
DefaultRowPolicy
public void setKey(Object key)
ITreeTableNode
setKey
in interface ITreeTableNode
key
- the node's key objectITreeTableNode.getKey()
,
DefaultChangeKeyCommand
,
INodeEditPolicy.getChangeKeyCommand(Object, ITreeTableModel, Object)
public Object getKey()
ITreeTableNode
getKey
in interface ITreeTableNode
ITreeTableNode.setKey(Object)
,
ITreeTableModel.getKey(Object)
,
DefaultTreeTableModel.getKey(ITreeTableNode)
,
setKey(Object)
,
getKey()
public boolean isDeletable()
ITreeTableNode
isDeletable
in interface ITreeTableNode
INodeEditPolicy.isDeletable(Object, ITreeTableModel)
,
INodeEditPolicy.getDeleteNodesCommand(java.util.List,
ITreeTableModel)
,
DefaultDeleteNodeCommand
public void setDeletable(boolean b)
b
- if TRUE the node can be deletedisDeletable()
public Object getRowHeaderValue()
ITreeTableNode
getRowHeaderValue
in interface ITreeTableNode
IRowHeaderRenderer
,
ITreeTableModel.getRowHeaderValue(Object)
public void setRowHeaderValue(Object value)
ITreeTableNode
setRowHeaderValue
in interface ITreeTableNode
value
- the row header valueIRowHeaderRenderer
,
ITreeTableModel.getRowHeaderValue(Object)
@Deprecated public final void setUserObject(Object userObject)
setTypedUserObject(Object)
insteadsetUserObject
in interface MutableTreeNode
setUserObject
in class DefaultMutableTreeNode
@Deprecated public final Object getUserObject()
getTypedUserObject()
insteadgetUserObject
in class DefaultMutableTreeNode
public void setTypedUserObject(T userObject)
setUserObject(Object)
in order to support generics for user
objects.userObject
- the user object to set on the nodepublic T getTypedUserObject()
getUserObject()
method in order to support generics for user
object.public void sort(int[] modelIndices, boolean[] sortDirections)
ITreeTableNode
sort
in interface ITreeTableNode
modelIndices
- the model indices that are used to determine which column
values to compare for sorting (use
KeyColumn.MODEL_INDEX
to specify a sort based on the
key columnsortDirections
- if TRUE the sort direction will be ascendingITreeTableModel.sort(Object, int[], boolean[])
public boolean isSorting()
sort(int[], boolean[])
public void add(MutableTreeNode newChild)
add
in class DefaultMutableTreeNode
public void insert(MutableTreeNode newChild, int childIndex)
insert
in interface MutableTreeNode
insert
in class DefaultMutableTreeNode
public void setKeyComparator(Comparator comparator)
Comparable
interface implementation.comparator
- the comparator that will be used when sorting key valuesgetKeyComparator()
public Comparator getKeyComparator()
Comparable
interface implementation.public void setComparator(int modelIndex, Comparator comp)
modelIndex
- the model index for which to specify a comparatorcomp
- the comparator that will be used for comparing values stored
under the given model indexgetComparator(int)
,
compare(Object, Object)
public Comparator getComparator(int modelIndex)
Comparable
interface implemenation.modelIndex
- the model index for which to return a comparatorsetComparator(int, Comparator)
,
compare(int, Object, Object, boolean)
,
compare(Object, Object)
public int compare(Object o1, Object o2)
compare
in interface Comparator
protected int compare(int modelIndex, Object value1, Object value2, boolean ascending)
if value1 is NULL then return -1
if value2 is NULL then return +1
if getComparator(modelIndex) != null then return result of Comparator#compare(Object, Object)
if values implement Comparable
then return Comparable#compareTo(Object)
throw IllegalArgumentException -> unable to sort
modelIndex
- the model index under which the values were stored (the index
is important for looking up the correct comparator)value1
- the first value for the comparisonvalue2
- the second value for the commparisonascending
- the sort order (ascending or descending)getComparator(int)
,
sort(int[], boolean[])
public int getDragActions()
ITreeTableNode
DnDConstants
. Possible values are:
Declaring the drag actions is only half of the work needed for correct
drag and drop behaviour. A node might be draggable but it also needs a
place where it can be dropped. The drop places are defined by
ITreeTableNode.getDropActions(ITreeTableNode)
.getDragActions
in interface ITreeTableNode
DefaultNodeDragAndDropCommand
,
INodeDragAndDropPolicy.getDragActions(Object, ITreeTableModel)
public void setDragActions(int actions)
DnDConstants
. Possible values are:
Declaring the drag actions is only half of the work needed for correct
drag and drop behaviour. A node might be draggable but it also needs a
place where it can be dropped. The drop places are defined by
ITreeTableNode.getDropActions(ITreeTableNode)
.actions
- the supported drag actions (move, copy, or both)DefaultNodeDragAndDropCommand
,
INodeDragAndDropPolicy.getDragActions(Object, ITreeTableModel)
public int getDropActions(ITreeTableNode dropCandidate)
ITreeTableNode
DnDConstants
.
Possible values are:
Declaring the drop actions is only half of the work needed for correct
drag and drop behaviour. A node might be droppable onto another
node but it also needs to be draggable.This behaviour is defined
by calling ITreeTableNode.getDragActions()
.getDropActions
in interface ITreeTableNode
dropCandidate
- the node that might get dropped onto this nodeDefaultNodeDragAndDropCommand
,
INodeDragAndDropPolicy.getDropActions(Object, Object,
ITreeTableModel, Object, ITreeTableModel)
public boolean isReassignable(Object parent)
MutableTreeNode
interface and if
the new parent returns TRUE when calling
TreeNode.getAllowsChildren()
.isReassignable
in interface ITreeTableNode
parent
- the potential new parentpublic Object getPopupObject(boolean extended)
ITreeTableNode
getPopupObject
in interface ITreeTableNode
extended
- a flag that signals whether the user wants to see the standard
popup information or the extended versionPopupLayer
,
IPopupRenderer
,
DefaultPopupRenderer
,
IPopupPolicy.getPopupValue(javax.swing.tree.TreePath,
IGanttChartModel, boolean)
public void setPopupObject(Object object, boolean extended)
extended
- a flag used to determine if the given object will be used as
for the standard or the extended popupobject
- the popup object that will be visualized by the popup layer
and rendererIPopupRenderer
,
PopupLayer
,
IPopupPolicy
public Object getPopupTitleObject()
ITreeTableNode
getPopupTitleObject
in interface ITreeTableNode
PopupLayer
,
IPopupRenderer
,
DefaultPopupRenderer
,
IPopupPolicy.getPopupTitleValue(javax.swing.tree.TreePath,
IGanttChartModel)
public void setPopupTitleObject(Object object)
object
- IPopupPolicy.getPopupTitleValue(javax.swing.tree.TreePath,
IGanttChartModel)
,
DefaultPopupRenderer
public static void setDefaultRowHeight(int height)
height
- the row height that any new node will initially haveCopyright © 2006–2016 Dirk Lemmermann Software & Consulting. All rights reserved.