|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.util.treetable.TreeTableSupport
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.
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 |
public static final int TREE
public static final int TABLE
public static final int NODE_LINES_SHOW
public static final int NODE_LINES_HIDE
public static final int NODE_LINES_USE_PLAF
protected boolean sortable
protected int sortOrder
protected int[][] keyColumnsArray
protected boolean autoSort
protected int showNodeLines
protected JComponent visualComponent
protected int view
protected com.klg.jclass.util.treetable.JCTreeTableModel treetable
protected TableModel table
protected TreeModelListener treeListener
protected com.klg.jclass.util.JCListenerList tableListeners
protected int treeColumn
protected com.klg.jclass.util.JCListenerList treeExpansionListeners
protected com.klg.jclass.util.JCListenerList treeSelectionListeners
protected com.klg.jclass.util.JCListenerList treeWillExpandListeners
protected boolean rootVisible
protected boolean showsRootHandles
protected com.klg.jclass.util.treetable.JCTreeIconRenderer iconRenderer
protected boolean scrollsOnExpand
protected Icon expandedIcon
protected Icon collapsedIcon
protected int leftLevelSpacing
protected int rightLevelSpacing
protected int levelIndent
protected Icon openIcon
protected Icon closedIcon
protected Icon leafIcon
protected Color lineColor
protected int lineThickness
protected Stroke lineStroke
protected boolean drawLines
protected Color tableBackground
protected int cellHeight
protected com.klg.jclass.util.treetable.TreeTableSupport.RemovableVector rowMap
protected Hashtable expandedState
Constructor Detail |
public TreeTableSupport(JComponent visual_component, com.klg.jclass.util.treetable.JCTreeTableModel model)
public TreeTableSupport(JComponent visual_component)
visual_component
- is the component we are supporting; this needed
for posting the correct event source.Method Detail |
public void inferLookAndFeel()
public int[] getRowsForPaths(TreePath[] paths)
getRowsForPaths
in interface RowMapper
paths
- The paths whose rows are needed
public void setShowNodeLines(int lines)
lines
- The type of line drawing desired. Valid values are
NODE_LINES_USE_PLAF (the default), NODE_LINES_SHOW,
NODE_LINES_HIDE.public int getShowNodeLines()
setShowNodeLines(int)
public int getMaxIconHeight()
public boolean isSortable()
setSortable(boolean)
public void setSortable(boolean sortable)
sortable
- The new value of sortable.isSortable()
protected void initTableViewModels()
public void setView(int view)
view
- valid values are TREE and TABLEpublic int getView()
setView(int)
public void setTreeTableModel(com.klg.jclass.util.treetable.JCTreeTableModel treetable)
treetable
- The new treetable modelpublic void clearExpandedState()
protected void clearExpandedState(boolean post_change_event)
protected void mapTreeTable(boolean post_change_event)
public com.klg.jclass.util.treetable.JCTreeTableModel getTreeTableModel()
public TableModel getTableModel()
TableFromTreeTable
,
DefaultRowSortTableModel
public boolean hasBeenExpanded(TreePath path)
path
- The input path
protected void postTableModelChanged(TableModelEvent event)
event
- The event generated by the model changepublic void setTreeIconRenderer(com.klg.jclass.util.treetable.JCTreeIconRenderer renderer)
renderer
- The new icon rendererpublic com.klg.jclass.util.treetable.JCTreeIconRenderer getTreeIconRenderer()
public TreePath getPathForRow(int row)
row
- An int specifying a row
protected TreePath getPathForRow(int viewType, int row)
viewType
- The type of view. Possible values are TREE and TABLE.row
- An int specifying a row
public int getRowForPath(TreePath path)
path
- the TreePath identifying a node
protected int getRowForPath(int viewType, TreePath path)
viewType
- The type of view. Possible values are TREE and TABLE.path
- the TreePath identifying a node
public boolean isExpanded(TreePath path)
path
- the TreePath specifying the node to check
public boolean getAutoSort()
getAutoSort
in interface JCRowSortModel
public void setAutoSort(boolean autoSort)
setAutoSort
in interface JCRowSortModel
autoSort
- If true, the data will be automatically sorted.public void setKeyColumns(int column, int[] keyColumns)
setKeyColumns
in interface JCRowSortModel
column
- index of column in TableModelkeyColumns
- columns to use as keys to sort when sorting
on the specified column.public int[] getKeyColumns(int column)
getKeyColumns
in interface JCRowSortModel
column
- The column for which the key columns are required
protected com.klg.jclass.util.swing.JCRowSortModel getRowSortModel()
public boolean isDataSorted()
isDataSorted
in interface JCRowSortModel
public void setDataSorted(boolean sorted)
setDataSorted
in interface JCRowSortModel
sorted
- Causes a sort (if needed) if true and an unsort if false.public int getSortColumn()
getSortColumn
in interface JCRowSortModel
public void setSortColumn(int column)
setSortColumn
in interface JCRowSortModel
column
- only valid column indicies are allowedpublic int getSortOrder()
getSortOrder
in interface JCRowSortModel
public void setSortOrder(int order)
setSortOrder
in interface JCRowSortModel
order
- Sets the sort order to JCRowSortModel.FORWARD or
JCRowSortModel.BACKWARD.public void toggleSortOrder()
toggleSortOrder
in interface JCRowSortModel
public int getUnsortedRow(int sortRow)
getUnsortedRow
in interface JCRowSortTableModel
sortRow
- The sorted row
public int getSortedRow(int row)
getSortedRow
in interface JCRowSortTableModel
row
- The unsorted row
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
e
- The event generated by the changepublic void addTableModelListener(TableModelListener l)
addTableModelListener
in interface TableModel
public void removeTableModelListener(TableModelListener l)
removeTableModelListener
in interface TableModel
public Class getColumnClass(int column)
getColumnClass
in interface TableModel
public int getColumnCount()
getColumnCount
in interface TableModel
public String getColumnName(int column)
getColumnName
in interface TableModel
public int getRowCount()
getRowCount
in interface TableModel
public Object getValueAt(int row, int column)
getValueAt
in interface TableModel
public boolean isCellEditable(int row, int column)
isCellEditable
in interface TableModel
public void setValueAt(Object value, int row, int column)
setValueAt
in interface TableModel
protected static Object getParent(TreePath path)
path
- The path for which the parent is needed.
getNode(javax.swing.tree.TreePath)
protected static Object getNode(TreePath path)
path
- The path from which to get the node or last component
getParent(javax.swing.tree.TreePath)
protected Object getNode(int row)
row
- The row for which the node is needed
protected int getLevel(int row)
row
- The row for which the level is needed
protected void toggleState(int row)
row
- The row on which the toggle is needed.public boolean processClickInTreeColumn(MouseEvent ev, int row, int column, Point p, int cell_height)
ev
- The event from the mouse clickrow
- The row the point is incolumn
- The column the point is inp
- The coordinates of the point clicked relative to the cellcell_height
- The cell or row height
protected boolean isPointInControlBox(Point p, int row, int column, int cell_height, int level)
p
- The point to checkrow
- The row of the cellcolumn
- The column of the cell (must be the tree column)cell_height
- The cell or row heightlevel
- The level (how many nodes on the path) for the current row
protected void addKids(Object parent, TreePath parent_path, Vector new_kids)
parent
- The parent which is assumed to be the last component of the
passed in parent_pathparent_path
- The path of the parentnew_kids
- The vector which holds the list of childrenpublic void expandRow(int row)
If row
is < 0 or >= getRowCount this
will have no effect.
row
- an int specifying a display row, where 0 is the
first row in the displayprotected int countKidsToRemove(Object parent, TreePath parent_path)
public void collapseRow(int row)
If row
is < 0 or >= getRowCount this
will have no effect.
row
- an int specifying a display row, where 0 is the
first row in the displaypublic void collapsePathRow(TreePath path, int row)
protected static boolean isLastChild(com.klg.jclass.util.treetable.JCTreeTableModel treetable, TreePath path)
treetable
- The tree tabl model to do the checkpath
- The path of the child node to test
public void prepareCellForRender(Graphics gc, int width, int height)
gc
- The gc to usewidth
- The width to fillheight
- The height to fillprotected Icon getNodeIcon(TreePath path, Object value, Class value_class, boolean is_leaf, boolean is_expanded)
path
- The path for which the node icon is required.value
- The value at nodevalue_class
- The class of the value at the nodeis_leaf
- Is the node a leaf?is_expanded
- Has the node been expanded?
public void renderHierarchy(Graphics gc, Rectangle drawing_area, TreePath path, Object value, Class value_class)
gc
- Graphics context to use for drawing.drawing_area
- The rectangle into which to drawpath
- The path to the node to drawvalue
- The value of the cellvalue_class
- The class of the value of the cell
Render the visual hierarchy informaionpublic int getNodeIndent(TreePath path)
path
- The path for which the indent is required
public int getRendererIndent(TreePath path)
path
- The path for which the renderer indent is required
public int getRendererIndent(TreePath path, Object value, Class value_class)
path
- The path for which the renderer indent is requiredvalue
- The value at nodevalue_class
- The class of the value at the node
public int getLevelIndent()
public Class getTreeColumnClass()
public Object getTreeColumnValue(Object node)
node
- The node for which the value is required
public int getTreeColumn()
public Enumeration getExpandedDescendants(TreePath parent)
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.
parent
- The path of the parent whose descendants are required
protected void getExpandedKids(TreePath parent, Vector kids)
parent
- The path of the parentkids
- The place in which to store the expanded childrenpublic void addTreeExpansionListener(TreeExpansionListener l)
l
- a TreeExpansionListener that will be notified when
a tree node is expanded or collapsed (a "negative
expansion")public void removeTreeExpansionListener(TreeExpansionListener l)
l
- the TreeExpansionListener to removepublic void addTreeWillExpandListener(TreeWillExpandListener l)
l
- a TreeWillExpandListener that will be notified when
a tree node will be expanded or collapsed (a "negative
expansion")public void removeTreeWillExpandListener(TreeWillExpandListener l)
l
- the TreeWillExpandListener to removepublic void collapsePath(TreePath path)
path
- The TreePath identifying a nodepublic void expandPath(TreePath path)
path
- The TreePath identifying a nodeprotected void expandPathRow(TreePath path, int row)
path
- The TreePath identifying a noderow
- The row this path is displayed atpublic boolean getScrollsOnExpand()
public void setScrollsOnExpand(boolean newValue)
newValue
- The new value of scrollsOnExpandpublic boolean isRootVisible()
rootVisible
public void setRootVisible(boolean rootVisible)
rootVisible
- true if the root node of the tree is to be displayedrootVisible
public boolean getShowsRootHandles()
showsRootHandles
public void setShowsRootHandles(boolean newValue)
newValue
- true if root handles are to be displayedshowsRootHandles
public void scrollPathToVisible(TreePath path)
path
- the TreePath identifying the node to bring into view
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |