Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.pivot
Class PivotTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by com.citra.table.AdvancedJTable
                      extended by com.citra.pivot.PivotTable
All Implemented Interfaces:
VetoableTableColumnModelListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
OlapPivotTable

public class PivotTable
extends AdvancedJTable

PivotTable is a JTable subclass able to display data pivoted in two edges, row and column. The pivot table's model is a PivotTableModel.


Nested Class Summary
 class PivotTable.PivotDataStyleModel
          PivotDataStyleModel is the PivotTable's style model.
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable
 
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
static String COLUMN_HEADER_SEPARATOR
          constant indicating a column used as a separator for the column header
static String COLUMN_NAMES_SEPARATOR
          constant indicating a column used as a separator for the column header hierarchy names
protected  boolean pivotRowHeader
          whether to render the row header in pivot style
protected  PivotStyleModel pivotStyleModel
          the pivot style model
static String ROW_COLUMN_SEPARATOR
          constant indicating a column used as a separator between the row and column header
static String ROW_HEADER_SEPARATOR
          constant indicating a column used as a separator for the row header
protected  PivotRowHeaderRenderer rowHeaderRenderer
          the renderer for the pivot table's row header cells
protected  boolean showColumnHierarchyNames
          whether to show the column hierarchy names
protected  boolean showRowHierarchyNames
          whether to show the row hierarchy names
 
Fields inherited from class com.citra.table.AdvancedJTable
cellResizer, COMMIT_EDIT, CONTINUE_EDIT, DISCARD_EDIT, editMode, isFirstColumnFixed, nonContiguousCellSelection, nonContiguousSelectionModel, rowHeader, scroller, showRowHeader, spanDrawer, styleModel, tableAssistant, tableReorder, viewableResizer
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
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
PivotTable()
          Constructs a PivotTable.
PivotTable(PivotDataModel dataModel)
          Constructs a PivotTable.
PivotTable(PivotTableModel model)
          Constructs a PivotTable having model as its model.
 
Method Summary
protected  PivotRowHeaderRenderer createDefaultPivotRowRenderer()
          Returns a default renderer for displaying the rows of the pivot table's row header.
protected  PivotStyleModel createDefaultPivotStyleModel()
          Creates and returns a PivotStyleModel.
protected  StyleModel createDefaultStyleModel()
          Overrides the method in order to create a new instance of PivotTable.PivotDataStyleModel.
 boolean getFixedGrandTotals()
          Determines whether row and column grand totals are always showing in the table.
 boolean getPivotRowHeader()
          Determines whether to render the row header in pivot style.
 PivotStyleModel getPivotStyleModel()
          Returns the currently assigned pivot style model.
 PivotTableHeader getPivotTableHeader()
          Convenience method to return the pivot table's accompanying pivot table header.
 PivotTableModel getPivotTableModel()
          Convenience method to return the pivot table's data model, casted to PivotTableModel.
 PivotRowHeaderRenderer getPivotTableRenderer()
          Returns the renderer for displaying the rows of the pivot table's row header.
 boolean getShowColumnHierarchyNames()
          Determines whether the hierarchy names shown on the column header will be displayed.
 boolean getShowRowHierarchyNames()
          Determines whether the hierarchy names shown on the row header will be displayed.
 void setFixedGrandTotals(boolean fixed)
          Determines whether row and column grand totals are always showing in the table.
 void setPivotRowHeader(boolean pivotRowHeader)
          Determines whether to render the row header in pivot style.
 void setPivotRowRenderer(PivotRowHeaderRenderer rowHeaderRenderer)
          Assigns the renderer for displaying the rows of the pivot table's row header.
 void setPivotStyleModel(PivotStyleModel pivotStyleModel)
          Assigns the pivot style model.
 void setShowColumnHierarchyNames(boolean showColumn)
          Determines whether the hierarchy names shown on the column header will be displayed.
 void setShowRowHierarchyNames(boolean showRow)
          Determines whether the hierarchy names shown on the row header will be displayed.
