com.dlsc.flexgantt.swing.layer.system
Class DefaultRowRenderer

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.layer.system.DefaultRowRenderer
All Implemented Interfaces:
IRowRenderer, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
DefaultResourceRowRenderer

public class DefaultRowRenderer
extends javax.swing.JPanel
implements IRowRenderer

The default row renderer implementation. This renderer is capable of visualizing the row focus and selection state. It also renders grid lines for inner lines.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
RowLayer.setRowRenderer(Class, IRowRenderer), ILinePolicy, setFocusVisible(boolean), setShowingSelection(boolean), setPaintingLines(boolean), 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
protected  IGanttChartModel model
          The model that returned the node for which the row renderer gets invoked.
protected  java.lang.Object node
          The node for which the row renderer gets invoked.
 
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
DefaultRowRenderer()
          Constructs a new row renderer instance.
 
Method Summary
 void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
          Overriden for performance reasons.
 void firePropertyChange(java.lang.String propertyName, byte oldValue, byte newValue)
          Overriden for performance reasons.
 void firePropertyChange(java.lang.String propertyName, char oldValue, char newValue)
          Overriden for performance reasons.
 void firePropertyChange(java.lang.String propertyName, double oldValue, double newValue)
          Overriden for performance reasons.
 void firePropertyChange(java.lang.String propertyName, float oldValue, float newValue)
          Overriden for performance reasons.
 void firePropertyChange(java.lang.String propertyName, long oldValue, long newValue)
          Overriden for performance reasons.
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Overriden for performance reasons.
 void firePropertyChange(java.lang.String propertyName, short oldValue, short newValue)
          Overriden for performance reasons.
 java.awt.Color getFocusBackground()
          Returns the color used for the background when the row is the focus owner.
 java.awt.Color getFocusForeground()
          Returns the color used for the foreground when the row is the focus owner.
 java.awt.Color getLineColor()
          Returns the color used for drawing inner lines.
protected  java.awt.Color getLineColor(int lineIndex)
          Returns the line color for the given line index.
protected  IGanttChartModel getModel()
          Returns the Gantt chart model of which the node in need of rendering is a member.
protected  java.lang.Object getNode()
          Returns the tree node shown in the row that gets currently drawn.
protected  int getRow()
          Returns the row number of the currently drawn row.
protected  RowLayer getRowLayer()
          Returns the row layer in which the drawing takes place.
 java.awt.Component getRowRendererComponent(RowLayer layer, java.lang.Object node, boolean selected, int row, ITimeSpan span, boolean hasFocus)
          Returns a component that will be used for renderering additional information about a row (for example resource capacity lines).
protected  ITimeSpan getTimeSpan()
          Returns the time span that is currently being drawn by the renderer.
 boolean hasFocus()
           
 void invalidate()
          Overriden for performance reasons.
 boolean isDebug()
          Determines whether the visual debugging feature is turned on for the row renderer.
 boolean isFocusVisible()
          Determines if the row renderer will visualize that the row is the current focus owner.
 boolean isPaintingLines()
          Determines whether the renderer also draws lines for each inner line shown inside the row.
protected  boolean isSelected()
          Determines whether the current row is considered 'selected' or not.
 boolean isShowingSelection()
          Determines if the row renderer will show the selection state of the row.
protected  void paintComponent(java.awt.Graphics g)
           
protected  void paintLines(java.awt.Graphics g)
          Draws the inner lines of the row.
 void repaint()
          Overriden for performance reasons.
 void repaint(int x, int y, int width, int height)
          Overriden for performance reasons.
 void repaint(long tm)
          Overriden for performance reasons.
 void revalidate()
          Overriden for performance reasons.
 void setDebug(boolean debug)
          Specifies whether the visual debugging feature is turned on for the row renderer.
 void setFocusBackground(java.awt.Color color)
          Sets the color used for the background when the row is the focus owner.
 void setFocusForeground(java.awt.Color color)
          Sets the color used for the foreground when the row is the focus owner.
 void setFocusVisible(boolean visible)
          Specifies whether the row renderer will visualize that the row is the current focus owner.
 void setLineColor(java.awt.Color lineColor)
          Sets the color used for drawing inner lines.
 void setPaintingLines(boolean paint)
          Specifies whether the renderer also draws lines for each inner line shown inside the row.
 void setShowingSelection(boolean show)
          Specifies whether the row renderer will show the selection state of the row.
 void validate()
          Overriden for performance reasons.
 
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, 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, getPreferredSize, 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, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, 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, 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, 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, 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, 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, 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
 

