JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.treetable
Class TreeTableSupport

java.lang.Object
  |
  +--com.klg.jclass.util.treetable.TreeTableSupport
All Implemented Interfaces:
EventListener, JCRowSortModel, JCRowSortTableModel, RowMapper, Serializable, TableModel, TableModelListener

public class TreeTableSupport
extends Object
implements TableModel, JCRowSortTableModel, TableModelListener, RowMapper, Serializable

Internal class.

It is used by JCTreeTable to map tree functionality to a table component.

This class provides an implementation to handle a TreeModel/Table Model combination for use within a Table component.

Specific functionality includes tracking expanded node counts as well as mapping and posting expansion and selection events.

This class also provides a node "painter" object that can be wrapped into a Swing CellRenderer or a JClass CellRenderer.

NOTE: the API for this class is not frozen.

See Also:
Serialized Form

Nested Class Summary
protected  class TreeTableSupport.DefaultIcon
          Icon to use if plaf fails to provide one
 
Field Summary
protected  boolean autoSort
           
protected  int cellHeight
           
protected  Icon closedIcon
           
protected  Icon collapsedIcon
           
protected  boolean drawLines
           
protected  Icon expandedIcon
           
protected  Hashtable expandedState
           
protected  com.klg.jclass.util.treetable.JCTreeIconRenderer iconRenderer
           
protected  int[][] keyColumnsArray
           
protected  Icon leafIcon
           
protected  int leftLevelSpacing
           
protected  int levelIndent
           
protected  Color lineColor
           
protected  Stroke lineStroke
           
protected  int lineThickness
           
static int NODE_LINES_HIDE
          valid value for ShowNodeLines
static int NODE_LINES_SHOW
          valid value for ShowNodeLines
static int NODE_LINES_USE_PLAF
          valid (default) value for ShowNodeLines
protected  Icon openIcon
           
protected  int rightLevelSpacing
           
protected  boolean rootVisible
           
protected  com.klg.jclass.util.treetable.TreeTableSupport.RemovableVector rowMap
          Map of expanded nodes to "treetable" rows
protected  boolean scrollsOnExpand
           
protected  int showNodeLines
           
protected  boolean showsRootHandles
           
protected  boolean sortable
           
protected  int sortOrder
           
protected  TableModel table
           
static int TABLE
          valid value for view
protected  Color tableBackground
           
protected  com.klg.jclass.util.JCListenerList tableListeners
           
static int TREE
          valid value for view
protected  int treeColumn
           
protected  com.klg.jclass.util.JCListenerList treeExpansionListeners
           
protected  TreeModelListener treeListener
           
protected  com.klg.jclass.util.JCListenerList treeSelectionListeners
           
protected  com.klg.jclass.util.treetable.JCTreeTableModel treetable
           
protected  com.klg.jclass.util.JCListenerList treeWillExpandListeners
           
protected  int view
           
protected  JComponent visualComponent
           
 
Fields inherited from interface com.klg.jclass.util.swing.JCRowSortModel
FORWARD, REVERSE
 
Constructor Summary
TreeTableSupport(JComponent visual_component)
          construct a treetable support class
TreeTableSupport(JComponent visual_component, com.klg.jclass.util.treetable.JCTreeTableModel model)
           
 
Method Summary
protected  void addKids(Object parent, TreePath parent_path, Vector new_kids)
          Add children of the parent whose path is in parent_path to the new_kids vector
 void addTableModelListener(TableModelListener l)
           
 void addTreeExpansionListener(TreeExpansionListener l)
          Adds a listener for TreeExpansion events.
 void addTreeWillExpandListener(TreeWillExpandListener l)
          Adds a listener for TreeWillExpand events.
 void clearExpandedState()
          Resets the expanded state hashtable.
protected  void clearExpandedState(boolean post_change_event)
          Resets the expanded state hashtable.
 void collapsePath(TreePath path)
          Ensures that the node identified by the specified path is collapsed and viewable.
 void collapsePathRow(TreePath path, int row)
           
 void collapseRow(int row)
          Ensures that the node in the specified row is collapsed.
