jdbreport.grid
Class RowHeader

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by jdbreport.grid.RowHeader
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, TableRowModelListener

public class RowHeader
extends JComponent
implements TableRowModelListener, Accessible

Version:
1.1 03/09/08
Author:
Andrey Kholmanskih
See Also:
Serialized Form

Nested Class Summary
protected  class RowHeader.AccessibleRowHeader
          This class implements accessibility support for the RowHeader class.
 
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
protected  int draggedDistance
          The distance from its original position the row has been dragged.
protected  TableRow draggedRow
          The index of the row being dragged.
static int LEVEL_WIDTH
           
protected  TableRow resizingRow
          The index of the row being resized.
protected  TableRowModel rowModel
           
protected  JReportGrid table
           
 
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
RowHeader(JReportGrid table)
          Constructs a RowHeader which is initialized with cm as the row model.
 
Method Summary
protected  TableCellRenderer createDefaultRenderer()
          Returns a default renderer to be used when no header renderer is defined by a TableRow.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this RowHeader.
 TableCellRenderer getDefaultRenderer()
          Returns the default renderer used when no headerRenderer is defined by a TableRow.
 int getDraggedDistance()
          Returns the row's vertical distance from its original position, if and only if, a drag is in process.
 TableRow getDraggedRow()
          Returns the the dragged row, if and only if, a drag is in process, otherwise returns null.
 Rectangle getHeaderRect(int row)
          Returns the rectangle containing the header tile at row.
 ImageIcon getHideGroupImage()
           
 boolean getReorderingAllowed()
          Returns true if the user is allowed to rearrange rows by dragging their headers, false otherwise.
 boolean getResizingAllowed()
          Returns true if the user is allowed to resize rows by dragging between their headers, false otherwise.
 TableRow getResizingRow()
          Returns the resizing row.
 TableRowModel getRowModel()
          Returns the TableRowModel that contains all row information of this table RowHeader.
 ImageIcon getShowGroupImage()
           
 JTable getTable()
          Returns the table associated with this header.
 String getToolTipText(MouseEvent event)
          Allows the renderer's tips to be used if there is text set.
 TableRowHeaderUI getUI()
          Returns the look and feel (L&F) object that renders this component.
 String getUIClassID()
          Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component.
 int getWidth()
           
protected  void initializeLocalVars()
          Initializes the local variables and properties with default values.
protected  String paramString()
          Returns a string representation of this RowHeader.
 void resizeAndRepaint()
          Sizes the header and marks it as needing display.
 void rowAdded(TableRowModelEvent e)
          Invoked when a row is added to the table row model.
 int rowAtPoint(Point point)
          Returns the index of the row that point lies in, or -1 if it lies out of bounds.
 void rowMarginChanged(ChangeEvent e)
          Invoked when a row is moved due to a margin change.
 void rowMoved(TableRowModelEvent e)
          Invoked when a row is repositioned.
 void rowRemoved(TableRowModelEvent e)
          Invoked when a row is removed from the table row model.
 void rowResized(TableRowModelEvent e)
          Invoked when a row is resized.
 void rowSelectionChanged(ListSelectionEvent e)
          Tells listeners that the selection model of the TableRowModel changed.
 void rowUpdated(TableRowModelEvent e)
          Tells listeners that a rows was change.
 void setDefaultRenderer(TableCellRenderer defaultRenderer)
          Sets the default renderer to be used when no headerRenderer is defined by a TableRow.
 void setDraggedDistance(int distance)
          Sets the header's draggedDistance to distance.
 void setDraggedRow(TableRow aRow)
          Sets the header's draggedRow to aRow.
 void setReorderingAllowed(boolean reorderingAllowed)
          Sets whether the user can drag row headers to reorder rows.
 void setResizingAllowed(boolean resizingAllowed)
          Sets whether the user can resize rows by dragging between headers.
 void setResizingRow(TableRow aRow)
          Sets the header's resizingRow to aRow.
 void setRowModel(TableRowModel rowModel)
          Sets the row model for this table to newModel and registers for listener notifications from the new row model.
 void setTable(JReportGrid table)
          Sets the table associated with this header.
 void setUI(TableRowHeaderUI ui)
          Sets the look and feel (L&F) object that renders this component.
 void setVisible(boolean flag)
           
 void updateUI()
          Notification from the UIManager that the look and feel (L&F) has changed.
 
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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEVEL_WIDTH

