Copyright © 2005 Scientific Applications. All Rights Reserved.

com.sciapp.renderers
Class DefaultAggregateRenderer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by javax.swing.table.DefaultTableCellRenderer
                      extended by com.sciapp.renderers.DefaultRenderer
                          extended by com.sciapp.renderers.DefaultAggregateRenderer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, TableCellRenderer

public class DefaultAggregateRenderer
extends DefaultRenderer

DefaultAggregateRenderer is the default renderer for the aggregate rows of a TreeTable. This class wraps around a DefaultRenderer object passed as an argument in the constructor, by having the getTableCellRendererComponent method return this renderer.

This class affects only FooterRow objects. In fact, if a cell is part of a footer row, it's text is changed to BOLD and its background and foreground color are set by calling the getLevelBackGround and getLevelForeground method respectively.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.table.DefaultTableCellRenderer
DefaultTableCellRenderer.UIResource
 
Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Color defaultLevelBackground
          the default background color for aggregate rows
protected  Color defaultLevelForeground
          the default foreground color for aggregate rows
protected  DefaultRenderer defaultRenderer
          the renderer contained in this DefaultAggregateRenderer
 
Fields inherited from class com.sciapp.renderers.DefaultRenderer
evenColor, oddColor, space, spacing
 
Fields inherited from class javax.swing.table.DefaultTableCellRenderer
noFocusBorder
 
Fields inherited from class javax.swing.JLabel
labelFor
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DefaultAggregateRenderer(DefaultRenderer defaultRenderer)
          Constructs a DefaultAggregateRenderer.
 
Method Summary
 Color getDefaultLevelBackground()
          Return the default background color for aggregate rows
 Color getDefaultLevelForeground()
          Return the default foreground color for aggregate rows
 DefaultRenderer getDefaultRenderer()
          Return the renderer this DefaultAggregateRenderer instance is associated with.
 Color getLevelBackGround(int groupLevel, int row, int column)
          Returns a color to be set as the background color of the cell at (row, column), depending on the level of the TreeTableRow.
 Color getLevelForeground(int groupLevel, int row, int column)
          Returns a color to be set as the foreground color of the cell at (row, column), depending on the level of the TreeTableRow.
 Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
          Returns the component used for drawing the cell.
 void setDefaultLevelBackground(Color newDefaultLevelBackground)
          Sets the default background color for aggregate rows.
 void setDefaultLevelForeground(Color newDefaultLevelForeground)
          Sets the default foreground color for aggregate rows.
 void setDefaultRenderer(DefaultRenderer newDefaultRenderer)
          Sets a new DefaultRenderer object.
 void setEvenColor(Color evenColor)
          Sets the color for painting the even rows of the table.
 void setOddColor(Color oddColor)
          Sets the color for painting the odd rows of the table.
 void setSpaces(int numSpaces)
          Sets the number of spaces to add at the end of each cell.
 void setSpacing(boolean spacing)
          Tells the renderer whether to add spaces at the end of each cell.
 
Methods inherited from class com.sciapp.renderers.DefaultRenderer
getEvenColor, getOddColor, getSpacing, setText
 
Methods inherited from class javax.swing.table.DefaultTableCellRenderer
firePropertyChange, firePropertyChange, isOpaque, repaint, repaint, revalidate, setBackground, setForeground, setValue, updateUI, validate
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Field Detail

defaultRenderer

protected DefaultRenderer defaultRenderer
the renderer contained in this DefaultAggregateRenderer


defaultLevelBackground

protected Color defaultLevelBackground
the default background color for aggregate rows


defaultLevelForeground

protected Color defaultLevelForeground
the default foreground color for aggregate rows

Constructor Detail

DefaultAggregateRenderer

public DefaultAggregateRenderer(DefaultRenderer defaultRenderer)
Constructs a DefaultAggregateRenderer.

Method Detail

getDefaultLevelBackground

public Color getDefaultLevelBackground()
Return the default background color for aggregate rows

Returns:
a color

getDefaultLevelForeground

public Color getDefaultLevelForeground()
Return the default foreground color for aggregate rows

Returns:
a color

getDefaultRenderer

public DefaultRenderer getDefaultRenderer()
Return the renderer this DefaultAggregateRenderer instance is associated with.

Returns:
the underlying DefaultRenderer instance

getLevelBackGround

public Color getLevelBackGround(int groupLevel,
                                int row,
                                int column)
Returns a color to be set as the background color of the cell at (row, column), depending on the level of the TreeTableRow.

By default, this method calls getDefaultLevelBackground(). Override it to implement a different behaviour.

Parameters:
groupLevel - the level of the TreeTableRow
row - the current row
column - the current column
Returns:
a color

getLevelForeground

public Color getLevelForeground(int groupLevel,
                                int row,
                                int column)
Returns a color to be set as the foreground color of the cell at (row, column), depending on the level of the TreeTableRow.

By default, this method calls getDefaultLevelForeground(). Override it to implement a different behaviour.

Parameters:
groupLevel - the level of the TreeTableRow
row - the current row
column - the current column
Returns:
a color

getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
Returns the component used for drawing the cell. This method is used to configure the renderer appropriately before drawing.

Specified by:
getTableCellRendererComponent in interface TableCellRenderer
Overrides:
getTableCellRendererComponent in class DefaultRenderer
Parameters:
table - the JTable
value - the value to assign to the cell at [row, column]
isSelected - true if cell is selected
hasFocus - true if cell has focus
row - the row of the cell to render
column - the column of the cell to render
Returns:
the component used for drawing the cell

setDefaultLevelBackground

public void setDefaultLevelBackground(Color newDefaultLevelBackground)
Sets the default background color for aggregate rows.

Parameters:
newDefaultLevelBackground - the new background color

setDefaultLevelForeground

public void setDefaultLevelForeground(Color newDefaultLevelForeground)
Sets the default foreground color for aggregate rows.

Parameters:
newDefaultLevelForeground - the new foreground color

setDefaultRenderer

public void setDefaultRenderer(DefaultRenderer newDefaultRenderer)
Sets a new DefaultRenderer object.

Parameters:
newDefaultRenderer - the renderer to set

setEvenColor

public void setEvenColor(Color evenColor)
Sets the color for painting the even rows of the table.

Overrides:
setEvenColor in class DefaultRenderer
Parameters:
evenColor - the even row color

setOddColor

public void setOddColor(Color oddColor)
Sets the color for painting the odd rows of the table.

Overrides:
setOddColor in class DefaultRenderer
Parameters:
oddColor - the odd row color

setSpaces

public void setSpaces(int numSpaces)
Sets the number of spaces to add at the end of each cell.

Overrides:
setSpaces in class DefaultRenderer
Parameters:
numSpaces - the number of spaces.

setSpacing

public void setSpacing(boolean spacing)
Tells the renderer whether to add spaces at the end of each cell.

Overrides:
setSpacing in class DefaultRenderer
Parameters:
spacing - true if spacing is used

Copyright © 2005 Scientific Applications. All Rights Reserved.