com.dlsc.flexgantt.swing.treetable
Class TreeTableHeader

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.dlsc.flexgantt.swing.GanttChartControl
                      extended by com.dlsc.flexgantt.swing.treetable.TreeTableHeader
All Implemented Interfaces:
IColumnModelListener, ISortingListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class TreeTableHeader
extends GanttChartControl
implements java.beans.PropertyChangeListener, java.awt.event.MouseListener, java.awt.event.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
Author:
Dirk Lemmermann
See Also:
DefaultColumnModel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
TreeTableHeader(AbstractGanttChart gc)
          Constructs a new column header.
 
Method Summary
 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.
 java.awt.Rectangle getColumnBounds(int index)
          Returns the bounds of the column at the given index.
 java.awt.Rectangle getColumnBounds(TreeTableColumn c)
          Returns the bounds of the given column.
 IColumnHeaderRenderer getColumnHeaderRenderer(java.lang.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.
 java.awt.Color getGridColor()
          Returns the color used by the table header to draw its grid lines.
 int getHeaderHeight()
          Returns the header height.
 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.
 java.awt.Dimension getPreferredSize()
           
 java.util.Map<java.lang.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 isShowingFillerColumn()
          Returns TRUE if the tree table places an unused filler column to the right of the last used column.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void paintColumnHeader(java.awt.Graphics g, TreeTableColumn column, int x, int y, int width, int height)
          Paints the column header for the given column.
protected  void paintColumnHeaders(java.awt.Graphics g)
          Paints all column headers.
protected  void paintComponent(java.awt.Graphics g)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void setColumnHeaderRenderer(java.lang.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 setGridColor(java.awt.Color color)
          Sets the color used by the table header to draw its grid lines.
 void setHeaderHeight(int h)
          Sets the header height.
 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(java.util.Map<java.lang.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, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, 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, 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, hide, 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, 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(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

paintColumnHeaders

protected void paintColumnHeaders(java.awt.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(java.awt.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 java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.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

setHeaderHeight

public void setHeaderHeight(int h)
Sets the header height.

Parameters:
h - the new height of the header
Since:
1.0

getHeaderHeight

public int getHeaderHeight()
Returns the header height.

Returns:
the height of the header in pixel
Since:
1.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(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.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(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.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 java.awt.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 java.awt.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 java.awt.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(java.awt.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(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class GanttChartControl

setColumnHeaderRenderer

public void setColumnHeaderRenderer(java.lang.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(java.lang.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 java.util.Map<java.lang.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(java.util.Map<java.lang.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