Class BranchRenderer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ASCENDER
      A vertical bar from the top to the toggle
      private int[] branches  
      static int DESCENDER
      A vertical bar from the toggle to the bottom
      static int H_CENTRE_TOGGLE
      A horizontal bar from the centre to the toggle
      static int H_FULL
      A full-width horizontal bar
      static int H_LEFT_TOGGLE
      A horizontal bar from the left to the toggle
      static int H_RIGHT
      A horizontal bar from the centre to the right
      static int I
      Indicates that a branch should be rendered as a 'I' shape.
      private int indent  
      static int L
      Indicates that a branch should be rendered as an 'L' shape.
      static int LAST_ROOT
      Indicates that the decoration for the last root node should be drawn
      static int LEAF
      Indicates that the decoration for a leaf node should be drawn
      private static int[] LINE_STYLE  
      static int NODE
      Indicates that the toggle decoration for an expanded parent should be drawn
      static int NONE
      Indicates that a branch should not be rendered.
      static int ROOT
      Indicates that the decoration for a root node should be drawn
      static int SMALL_L
      A half-width L used on roots with no children
      static int SMALL_T
      A half-width T used on roots with no children
      static int T
      Indicates that a branch should be rendered as a 'T' shape.
      private org.eclipse.swt.graphics.Rectangle toggleBounds  
      static int V_FULL
      A full-height vertical bar
      static int V_TOP
      A vertical bar from the top to the middle
    • Constructor Summary

      Constructors 
      Constructor Description
      BranchRenderer()  
    • Field Detail

      • LINE_STYLE

        private static final int[] LINE_STYLE
      • H_RIGHT

        public static final int H_RIGHT
        A horizontal bar from the centre to the right
        See Also:
        Constant Field Values
      • H_CENTRE_TOGGLE

        public static final int H_CENTRE_TOGGLE
        A horizontal bar from the centre to the toggle
        See Also:
        Constant Field Values
      • H_LEFT_TOGGLE

        public static final int H_LEFT_TOGGLE
        A horizontal bar from the left to the toggle
        See Also:
        Constant Field Values
      • V_TOP

        public static final int V_TOP
        A vertical bar from the top to the middle
        See Also:
        Constant Field Values
      • DESCENDER

        public static final int DESCENDER
        A vertical bar from the toggle to the bottom
        See Also:
        Constant Field Values
      • ASCENDER

        public static final int ASCENDER
        A vertical bar from the top to the toggle
        See Also:
        Constant Field Values
      • NONE

        public static final int NONE
        Indicates that a branch should not be rendered.
        See Also:
        Constant Field Values
      • T

        public static final int T
        Indicates that a branch should be rendered as a 'T' shape. This is used for normal children with following siblings
        See Also:
        Constant Field Values
      • L

        public static final int L
        Indicates that a branch should be rendered as an 'L' shape. This is used for the last child element
        See Also:
        Constant Field Values
      • I

        public static final int I
        Indicates that a branch should be rendered as a 'I' shape. This is used for connecting children when intermediate children are shown.
        See Also:
        Constant Field Values
      • NODE

        public static final int NODE
        Indicates that the toggle decoration for an expanded parent should be drawn
        See Also:
        Constant Field Values
      • LEAF

        public static final int LEAF
        Indicates that the decoration for a leaf node should be drawn
        See Also:
        Constant Field Values
      • ROOT

        public static final int ROOT
        Indicates that the decoration for a root node should be drawn
        See Also:
        Constant Field Values
      • LAST_ROOT

        public static final int LAST_ROOT
        Indicates that the decoration for the last root node should be drawn
        See Also:
        Constant Field Values
      • SMALL_T

        public static final int SMALL_T
        A half-width T used on roots with no children
        See Also:
        Constant Field Values
      • SMALL_L

        public static final int SMALL_L
        A half-width L used on roots with no children
        See Also:
        Constant Field Values
      • indent

        private int indent
      • branches

        private int[] branches
      • toggleBounds

        private org.eclipse.swt.graphics.Rectangle toggleBounds
    • Constructor Detail

      • BranchRenderer

        public BranchRenderer()
    • Method Detail

      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(org.eclipse.swt.graphics.GC gc,
                                                          int hint,
                                                          int hint2,
                                                          java.lang.Object value)
        Returns the size of the given value's visual representation.
        Parameters:
        gc - convenience GC for string and text extents
        hint - given width (or SWT.DEFAULT)
        hint2 - given height (or SWT.DEFAULT)
        value - value to be sized
        Returns:
        the size
      • paint

        public void paint​(org.eclipse.swt.graphics.GC gc,
                          java.lang.Object value)
        Paints the visual representation of the given value on the given GC. The actual class of the value object is determined by the use of the implementing class.

        Implementors need to respect the bounds values that may have been specified. The bounds values may affect the x and y values for all drawing operations as well as the width and heights. Implementors may use a Transform to translate the coordinates of all the drawing operations, otherwise they will need to offset each draw.

        Parameters:
        gc - GC to paint with
        value - the value being painted
      • setBranches

        public void setBranches​(int[] branches)
        Sets the branches that will be used. The values are taken from the constants in this class such as I, L, T, NODE, LEAF and NONE, which represent the branch type to be used for each level.
        Parameters:
        branches - an array of branch types
      • setIndent

        public void setIndent​(int toggleIndent)
        Sets the indent used for rendering the tree branches
        Parameters:
        toggleIndent - the indent used for the tree
      • setToggleBounds

        public void setToggleBounds​(org.eclipse.swt.graphics.Rectangle toggleBounds)
        Sets bounds of the toggle control. This is used to position the downwards branches
        Parameters:
        toggleBounds - the bounds of the toggle control