public static final int LEVEL_WIDTH
See Also:
Constant Field Values

table

protected JReportGrid table

rowModel

protected TableRowModel rowModel

resizingRow

protected transient TableRow resizingRow
The index of the row being resized. null if not resizing.


draggedRow

protected transient TableRow draggedRow
The index of the row being dragged. null if not dragging.


draggedDistance

protected transient int draggedDistance
The distance from its original position the row has been dragged.

Constructor Detail

RowHeader

public RowHeader(JReportGrid table)
Constructs a RowHeader which is initialized with cm as the row model. If cm is null this method will initialize the table header with a default RowModel.

Method Detail

getShowGroupImage

public ImageIcon getShowGroupImage()

getHideGroupImage

public ImageIcon getHideGroupImage()

setTable

public void setTable(JReportGrid table)
Sets the table associated with this header.

Parameters:
table - the new table

getTable

public JTable getTable()
Returns the table associated with this header.

Returns:
the table property

setReorderingAllowed

public void setReorderingAllowed(boolean reorderingAllowed)
Sets whether the user can drag row headers to reorder rows.

Parameters:
reorderingAllowed - true if the table view should allow reordering; otherwise false

getReorderingAllowed

public boolean getReorderingAllowed()
Returns true if the user is allowed to rearrange rows by dragging their headers, false otherwise. The default is true. You can rearrange rows programmatically regardless of this setting.

Returns:
the reorderingAllowed property
See Also:
setReorderingAllowed(boolean)

setResizingAllowed

public void setResizingAllowed(boolean resizingAllowed)
Sets whether the user can resize rows by dragging between headers.

Parameters:
resizingAllowed - true if table view should allow resizing

getResizingAllowed

public boolean getResizingAllowed()
Returns true if the user is allowed to resize rows by dragging between their headers, false otherwise. The default is true. You can resize rows programmatically regardless of this setting.

Returns:
the resizingAllowed property
See Also:
setResizingAllowed(boolean)

getDraggedRow

public TableRow getDraggedRow()
Returns the the dragged row, if and only if, a drag is in process, otherwise returns null.

Returns:
the dragged row, if a drag is in process, otherwise returns null
See Also:
getDraggedDistance()

getDraggedDistance

public int getDraggedDistance()
Returns the row's vertical distance from its original position, if and only if, a drag is in process. Otherwise, the the return value is meaningless.

Returns:
the row's vertical distance from its original position, if a drag is in process, otherwise the return value is meaningless
See Also:
getDraggedRow()

getResizingRow

public TableRow getResizingRow()
Returns the resizing row. If no row is being resized this method returns null.

Returns:
the resizing row, if a resize is in process, otherwise returns null

setDefaultRenderer

public void setDefaultRenderer(TableCellRenderer defaultRenderer)
Sets the default renderer to be used when no headerRenderer is defined by a TableRow.

Parameters:
defaultRenderer - the default renderer

getDefaultRenderer

public TableCellRenderer getDefaultRenderer()
Returns the default renderer used when no headerRenderer is defined by a TableRow.

Returns:
the default renderer

rowAtPoint

public int rowAtPoint(Point point)
Returns the index of the row that point lies in, or -1 if it lies out of bounds.

Returns:
the index of the row that point lies in, or -1 if it lies out of bounds

getWidth

public int getWidth()
Overrides:
getWidth in class JComponent

getHeaderRect

public Rectangle getHeaderRect(int row)
Returns the rectangle containing the header tile at row. When the row parameter is out of bounds this method uses the same conventions as the JTable method getCellRect.

Returns:
the rectangle containing the header tile at row

getToolTipText

public String getToolTipText(MouseEvent event)
Allows the renderer's tips to be used if there is text set.

Overrides:
getToolTipText in class JComponent
Parameters:
event - the location of the event identifies the proper renderer and, therefore, the proper tip
Returns:
the tool tip for this component

setVisible

public void setVisible(boolean flag)
Overrides:
setVisible in class JComponent

getUI

public TableRowHeaderUI getUI()
Returns the look and feel (L&F) object that renders this component.

