JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing
Class JCTreeTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTable
                          |
                          +--com.klg.jclass.util.swing.JCSortableTable
                                |
                                +--com.klg.jclass.swing.JCTreeTable
All Implemented Interfaces:
Accessible, CellEditorListener, EventListener, ImageObserver, ListSelectionListener, MenuContainer, Scrollable, Serializable, TableColumnModelListener, TableModelListener

public class JCTreeTable
extends JCSortableTable

A component that gives a visual representation of the hierarchical nature of its structure.

See The Java 2 API to compare this component to JTree and JTable.

See Also:
Serialized Form

Nested Class Summary
protected  class JCTreeTable.Editor
           
protected static class JCTreeTable.EmptyTreeSelectionModel
          EmptySelectionModel is a TreeSelectionModel that does not allow anything to be selected.
protected  class JCTreeTable.Renderer
           
protected static class JCTreeTable.SwitchIcon
          The icon that renderers itself differently whether the view is TREE or TABLE.
protected  class JCTreeTable.SwitchRenderer
          Renderer used to draw the tree<-->table switch icon in the tree column header.
protected  class JCTreeTable.SwitchTableColumn
          Overridden version of TableColumn that returns SwitchRenderer instead of the normal default for the tree column.
protected  class JCTreeTable.TableHeaderMouseAdapter
          MouseAdapter for the table header.
protected  class JCTreeTable.TreeRendererEditor
          Inner class to render the node hierarchy and wrap the defined PLAF renderer behavior.
protected  class JCTreeTable.TreeTableUI
           
 
Nested classes inherited from class com.klg.jclass.util.swing.JCSortableTable
JCSortableTable.SortableTableColumn, JCSortableTable.SortIcon
 
Nested classes inherited from class javax.swing.JTable
JTable.AccessibleJTable
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean expandInTreeColumnOnly
           
protected static int ICON_SIZE
           
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  boolean sortable
           
protected  com.klg.jclass.util.treetable.TreeTableSupport support
           
static int SWITCH_BUTTON_DONT_SHOW
          Valid value for SwitchPolicy.
static int SWITCH_VIEW_NEVER
          Valid value for SwitchPolicy.
static int SWITCH_VIEW_ON_ICON_ONLY
          Valid (default) value for SwitchPolicy.
static int SWITCH_VIEW_TO_TABLE_ON_SORT
          Valid value for SwitchPolicy.
protected  int switchPolicy
           
static int TABLE
          Valid value for view.
static int TREE
          Valid value for view.
protected  com.klg.jclass.swing.JCTreeTableSelectionModel treeSelectionModel
           
 
Fields inherited from class com.klg.jclass.util.swing.JCSortableTable
downIcon, sortModel, tableHeaderMouseListener, upIcon
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JCTreeTable()
          Null constructor.
JCTreeTable(com.klg.jclass.util.treetable.JCTreeTableModel model)
          Constructor which uses the passed in model.
JCTreeTable(com.klg.jclass.util.treetable.JCTreeTableModel model, Dimension intercellSpacing)
          Constructor which uses the passed in model and a preset intercellspacing.
 
Method Summary
 void addSelectionPath(TreePath path)
          Adds the node identified by the specified TreePath to the current selection.
 void addSelectionPaths(TreePath[] paths)
          Adds each path in the array of paths to the current selection.
 void addTreeExpansionListener(TreeExpansionListener l)
          Adds a listener for TreeExpansion events.
 void addTreeWillExpandListener(TreeWillExpandListener l)
          Adds a listener for TreeWillExpand events.
 void collapsePath(TreePath path)
          Ensures that the node identified by the specified path is collapsed and viewable.
 void collapseRow(int row)
          Ensures that the node in the specified row is collapsed.
 TableColumn createSortableTableColumn(int column)
          Creates the TableColumn needed.
