com.dlsc.flexgantt.swing.treetable

## Class TreeTableHeader

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JPanel
        - - com.dlsc.flexgantt.swing.GanttChartControl
          - - com.dlsc.flexgantt.swing.treetable.TreeTableHeader

- All Implemented Interfaces:
    IColumnModelListener, ISortingListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible

      public class TreeTableHeader
      extends GanttChartControl
      implements PropertyChangeListener, MouseListener, MouseMotionListener, IColumnModelListener, ISortingListener

  The column heder is used in combination with the `TreeTable`. It's purpose is to visualize the columns that are provided by the Gantt chart's column model (see `IColumnModel`).
  Since:
    1.0
  Version:
    $Revision: 1.19 $
  Author:
    Dirk Lemmermann
  See Also:
    `DefaultColumnModel`, Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class javax.swing.JPanel

      `JPanel.AccessibleJPanel`

    - ### Nested classes/interfaces inherited from class javax.swing.JComponent

      `JComponent.AccessibleJComponent`

    - ### Nested classes/interfaces inherited from class java.awt.Container

      `Container.AccessibleAWTContainer`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy`

  - ### Field Summary

    - ### Fields inherited from class javax.swing.JComponent

      `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

      `accessibleContext, 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

    Constructors
    Constructor and Description
    `TreeTableHeader(AbstractGanttChart gc)` Constructs a new column header.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `columnModelChanged(ColumnModelEvent evt)` The listener's callback method that will be invoked when columns get added, removed, inserted.
    `TreeTableColumn` | `getColumn(int index)` Returns the tree table column for the given index.
    `TreeTableColumn` | `getColumnAt(int x)` Returns the column located at the given location.
    `Rectangle` | `getColumnBounds(int index)` Returns the bounds of the column at the given index.
    `Rectangle` | `getColumnBounds(TreeTableColumn c)` Returns the bounds of the given column.
    `IColumnHeaderRenderer` | `getColumnHeaderRenderer(Class cl)` Returns a column header renderer for an object type.
    `int` | `getColumnIndexAt(int x)` Returns the index of the column at the given x-coordinate.
    `int` | `getColumnLocation(TreeTableColumn c)` Returns the x-coordinate of the given column.
    `TreeTableColumn` | `getDraggedColumn()` Returns the tree table column on which drag operations are currently performed (resize or move).
    `TreeTableColumn` | `getFillerColumn()` Returns the filler column that gets placed at the end of the column header and that causes a column to be rendered when the left-hand side of the Gantt chart gets resized so much that it is larger than the table that it contains.
    `Color` | `getGridColor()` Returns the color used by the table header to draw its grid lines.
    `ITreeTableHeaderMenuProvider` | `getMenuProvider()` Returns the menu provider used by the tree table header to lookup a popup menu based on the location and context of the popup trigger event.
    `IColumnModel` | `getModel()` Returns the column model that gets visualized by the column header.
    `Dimension` | `getPreferredSize()`
    `Map<Class,IColumnHeaderRenderer>` | `getRendererMap()` Returns the map that stores the mappings between column header values and column header renderers.
    `int` | `getSortCount()` The tree table supports multi-column sorting and this method returns the number of columns used for sorting.
    `int` | `getSortPosition(int modelIndex)` The tree table and the tree table header support multi column sorting.
    `boolean` | `isDoubleClickResizeEnabled()` Determines whether the user can auto resize a column by double clicking on its right edge.
    `boolean` | `isFocusEnabled()` Determines whether focus will be shown to the user when the mouse cursor hovers over a column header.
    `boolean` | `isShowingFillerColumn()` Returns TRUE if the tree table places an unused filler column to the right of the last used column.
    `void` | `mouseClicked(MouseEvent e)`
    `void` | `mouseDragged(MouseEvent e)`
    `void` | `mouseEntered(MouseEvent e)`
    `void` | `mouseExited(MouseEvent e)`
    `void` | `mouseMoved(MouseEvent e)`
    `void` | `mousePressed(MouseEvent e)`
    `void` | `mouseReleased(MouseEvent e)`
    `protected void` | `paintColumnHeader(Graphics g, TreeTableColumn column, int x, int y, int width, int height)` Paints the column header for the given column.
    `protected void` | `paintColumnHeaders(Graphics g)` Paints all column headers.
    `protected void` | `paintComponent(Graphics g)`
    `void` | `propertyChange(PropertyChangeEvent evt)`
    `void` | `setColumnHeaderRenderer(Class objectType, IColumnHeaderRenderer renderer)` Maps the implementation of a column header renderer to a class definition.
    `void` | `setDoubleClickResizeEnabled(boolean enabled)` Specifies whether the user can auto resize a column by double clicking on its right edge.
    `void` | `setFocusEnabled(boolean focusEnabled)` Specifies whether focus will be shown to the user when the mouse cursor hovers over a column header.
    `void` | `setGridColor(Color color)` Sets the color used by the table header to draw its grid lines.
    `void` | `setMenuProvider(ITreeTableHeaderMenuProvider provider)` Sets the menu provider used by the tree table header to lookup a popup menu based on the location and context of the popup trigger event.
    `void` | `setRendererMap(Map<Class,IColumnHeaderRenderer> map)` Sets the map that stores the mappings between column header values and column header renderers.
    `void` | `setShowingFillerColumn(boolean show)` Specifies whether an unused filler column will be placed to the right of the last used column.
    `void` | `sortColumn(TreeTableColumn col, boolean keepSortedColumns)` Sorts the given column.
    `void` | `sorting(SortingEvent evt)` Callback method that gets invoked when a sort starts or finishes.

    - ### Methods inherited from class com.dlsc.flexgantt.swing.GanttChartControl

      `getGanttChart, print, printBorder`

    - ### Methods inherited from class javax.swing.JPanel

      `getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI`

    - ### Methods inherited from class javax.swing.JComponent

      `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, printAll, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TreeTableHeader

          public TreeTableHeader(AbstractGanttChart gc)

      Constructs a new column header.
      Parameters:
        `gc` - the parent Gantt chart container
      Since:
        1.0

  - ### Method Detail

    - #### paintComponent

          protected void paintComponent(Graphics g)

      Overrides:
        `paintComponent` in class `JComponent`

    - #### paintColumnHeaders

          protected void paintColumnHeaders(Graphics g)

      Paints all column headers.
      Parameters:
        `g` - the graphics context into which to draw
      Since:
        1.0
      See Also:
        `paintColumnHeader(Graphics, TreeTableColumn, int, int, int, int)`

    - #### paintColumnHeader

          protected void paintColumnHeader(Graphics g,
                                           TreeTableColumn column,
                                           int x,
                                           int y,
                                           int width,
                                           int height)

      Paints the column header for the given column.
      Parameters:
        `g` - the graphics context into which to draw
        `column` - the column for which to draw a header
        `x` - the x-coordinate of the header
        `y` - the y-coordinate of the header
        `width` - the width of the header
        `height` - the height of the header
      Since:
        1.0

    - #### getSortPosition

          public int getSortPosition(int modelIndex)

      The tree table and the tree table header support multi column sorting. This method returns the position of the column with the given model index within the array of sorted columns. Example: the table is sorted based on the 3 columns with the columns representing model indices 4, 2, and 5. The method will then return 1 for model index 4, 2 for model index 2, and 3 for model index 5. The return value of this method can be used to visualize the sort order inside the column headers.
      Parameters:
        `modelIndex` - the model index that gets checked for its sort position
      Returns:
        the position of the given model index within the array of sorted columns (-1 if the model index is not being sorted)
      Since:
        1.0

    - #### getSortCount

          public int getSortCount()

      The tree table supports multi-column sorting and this method returns the number of columns used for sorting.
      Returns:
        the number of columns used for sorting
      Since:
        1.0

    - #### getDraggedColumn

          public TreeTableColumn getDraggedColumn()

      Returns the tree table column on which drag operations are currently performed (resize or move). Returns NULL if no column gets dragged.
      Returns:
        the currently dragged column
      Since:
        1.0

    - #### getPreferredSize

          public Dimension getPreferredSize()

      Overrides:
        `getPreferredSize` in class `JComponent`

    - #### getColumnIndexAt

          public int getColumnIndexAt(int x)

      Returns the index of the column at the given x-coordinate. This index is not the model index but simply reflects the position of the column found at the given location. The method will return -1 for the key column or `Integer.MIN_VALUE` if no column could be found. The filler column will not be taken into consideration.
      Parameters:
        `x` - the x-coordinate to check
      Returns:
        the positon of the tree table column found at the given x-coordinate or `Integer.MIN_VALUE` if no column can be found
      Since:
        1.0

    - #### getModel

          public IColumnModel getModel()

      Returns the column model that gets visualized by the column header.
      Returns:
        the header's column model
      Since:
        1.0

    - #### setFocusEnabled

          public void setFocusEnabled(boolean focusEnabled)

      Specifies whether focus will be shown to the user when the mouse cursor hovers over a column header.
      Parameters:
        `focusEnabled` - if TRUE the background color of column header will change when the mouse cursor hovers over it
      Since:
        2.0

    - #### isFocusEnabled

          public boolean isFocusEnabled()

      Determines whether focus will be shown to the user when the mouse cursor hovers over a column header.
      Returns:
        TRUE the background color of column header will change when the mouse cursor hovers over it
      Since:
        2.0

    - #### columnModelChanged

          public void columnModelChanged(ColumnModelEvent evt)

      Description copied from interface: `IColumnModelListener`
      The listener's callback method that will be invoked when columns get added, removed, inserted.
      Specified by:
        `columnModelChanged` in interface `IColumnModelListener`
      Parameters:
        `evt` - the event description

    - #### getColumn

          public TreeTableColumn getColumn(int index)

      Returns the tree table column for the given index. This is not the model index but the column's position within the header. The method returns NULL if no column exists for the given index.
      Parameters:
        `index` - the index for which to return a column
      Returns:
        the table column at the given location (index)
      Since:
        1.0

    - #### getColumnAt

          public TreeTableColumn getColumnAt(int x)

      Returns the column located at the given location.
      Parameters:
        `x` - the location for which to return the column
      Returns:
        the tree table column at the given location
      Since:
        1.0

    - #### mouseClicked

          public void mouseClicked(MouseEvent e)

      Specified by:
        `mouseClicked` in interface `MouseListener`

    - #### sortColumn

          public void sortColumn(TreeTableColumn col,
                                 boolean keepSortedColumns)

      Sorts the given column. The initial sorting will be ascending if this sort direction is supported. If not it will be descending.
      Parameters:
        `col` - the column to sort
        `keepSortedColumns` - if TRUE the sorting of the other columns will be maintained
      Since:
        1.0

    - #### mousePressed

          public void mousePressed(MouseEvent e)

      Specified by:
        `mousePressed` in interface `MouseListener`

    - #### mouseReleased

          public void mouseReleased(MouseEvent e)

      Specified by:
        `mouseReleased` in interface `MouseListener`

    - #### mouseEntered

          public void mouseEntered(MouseEvent e)

      Specified by:
        `mouseEntered` in interface `MouseListener`

    - #### mouseExited

          public void mouseExited(MouseEvent e)

      Specified by:
        `mouseExited` in interface `MouseListener`

    - #### mouseDragged

          public void mouseDragged(MouseEvent e)

      Specified by:
        `mouseDragged` in interface `MouseMotionListener`

    - #### mouseMoved

          public void mouseMoved(MouseEvent e)

      Specified by:
        `mouseMoved` in interface `MouseMotionListener`

    - #### getColumnLocation

          public int getColumnLocation(TreeTableColumn c)

      Returns the x-coordinate of the given column.
      Parameters:
        `c` - the tree table column
      Returns:
        the location of the given column
      Since:
        1.0

    - #### getColumnBounds

          public Rectangle getColumnBounds(TreeTableColumn c)

      Returns the bounds of the given column.
      Parameters:
        `c` - the tree table column
      Returns:
        a rectangle that represents the bounds of the given column
      Since:
        1.0

    - #### getColumnBounds

          public Rectangle getColumnBounds(int index)

      Returns the bounds of the column at the given index. This is not the model index but simply the position of the column within the group of columns. This method might return NULL if no column can be found for the given index.
      Parameters:
        `index` - the column's index
      Returns:
        the bounds of the column at the given index
      Since:
        1.0

    - #### getFillerColumn

          public TreeTableColumn getFillerColumn()

      Returns the filler column that gets placed at the end of the column header and that causes a column to be rendered when the left-hand side of the Gantt chart gets resized so much that it is larger than the table that it contains.
      Returns:
        the filler / pseudo tree table column
      Since:
        1.0
      See Also:
        `setShowingFillerColumn(boolean)`

    - #### isShowingFillerColumn

          public boolean isShowingFillerColumn()

      Returns TRUE if the tree table places an unused filler column to the right of the last used column.
      Returns:
        TRUE if a filler column will be shown
      Since:
        1.0

    - #### setShowingFillerColumn

          public void setShowingFillerColumn(boolean show)

      Specifies whether an unused filler column will be placed to the right of the last used column.
      Parameters:
        `show` - flag signalling use of filler column
      Since:
        1.0

    - #### getGridColor

          public Color getGridColor()

      Returns the color used by the table header to draw its grid lines.
      Returns:
        the grid line color
      Since:
        1.0

    - #### setGridColor

          public void setGridColor(Color color)

      Sets the color used by the table header to draw its grid lines.
      Parameters:
        `color` - the grid line color
      Since:
        1.0

    - #### propertyChange

          public void propertyChange(PropertyChangeEvent evt)

      Specified by:
        `propertyChange` in interface `PropertyChangeListener`
      Overrides:
        `propertyChange` in class `GanttChartControl`

    - #### setColumnHeaderRenderer

          public void setColumnHeaderRenderer(Class objectType,
                                              IColumnHeaderRenderer renderer)

      Maps the implementation of a column header renderer to a class definition.
      Parameters:
        `objectType` - the type of those header values that will be rendered with the given renderer
        `renderer` - an implementation that will be used to renderer instances of the given object type
      Since:
        1.0
      See Also:
        `DefaultColumnHeaderRenderer`, `getColumnHeaderRenderer(Class)`

    - #### getColumnHeaderRenderer

          public IColumnHeaderRenderer getColumnHeaderRenderer(Class cl)

      Returns a column header renderer for an object type. The lookup of the renderer is based on the object type of the given object.
      Parameters:
        `cl` - the type of the object in need of rendering
      Returns:
        a matching column header renderer implementation
      Since:
        1.0
      See Also:
        `setColumnHeaderRenderer(Class, IColumnHeaderRenderer)`, `DefaultColumnHeaderRenderer`

    - #### getMenuProvider

          public ITreeTableHeaderMenuProvider getMenuProvider()

      Returns the menu provider used by the tree table header to lookup a popup menu based on the location and context of the popup trigger event.
      Returns:
        the table header's menu provider
      Since:
        1.0

    - #### setMenuProvider

          public void setMenuProvider(ITreeTableHeaderMenuProvider provider)

      Sets the menu provider used by the tree table header to lookup a popup menu based on the location and context of the popup trigger event.
      Parameters:
        `provider` - the table header's menu provider
      Since:
        1.0

    - #### getRendererMap

          public Map<Class,IColumnHeaderRenderer> getRendererMap()

      Returns the map that stores the mappings between column header values and column header renderers.
      Returns:
        the renderer map
      Since:
        1.0

    - #### setRendererMap

          public void setRendererMap(Map<Class,IColumnHeaderRenderer> map)

      Sets the map that stores the mappings between column header values and column header renderers.
      Parameters:
        `map` - the renderer map
      Since:
        1.0

    - #### isDoubleClickResizeEnabled

          public boolean isDoubleClickResizeEnabled()

      Determines whether the user can auto resize a column by double clicking on its right edge.
      Returns:
        TRUE if the double-click auto-resize feature is enabled
      Since:
        1.0

    - #### setDoubleClickResizeEnabled

          public void setDoubleClickResizeEnabled(boolean enabled)

      Specifies whether the user can auto resize a column by double clicking on its right edge.
      Parameters:
        `enabled` - if TRUE the double-click auto-resize feature is enabled
      Since:
        1.0

    - #### sorting

          public void sorting(SortingEvent evt)

      Description copied from interface: `ISortingListener`
      Callback method that gets invoked when a sort starts or finishes.
      Specified by:
        `sorting` in interface `ISortingListener`
      Parameters:
        `evt` - an event object with details about the sorting operation

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.