Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.pivot
Class DefaultPivotRowHeaderRenderer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.CellRendererPane
              extended by com.citra.table.WrapperCellRendererPane
                  extended by com.citra.pivot.DefaultPivotRowHeaderRenderer
All Implemented Interfaces:
PivotRowHeaderRenderer, ImageObserver, MenuContainer, Serializable, Accessible

public class DefaultPivotRowHeaderRenderer
extends WrapperCellRendererPane
implements PivotRowHeaderRenderer

DefaultPivotRowHeaderRenderer is the default PivotRowHeaderRenderer implementation. It draws an icon on the left of the cell that indicates whether the row can be expanded or if it is collapsed. If it is a leaf row (no children), then no icon is drawn. The row is expanded/collapsed upon MOUSE_PRESSED events, which is handled in the implemented method handleEvent.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.CellRendererPane
CellRendererPane.AccessibleCellRendererPane
 
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  Icon collapsedIcon
          the collapsed icon
protected  Icon expandedIcon
          the expanded icon
protected  Icon waitIcon
          the wait icon
 
Fields inherited from class com.citra.table.WrapperCellRendererPane
opaqueFalse
 
Fields inherited from class javax.swing.CellRendererPane
accessibleContext
 
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
DefaultPivotRowHeaderRenderer()
          Constructs a DefaultPivotRowHeaderRenderer.
 
Method Summary
protected  Icon createCollapsedIcon()
          Creates and returns an icon that represents the collapsed state of a 'non-leaf' node.
protected  Icon createExpandedIcon()
          Creates and returns an icon that represents the expanded state of a 'non-leaf' node.
protected  void createIcons()
          Creates icons to be used by the renderer.
protected  Icon createWaitIcon()
          Creates and returns an icon that represents a loading state of an expanding node.
 Rectangle getEditableBounds()
          Returns the bounds of the editable component that is drawn.
protected  Icon getIcon(boolean isExpanded, boolean isLeaf, PivotRowAdapter adapter, TreePath path)
          Retrieves the icon to be used at a given node.
 Component getTreeTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean isLeaf, boolean isExpanded, PivotRowAdapter adapter, TreePath path, TableCellRenderer cellRenderer)
          Returns the component used for drawing the expandable row.
 boolean handleEvent(MouseEvent e, PivotTable table)
          This method is called whenever a mouse event such as MOUSE_PRESSED is captured on a cell of the pivot table's row header.
 boolean swapExpandedState(MouseEvent e, PivotTable table)
          Changes the expanded state of a non-leaf column, according to a mouse event on the header.
 
Methods inherited from class com.citra.table.WrapperCellRendererPane
getMainComponent, getMainComponent, getToolTipText, paint, paintComponent
 
Methods inherited from class javax.swing.CellRendererPane
addImpl, getAccessibleContext, invalidate, paintComponent, paintComponent, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, 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

expandedIcon

protected Icon expandedIcon
the expanded icon


collapsedIcon

protected Icon collapsedIcon
the collapsed icon


waitIcon

protected Icon waitIcon
the wait icon

Constructor Detail

DefaultPivotRowHeaderRenderer

public DefaultPivotRowHeaderRenderer()
Constructs a DefaultPivotRowHeaderRenderer.

Method Detail

createWaitIcon

protected Icon createWaitIcon()
Creates and returns an icon that represents a loading state of an expanding node.

Returns:
the wait icon

createCollapsedIcon

protected Icon createCollapsedIcon()
Creates and returns an icon that represents the collapsed state of a 'non-leaf' node.

Returns:
the collapsed icon

createExpandedIcon

protected Icon createExpandedIcon()
Creates and returns an icon that represents the expanded state of a 'non-leaf' node.

Returns:
the expanded icon

createIcons

protected void createIcons()
Creates icons to be used by the renderer.


getEditableBounds

public Rectangle getEditableBounds()
Returns the bounds of the editable component that is drawn.

Specified by:
getEditableBounds in interface PivotRowHeaderRenderer
Returns:
the editable component's bounds

getTreeTableCellRendererComponent

public Component getTreeTableCellRendererComponent(JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column,
                                                   boolean isLeaf,
                                                   boolean isExpanded,
                                                   PivotRowAdapter adapter,
                                                   TreePath path,
                                                   TableCellRenderer cellRenderer)
Returns the component used for drawing the expandable row. This method is used to configure the renderer appropriately before drawing.

Specified by:
getTreeTableCellRendererComponent in interface PivotRowHeaderRenderer
Parameters:
table - the table that is asking the renderer to draw
value - the value of the cell to be rendered
isSelected - true if the cell is to be rendered with the selection highlighted, false otherwise
hasFocus - if true, render cell appropriately. For example, put a special border on the cell, if the cell can be edited, render in the color used to indicate editing
row - the row index of the cell being drawn
column - the column index of the cell being drawn
isLeaf - true if the cell has children, false otherwise
isExpanded - true if the cell is expanded, false otherwise
adapter - the adapter that was found at the specified cell
path - the corresponding path in the adapter
cellRenderer - the renderer of the cell being drawn
Returns:
the component used for drawing the expandable row

handleEvent

public boolean handleEvent(MouseEvent e,
                           PivotTable table)
This method is called whenever a mouse event such as MOUSE_PRESSED is captured on a cell of the pivot table's row header. The renderer should act on the event, such as expand/collapse a node or display a tooltip. It returns a boolean depending on whether the event should be consumed. A consumed event is not propagated to any mouse listeners added on the table, therefore the return value is crucial to an application's functionality.

Specified by:
handleEvent in interface PivotRowHeaderRenderer
Parameters:
e - the mouse event triggering the method call
table - the pivot table which is the source of the event
Returns:
true if the event should be consumed, false otherwise

swapExpandedState

public boolean swapExpandedState(MouseEvent e,
                                 PivotTable table)
Changes the expanded state of a non-leaf column, according to a mouse event on the header.

Parameters:
e - the mouse event responsible for the state change
Returns:
true if the mouse event was inside the borders of the expansion control, false otherwise

getIcon

protected Icon getIcon(boolean isExpanded,
                       boolean isLeaf,
                       PivotRowAdapter adapter,
                       TreePath path)
Retrieves the icon to be used at a given node.

Parameters:
isExpanded - whether the node is expanded
isLeaf - whether the node is a leaf
adapter - the adapter to which the node belongs
path - the node's path
Returns:
the node's icon

Copyright © 2011 Citra Technologies. All Rights Reserved.