Class SynthTreeUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TreeUI
javax.swing.plaf.basic.BasicTreeUI
javax.swing.plaf.synth.SynthTreeUI
- All Implemented Interfaces:
PropertyChangeListener, EventListener, SynthConstants, SynthUI
Provides the Synth L&F UI delegate for
JTree.- Since:
- 1.7
-
Nested Class Summary
Nested classes/interfaces declared in class BasicTreeUI
BasicTreeUI.CellEditorHandler, BasicTreeUI.ComponentHandler, BasicTreeUI.FocusHandler, BasicTreeUI.KeyHandler, BasicTreeUI.MouseHandler, BasicTreeUI.MouseInputHandler, BasicTreeUI.NodeDimensionsHandler, BasicTreeUI.PropertyChangeHandler, BasicTreeUI.SelectionModelPropertyChangeHandler, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeExpansionHandler, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreeModelHandler, BasicTreeUI.TreePageAction, BasicTreeUI.TreeSelectionHandler, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseActionModifier and TypeClassDescriptionclassListener responsible for getting cell editing events and updating the tree accordingly.classUpdates the preferred size when scrolling (if necessary).classRepaints the lead selection row when focus is lost/gained.classThis is used to get multiple key down events to appropriately generate events.classTreeMouseListener is responsible for updating the selection based on mouse events.classMouseInputHandler handles passing all mouse events, including mouse motion events, until the mouse is released to the destination it is constructed with.classClass responsible for getting size of node, method is forwarded to BasicTreeUI method.classPropertyChangeListener for the tree.classListener on the TreeSelectionModel, resets the row selection if any of the properties of the model change.classActionListener that invokes cancelEditing when action performed.classUpdates the TreeState in response to nodes expanding/collapsing.classTreeHomeAction is used to handle end/home actions.classTreeIncrementAction is used to handle up/down actions.classForwards all TreeModel events to the TreeState.classTreePageAction handles page up and page down events.classListens for changes in the selection model and updates the display accordingly.classFor the first selected row expandedness will be toggled.classTreeTraverseActionis the action used for left/right keys. -
Field Summary
Fields declared in class BasicTreeUI
cellEditor, collapsedIcon, createdCellEditor, createdRenderer, currentCellRenderer, depthOffset, drawingCache, editingComponent, editingPath, editingRow, editorHasDifferentSize, expandedIcon, largeModel, lastSelectedRow, leftChildIndent, nodeDimensions, preferredMinSize, preferredSize, rendererPane, rightChildIndent, stopEditingInCompleteEditing, totalChildIndent, tree, treeModel, treeSelectionModel, treeState, validCachedPreferredSizeModifier and TypeFieldDescriptionprotected TreeCellEditorEditor for the tree.protected IconThe collapsed icon.protected booleanSet to true if editor that is currently in the tree was created by this instance.protected booleanSet to true if the renderer that is currently in the tree was created by this instance.protected TreeCellRendererRenderer that is being used to do the actual cell drawing.protected intHow much the depth should be offset to properly calculate x locations.Used for minimizing the drawing of vertical lines.protected ComponentWhen editing, this will be the Component that is doing the actual editing.protected TreePathPath that is being edited.protected intRow that is being edited.protected booleanSet to true if the editor has a different size than the renderer.protected IconThe expanded icon.protected booleanTrue if doing optimizations for a largeModel.protected intIndex of the row that was last selected.protected intDistance between left margin and where vertical dashes will be drawn.protected AbstractLayoutCache.NodeDimensionsResponsible for telling the TreeState the size needed for a node.protected DimensionMinimum preferred size.protected DimensionSize needed to completely display all the nodes.protected CellRendererPaneUsed to paint the TreeCellRenderer.protected intDistance to add to leftChildIndent to determine where cell contents will be drawn.protected booleanSet to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing.protected intTotal distance that will be indented.protected JTreeComponent that we're going to be drawing into.protected TreeModelUsed to determine what to display.protected TreeSelectionModelModel maintaining the selection.protected AbstractLayoutCacheObject responsible for handling sizing and expanded issues.protected booleanIs the preferredSize valid?Fields declared in interface SynthConstants
DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTEDModifier and TypeFieldDescriptionstatic final intIndicates the region is the default.static final intPrimary state indicating the region is not enabled.static final intPrimary state indicating the component is enabled.static final intIndicates the region has focus.static final intPrimary state indicating the mouse is over the region.static final intPrimary state indicating the region is in a pressed state.static final intIndicates the region is selected. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentUICreates a new UI object for the given component.Returns the Context for the specified component.voidpaint(Graphics g, JComponent c) Paints the specified component according to the Look and Feel.protected voidpaint(SynthContext context, Graphics g) Paints the specified component.voidpaintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) Paints the border.voidThis method gets called when a bound property is changed.voidupdate(Graphics g, JComponent c) Notifies this UI delegate to repaint the specified component.Methods declared in class BasicTreeUI
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createDefaultCellEditor, createDefaultCellRenderer, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createNodeDimensions, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getDropLineRect, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeadSelectionRow, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installKeyboardActions, installListeners, isDropLine, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintDropLine, paintExpandControl, paintHorizontalLine, paintHorizontalPartOfLeg, paintRow, paintVerticalLine, paintVerticalPartOfLeg, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, selectPathForEvent, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateLeadSelectionRow, updateRenderer, updateSizeModifier and TypeMethodDescriptionvoidcancelEditing(JTree tree) Cancels the current editing session.protected voidcheckForClickInExpandControl(TreePath path, int mouseX, int mouseY) If themouseXandmouseYare in the expand/collapse region of therow, this will toggle the row.protected voidMessages to stop the editing session.protected voidcompleteEditing(boolean messageStop, boolean messageCancel, boolean messageTree) Stops the editing session.protected voidInvoked from installUI after all the defaults/listeners have been installed.protected voidUninstalls UI.protected voidResets the TreeState instance based on the tree we're providing the look and feel for.protected CellEditorListenerCreates a listener to handle events from the current editor.protected CellRendererPaneReturns the renderer pane that renderer components are placed in.protected ComponentListenerCreates and returns a new ComponentHandler.protected TreeCellEditorCreates a default cell editor.protected TreeCellRendererReturns the default cell renderer that is used to do the stamping of each node.protected FocusListenerCreates a listener that is responsible for updating the display when focus is lost/gained.protected KeyListenerCreates the listener responsible for getting key events from the tree.protected AbstractLayoutCacheCreates the object responsible for managing what is expanded, as well as the size of nodes.protected MouseListenerCreates the listener responsible for updating the selection based on mouse events.protected AbstractLayoutCache.NodeDimensionsCreates an instance ofNodeDimensionsthat is able to determine the size of a given node in the tree.protected PropertyChangeListenerCreates a listener that is responsible that updates the UI based on how the tree changes.protected PropertyChangeListenerCreates the listener responsible for getting property change events from the selection model.protected TreeExpansionListenerCreates and returns the object responsible for updating the treestate when nodes expanded state changes.protected TreeModelListenerReturns a listener that can update the tree when the model changes.protected TreeSelectionListenerCreates the listener that updates the display based on selection change methods.protected voiddrawCentered(Component c, Graphics graphics, Icon icon, int x, int y) Draws theiconcentered at (x,y).protected voiddrawDashedHorizontalLine(Graphics g, int y, int x1, int x2) Draws a horizontal dashed line.protected voiddrawDashedVerticalLine(Graphics g, int x, int y1, int y2) Draws a vertical dashed line.protected voidensureRowsAreVisible(int beginRow, int endRow) Ensures that the rows identified bybeginRowthroughendRoware visible.intgetBaseline(JComponent c, int width, int height) Returns the baseline.Returns an enum indicating how the baseline of the component changes as the size changes.protected TreeCellEditorReturns the editor used to edit entries in the drawn tree component, ornullif the tree cannot be edited.protected TreeCellRendererReturns the current instance of theTreeCellRendererthat is rendering each cell.getClosestPathForLocation(JTree tree, int x, int y) Returns the path to the node that is closest to x,y.Returns the collapsed icon.protected RectangleReturns a unbounding box for the drop line.getEditingPath(JTree tree) Returns the path to the element that is being edited.Returns the expanded icon.protected ColorReturns the hash color.protected intThe horizontal element of legs between nodes starts at the right of the left-hand side of the child node by default.protected TreePathgetLastChildPath(TreePath parent) Returns a path to the last child ofparent.protected intReturns the lead row of the selection.intReturns the left child indent.Returns the maximum size for this component, which will be the preferred size if the instance is currently in a JTree, or 0, 0.Returns the minimum size for this component.protected TreeModelgetModel()Returns the tree model.getPathBounds(JTree tree, TreePath path) Returns the Rectangle enclosing the label portion that the last item in path will be drawn into.getPathForRow(JTree tree, int row) Returns the path for passed in row.Returns the minimum preferred size.Returns the preferred size to properly display the tree, this is a cover method forgetPreferredSize(c, true).getPreferredSize(JComponent c, boolean checkConsistency) Returns the preferred size to represent the tree in c.intReturns the right child indent.intgetRowCount(JTree tree) Returns the number of rows that are being displayed.intgetRowForPath(JTree tree, TreePath path) Returns the row that the last item identified in path is visible at.protected intReturns the height of each row in the drawn tree component.protected intgetRowX(int row, int depth) Returns the location, along the x-axis, to render a particular row at.protected TreeSelectionModelReturns the current instance of theTreeSelectionModelwhich is the model for selections.protected booleanReturnstrueif the root handles are to be displayed.protected intThe vertical element of legs between nodes starts at the bottom of the parent node by default.protected voidhandleExpandControlClick(TreePath path, int mouseX, int mouseY) Messaged when the user clicks the particular row, this invokestoggleExpandState.protected voidInstalls the subcomponents of the tree, which is the renderer pane.protected voidInstalls default properties.protected voidRegisters keyboard actions.protected voidRegisters listeners.protected booleanTells if aDropLocationshould be indicated by a line between nodes.protected booleanReturns whether the drawn tree component should be enabled for editing.booleanReturns true if the tree is being edited.protected booleanReturnstrueif large model is set.protected booleanisLeaf(int row) Returnstrueif the node atrowis a leaf.protected booleanisLocationInExpandControl(TreePath path, int mouseX, int mouseY) ReturnstrueifmouseXandmouseYfall in the area of row that is used to expand/collapse the node and the node atrowdoes not represent a leaf.protected booleanisMultiSelectEvent(MouseEvent event) Returningtruesignifies a mouse event on the node should select from the anchor point.protected booleanReturns whether the root node of the drawn tree component should be displayed.protected booleanisToggleEvent(MouseEvent event) Returningtrueindicates the row under the mouse should be toggled based on the event.protected booleanisToggleSelectionEvent(MouseEvent event) Returningtruesignifies a mouse event on the node should toggle the selection of only the row under mouse.protected voidPaints the drop line.protected voidpaintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) Paints the expand (toggle) part of a row.protected voidpaintHorizontalLine(Graphics g, JComponent c, int y, int left, int right) Paints a horizontal line.protected voidpaintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) Paints the horizontal part of the leg.protected voidpaintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) Paints the renderer part of a row.protected voidpaintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom) Paints a vertical line.protected voidpaintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) Paints the vertical part of the leg.protected voidpathWasCollapsed(TreePath path) Messaged from theVisibleTreeNodeafter it has collapsed.protected voidpathWasExpanded(TreePath path) Messaged from theVisibleTreeNodeafter it has been expanded.protected voidInvoked after thetreeinstance variable has been set, but before any defaults/listeners have been installed.protected voidInvoked before uninstallation of UI.protected voidselectPathForEvent(TreePath path, MouseEvent event) Messaged to update the selection based on aMouseEventover a particular row.protected voidsetCellEditor(TreeCellEditor editor) Sets the cell editor.protected voidSets theTreeCellRenderertotcr.voidsetCollapsedIcon(Icon newG) Sets the collapsed icon.protected voidsetEditable(boolean newValue) Configures the receiver to allow, or not allow, editing.voidsetExpandedIcon(Icon newG) Sets the expanded icon.protected voidsetHashColor(Color color) Sets the hash color.protected voidsetLargeModel(boolean largeModel) Sets thelargeModel.voidsetLeftChildIndent(int newAmount) Sets the left child indent.protected voidSets theTreeModel.voidsetPreferredMinSize(Dimension newSize) Sets the preferred minimum size.voidsetRightChildIndent(int newAmount) Sets the right child indent.protected voidsetRootVisible(boolean newValue) Sets the root to being visible.protected voidsetRowHeight(int rowHeight) Sets the row height, this is forwarded to the treeState.protected voidsetSelectionModel(TreeSelectionModel newLSM) Resets the selection model.protected voidsetShowsRootHandles(boolean newValue) Determines whether the node handles are to be displayed.protected booleanshouldPaintExpandControl(TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) Returnstrueif the expand (toggle) control should be drawn for the specified row.protected booleanstartEditing(TreePath path, MouseEvent event) Will start editing for node if there is acellEditorandshouldSelectCellreturnstrue.voidstartEditingAtPath(JTree tree, TreePath path) Selects the last item in path and tries to edit it.booleanstopEditing(JTree tree) Stops the current editing session.protected voidtoggleExpandState(TreePath path) Expands path if it is not expanded, or collapses row if it is expanded.protected voidUninstalls the renderer pane.protected voidUninstalls default properties.protected voidUnregisters keyboard actions.protected voidUnregisters listeners.protected voidUpdates thepreferredSizeinstance variable, which is returned fromgetPreferredSize().protected voidUpdates the cellEditor based on the editability of the JTree that we're contained in.protected voidUpdates how much each depth should be offset by.protected voidUpdates the expanded state of all the descendants ofpathby getting the expanded descendants from the tree and forwarding to the tree state.protected voidMakes all the nodes that are expanded in JTree expanded in LayoutCache.protected voidUpdates the lead row of the selection.protected voidMessaged from the tree we're in when the renderer has changed.protected voidMarks the cached size as being invalid, and messages the tree withtreeDidChange.Methods declared in class ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, installUI, uninstallUIModifier and TypeMethodDescriptionbooleancontains(JComponent c, int x, int y) Returnstrueif the specified x,y location is contained within the look and feel's defined shape of the specified component.getAccessibleChild(JComponent c, int i) Returns theithAccessiblechild of the object.intReturns the number of accessible children in the object.voidConfigures the specified component appropriately for the look and feel.voidReverses configuration which was done on the specified component duringinstallUI.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
SynthTreeUI
public SynthTreeUI()Constructs aSynthTreeUI.
-
-
Method Details
-
createUI
Creates a new UI object for the given component.- Parameters:
x- component to create UI object for- Returns:
- the UI object
-
getContext
Returns the Context for the specified component.- Specified by:
getContextin interfaceSynthUI- Parameters:
c- Component requesting SynthContext.- Returns:
- SynthContext describing component.
-
update
Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls thepaint(SynthContext,Graphics)method.In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the
paintmethod.- Overrides:
updatein classComponentUI- Parameters:
g- theGraphicsobject used for paintingc- the component being painted- See Also:
-
paintBorder
Paints the border.- Specified by:
paintBorderin interfaceSynthUI- Parameters:
context- a component contextg-Graphicsto paint onx- the X coordinatey- the Y coordinatew- width of the borderh- height of the border
-
paint
Paints the specified component according to the Look and Feel.This method is not used by Synth Look and Feel. Painting is handled by the
paint(SynthContext,Graphics)method.- Overrides:
paintin classComponentUI- Parameters:
g- theGraphicsobject used for paintingc- the component being painted- See Also:
-
paint
Paints the specified component.- Parameters:
context- context for the component being paintedg- theGraphicsobject used for painting- See Also:
-
propertyChange
This method gets called when a bound property is changed.- Specified by:
propertyChangein interfacePropertyChangeListener- Parameters:
event- A PropertyChangeEvent object describing the event source and the property that has changed.
-