protected  MouseAdapter createTableHeaderMouseListener()
          Adds a MouseListener to the table header.
 void expandPath(TreePath path)
          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.
 String getAbout()
          Returns vendor information.
 TableCellEditor getCellEditor(int row, int column)
          Overridden to return the appropriate data editor for the first column if treetable is in tree display mode.
 TableCellRenderer getCellRenderer(int row, int column)
          Overridden to return the appropriate data renderer for the first column if treetable is in tree display mode.
 TreePath getClosestPathForLocation(int x, int y)
          Returns the path to the node that is closest to X,Y.
 int getClosestRowForLocation(int x, int y)
          Returns the row to the node that is closest to X,Y.
 TreePath getEditingPath()
          Returns the path to the element that is currently being edited.
 Enumeration getExpandedDescendants(TreePath parent)
          Returns an Enumeration of the descendants of path that are currently expanded.
 Rectangle getPathBounds(TreePath path)
          This method not functional in this release
 TreePath getPathForLocation(int x, int y)
          Returns the path for the node at the specified location.
 TreePath getPathForRow(int row)
          Returns the path that is displayed at the table row specified.
 Dimension getPreferredSize()
          Override this method to allow a different default preferred size for design time.
 Rectangle getRowBounds(int row)
          This method is not functional in this release
 int getRowForLocation(int x, int y)
          Returns the row for the specified location.
 int getRowForPath(TreePath path)
          Returns the row that displays the node identified by the specified path.
 int[] getRowsForPaths(TreePath[] paths)
          Returns the rows for the visible specified paths.
 boolean getScrollsOnExpand()
          Returns true if the tree scrolls to show previously hidden children.
 TreePath getSelectionPath()
          Returns the path to the first selected node.
 TreePath[] getSelectionPaths()
          Returns the paths of all selected values.
 int getShowNodeLines()
          Returns the state of ShowNodeLines.
 boolean getShowsRootHandles()
          Returns true if handles for the root nodes are displayed.
 int getSwitchPolicy()
          Returns the current value of the switchPolicy variable.
 int getTreeColumn()
          Returns the actual tree column index.
 com.klg.jclass.util.treetable.JCTreeIconRenderer getTreeIconRenderer()
          Returns the icon renderer being used.
 com.klg.jclass.swing.JCTreeTableSelectionModel getTreeSelectionModel()
          Returns the model for selections.
 com.klg.jclass.util.treetable.JCTreeTableModel getTreeTableModel()
          Returns the JCTreeTableModel that is providing the data.
 int getView()
          Returns the current view.
 boolean isExpandInTreeColumnOnly()
          Gets the value of the expandInTreeColumnOnly property.
 boolean isPathSelected(TreePath path)
          Returns true if the item identified by the path is currently selected.
protected  boolean isPointOverSwitch(Point p)
          Asks: "Is the point over the icon that controls whether the view is TREE or TABLE?".
 boolean isRootVisible()
          Returns true if the root node of the tree is displayed.
 boolean isSortable()
          Gets whether the treetable is sortable or not.
 void makeVisible(TreePath path)
          Ensures that the node identified by path is currently viewable.
protected  void reLayoutColumnRenderers()
          Iterate through the columns to get the renderer so that we can reset the horizontal alignment on JCCellRenderers.
 void removeTreeExpansionListener(TreeExpansionListener l)
          Removes a listener for TreeExpansion events.
 void removeTreeWillExpandListener(TreeWillExpandListener l)
          Removes a listener for TreeWillExpand events.
 void setAbout(String s)
          Provided for Beans property editors - has no effect.
 void setExpandInTreeColumnOnly(boolean expandInTreeColumnOnly)
          Sets the value of the expandInTreeColumnOnly property.
 void setRootVisible(boolean rootVisible)
          Determines whether or not the root node from the TreeModel is visible.
 void setScrollsOnExpand(boolean newValue)
          Determines whether or not as many of the descendants are scrolled to be inside the viewport as possible when a node is expanded.
 void setSelectionPath(TreePath path)
          Selects the node identified by the specified path.
 void setSelectionPaths(TreePath[] paths)
          Select the specified paths.
 void setShowNodeLines(int lines)
          Allows you override the PLAF specified behavior of drawing lines.
 void setShowsRootHandles(boolean newValue)
          Determines whether the handles for the root nodes are to be displayed.
 void setSortable(boolean sortable)
          Sets whether the treetable is sortable or not.
 void setSwitchPolicy(int policy)
          Sets the switchPolicy variable which determines whether or not to allow view switching.
 void setTreeIconRenderer(com.klg.jclass.util.treetable.JCTreeIconRenderer renderer)
          Sets the icon renderer.
 void setTreeTableModel(com.klg.jclass.util.treetable.JCTreeTableModel model)
          Sets the TreeModel that will provide the data.
 void setTreeTableSelectionModel(com.klg.jclass.swing.JCTreeTableSelectionModel treeSelectionModel)
          Sets the tree's selection model.
 void setUI(TableUI ui)
           
 void setView(int view)
          Sets whether we are viewing this as a tree or a table.