protected  boolean shouldToggleExpand(int row, int column, EventObject e, boolean editingStarted)
          This method determines the situation under which a pivot table's node is expanded/collapsed.
 
Methods inherited from class com.citra.table.AdvancedJTable
changeSelection, columnSelectionChanged, columnWillBeAdded, columnWillBeMoved, columnWillBeRemoved, configureEnclosingScrollPane, createDefaultCellResizer, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultEditors, createDefaultNonContiguousSelectionModel, createDefaultRenderers, createDefaultRowHeader, createDefaultTableAssistant, createDefaultTableHeader, createReorder, createSpanDrawer, doEdit, doEdit, doProcessMouseEvent, doProcessMouseMotionEvent, editCellAt, editingStopped, getCellResizer, getColumnClass, getColumnName, getEditingRow, getEditMode, getNonContiguousCellSelection, getNonContiguousSelectionModel, getRealEditingRow, getRowHeader, getScrollPane, getShowDummyColumn, getShowRowHeader, getSpanDrawer, getStyleModel, getTableAssistant, getTableReorder, getTableState, getToolTipLocation, getToolTipText, getValueAt, getViewableResizer, handleEvent, initializeLocalVars, isCellEditable, isCellSelected, isDummyColumn, isDummyColumn, isFirstColumnFixed, prepareEditor, prepareRenderer, processMouseEvent, processMouseMotionEvent, removeEditor, scrollRectToVisible, selectAll, setAutoResizeMode, setCellResizer, setColumnModel, setEditMode, setEvenColor, setFirstColumnFixed, setModel, setNonContiguousCellSelection, setNonContiguousSelectionModel, setOddColor, setRowHeader, setShowDummyColumn, setShowRowHeader, setSpanDrawer, setStyleModel, setTableAssistant, setTableHeader, setTableReorder, setTableState, sizeColumnsToFit, tableChanged, updateUI, valueChanged
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, convertColumnIndexToModel, convertColumnIndexToView, createDefaultDataModel, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editingCanceled, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnCount, getColumnModel, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, setAutoCreateColumnsFromModel, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setUI, setValueAt, sizeColumnsToFit, unconfigureEnclosingScrollPane
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, 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, 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, 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, imageUpdate, 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, 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

ROW_HEADER_SEPARATOR

public static final String ROW_HEADER_SEPARATOR
constant indicating a column used as a separator for the row header

See Also:
Constant Field Values

ROW_COLUMN_SEPARATOR

public static final String ROW_COLUMN_SEPARATOR
constant indicating a column used as a separator between the row and column header

See Also:
Constant Field Values

COLUMN_HEADER_SEPARATOR

public static final String COLUMN_HEADER_SEPARATOR
constant indicating a column used as a separator for the column header

See Also:
Constant Field Values

COLUMN_NAMES_SEPARATOR

public static final String COLUMN_NAMES_SEPARATOR
constant indicating a column used as a separator for the column header hierarchy names

See Also:
Constant Field Values

rowHeaderRenderer

protected PivotRowHeaderRenderer rowHeaderRenderer
the renderer for the pivot table's row header cells


pivotStyleModel

protected PivotStyleModel pivotStyleModel
the pivot style model


pivotRowHeader

protected boolean pivotRowHeader
whether to render the row header in pivot style


showRowHierarchyNames

protected boolean showRowHierarchyNames
whether to show the row hierarchy names


showColumnHierarchyNames

protected boolean showColumnHierarchyNames
whether to show the column hierarchy names

Constructor Detail

PivotTable

public PivotTable()
Constructs a PivotTable.


PivotTable

public PivotTable(PivotDataModel dataModel)
Constructs a PivotTable.


PivotTable

public PivotTable(PivotTableModel model)
Constructs a PivotTable having model as its model.

Method Detail

createDefaultPivotRowRenderer

protected PivotRowHeaderRenderer createDefaultPivotRowRenderer()
Returns a default renderer for displaying the rows of the pivot table's row header.

Returns:
the default renderer for the table's row header