protected  int countKidsToRemove(Object parent, TreePath parent_path)
           
 void expandPath(TreePath path)
          Ensures that the node identified by the specified path is expanded and viewable.
protected  void expandPathRow(TreePath path, int row)
          Ensures that the node identified by the specified path is expanded and viewable.
 void expandRow(int row)
          Ensures that the node in the specified row is expanded and viewable.
 boolean getAutoSort()
          Returns whether the data is automatically sorted when it changes according the current comparator.
 Class getColumnClass(int column)
           
 int getColumnCount()
           
 String getColumnName(int column)
           
 Enumeration getExpandedDescendants(TreePath parent)
          Returns an Enumeration of the descendants of path that are currently expanded.
protected  void getExpandedKids(TreePath parent, Vector kids)
          Store the paths of the children which are expanded for a given parent in a vector
 int[] getKeyColumns(int column)
          Return the key columns used to sort the table model when clicking on the specified column.
protected  int getLevel(int row)
          Get the level (how many nodes on the path) for the current row
 int getLevelIndent()
          Get the width of a single indent level.
 int getMaxIconHeight()
          Return the maximum height of the icons used
protected  Object getNode(int row)
          Returns the node that maps to the specified row of the treetable view.
protected static Object getNode(TreePath path)
          Given a TreePath this method returns the last component or "node" of the TreePath.
protected  Icon getNodeIcon(TreePath path, Object value, Class value_class, boolean is_leaf, boolean is_expanded)
          Return the icon for the node of a given path.
 int getNodeIndent(TreePath path)
          Returns the x offset at which we can begin drawing the value of the heirarchy column.
protected static Object getParent(TreePath path)
          Given a tree path, this method returns the parent object or null if no parent exists.
 TreePath getPathForRow(int row)
          Returns the path for the specified row.
protected  TreePath getPathForRow(int viewType, int row)
          Returns the path for the specified row.
 int getRendererIndent(TreePath path)
          Deprecated. As of JClass DesktopViews 6.3. Use getRenderIndent(path, value, value_class) instead.
 int getRendererIndent(TreePath path, Object value, Class value_class)
          Returns the x offset at which we need to place the renderer.
 int getRowCount()
           
protected  int getRowForPath(int viewType, TreePath path)
          Returns the row that displays the node identified by the specified path.
 int getRowForPath(TreePath path)
          Returns the row that displays the node identified by the specified path.
 int[] getRowsForPaths(TreePath[] paths)
          Return the rows for the visible specified paths
protected  com.klg.jclass.util.swing.JCRowSortModel getRowSortModel()
          Routine that returns a JCRowSortModel if the cirrcumstances warrant it.
 boolean getScrollsOnExpand()
          Returns true if the tree scrolls to show previously hidden children.
 int getShowNodeLines()
          Return the state of ShowNodeLines.
 boolean getShowsRootHandles()
          Returns true if handles for the root nodes are displayed.
 int getSortColumn()
          Gets the sorting column.
 int getSortedRow(int row)
          Returns the index of the unsorted row for the table view
 int getSortOrder()
          Gets the sorting order to use the next time a sort is performed
 TableModel getTableModel()
          Return the table model that corresponds to the treetable model.
 int getTreeColumn()
          Get the tree column index
 Class getTreeColumnClass()
          Returns the true class stored in the tree column.
 Object getTreeColumnValue(Object node)
          Returns the true value stored in the tree column.
 com.klg.jclass.util.treetable.JCTreeIconRenderer getTreeIconRenderer()
          Return the icon renderer being used.
 com.klg.jclass.util.treetable.JCTreeTableModel getTreeTableModel()
          Return the treetable model that is the source of all.
 int getUnsortedRow(int sortRow)
          Returns the index of the unsorted row for the table view
 Object getValueAt(int row, int column)
           
 int getView()
          Return the current view.
 boolean hasBeenExpanded(TreePath path)
          Returns true if the node identified by the path has ever been expanded (since the last "clearExpandedState" call).
 void inferLookAndFeel()
           
protected  void initTableViewModels()
           
 boolean isCellEditable(int row, int column)
           
 boolean isDataSorted()
          Returns whether or not the data set is currently sorted
 boolean isExpanded(TreePath path)
          Returns true if the node identified by the path is currently expanded,