protected  void toggleView()
          Switches views between TREE and TABLE.
 void updateUI()
           
 
Methods inherited from class com.klg.jclass.util.swing.JCSortableTable
addTableHeaderMouseListener, checkColumnModel, clearSortIcons, configureEnclosingScrollPane, createDefaultColumnsFromModel, getAutoSort, getDownIcon, getKeyColumns, getSortedRow, getTableHeaderMouseListener, getUnsortedRow, getUpIcon, removeTableHeaderMouseListener, setAutoSort, setColumnModel, setComponentOrientation, setComponentOrientation, setDownIcon, setKeyColumns, setModel, setSortIcon, setSortIcon, setSortIcon, setTableHeader, setTableHeaderMouseListener, setUpIcon, sort, tableChanged, unsort
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setValueAt, sizeColumnsToFit, sizeColumnsToFit, unconfigureEnclosingScrollPane, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

SWITCH_VIEW_NEVER

public static final int SWITCH_VIEW_NEVER
Valid value for SwitchPolicy. View is not interactively switchable.

See Also:
Constant Field Values

SWITCH_VIEW_TO_TABLE_ON_SORT

public static final int SWITCH_VIEW_TO_TABLE_ON_SORT
Valid value for SwitchPolicy. Switch view to table any time a sort is invoked and whenever the switch icon is clicked.

See Also:
Constant Field Values

SWITCH_VIEW_ON_ICON_ONLY

public static final int SWITCH_VIEW_ON_ICON_ONLY
Valid (default) value for SwitchPolicy. Switch only when the switch icon is clicked on.

See Also:
Constant Field Values

SWITCH_BUTTON_DONT_SHOW

public static final int SWITCH_BUTTON_DONT_SHOW
Valid value for SwitchPolicy. Do not even show the switch icon. Thus the view is also not interactively switchable.

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

ICON_SIZE

protected static final int ICON_SIZE
See Also:
Constant Field Values

switchPolicy

protected int switchPolicy

support

protected com.klg.jclass.util.treetable.TreeTableSupport support

treeSelectionModel

protected com.klg.jclass.swing.JCTreeTableSelectionModel treeSelectionModel

sortable

protected boolean sortable

expandInTreeColumnOnly

protected boolean expandInTreeColumnOnly
Constructor Detail

JCTreeTable

public JCTreeTable()
Null constructor. An EmptyTreeTableModel will be used.


JCTreeTable

public JCTreeTable(com.klg.jclass.util.treetable.JCTreeTableModel model)
Constructor which uses the passed in model. Use an intercellspacing of 0.

Parameters:
model - the JCTreeTableModel to be used

JCTreeTable

public JCTreeTable(com.klg.jclass.util.treetable.JCTreeTableModel model,
                   Dimension intercellSpacing)
Constructor which uses the passed in model and a preset intercellspacing.

Parameters:
model - the JCTreeTableModel to be used
intercellSpacing - the horizontal and vertical space between cells
Method Detail

setUI

