Class TerraTreeViewSkin

    • Constructor Detail

      • TerraTreeViewSkin

        public TerraTreeViewSkin()
    • Method Detail

      • getTreeView

        public TreeView getTreeView()
        Returns:
        the TreeView we are attached to.
      • install

        public void install​(Component component)
        Description copied from class: ComponentSkin
        Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.
        Specified by:
        install in interface Skin
        Overrides:
        install in class ComponentSkin
        Parameters:
        component - The component to which the skin is being attached.
      • getPreferredWidth

        public int getPreferredWidth​(int height)
        Description copied from interface: ConstrainedVisual
        Returns the visual's preferred width given the provided height constraint.
        Specified by:
        getPreferredWidth in interface ConstrainedVisual
        Parameters:
        height - The height by which to constrain the preferred width, or -1 for no constraint.
        Returns:
        The preferred width given the height constraint.
      • getPreferredHeight

        public int getPreferredHeight​(int width)
        Description copied from interface: ConstrainedVisual
        Returns the visual's preferred height given the provided width constraint.
        Specified by:
        getPreferredHeight in interface ConstrainedVisual
        Parameters:
        width - The width by which to constrain the preferred height, or -1 for no constraint.
        Returns:
        The preferred height given the width constraint.
      • getBaseline

        public int getBaseline​(int width,
                               int height)
        Description copied from class: ComponentSkin
        Should be implemented in every subclass.

        The default implementation here simply returns -1 (no baseline).

        Specified by:
        getBaseline in interface ConstrainedVisual
        Overrides:
        getBaseline in class ComponentSkin
        Parameters:
        width - Constrained width to compute the baseline for.
        height - Constrained height to compute the baseline for.
        Returns:
        The baseline relative to the origin of this visual, or -1 if this visual does not have a baseline.
      • layout

        public void layout()
        Description copied from interface: Skin
        If the component on which the skin is installed is a container, lays out the container's children.
        Specified by:
        layout in interface Skin
      • paint

        public void paint​(java.awt.Graphics2D graphics)
        Description copied from interface: Visual
        Paints the visual.
        Specified by:
        paint in interface Visual
        Parameters:
        graphics - The graphics context in which to paint the visual.
      • getFont

        public java.awt.Font getFont()
      • setFont

        public void setFont​(java.awt.Font newFont)
      • setFont

        public final void setFont​(java.lang.String fontString)
      • setFont

        public final void setFont​(Dictionary<java.lang.String,​?> fontDictionary)
      • getColor

        public java.awt.Color getColor()
      • setColor

        public void setColor​(java.awt.Color colorValue)
      • setColor

        public void setColor​(java.lang.String colorString)
      • setColor

        public final void setColor​(int colorIndex)
      • getDisabledColor

        public java.awt.Color getDisabledColor()
      • setDisabledColor

        public void setDisabledColor​(java.awt.Color disabledColorValue)
      • setDisabledColor

        public void setDisabledColor​(java.lang.String disabledColorString)
      • setDisabledColor

        public final void setDisabledColor​(int disabledColorIndex)
      • getBackgroundColor

        public java.awt.Color getBackgroundColor()
      • setBackgroundColor

        public void setBackgroundColor​(java.awt.Color backgroundColorValue)
      • setBackgroundColor

        public void setBackgroundColor​(java.lang.String backgroundColorString)
      • setBackgroundColor

        public final void setBackgroundColor​(int backgroundColorIndex)
      • getSelectionColor

        public java.awt.Color getSelectionColor()
      • setSelectionColor

        public void setSelectionColor​(java.awt.Color selectionColorValue)
      • setSelectionColor

        public void setSelectionColor​(java.lang.String selectionColorString)
      • setSelectionColor

        public final void setSelectionColor​(int selectionColorIndex)
      • getSelectionBackgroundColor

        public java.awt.Color getSelectionBackgroundColor()
      • setSelectionBackgroundColor

        public void setSelectionBackgroundColor​(java.awt.Color selectionBackgroundColorValue)
      • setSelectionBackgroundColor

        public void setSelectionBackgroundColor​(java.lang.String selectionBackgroundColorString)
      • setSelectionBackgroundColor

        public final void setSelectionBackgroundColor​(int selectionBackgroundColorIndex)
      • getInactiveSelectionColor

        public java.awt.Color getInactiveSelectionColor()
      • setInactiveSelectionColor

        public void setInactiveSelectionColor​(java.awt.Color inactiveSelectionColorValue)
      • setInactiveSelectionColor

        public void setInactiveSelectionColor​(java.lang.String inactiveSelectionColorString)
      • setInactiveSelectionColor

        public final void setInactiveSelectionColor​(int inactiveSelectionColorIndex)
      • getInactiveSelectionBackgroundColor

        public java.awt.Color getInactiveSelectionBackgroundColor()
      • setInactiveSelectionBackgroundColor

        public void setInactiveSelectionBackgroundColor​(java.awt.Color inactiveSelectionBackgroundColorValue)
      • setInactiveSelectionBackgroundColor

        public void setInactiveSelectionBackgroundColor​(java.lang.String inactiveSelectionBackgroundString)
      • setInactiveSelectionBackgroundColor

        public final void setInactiveSelectionBackgroundColor​(int inactiveSelectionBackgroundIndex)
      • getHighlightColor

        public java.awt.Color getHighlightColor()
      • setHighlightColor

        public void setHighlightColor​(java.awt.Color highlightColorValue)
      • setHighlightColor

        public void setHighlightColor​(java.lang.String highlightColorString)
      • setHighlightColor

        public final void setHighlightColor​(int highlightColorIndex)
      • getHighlightBackgroundColor

        public java.awt.Color getHighlightBackgroundColor()
      • setHighlightBackgroundColor

        public void setHighlightBackgroundColor​(java.awt.Color highlightBackgroundColorValue)
      • setHighlightBackgroundColor

        public void setHighlightBackgroundColor​(java.lang.String highlightBackgroundColorString)
      • setHighlightBackgroundColor

        public final void setHighlightBackgroundColor​(int highlightBackgroundColorIndex)
      • getSpacing

        public int getSpacing()
      • setSpacing

        public void setSpacing​(int spacingValue)
      • setSpacing

        public void setSpacing​(java.lang.Number spacingValue)
      • getIndent

        public int getIndent()
      • setIndent

        public void setIndent​(int indentValue)
      • setIndent

        public void setIndent​(java.lang.Number indentValue)
      • getShowHighlight

        public boolean getShowHighlight()
      • setShowHighlight

        public void setShowHighlight​(boolean showHighlightValue)
      • getShowBranchControls

        public boolean getShowBranchControls()
      • setShowBranchControls

        public void setShowBranchControls​(boolean showBranchControlsValue)
      • getShowEmptyBranchControls

        public boolean getShowEmptyBranchControls()
      • setShowEmptyBranchControls

        public void setShowEmptyBranchControls​(boolean showEmptyBranchControlsValue)
      • getBranchControlColor

        public java.awt.Color getBranchControlColor()
      • setBranchControlColor

        public void setBranchControlColor​(java.awt.Color branchControlColorValue)
      • setBranchControlColor

        public void setBranchControlColor​(java.lang.String branchControlColorString)
      • setBranchControlColor

        public final void setBranchControlColor​(int branchControlColorIndex)
      • getBranchControlSelectionColor

        public java.awt.Color getBranchControlSelectionColor()
      • setBranchControlSelectionColor

        public void setBranchControlSelectionColor​(java.awt.Color branchControlSelectionColorValue)
      • setBranchControlSelectionColor

        public void setBranchControlSelectionColor​(java.lang.String branchControlSelectionColorString)
      • setBranchControlSelectionColor

        public final void setBranchControlSelectionColor​(int branchControlSelectionColorIndex)
      • getBranchControlInactiveSelectionColor

        public java.awt.Color getBranchControlInactiveSelectionColor()
      • setBranchControlInactiveSelectionColor

        public void setBranchControlInactiveSelectionColor​(java.awt.Color branchControlInactiveSelectionColorValue)
      • setBranchControlInactiveSelectionColor

        public void setBranchControlInactiveSelectionColor​(java.lang.String branchControlInactiveSelectionString)
      • setBranchControlInactiveSelectionColor

        public final void setBranchControlInactiveSelectionColor​(int branchControlInactiveSelectionIndex)
      • getGridColor

        public java.awt.Color getGridColor()
      • setGridColor

        public void setGridColor​(java.awt.Color gridColorValue)
      • setGridColor

        public void setGridColor​(java.lang.String gridColorString)
      • setGridColor

        public final void setGridColor​(int gridColorIndex)
      • getShowGridLines

        public boolean getShowGridLines()
      • setShowGridLines

        public void setShowGridLines​(boolean showGridLinesValue)
      • getNodeHeight

        protected int getNodeHeight()
        Returns:
        The fixed node height of this skin.
      • getNodeInfoAt

        protected final org.apache.pivot.wtk.skin.terra.TerraTreeViewSkin.NodeInfo getNodeInfoAt​(int y)
        Parameters:
        y - The current Y location.
        Returns:
        The metadata associated with the node found at the specified y-coordinate, or null if there is no node at that location.
      • getNodeInfoAt

        protected final org.apache.pivot.wtk.skin.terra.TerraTreeViewSkin.NodeInfo getNodeInfoAt​(Sequence.Tree.Path path)
        Parameters:
        path - The path to query.
        Returns:
        The metadata associated with the node at the specified path. The path must be valid. The empty path is supported and represents the root node info.
      • getBranchInfoAt

        protected final org.apache.pivot.wtk.skin.terra.TerraTreeViewSkin.BranchInfo getBranchInfoAt​(Sequence.Tree.Path path)
        Parameters:
        path - The path to query.
        Returns:
        The metadata for the branch node at the specified path.
        See Also:
        getNodeInfoAt(Path)
      • getNodeBounds

        protected final Bounds getNodeBounds​(org.apache.pivot.wtk.skin.terra.TerraTreeViewSkin.NodeInfo nodeInfo)
        Parameters:
        nodeInfo - The node information to search for.
        Returns:
        The bounding box defined by the specified node, or null if the node is not currently visible.
      • accept

        protected final void accept​(TerraTreeViewSkin.NodeInfoVisitor visitor)
        Accepts the specified visitor on all node info objects that exist in this skin's node info hierarchy.
        Parameters:
        visitor - The callback to execute on each node info object
      • repaintNode

        protected void repaintNode​(org.apache.pivot.wtk.skin.terra.TerraTreeViewSkin.NodeInfo nodeInfo)
        Repaints the region occupied by the specified node.
        Parameters:
        nodeInfo - The node to search for.
      • clearHighlightedNode

        protected void clearHighlightedNode()
        Clears the highlighted node if one exists.
      • mouseMove

        public boolean mouseMove​(Component component,
                                 int x,
                                 int y)
        Description copied from interface: ComponentMouseListener
        Called when the mouse is moved over a component.
        Specified by:
        mouseMove in interface ComponentMouseListener
        Overrides:
        mouseMove in class ComponentSkin
        Parameters:
        component - Component that is under the mouse.
        x - X position of the mouse.
        y - Y position of the mouse.
        Returns:
        true to consume the event; false to allow it to propagate (default return).
      • mouseDown

        public boolean mouseDown​(Component component,
                                 Mouse.Button button,
                                 int x,
                                 int y)
        Description copied from interface: ComponentMouseButtonListener
        Called when a mouse button is pressed over a component.
        Specified by:
        mouseDown in interface ComponentMouseButtonListener
        Overrides:
        mouseDown in class ComponentSkin
        Parameters:
        component - Component that is under the mouse pointer.
        button - Which mouse button was pressed.
        x - X position of the mouse.
        y - Y position of the mouse.
        Returns:
        true to consume the event; false to allow it to propagate (default).
      • mouseUp

        public boolean mouseUp​(Component component,
                               Mouse.Button button,
                               int x,
                               int y)
        Description copied from interface: ComponentMouseButtonListener
        Called when a mouse button is released over a component.
        Specified by:
        mouseUp in interface ComponentMouseButtonListener
        Overrides:
        mouseUp in class ComponentSkin
        Parameters:
        component - Component user the mouse pointer.
        button - Which mouse button that was released.
        x - X position of the mouse.
        y - Y position of the mouse.
        Returns:
        true to consume the event; false to allow it to propagate (default).
      • mouseClick

        public boolean mouseClick​(Component component,
                                  Mouse.Button button,
                                  int x,
                                  int y,
                                  int count)
        Description copied from interface: ComponentMouseButtonListener
        Called when a mouse button is clicked over a component.
        Specified by:
        mouseClick in interface ComponentMouseButtonListener
        Overrides:
        mouseClick in class ComponentSkin
        Parameters:
        component - Component user the mouse pointer.
        button - Which mouse button was clicked.
        x - X position of the mouse.
        y - Y position of the mouse.
        count - Number of clicks (1 = single click, 2 = double click, etc.).
        Returns:
        true to consume the event; false to allow it to propagate (default).
      • mouseWheel

        public boolean mouseWheel​(Component component,
                                  Mouse.ScrollType scrollType,
                                  int scrollAmount,
                                  int wheelRotation,
                                  int x,
                                  int y)
        Description copied from interface: ComponentMouseWheelListener
        Called when the mouse wheel is scrolled over a component.
        Specified by:
        mouseWheel in interface ComponentMouseWheelListener
        Overrides:
        mouseWheel in class ComponentSkin
        Parameters:
        component - Component under the mouse pointer.
        scrollType - What type of scroll was requested on the mouse.
        scrollAmount - Amount of scrolling.
        wheelRotation - Rotation value.
        x - X position of the mouse.
        y - Y position of the mouse.
        Returns:
        true to consume the event; false to allow it to propagate.
      • isFocusable

        public boolean isFocusable()
        Description copied from class: ComponentSkin
        By default, skins are focusable.
        Specified by:
        isFocusable in interface Skin
        Overrides:
        isFocusable in class ComponentSkin
        Returns:
        true if this skin is focusable; false, otherwise.
      • isOpaque

        public boolean isOpaque()
        Description copied from class: ComponentSkin
        By default, skins are assumed to be opaque.
        Specified by:
        isOpaque in interface Skin
        Overrides:
        isOpaque in class ComponentSkin
        Returns:
        true if this skin is opaque; false if any part of it is transparent or translucent.
      • enabledChanged

        public void enabledChanged​(Component component)
        Description copied from interface: ComponentStateListener
        Called when a component's enabled state has changed.

        Called both when the component is enabled and when it is disabled. The component's enabled flag has already been set when this method is called so the new state can be determined by calling the Component.isEnabled() method.

        Specified by:
        enabledChanged in interface ComponentStateListener
        Overrides:
        enabledChanged in class ComponentSkin
        Parameters:
        component - The component whose enabled state is changing.
      • focusedChanged

        public void focusedChanged​(Component component,
                                   Component obverseComponent)
        Description copied from interface: ComponentStateListener
        Called when a component's focused state has changed.

        This will be called both when a component gains focus and when it loses focus. The currently focused component has already been set when this method is called, so that the new state of the component can be determined by calling the Component.isFocused() method.

        Specified by:
        focusedChanged in interface ComponentStateListener
        Overrides:
        focusedChanged in class ComponentSkin
        Parameters:
        component - The component that is either gaining focus or the one that previously had focus and is now losing it.
        obverseComponent - If the component is gaining focus, this is the component that is losing focus. If the component is losing focus this is the component that is gaining the focus instead.
      • getNodeAt

        public Sequence.Tree.Path getNodeAt​(int y)
        Description copied from interface: TreeView.Skin
        Gets the path to the node found at the specified y-coordinate (relative to the tree view).
        Specified by:
        getNodeAt in interface TreeView.Skin
        Parameters:
        y - The y-coordinate in pixels.
        Returns:
        The path to the node, or null if there is no node being painted at the specified y-coordinate.
      • getNodeBounds

        public Bounds getNodeBounds​(Sequence.Tree.Path path)
        Description copied from interface: TreeView.Skin
        Gets the bounds of the node at the specified path relative to the tree view. Note that all nodes are left aligned with the tree; to get the pixel value of a node's indent, use TreeView.Skin.getNodeIndent(int).
        Specified by:
        getNodeBounds in interface TreeView.Skin
        Parameters:
        path - The path to the node.
        Returns:
        The bounds, or null if the node is not currently visible.
      • getNodeIndent

        public int getNodeIndent​(int depth)
        Description copied from interface: TreeView.Skin
        Gets the pixel indent of nodes at the specified depth. Depth is measured in generations away from the tree view's "root" node, which is represented by the tree data.
        Specified by:
        getNodeIndent in interface TreeView.Skin
        Parameters:
        depth - The depth, where the first child of the root has depth 1, the child of that branch has depth 2, etc.
        Returns:
        The indent in pixels to the node's content.
      • getRowIndex

        public int getRowIndex​(Sequence.Tree.Path path)
        Description copied from interface: TreeView.Skin
        Gets the row index of the node, as seen in the current visible nodes list. Note that as branches are expanded and collapsed, the row index of any given node in the tree will change.
        Specified by:
        getRowIndex in interface TreeView.Skin
        Parameters:
        path - The path to the node.
        Returns:
        The row index of the node, or -1 if the node is not currently visible.
      • treeDataChanged

        public void treeDataChanged​(TreeView treeView,
                                    List<?> previousTreeData)
        Description copied from interface: TreeViewListener
        Called when a tree view's data has changed.
        Specified by:
        treeDataChanged in interface TreeViewListener
        Parameters:
        treeView - The source of this event.
        previousTreeData - The previous data for this tree.
      • nodeRendererChanged

        public void nodeRendererChanged​(TreeView treeView,
                                        TreeView.NodeRenderer previousNodeRenderer)
        Description copied from interface: TreeViewListener
        Called when a tree view's node renderer has changed.
        Specified by:
        nodeRendererChanged in interface TreeViewListener
        Parameters:
        treeView - The source of this event.
        previousNodeRenderer - The previous renderer for tree nodes.
      • selectModeChanged

        public void selectModeChanged​(TreeView treeView,
                                      TreeView.SelectMode previousSelectMode)
        Description copied from interface: TreeViewListener
        Called when a tree view's select mode has changed.
        Specified by:
        selectModeChanged in interface TreeViewListener
        Parameters:
        treeView - The source of this event.
        previousSelectMode - What the tree view's select mode was before the change.
      • checkmarksEnabledChanged

        public void checkmarksEnabledChanged​(TreeView treeView)
        Description copied from interface: TreeViewListener
        Called when a tree view's checkmarks enabled flag has changed.
        Specified by:
        checkmarksEnabledChanged in interface TreeViewListener
        Parameters:
        treeView - The source of this event.
      • showMixedCheckmarkStateChanged

        public void showMixedCheckmarkStateChanged​(TreeView treeView)
        Description copied from interface: TreeViewListener
        Called when a tree view's "show mixed checkmark state" flag has changed.
        Specified by:
        showMixedCheckmarkStateChanged in interface TreeViewListener
        Parameters:
        treeView - The tree view that has changed.
      • disabledNodeFilterChanged

        public void disabledNodeFilterChanged​(TreeView treeView,
                                              Filter<?> previousDisabledNodeFilter)
        Description copied from interface: TreeViewListener
        Called when a tree view's disabled node filter has changed.
        Specified by:
        disabledNodeFilterChanged in interface TreeViewListener
        Parameters:
        treeView - The tree view that has changed.
        previousDisabledNodeFilter - The previous filter that determines the disabled nodes.
      • disabledCheckmarkFilterChanged

        public void disabledCheckmarkFilterChanged​(TreeView treeView,
                                                   Filter<?> previousDisabledCheckmarkFilter)
        Description copied from interface: TreeViewListener
        Called when a tree view's disabled checkmark filter has changed.
        Specified by:
        disabledCheckmarkFilterChanged in interface TreeViewListener
        Parameters:
        treeView - The source of this event.
        previousDisabledCheckmarkFilter - The previous filter that determined the disabled checkmarks.
      • previewBranchExpandedChange

        public Vote previewBranchExpandedChange​(TreeView treeView,
                                                Sequence.Tree.Path path)
        Description copied from interface: TreeViewBranchListener
        Called before a tree node is expanded or collapsed to allow the application or the skin to refuse the operation.
        Specified by:
        previewBranchExpandedChange in interface TreeViewBranchListener
        Parameters:
        treeView - The source of the event.
        path - The path of the node about to be collapsed or expanded.
        Returns:
        The accumulated vote as to whether to allow this expansion or collapse.
      • nodeInserted

        public void nodeInserted​(TreeView treeView,
                                 Sequence.Tree.Path path,
                                 int index)
        Description copied from interface: TreeViewNodeListener
        Called when a node has been inserted into the tree view.
        Specified by:
        nodeInserted in interface TreeViewNodeListener
        Parameters:
        treeView - The source of this event.
        path - The path to the branch where the node was inserted.
        index - The index of the newly inserted node within the branch.
      • nodesRemoved

        public void nodesRemoved​(TreeView treeView,
                                 Sequence.Tree.Path path,
                                 int index,
                                 int count)
        Description copied from interface: TreeViewNodeListener
        Called when nodes have been removed from the tree view.
        Specified by:
        nodesRemoved in interface TreeViewNodeListener
        Parameters:
        treeView - The source of this event.
        path - The path to the branch where the node(s) were removed.
        index - The index to the first removed node within the branch.
        count - The number of nodes that were removed, or -1 if all nodes were removed.
      • nodeUpdated

        public void nodeUpdated​(TreeView treeView,
                                Sequence.Tree.Path path,
                                int index)
        Description copied from interface: TreeViewNodeListener
        Called when a node in the tree view has been updated.
        Specified by:
        nodeUpdated in interface TreeViewNodeListener
        Parameters:
        treeView - The source of this event.
        path - Path to the branch that is the parent of the updated node.
        index - Index of the updated node within the branch.