protected static boolean isLastChild(com.klg.jclass.util.treetable.JCTreeTableModel treetable, TreePath path)
          Figure out if the current node is the last of it's siblings we need to know this so we can figure out whether to draw a continuation line or not
protected  boolean isPointInControlBox(Point p, int row, int column, int cell_height, int level)
          Is the point within the dimensions of the control icon within the tree column cell for a given row.
 boolean isRootVisible()
          Returns true if the root node of the tree is displayed.
 boolean isSortable()
          Returns whether we allow sorting of the data or not
protected  void mapTreeTable(boolean post_change_event)
           
protected  void postTableModelChanged(TableModelEvent event)
          Sent the given table model changed event to interested listeners.
 void prepareCellForRender(Graphics gc, int width, int height)
          Set the color and fill an area of width by height with that color
 boolean processClickInTreeColumn(MouseEvent ev, int row, int column, Point p, int cell_height)
          Processes a click in the table.
 void removeTableModelListener(TableModelListener l)
           
 void removeTreeExpansionListener(TreeExpansionListener l)
          Removes a listener for TreeExpansion events.
 void removeTreeWillExpandListener(TreeWillExpandListener l)
          Removes a listener for TreeWillExpand events.
 void renderHierarchy(Graphics gc, Rectangle drawing_area, TreePath path, Object value, Class value_class)
          Used to draw the cell.
 void scrollPathToVisible(TreePath path)
          Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed.
 void setAutoSort(boolean autoSort)
          Sets whether the data should be automatically sorted when it changes
 void setDataSorted(boolean sorted)
          Sorts data by current column if set to true and the data needs sorting; or if set to false it returns the data set to its native unsorted state
 void setKeyColumns(int column, int[] keyColumns)
          Set the key columns used to sort the table model when clicking on specified column.
 void setRootVisible(boolean rootVisible)
          Determines whether or not the root node from the TreeModel is visible.
 void setScrollsOnExpand(boolean newValue)
          Determines whether or not when a node is expanded, as many of the descendants are scrolled to be inside the viewport as possible.
 void setShowNodeLines(int lines)
          Allows you override the plaf specified behavior of drawing lines.
 void setShowsRootHandles(boolean newValue)
          Determines whether the node handles are to be displayed.
 void setSortable(boolean sortable)
          Sets whether we allow sorting or not.
 void setSortColumn(int column)
          Set the column to use the next time a sort is performed
 void setSortOrder(int order)
          Sets the sorting order.
 void setTreeIconRenderer(com.klg.jclass.util.treetable.JCTreeIconRenderer renderer)
          Set the icon renderer.
 void setTreeTableModel(com.klg.jclass.util.treetable.JCTreeTableModel treetable)
          Set the tree/table model that we are using
 void setValueAt(Object value, int row, int column)
           
 void setView(int view)
          Set whether we are viewing this as a tree or a table.
 void tableChanged(TableModelEvent e)
          Called when the table's model is changed
 void toggleSortOrder()
          Toggles the sorting order.
protected  void toggleState(int row)
          Toggle the expanded/collapsed state of a row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TREE

public static final int TREE
valid value for view

See Also:
Constant Field Values

TABLE

public static final int TABLE
valid value for view

See Also:
Constant Field Values

NODE_LINES_SHOW

public static final int NODE_LINES_SHOW
valid value for ShowNodeLines

See Also:
Constant Field Values

NODE_LINES_HIDE

public static final int NODE_LINES_HIDE
valid value for ShowNodeLines

See Also:
Constant Field Values

NODE_LINES_USE_PLAF

public static final int NODE_LINES_USE_PLAF
valid (default) value for ShowNodeLines

See Also:
Constant Field Values

sortable

protected boolean sortable

sortOrder

protected int sortOrder

keyColumnsArray

protected int[][] keyColumnsArray

autoSort

protected boolean autoSort

showNodeLines

protected int showNodeLines

visualComponent

protected JComponent visualComponent

view

protected int view

treetable

protected com.klg.jclass.util.treetable.JCTreeTableModel treetable

table

protected TableModel table

treeListener

protected TreeModelListener treeListener

tableListeners