public void setUI(TableUI ui)
Overrides:
setUI in class JTable

updateUI

public void updateUI()
Overrides:
updateUI in class JTable

getPreferredSize

public Dimension getPreferredSize()
Description copied from class: JCSortableTable
Override this method to allow a different default preferred size for design time.

Overrides:
getPreferredSize in class JCSortableTable
Returns:
the preferred size of the table

setAbout

public void setAbout(String s)
Provided for Beans property editors - has no effect.

Overrides:
setAbout in class JCSortableTable
Parameters:
s - ignored

getAbout

public String getAbout()
Returns vendor information.

Overrides:
getAbout in class JCSortableTable
Returns:
the version String

isSortable

public boolean isSortable()
Gets whether the treetable is sortable or not.

Returns:
sortable the boolean value

setSortable

public void setSortable(boolean sortable)
Sets whether the treetable is sortable or not.

Parameters:
sortable - the boolean value

setSwitchPolicy

public void setSwitchPolicy(int policy)
Sets the switchPolicy variable which determines whether or not to allow view switching.

Parameters:
policy - the new switch policy; valid values are SWITCH_VIEW_NEVER, SWITCH_VIEW_TO_TABLE_ON_SORT, SWITCH_VIEW_ON_ICON_ONLY, or SWITCH_BUTTON_DONT_SHOW

getSwitchPolicy

public int getSwitchPolicy()
Returns the current value of the switchPolicy variable.

Returns:
policy the int which indicates the policy; will be one of SWITCH_VIEW_NEVER, SWITCH_VIEW_TO_TABLE_ON_SORT, SWITCH_VIEW_ON_ICON_ONLY, or SWITCH_BUTTON_DONT_SHOW

setView

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

Parameters:
view - Valid values are TREE and TABLE

getView

public int getView()
Returns the current view.

Returns:
The current view; will be one of TREE or TABLE
See Also:
setView(int)

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 new line drawing style; must be one of NODE_LINES_USE_PLAF (the default), NODE_LINES_SHOW, or NODE_LINES_HIDE

getShowNodeLines

public int getShowNodeLines()
Returns the state of ShowNodeLines.

Returns:
the current line drawing style; will be one of NODE_LINES_USE_PLAF (the default), NODE_LINES_SHOW, or NODE_LINES_HIDE
See Also:
setShowNodeLines(int)

isExpandInTreeColumnOnly

public boolean isExpandInTreeColumnOnly()
Gets the value of the expandInTreeColumnOnly property. If true, the only way to expand or collapse the tree is to click or double click in the tree column. If false (the default value), clicking anywhere in the row (where an editor is not present) will expand/collapse the tree.

Returns:
current value of the expandInTreeColumnOnly property

setExpandInTreeColumnOnly

public void setExpandInTreeColumnOnly(boolean expandInTreeColumnOnly)
Sets the value of the expandInTreeColumnOnly property. If true, the only way to expand or collapse the tree is to click or double click in the tree column. If false (the default value), clicking anywhere in the row (where an editor is not present) will expand/collapse the tree.

Parameters:
expandInTreeColumnOnly - the new value of the expandInTreeColumnOnly property

getTreeColumn

public int getTreeColumn()
Returns the actual tree column index. It is usually 0, but it may have been moved by the user.

Returns:
the current column, which displays the tree when the view is TREE

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
Overridden to return the appropriate data renderer for the first column if treetable is in tree display mode.

Overrides:
getCellRenderer in class JCSortableTable
Parameters:
row - the row of the cell to render, where 0 is the first
column - the column of the cell to render, where 0 is the first
Returns:
the current cell renderer for this row and column

getCellEditor

public TableCellEditor getCellEditor(int row,
                                     int column)
Overridden to return the appropriate data editor for the first column if treetable is in tree display mode.

Overrides:
getCellEditor in class JCSortableTable
Parameters:
row - the row of the cell to edit, where 0 is the first
column - the column of the cell to edit, where 0 is the first
Returns:
the current cell editor for this row and column

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