Returns:
the TableRowHeaderUI object that renders this component

setUI

public void setUI(TableRowHeaderUI ui)
Sets the look and feel (L&F) object that renders this component.

Parameters:
ui - the TableHeaderUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

updateUI

public void updateUI()
Notification from the UIManager that the look and feel (L&F) has changed. Replaces the current UI object with the latest version from the UIManager.

Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component.

Overrides:
getUIClassID in class JComponent
Returns:
the string "TableRowHeaderUI"

setRowModel

public void setRowModel(TableRowModel rowModel)
Sets the row model for this table to newModel and registers for listener notifications from the new row model.

Parameters:
rowModel - the new data source for this table
Throws:
IllegalArgumentException - if newModel is null
See Also:
getRowModel()

getRowModel

public TableRowModel getRowModel()
Returns the TableRowModel that contains all row information of this table RowHeader.

Returns:
the rowModel property

rowAdded

public void rowAdded(TableRowModelEvent e)
Invoked when a row is added to the table row model.

Application code will not use these methods explicitly, they are used internally by JReportGrid.

Specified by:
rowAdded in interface TableRowModelListener
Parameters:
e - the event received
See Also:
TableRowModelListener

rowUpdated

public void rowUpdated(TableRowModelEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that a rows was change.

Specified by:
rowUpdated in interface TableRowModelListener

rowRemoved

public void rowRemoved(TableRowModelEvent e)
Invoked when a row is removed from the table row model.

Application code will not use these methods explicitly, they are used internally by JReportGrid.

Specified by:
rowRemoved in interface TableRowModelListener
Parameters:
e - the event received
See Also:
TableRowModelListener

rowMoved

public void rowMoved(TableRowModelEvent e)
Invoked when a row is repositioned.

Application code will not use these methods explicitly, they are used internally by JReportGrid.

Specified by:
rowMoved in interface TableRowModelListener
Parameters:
e - the event received
See Also:
TableRowModelListener

rowResized

public void rowResized(TableRowModelEvent e)
Invoked when a row is resized.

Application code will not use these methods explicitly, they are used internally by JReportGrid.

Specified by:
rowResized in interface TableRowModelListener
Parameters:
e - the event received
See Also:
TableRowModelListener

rowMarginChanged

public void rowMarginChanged(ChangeEvent e)
Invoked when a row is moved due to a margin change.

Application code will not use these methods explicitly, they are used internally by JReportGrid.

Specified by:
rowMarginChanged in interface TableRowModelListener
Parameters:
e - the event received
See Also:
TableRowModelListener

rowSelectionChanged

public void rowSelectionChanged(ListSelectionEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that the selection model of the TableRowModel changed.

Specified by:
rowSelectionChanged in interface TableRowModelListener

createDefaultRenderer

protected TableCellRenderer createDefaultRenderer()
Returns a default renderer to be used when no header renderer is defined by a TableRow.

Returns:
the default table cell renderer

initializeLocalVars

protected void initializeLocalVars()
Initializes the local variables and properties with default values. Used by the constructor methods.


resizeAndRepaint

public void resizeAndRepaint()
Sizes the header and marks it as needing display. Equivalent to revalidate followed by repaint.


setDraggedRow

public void setDraggedRow(TableRow aRow)
Sets the header's draggedRow to aRow.

Application code will not use this method explicitly, it is used internally by the row dragging mechanism.

Parameters:
aRow - the row being dragged, or null if no row is being dragged

setDraggedDistance

public void setDraggedDistance(int distance)
Sets the header's draggedDistance to distance.

Parameters:
distance - the distance dragged

setResizingRow

public void setResizingRow(TableRow aRow)
Sets the header's resizingRow to aRow.

Application code will not use this method explicitly, it is used internally by the row sizing mechanism.

Parameters:
aRow - the row being resized, or null if no row is being resized

paramString

protected String paramString()
Returns a string representation of this RowHeader. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overriding paramString to provide information about the specific new aspects of the JFC components.

Overrides:
paramString in class JComponent
Returns:
a string representation of this RowHeader

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this RowHeader. For RowHeaders, the AccessibleContext takes the form of an AccessibleRowHeader. A new AccessibleRowHeader instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleRowHeader that serves as the AccessibleContext of this RowHeader