protected com.klg.jclass.util.JCListenerList tableListeners

treeColumn

protected int treeColumn

treeExpansionListeners

protected com.klg.jclass.util.JCListenerList treeExpansionListeners

treeSelectionListeners

protected com.klg.jclass.util.JCListenerList treeSelectionListeners

treeWillExpandListeners

protected com.klg.jclass.util.JCListenerList treeWillExpandListeners

rootVisible

protected boolean rootVisible

showsRootHandles

protected boolean showsRootHandles

iconRenderer

protected com.klg.jclass.util.treetable.JCTreeIconRenderer iconRenderer

scrollsOnExpand

protected boolean scrollsOnExpand

expandedIcon

protected Icon expandedIcon

collapsedIcon

protected Icon collapsedIcon

leftLevelSpacing

protected int leftLevelSpacing

rightLevelSpacing

protected int rightLevelSpacing

levelIndent

protected int levelIndent

openIcon

protected Icon openIcon

closedIcon

protected Icon closedIcon

leafIcon

protected Icon leafIcon

lineColor

protected Color lineColor

lineThickness

protected int lineThickness

lineStroke

protected Stroke lineStroke

drawLines

protected boolean drawLines

tableBackground

protected Color tableBackground

cellHeight

protected int cellHeight

rowMap

protected com.klg.jclass.util.treetable.TreeTableSupport.RemovableVector rowMap
Map of expanded nodes to "treetable" rows


expandedState

protected Hashtable expandedState
Constructor Detail

TreeTableSupport

public TreeTableSupport(JComponent visual_component,
                        com.klg.jclass.util.treetable.JCTreeTableModel model)

TreeTableSupport

public TreeTableSupport(JComponent visual_component)
construct a treetable support class

Parameters:
visual_component - is the component we are supporting; this needed for posting the correct event source.
Method Detail

inferLookAndFeel

public void inferLookAndFeel()

getRowsForPaths

public int[] getRowsForPaths(TreePath[] paths)
Return the rows for the visible specified paths

Specified by:
getRowsForPaths in interface RowMapper
Parameters:
paths - The paths whose rows are needed
Returns:
The list of rows for the given paths

setShowNodeLines

public void setShowNodeLines(int lines)
Allows you override the plaf specified behavior of drawing lines. Particularly useful in the Metal LookAndFeel.

Parameters:
lines - The type of line drawing desired. Valid values are NODE_LINES_USE_PLAF (the default), NODE_LINES_SHOW, NODE_LINES_HIDE.

getShowNodeLines

public int getShowNodeLines()
Return the state of ShowNodeLines.

Returns:
The current style of line drawing used. Will be one of NODE_LINES_USE_PLAF (the default), NODE_LINES_SHOW, NODE_LINES_HIDE.
See Also:
setShowNodeLines(int)

getMaxIconHeight

public int getMaxIconHeight()
Return the maximum height of the icons used

Returns:
The maximum height of the icons used

isSortable

public boolean isSortable()
Returns whether we allow sorting of the data or not

Returns:
Is sorting of data allowed?
See Also:
setSortable(boolean)

setSortable

public void setSortable(boolean sortable)
Sets whether we allow sorting or not.

Parameters:
sortable - The new value of sortable.
See Also:
isSortable()

initTableViewModels

protected void initTableViewModels()

setView

public void setView(int view)
Set whether we are viewing this as a tree or a table.

Parameters:
view - valid values are TREE and TABLE

getView

public int getView()
Return the current view.

Returns:
The current view. Will be one TREE or TABLE.
See Also:
setView(int)

setTreeTableModel

public void setTreeTableModel(com.klg.jclass.util.treetable.JCTreeTableModel treetable)
Set the tree/table model that we are using

Parameters:
treetable - The new treetable model

clearExpandedState

public void clearExpandedState()
Resets the expanded state hashtable. Has effect of setting the expanded state back to the default.


clearExpandedState

protected void clearExpandedState(boolean post_change_event)
Resets the expanded state hashtable. Has effect of setting the expanded state back to the default.


mapTreeTable

protected void mapTreeTable(boolean post_change_event)

getTreeTableModel