setTreeIconRenderer

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

Parameters:
renderer - the new icon renderer

getTreeIconRenderer

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

Returns:
the current icon renderer

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

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

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

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

makeVisible

public void makeVisible(TreePath path)
Ensures that the node identified by path is currently viewable.

Parameters:
path - the TreePath to make visible

getClosestPathForLocation

public TreePath getClosestPathForLocation(int x,
                                          int y)
Returns the path to the node that is closest to X,Y. If no nodes are currently viewable, or there is no model, returns null; otherwise it always returns a valid path. To test if the node is exactly at X, Y, get the node's bounds and test X, Y against that.

Parameters:
x - an int giving the number of pixels horizontally from the left edge of the display area, minus any left margin
y - an int giving the number of pixels vertically from the top of the display area, minus any top margin
Returns:
the TreePath for the node closest to that location; null if nothing is viewable or there is no model
See Also:
getPathForLocation(int, int), getPathBounds(javax.swing.tree.TreePath)

getClosestRowForLocation

public int getClosestRowForLocation(int x,
                                    int y)
Returns the row to the node that is closest to X,Y. If no nodes are viewable or there is no model, returns -1. Otherwise, it always returns a valid row. To test if the returned object is exactly at X, Y, get the bounds for the node at the returned row and test X, Y against that.

Parameters:
x - an int giving the number of pixels horizontally from the left edge of the display area, minus any left margin
y - an int giving the number of pixels vertically from the top of the display area, minus any top margin
Returns:
the row closest to the location, -1 if nothing is viewable or there is no model
See Also:
getRowForLocation(int, int), getRowBounds(int)

getEditingPath

public TreePath getEditingPath()
Returns the path to the element that is currently being edited.

Returns:
the TreePath for the node being edited

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 to the parent whose expanded descendants are desired
Returns:
an Enumeration of the expanded descendants of the parent node

getTreeTableModel

public com.klg.jclass.util.treetable.JCTreeTableModel getTreeTableModel()
Returns the JCTreeTableModel that is providing the data.

Returns:
the TreeModel that is providing the data

setTreeTableModel

public void setTreeTableModel(com.klg.jclass.util.treetable.JCTreeTableModel model)
Sets the TreeModel that will provide the data.

Parameters:
model - the TreeModel that is to provide the data

getPathBounds

public Rectangle getPathBounds(TreePath path)
This method not functional in this release

Returns the Rectangle that the specified node will be drawn into. Returns null if any component in the path is hidden (under a collapsed parent).

Note: This method returns a valid rectangle, even if the specified node is not currently displayed.

Parameters:
path - the TreePath identifying the node
Returns:
the Rectangle the node is drawn in, or null

getPathForLocation

public TreePath getPathForLocation(int x,
                                   int y)
Returns the path for the node at the specified location.

Parameters:
x - an int giving the number of pixels horizontally from the left edge of the display area, minus any left margin
y - an int giving the number of pixels vertically from the top of the display area, minus any top margin
Returns:
the TreePath for the node at that location

getRowForLocation

public int getRowForLocation(int x,
                             int y)
Returns the row for the specified location.

Parameters:
x - an int giving the number of pixels horizontally from the left edge of the display area, minus any left margin
y - an int giving the number of pixels vertically from the top of the display area, minus any top margin
Returns:
the row corresponding to the location, or -1 if the location is not within the bounds of a displayed cell
See Also:
getClosestRowForLocation(int, int)

getRowBounds

public Rectangle getRowBounds(int row)
This method is not functional in this release

Returns the Rectangle that the node at the specified row is drawn in.

Parameters:
row - the row to be drawn, where 0 is the first row in the display
Returns:
the Rectangle the node is drawn in

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.

getPathForRow

public TreePath getPathForRow(int row)
Returns the path that is displayed at the table row specified.

Parameters:
row - the row whose path is returned
Returns:
the TreePath displayed at the specified row

getScrollsOnExpand

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

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