createDefaultPivotStyleModel

protected PivotStyleModel createDefaultPivotStyleModel()
Creates and returns a PivotStyleModel.

Returns:
a new instance of a PivotStyleModel

createDefaultStyleModel

protected StyleModel createDefaultStyleModel()
Overrides the method in order to create a new instance of PivotTable.PivotDataStyleModel.

Returns the default style model object which is a DefaultStyleModel.

Overrides:
createDefaultStyleModel in class AdvancedJTable
Returns:
the default style model object

getFixedGrandTotals

public boolean getFixedGrandTotals()
Determines whether row and column grand totals are always showing in the table.

Returns:
true, if grand totals are always visible, false otherwise

getPivotRowHeader

public boolean getPivotRowHeader()
Determines whether to render the row header in pivot style.

Returns:
true if row header is displayed in pivot style, false otherwise

getPivotStyleModel

public PivotStyleModel getPivotStyleModel()
Returns the currently assigned pivot style model.

Returns:
the assigned pivot style model

getPivotTableHeader

public PivotTableHeader getPivotTableHeader()
Convenience method to return the pivot table's accompanying pivot table header.

Returns:
the pivot table's header

getPivotTableModel

public PivotTableModel getPivotTableModel()
Convenience method to return the pivot table's data model, casted to PivotTableModel.

Returns:
the table's data model as a PivotTableModel

getPivotTableRenderer

public PivotRowHeaderRenderer getPivotTableRenderer()
Returns the renderer for displaying the rows of the pivot table's row header.

Returns:
the renderer for the table's row header

getShowColumnHierarchyNames

public boolean getShowColumnHierarchyNames()
Determines whether the hierarchy names shown on the column header will be displayed.

Returns:
true if column hierarchy names will be displayed, false otherwise

getShowRowHierarchyNames

public boolean getShowRowHierarchyNames()
Determines whether the hierarchy names shown on the row header will be displayed.

Returns:
true if row hierarchy names will be displayed, false otherwise

setFixedGrandTotals

public void setFixedGrandTotals(boolean fixed)
Determines whether row and column grand totals are always showing in the table.

Parameters:
fixed - true, if grand totals are always visible, false otherwise

setPivotRowHeader

public void setPivotRowHeader(boolean pivotRowHeader)
Determines whether to render the row header in pivot style.

Parameters:
pivotRowHeader - true if row header is displayed in pivot style, false otherwise

setPivotRowRenderer

public void setPivotRowRenderer(PivotRowHeaderRenderer rowHeaderRenderer)
Assigns the renderer for displaying the rows of the pivot table's row header.

Parameters:
rowHeaderRenderer - the renderer for the table's row header to assign

setPivotStyleModel

public void setPivotStyleModel(PivotStyleModel pivotStyleModel)
Assigns the pivot style model.

Parameters:
pivotStyleModel - the new pivot style model to assign

setShowColumnHierarchyNames

public void setShowColumnHierarchyNames(boolean showColumn)
Determines whether the hierarchy names shown on the column header will be displayed.

Parameters:
showColumn - true if column hierarchy names will be displayed, false otherwise

setShowRowHierarchyNames

public void setShowRowHierarchyNames(boolean showRow)
Determines whether the hierarchy names shown on the row header will be displayed.

Parameters:
showRow - true if row hierarchy names will be displayed, false otherwise

shouldToggleExpand

protected boolean shouldToggleExpand(int row,
                                     int column,
                                     EventObject e,
                                     boolean editingStarted)
This method determines the situation under which a pivot table's node is expanded/collapsed. By default, a node is expanded/collapsed if we are not editing and the event is a mouse event with a click count of two. You may override this method to define a custom behaviour.

Parameters:
row - the row we wish to expand/collapse
column - the column we wish to expand/collapse
e - the event that is used to expand/collapse the node, usually a MouseEvent
editingStarted - boolean indicating whether we are editing
Returns:
true if the node should be expanded/collapsed, false otherwise

Copyright © 2011 Citra Technologies. All Rights Reserved.