public com.klg.jclass.util.treetable.JCTreeTableModel getTreeTableModel()
Return the treetable model that is the source of all.

Returns:
The current treetable model

getTableModel

public TableModel getTableModel()
Return the table model that corresponds to the treetable model. Note that this model is a wrapper around the tree table model of type TableFromTreeTable which itself has been wrapped by a DefaultRowSortTableModel for sorting purposes. The returned model should be viewed as readonly!

Returns:
The current table model
See Also:
TableFromTreeTable, DefaultRowSortTableModel

hasBeenExpanded

public boolean hasBeenExpanded(TreePath path)
Returns true if the node identified by the path has ever been expanded (since the last "clearExpandedState" call).

Parameters:
path - The input path
Returns:
Whether this path has been expanded

postTableModelChanged

protected void postTableModelChanged(TableModelEvent event)
Sent the given table model changed event to interested listeners.

Parameters:
event - The event generated by the model change

setTreeIconRenderer

public void setTreeIconRenderer(com.klg.jclass.util.treetable.JCTreeIconRenderer renderer)
Set the icon renderer. If set to null no icon will be drawn

Parameters:
renderer - The new icon renderer

getTreeIconRenderer

public com.klg.jclass.util.treetable.JCTreeIconRenderer getTreeIconRenderer()
Return the icon renderer being used. If null then no icons are being drawn.

Returns:
The current icon renderer

getPathForRow

public TreePath getPathForRow(int row)
Returns the path for the specified row. If row is not visible null is returned.<-->

Parameters:
row - An int specifying a row
Returns:
The TreePath to the specified node, null if row < 0 or row > getRowCount()

getPathForRow

protected TreePath getPathForRow(int viewType,
                                 int row)
Returns the path for the specified row. If row is not visible null is returned.<-->

Parameters:
viewType - The type of view. Possible values are TREE and TABLE.
row - An int specifying a row
Returns:
The TreePath to the specified node, null if row < 0 or row > getRowCount()

getRowForPath

public int getRowForPath(TreePath path)
Returns the row that displays the node identified by the specified path.

Parameters:
path - the TreePath identifying a node
Returns:
an int specifying the display row, where 0 is the first row in the display, or -1 if any of the elements in path are hidden under a collapsed parent.

getRowForPath

protected int getRowForPath(int viewType,
                            TreePath path)
Returns the row that displays the node identified by the specified path.

Parameters:
viewType - The type of view. Possible values are TREE and TABLE.
path - the TreePath identifying a node
Returns:
an int specifying the display row, where 0 is the first row in the display, or -1 if any of the elements in path are hidden under a collapsed parent.

isExpanded

public boolean isExpanded(TreePath path)
Returns true if the node identified by the path is currently expanded,

Parameters:
path - the TreePath specifying the node to check
Returns:
false if any of the nodes in the node's path are collapsed, true if all nodes in the path are expanded

getAutoSort

public boolean getAutoSort()
Returns whether the data is automatically sorted when it changes according the current comparator. If sortable is false, this will also return false

Specified by:
getAutoSort in interface JCRowSortModel
Returns:
The current value of autoSort

setAutoSort

public void setAutoSort(boolean autoSort)
Sets whether the data should be automatically sorted when it changes

Specified by:
setAutoSort in interface JCRowSortModel
Parameters:
autoSort - If true, the data will be automatically sorted.

setKeyColumns

public void setKeyColumns(int column,
                          int[] keyColumns)
Set the key columns used to sort the table model when clicking on specified column.

Specified by:
setKeyColumns in interface JCRowSortModel
Parameters:
column - index of column in TableModel
keyColumns - columns to use as keys to sort when sorting on the specified column.

getKeyColumns

public int[] getKeyColumns(int column)
Return the key columns used to sort the table model when clicking on the specified column. If the user has not set the key columns the this returns an array of length 1 with the specified column as the only member.

Specified by:
getKeyColumns in interface JCRowSortModel
Parameters:
column - The column for which the key columns are required
Returns:
The key columns for the given column

getRowSortModel

protected com.klg.jclass.util.swing.JCRowSortModel getRowSortModel()
Routine that returns a JCRowSortModel if the cirrcumstances warrant it.