Field Detail

model

protected IGanttChartModel model
The model that returned the node for which the row renderer gets invoked.

Since:
1.0

node

protected java.lang.Object node
The node for which the row renderer gets invoked.

Since:
1.0
Constructor Detail

DefaultRowRenderer

public DefaultRowRenderer()
Constructs a new row renderer instance.

Since:
1.0
Method Detail

getRowRendererComponent

public java.awt.Component getRowRendererComponent(RowLayer layer,
                                                  java.lang.Object node,
                                                  boolean selected,
                                                  int row,
                                                  ITimeSpan span,
                                                  boolean hasFocus)
Description copied from interface: IRowRenderer
Returns a component that will be used for renderering additional information about a row (for example resource capacity lines). The component's width will be equal to the width of the layer container, which can be rather large (up to Integer.MAX_VALUE). The rendering routine needs to use the clipping information for its paint operations to guarantee high performance.

Specified by:
getRowRendererComponent in interface IRowRenderer
Parameters:
layer - the layer component that will lookup the renderer and call its paint method
node - the tree table / Gantt chart node for the given row
selected - a flag indicating whether the row is currently selected on the left-hand side. Usually selections are only visualized in the tree table but row renderers are free to choose whether they would also like to visualize it
row - the row for which a renderer component gets requested
span - the time span that needs to be painted. This span is not equivalent to the entire span of the Gantt chart. It is the time span that covers the clip that needs to be painted.
hasFocus - a flag indicating whether the row currently has the focus (the mouse cursor hovers on top of it)
Returns:
a component that will be used for rendering additional row information

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

paintLines

protected void paintLines(java.awt.Graphics g)
Draws the inner lines of the row.

Parameters:
g - the graphics context into which to draw
Since:
1.0
See Also:
ILinePolicy

isPaintingLines

public boolean isPaintingLines()
Determines whether the renderer also draws lines for each inner line shown inside the row.

Returns:
TRUE if the renderer draws lines for each inner line
Since:
1.0

setPaintingLines

public void setPaintingLines(boolean paint)
Specifies whether the renderer also draws lines for each inner line shown inside the row.

Parameters:
paint - if TRUE the renderer will draw a line for each inner line
Since:
1.0

getLineColor

protected java.awt.Color getLineColor(int lineIndex)
Returns the line color for the given line index. The default implementation always returns Color.GRAY. This default color can be changed by calling setLineColor(Color).

Parameters:
lineIndex - the line index for which to return a color
Returns:
a color that will be used for drawing the given line
Since:
1.0

getLineColor

public java.awt.Color getLineColor()
Returns the color used for drawing inner lines. The actual color used will be determined by a call to getLineColor(int). Subclasses can override either method to customize the line color.

Returns:
the lineColor
Since:
1.0
See Also:
ILinePolicy

setLineColor

public void setLineColor(java.awt.Color lineColor)
Sets the color used for drawing inner lines. The actual color used will be determined by a call to getLineColor(int). Subclasses can override either method to customize the line color.

Parameters:
lineColor - the lineColor to set
Since:
1.0

getModel

protected IGanttChartModel getModel()
Returns the Gantt chart model of which the node in need of rendering is a member.

Returns:
the Gantt chart model
Since:
1.0

getNode

protected java.lang.Object getNode()
Returns the tree node shown in the row that gets currently drawn.

Returns:
the node shown in the row that gets rendered
Since:
1.0

getRowLayer

protected RowLayer getRowLayer()
Returns the row layer in which the drawing takes place.

Returns:
the row layer in which the renderer will be drawn
Since:
1.0

hasFocus

public boolean hasFocus()
Overrides:
hasFocus in class java.awt.Component

getRow

protected int getRow()
Returns the row number of the currently drawn row.

Returns:
the row number
Since:
1.0

isSelected

protected boolean isSelected()
Determines whether the current row is considered 'selected' or not.