setScrollsOnExpand

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

Parameters:
newValue - if set to true, when a node is expanded as many of the descendants as possible are scrolled to be visible

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:
setRootVisible(boolean)

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:
isRootVisible()

getShowsRootHandles

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

Returns:
true if root handles are displayed
See Also:
setShowsRootHandles(boolean)

setShowsRootHandles

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

Parameters:
newValue - true if root handles are to be displayed
See Also:
getShowsRootHandles()

getRowsForPaths

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

Parameters:
paths - an array of paths for which the corresponding rows are required
Returns:
a list of row indicies corresponding to the paths

addSelectionPath

public void addSelectionPath(TreePath path)
Adds the node identified by the specified TreePath to the current selection. If any component of the path isn't viewable, it is made viewable.

Parameters:
path - the TreePath specifying the node to add to the selection

addSelectionPaths

public void addSelectionPaths(TreePath[] paths)
Adds each path in the array of paths to the current selection. If any component of any of the paths isn't viewable, it is made viewable.

Parameters:
paths - An array of TreePath objects that specifies the nodes to add to selection

setSelectionPath

public void setSelectionPath(TreePath path)
Selects the node identified by the specified path. If any component of the path is hidden (under a collapsed node), it is exposed (made viewable).

Parameters:
path - the TreePath specifying the node to select

setSelectionPaths

public void setSelectionPaths(TreePath[] paths)
Select the specified paths.

Parameters:
paths - an array of TreePath objects that specifies the nodes to select

isPathSelected

public boolean isPathSelected(TreePath path)
Returns true if the item identified by the path is currently selected.

Parameters:
path - the path to the item whose selection status is required
Returns:
asks: "is the item that the path identifies currently selected?"

getSelectionPath

public TreePath getSelectionPath()
Returns the path to the first selected node.

Returns:
the TreePath for the first selected node, or null if nothing is currently selected

getSelectionPaths

public TreePath[] getSelectionPaths()
Returns the paths of all selected values.

Returns:
an array of TreePath objects indicating the selected nodes, or null if nothing is currently selected.

setTreeTableSelectionModel

public void setTreeTableSelectionModel(com.klg.jclass.swing.JCTreeTableSelectionModel treeSelectionModel)
Sets the tree's selection model. When a null value is specified, an empty selectionModel is used, which does not allow selections.

Parameters:
treeSelectionModel - the TreeSelectionModel to use, or null to disable selections
See Also:
TreeSelectionModel

getTreeSelectionModel

public com.klg.jclass.swing.JCTreeTableSelectionModel getTreeSelectionModel()
Returns the model for selections. This should always return a non-null value. If you do not want to allow anything to be selected, set the selection model to null, which forces an empty selection model to be used.

Returns:
the current TreeSelectionModel in use
See Also:
JTable.setSelectionModel(javax.swing.ListSelectionModel)

isPointOverSwitch

protected boolean isPointOverSwitch(Point p)
Asks: "Is the point over the icon that controls whether the view is TREE or TABLE?".

Parameters:
p - the point to be tested
Returns:
true asks: is the input point over the "switch views" icon?

toggleView

protected void toggleView()
Switches views between TREE and TABLE.


createTableHeaderMouseListener

protected MouseAdapter createTableHeaderMouseListener()
Adds a MouseListener to the table header.

Overrides:
createTableHeaderMouseListener in class JCSortableTable
Returns:
the new table header mouse listener

reLayoutColumnRenderers

protected void reLayoutColumnRenderers()
Iterate through the columns to get the renderer so that we can reset the horizontal alignment on JCCellRenderers.

Overrides:
reLayoutColumnRenderers in class JCSortableTable

createSortableTableColumn

public TableColumn createSortableTableColumn(int column)
Creates the TableColumn needed. This method was created to allow subclasses to override, to easily change the default Column created.

Overrides:
createSortableTableColumn in class JCSortableTable
Parameters:
column - the column index for which the new table column is to be created
Returns:
the new sortable table column

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