Returns:
The model for sorting rows (different for TREE and TABLE view)

isDataSorted

public boolean isDataSorted()
Returns whether or not the data set is currently sorted

Specified by:
isDataSorted in interface JCRowSortModel
Returns:
Is the data currently sorted (this could be a different answer depending on the current view)?

setDataSorted

public void setDataSorted(boolean sorted)
Sorts data by current column if set to true and the data needs sorting; or if set to false it returns the data set to its native unsorted state

Specified by:
setDataSorted in interface JCRowSortModel
Parameters:
sorted - Causes a sort (if needed) if true and an unsort if false.

getSortColumn

public int getSortColumn()
Gets the sorting column. This should return -1 if the data is unsorted

Specified by:
getSortColumn in interface JCRowSortModel
Returns:
The current sorting column (-1 if the data is unsorted).

setSortColumn

public void setSortColumn(int column)
Set the column to use the next time a sort is performed

Specified by:
setSortColumn in interface JCRowSortModel
Parameters:
column - only valid column indicies are allowed

getSortOrder

public int getSortOrder()
Gets the sorting order to use the next time a sort is performed

Specified by:
getSortOrder in interface JCRowSortModel
Returns:
The current sorting order. Will be one of JCRowSortModel.FORWARD or JCRowSortModel.BACKARD.

setSortOrder

public void setSortOrder(int order)
Sets the sorting order.

Specified by:
setSortOrder in interface JCRowSortModel
Parameters:
order - Sets the sort order to JCRowSortModel.FORWARD or JCRowSortModel.BACKWARD.

toggleSortOrder

public void toggleSortOrder()
Toggles the sorting order.

Specified by:
toggleSortOrder in interface JCRowSortModel

getUnsortedRow

public int getUnsortedRow(int sortRow)
Returns the index of the unsorted row for the table view

Specified by:
getUnsortedRow in interface JCRowSortTableModel
Parameters:
sortRow - The sorted row
Returns:
The unsorted row based on the sorted row. Returns a negative value on error.

getSortedRow

public int getSortedRow(int row)
Returns the index of the unsorted row for the table view

Specified by:
getSortedRow in interface JCRowSortTableModel
Parameters:
row - The unsorted row
Returns:
The sorted row based on the unsorted row. Returns a negative value on error.

tableChanged

public void tableChanged(TableModelEvent e)
Called when the table's model is changed

Specified by:
tableChanged in interface TableModelListener
Parameters:
e - The event generated by the change

addTableModelListener

public void addTableModelListener(TableModelListener l)
Specified by:
addTableModelListener in interface TableModel

removeTableModelListener

public void removeTableModelListener(TableModelListener l)
Specified by:
removeTableModelListener in interface TableModel

getColumnClass

public Class getColumnClass(int column)
Specified by:
getColumnClass in interface TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getValueAt

public Object getValueAt(int row,
                         int column)
Specified by:
getValueAt in interface TableModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface TableModel

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Specified by:
setValueAt in interface TableModel

getParent

protected static Object getParent(TreePath path)
Given a tree path, this method returns the parent object or null if no parent exists.

Parameters:
path - The path for which the parent is needed.
Returns:
The parent object or null if no parent exists
See Also:
getNode(javax.swing.tree.TreePath)

getNode

protected static Object getNode(TreePath path)
Given a TreePath this method returns the last component or "node" of the TreePath.

Parameters:
path - The path from which to get the node or last component
Returns:
The last component or node of the path
See Also:
getParent(javax.swing.tree.TreePath)

getNode

protected Object getNode(int row)
Returns the node that maps to the specified row of the treetable view.

Parameters:
row - The row for which the node is needed
Returns:
The last component of the path for the given row

getLevel

protected int getLevel(int row)
Get the level (how many nodes on the path) for the current row

Parameters:
row - The row for which the level is needed
Returns:
The level for the given row

toggleState

protected void toggleState(int row)
Toggle the expanded/collapsed state of a row. Only TREE view is affected.

Parameters:
row - The row on which the toggle is needed.

processClickInTreeColumn

public boolean processClickInTreeColumn(MouseEvent ev,
                                        int row,
                                        int column,
                                        Point p,
                                        int cell_height)