Returns:
TRUE if the row is currrently selected
Since:
1.0

getTimeSpan

protected ITimeSpan getTimeSpan()
Returns the time span that is currently being drawn by the renderer.

Returns:
the time span that needs rendering
Since:
1.0

getFocusBackground

public java.awt.Color getFocusBackground()
Returns the color used for the background when the row is the focus owner.

Returns:
the focus background
Since:
1.0

setFocusBackground

public void setFocusBackground(java.awt.Color color)
Sets the color used for the background when the row is the focus owner.

Parameters:
color - the focus background color to set
Since:
1.0

getFocusForeground

public java.awt.Color getFocusForeground()
Returns the color used for the foreground when the row is the focus owner.

Returns:
the focus foreground
Since:
1.0

setFocusForeground

public void setFocusForeground(java.awt.Color color)
Sets the color used for the foreground when the row is the focus owner.

Parameters:
color - the focus foreground color to set
Since:
1.0

isFocusVisible

public boolean isFocusVisible()
Determines if the row renderer will visualize that the row is the current focus owner. Visualization is done by filling the background with the focus color.

Returns:
TRUE if the focus will be shown by the renderer
Since:
1.0
See Also:
setFocusForeground(Color), setFocusBackground(Color)

setFocusVisible

public void setFocusVisible(boolean visible)
Specifies whether the row renderer will visualize that the row is the current focus owner. Visualization is done by filling the background with the focus color.

Parameters:
visible - if TRUE the renderer will show the focus
Since:
1.0
See Also:
setFocusForeground(Color), setFocusBackground(Color)

isShowingSelection

public boolean isShowingSelection()
Determines if the row renderer will show the selection state of the row. The default implemenation does not show the selection. If enabled the renderer will lookup its background color from the tree table.

Returns:
TRUE if the renderer visualizes the selection state
Since:
1.0

setShowingSelection

public void setShowingSelection(boolean show)
Specifies whether the row renderer will show the selection state of the row. The default implemenation does not show the selection. If enabled the renderer will lookup its background color from the tree table.

Parameters:
show - if TRUE the renderer will fill its background with the selection color from the tree table
Since:
1.0

isDebug

public boolean isDebug()
Determines whether the visual debugging feature is turned on for the row renderer. The default implementation of the row renderer will draw markers showing the location and height of inner lines.

Returns:
TRUE if debugging is turned on
Since:
1.0

setDebug

public void setDebug(boolean debug)
Specifies whether the visual debugging feature is turned on for the row renderer. The default implementation of the row renderer will draw markers showing the location and height of inner lines.

Parameters:
debug - if TRUE the debugging feature will be turned on
Since:
1.0

validate

public void validate()
Overriden for performance reasons.

Overrides:
validate in class java.awt.Container
Since:
1.0

invalidate

public void invalidate()
Overriden for performance reasons.

Overrides:
invalidate in class java.awt.Container
Since:
1.0

revalidate

public void revalidate()
Overriden for performance reasons.

Overrides:
revalidate in class javax.swing.JComponent
Since:
1.0

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               boolean oldValue,
                               boolean newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class javax.swing.JComponent
Since:
1.0

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               byte oldValue,
                               byte newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class java.awt.Component
Since:
1.0

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               char oldValue,
                               char newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class javax.swing.JComponent
Since:
1.0

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               double oldValue,
                               double newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class java.awt.Component
Since:
1.0

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               float oldValue,
                               float newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class java.awt.Component
Since:
1.0

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               long oldValue,
                               long newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class java.awt.Component
Since:
1.0

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class java.awt.Component
Since:
1.0

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               short oldValue,
                               short newValue)
Overriden for performance reasons.

Overrides:
firePropertyChange in class java.awt.Component
Since:
1.0

repaint

public void repaint()
Overriden for performance reasons.

Overrides:
repaint in class java.awt.Component
Since:
1.0

repaint

public void repaint(int x,
                    int y,
                    int width,
                    int height)
Overriden for performance reasons.

Overrides:
repaint in class java.awt.Component
Since:
1.0

repaint

public void repaint(long tm)
Overriden for performance reasons.

Overrides:
repaint in class java.awt.Component
Since:
1.0