Processes a click in the table.

Parameters:
ev - The event from the mouse click
row - The row the point is in
column - The column the point is in
p - The coordinates of the point clicked relative to the cell
cell_height - The cell or row height
Returns:
true if the click has been processed

isPointInControlBox

protected boolean isPointInControlBox(Point p,
                                      int row,
                                      int column,
                                      int cell_height,
                                      int level)
Is the point within the dimensions of the control icon within the tree column cell for a given row.

Parameters:
p - The point to check
row - The row of the cell
column - The column of the cell (must be the tree column)
cell_height - The cell or row height
level - The level (how many nodes on the path) for the current row
Returns:
True if the point is within the control icon, false otherwise.

addKids

protected void addKids(Object parent,
                       TreePath parent_path,
                       Vector new_kids)
Add children of the parent whose path is in parent_path to the new_kids vector

Parameters:
parent - The parent which is assumed to be the last component of the passed in parent_path
parent_path - The path of the parent
new_kids - The vector which holds the list of children

expandRow

public void expandRow(int row)
Ensures that the node in the specified row is expanded and viewable.

If row is < 0 or >= getRowCount this will have no effect.

Parameters:
row - an int specifying a display row, where 0 is the first row in the display

countKidsToRemove

protected int countKidsToRemove(Object parent,
                                TreePath parent_path)

collapseRow

public void collapseRow(int row)
Ensures that the node in the specified row is collapsed.

If row is < 0 or >= getRowCount this will have no effect.

Parameters:
row - an int specifying a display row, where 0 is the first row in the display

collapsePathRow

public void collapsePathRow(TreePath path,
                            int row)

isLastChild

protected static boolean isLastChild(com.klg.jclass.util.treetable.JCTreeTableModel treetable,
                                     TreePath path)
Figure out if the current node is the last of it's siblings we need to know this so we can figure out whether to draw a continuation line or not

Parameters:
treetable - The tree tabl model to do the check
path - The path of the child node to test
Returns:
Whether the last component or node of the path is the last child of its parent

prepareCellForRender

public void prepareCellForRender(Graphics gc,
                                 int width,
                                 int height)
Set the color and fill an area of width by height with that color

Parameters:
gc - The gc to use
width - The width to fill
height - The height to fill

getNodeIcon

protected Icon getNodeIcon(TreePath path,
                           Object value,
                           Class value_class,
                           boolean is_leaf,
                           boolean is_expanded)
Return the icon for the node of a given path.

Parameters:
path - The path for which the node icon is required.
value - The value at node
value_class - The class of the value at the node
is_leaf - Is the node a leaf?
is_expanded - Has the node been expanded?
Returns:
The icon a the node of a given path.

renderHierarchy

public void renderHierarchy(Graphics gc,
                            Rectangle drawing_area,
                            TreePath path,
                            Object value,
                            Class value_class)
Used to draw the cell. Note that the size of the cell comes from drawing_area.

Parameters:
gc - Graphics context to use for drawing.
drawing_area - The rectangle into which to draw
path - The path to the node to draw
value - The value of the cell
value_class - The class of the value of the cell Render the visual hierarchy informaion

getNodeIndent

public int getNodeIndent(TreePath path)
Returns the x offset at which we can begin drawing the value of the heirarchy column.

Parameters:
path - The path for which the indent is required
Returns:
The indent of the given path

getRendererIndent

public int getRendererIndent(TreePath path)
Deprecated. As of JClass DesktopViews 6.3. Use getRenderIndent(path, value, value_class) instead.

Returns the x offset at which we need to place the renderer. This is usually getNodeIndent + the width of the plaf icons if TreeIconRenderer is not null.

Parameters:
path - The path for which the renderer indent is required
Returns:
The render indent for the given path.

getRendererIndent

public int getRendererIndent(TreePath path,
                             Object value,
                             Class value_class)
Returns the x offset at which we need to place the renderer. This is usually getNodeIndent + the width of the plaf icons if TreeIconRenderer is not null.

Parameters:
path - The path for which the renderer indent is required
value - The value at node
value_class - The class of the value at the node
Returns:
The render indent for the given path

getLevelIndent

public int getLevelIndent()
Get the width of a single indent level.

Returns:
The width of an indent level

getTreeColumnClass

public Class getTreeColumnClass()
Returns the true class stored in the tree column.

Returns:
The class of the tree column

getTreeColumnValue

public Object getTreeColumnValue(Object node)
Returns the true value stored in the tree column.

Parameters:
node - The node for which the value is required
Returns:
The value of the node stored in the tree column

getTreeColumn

public int getTreeColumn()
Get the tree column index

Returns:
The current tree column index

getExpandedDescendants

public Enumeration getExpandedDescendants(TreePath parent)
Returns an Enumeration of the descendants of path that are currently expanded. If path is not currently expanded, this will return null. If you expand/collapse nodes while iterating over the returned Enumeration this may not return all the expanded paths, or may return paths that are no longer expanded.

Parameters:
parent - The path of the parent whose descendants are required
Returns:
An enumeration of the descendants of the given path that are expanded

getExpandedKids

protected void getExpandedKids(TreePath parent,
                               Vector kids)
Store the paths of the children which are expanded for a given parent in a vector

Parameters:
parent - The path of the parent
kids - The place in which to store the expanded children

addTreeExpansionListener

public void addTreeExpansionListener(TreeExpansionListener l)
Adds a listener for TreeExpansion events.

Parameters:
l - a TreeExpansionListener that will be notified when a tree node is expanded or collapsed (a "negative expansion")

removeTreeExpansionListener

public void removeTreeExpansionListener(TreeExpansionListener l)
Removes a listener for TreeExpansion events.

Parameters:
l - the TreeExpansionListener to remove

addTreeWillExpandListener

public void addTreeWillExpandListener(TreeWillExpandListener l)
Adds a listener for TreeWillExpand events.

Parameters:
l - a TreeWillExpandListener that will be notified when a tree node will be expanded or collapsed (a "negative expansion")

removeTreeWillExpandListener

public void removeTreeWillExpandListener(TreeWillExpandListener l)
Removes a listener for TreeWillExpand events.

Parameters:
l - the TreeWillExpandListener to remove

collapsePath

public void collapsePath(TreePath path)
Ensures that the node identified by the specified path is collapsed and viewable.

Parameters:
path - The TreePath identifying a node

expandPath

public void expandPath(TreePath path)
Ensures that the node identified by the specified path is expanded and viewable.

Parameters:
path - The TreePath identifying a node

expandPathRow

protected void expandPathRow(TreePath path,
                             int row)
Ensures that the node identified by the specified path is expanded and viewable.

Parameters:
path - The TreePath identifying a node
row - The row this path is displayed at

getScrollsOnExpand

public boolean getScrollsOnExpand()
Returns true if the tree scrolls to show previously hidden children.

Returns:
true if when a node is expanded as many of the descendants as possible are scrolled to be visible.

setScrollsOnExpand

public void setScrollsOnExpand(boolean newValue)
Determines whether or not when a node is expanded, as many of the descendants are scrolled to be inside the viewport as possible. The default is true.

Parameters:
newValue - The new value of scrollsOnExpand

isRootVisible

public boolean isRootVisible()
Returns true if the root node of the tree is displayed.

Returns:
true if the root node of the tree is displayed
See Also:
rootVisible

setRootVisible

public void setRootVisible(boolean rootVisible)
Determines whether or not the root node from the TreeModel is visible.

Parameters:
rootVisible - true if the root node of the tree is to be displayed
See Also:
rootVisible

getShowsRootHandles

public boolean getShowsRootHandles()
Returns true if handles for the root nodes are displayed.

Returns:
true if root handles are displayed
See Also:
showsRootHandles

setShowsRootHandles

public void setShowsRootHandles(boolean newValue)
Determines whether the node handles are to be displayed.

Parameters:
newValue - true if root handles are to be displayed
See Also:
showsRootHandles

scrollPathToVisible

public void scrollPathToVisible(TreePath path)
Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed. Only works when this JCTreeTable is contained in a JScrollPane.

Parameters:
path - the TreePath identifying the node to bring into view

Copyright © 2004 Quest Software Inc..
All rights reserved.