Class SubstanceTableUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.TableUI
-
- javax.swing.plaf.basic.BasicTableUI
-
- org.pushingpixels.substance.internal.ui.SubstanceTableUI
-
- All Implemented Interfaces:
UpdateOptimizationAware
public class SubstanceTableUI extends BasicTableUI implements UpdateOptimizationAware
UI for tables in Substance look and feel. Unfortunately, the entire painting stack has been copied fromBasicTableUI
since the methods are private. The animation effects are implemented in theBasicTableUI.paintCell(Graphics, Rectangle, int, int)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
SubstanceTableUI.CellRepaintCallback
Repaints a single cell during the fade animation cycle.protected class
SubstanceTableUI.ColumnRepaintCallback
Repaints a single column during the fade animation cycle.protected class
SubstanceTableUI.RowRepaintCallback
Repaints a single row during the fade animation cycle.static class
SubstanceTableUI.TableCellId
ID of a single table cell.protected class
SubstanceTableUI.TableStateListener
State listener for tracking the selection changes.-
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTableUI
BasicTableUI.FocusHandler, BasicTableUI.KeyHandler, BasicTableUI.MouseInputHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Class<?>,TableCellEditor>
defaultEditors
Map of default editors.protected Map<Class<?>,TableCellRenderer>
defaultRenderers
Map of default renderers.protected Boolean
drawLeadingVerticalLine
protected Boolean
drawTrailingVerticalLine
protected SubstanceTableUI.TableCellId
focusedCellId
protected int
rolledOverColumn
Holds the currently rolled-over column index, or-1
if none such.protected Set<SubstanceTableUI.TableCellId>
rolledOverIndices
Holds the currently rolled-over row-column index, ornull
if none such.protected Map<SubstanceTableUI.TableCellId,Object>
selectedIndices
Holds the list of currently selected row-column indexes.protected org.pushingpixels.substance.internal.ui.SubstanceTableUI.RolloverFadeListener
substanceFadeRolloverListener
Listener for transition animations on table rollovers.protected FocusListener
substanceFocusListener
protected PropertyChangeListener
substancePropertyChangeListener
Listener that listens to changes on table properties.protected SubstanceTableUI.TableStateListener
substanceTableStateListener
Listener for transition animations on list selections.-
Fields inherited from class javax.swing.plaf.basic.BasicTableUI
focusListener, keyListener, mouseInputListener, rendererPane, table
-
-
Constructor Summary
Constructors Constructor Description SubstanceTableUI()
Creates a UI delegate for table.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_hasAnimations()
Checks whether the table has animations.protected boolean
_hasRolloverAnimations()
Checks whether the table has rollover animations.protected boolean
_hasSelectionAnimations()
Checks whether the table has selection animations.static ComponentUI
createUI(JComponent comp)
Insets
getCellRendererInsets()
Returns the cell renderer insets of this table.ComponentState
getCellState(SubstanceTableUI.TableCellId cellIndex)
Returns the current state for the specified cell.SubstanceTableUI.TableCellId
getId(int row, int column)
Returns a comparable ID for the specified location.StateTransitionTracker.ModelStateInfo
getModelStateInfo(SubstanceTableUI.TableCellId cellId)
Returns the current state for the specified cell.int
getRolloverColumnIndex()
Returns the index of the rollover column.StateTransitionTracker
getStateTransitionTracker(SubstanceTableUI.TableCellId tableId)
UpdateOptimizationInfo
getUpdateOptimizationInfo()
boolean
hasRolloverAnimations()
boolean
hasSelectionAnimations()
protected void
installDefaults()
protected void
installEditorIfNecessary(Class<?> clazz, TableCellEditor editor)
Installs Substance-specific renderers for column classes that don't have application-specific renderers installed by the user code.protected void
installListeners()
protected void
installRendererIfNecessary(Class<?> clazz, TableCellRenderer renderer)
Installs Substance-specific renderers for column classes that don't have application-specific renderers installed by the user code.boolean
isFocusedCell(int row, int column)
Returns indication whether the specified cell has focus.void
paint(Graphics g, JComponent c)
Paint a representation of thetable
instance that was set in installUI().protected void
paintCell(Graphics g, Rectangle cellRect, Rectangle highlightCellRect, int row, int column)
protected void
paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax)
protected void
paintDraggedArea(Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance)
protected void
paintDropLines(Graphics g)
protected void
paintGrid(Graphics g, int rMin, int rMax, int cMin, int cMax)
Paints the grid lines within aRect, using the grid color set with setGridColor.protected void
syncSelection(boolean enforceNoAnimations)
Synchronizes the current selection state.protected void
uninstallDefaults()
protected void
uninstallEditorIfNecessary(Class<?> clazz, TableCellEditor editor)
Uninstalls default Substance editors that were installed ininstallEditorIfNecessary(Class, TableCellEditor)
.protected void
uninstallListeners()
protected void
uninstallRendererIfNecessary(Class<?> clazz, TableCellRenderer renderer)
Uninstalls default Substance renderers that were installed ininstallRendererIfNecessary(Class, TableCellRenderer)
.void
update(Graphics g, JComponent c)
-
Methods inherited from class javax.swing.plaf.basic.BasicTableUI
createFocusListener, createKeyListener, createMouseInputListener, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installKeyboardActions, installUI, uninstallKeyboardActions, uninstallUI
-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
-
-
-
-
Field Detail
-
selectedIndices
protected Map<SubstanceTableUI.TableCellId,Object> selectedIndices
Holds the list of currently selected row-column indexes.
-
rolledOverIndices
protected Set<SubstanceTableUI.TableCellId> rolledOverIndices
Holds the currently rolled-over row-column index, ornull
if none such.
-
focusedCellId
protected SubstanceTableUI.TableCellId focusedCellId
-
rolledOverColumn
protected int rolledOverColumn
Holds the currently rolled-over column index, or-1
if none such. This is used for the table header animations.
-
defaultRenderers
protected Map<Class<?>,TableCellRenderer> defaultRenderers
Map of default renderers.
-
defaultEditors
protected Map<Class<?>,TableCellEditor> defaultEditors
Map of default editors.
-
substancePropertyChangeListener
protected PropertyChangeListener substancePropertyChangeListener
Listener that listens to changes on table properties.
-
substanceTableStateListener
protected SubstanceTableUI.TableStateListener substanceTableStateListener
Listener for transition animations on list selections.
-
substanceFadeRolloverListener
protected org.pushingpixels.substance.internal.ui.SubstanceTableUI.RolloverFadeListener substanceFadeRolloverListener
Listener for transition animations on table rollovers.
-
substanceFocusListener
protected FocusListener substanceFocusListener
-
drawLeadingVerticalLine
protected Boolean drawLeadingVerticalLine
-
drawTrailingVerticalLine
protected Boolean drawTrailingVerticalLine
-
-
Method Detail
-
createUI
public static ComponentUI createUI(JComponent comp)
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaults
in classBasicTableUI
-
installRendererIfNecessary
protected void installRendererIfNecessary(Class<?> clazz, TableCellRenderer renderer)
Installs Substance-specific renderers for column classes that don't have application-specific renderers installed by the user code.- Parameters:
clazz
- Column class.renderer
- Default renderer for the specified column class.
-
installEditorIfNecessary
protected void installEditorIfNecessary(Class<?> clazz, TableCellEditor editor)
Installs Substance-specific renderers for column classes that don't have application-specific renderers installed by the user code.- Parameters:
clazz
- Column class.editor
- Default renderer for the specified column class.
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaults
in classBasicTableUI
-
uninstallRendererIfNecessary
protected void uninstallRendererIfNecessary(Class<?> clazz, TableCellRenderer renderer)
Uninstalls default Substance renderers that were installed ininstallRendererIfNecessary(Class, TableCellRenderer)
.- Parameters:
clazz
- Column class.renderer
- Renderer to restore.
-
uninstallEditorIfNecessary
protected void uninstallEditorIfNecessary(Class<?> clazz, TableCellEditor editor)
Uninstalls default Substance editors that were installed ininstallEditorIfNecessary(Class, TableCellEditor)
.- Parameters:
clazz
- Column class.editor
- Editor to restore.
-
installListeners
protected void installListeners()
- Overrides:
installListeners
in classBasicTableUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListeners
in classBasicTableUI
-
paint
public void paint(Graphics g, JComponent c)
Paint a representation of thetable
instance that was set in installUI().- Overrides:
paint
in classBasicTableUI
-
paintGrid
protected void paintGrid(Graphics g, int rMin, int rMax, int cMin, int cMax)
Paints the grid lines within aRect, using the grid color set with setGridColor. Paints vertical lines ifgetShowVerticalLines()
returns true and paints horizontal lines ifgetShowHorizontalLines()
returns true.
-
paintCells
protected void paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax)
-
paintDraggedArea
protected void paintDraggedArea(Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance)
-
paintCell
protected void paintCell(Graphics g, Rectangle cellRect, Rectangle highlightCellRect, int row, int column)
-
paintDropLines
protected void paintDropLines(Graphics g)
-
getId
public SubstanceTableUI.TableCellId getId(int row, int column)
Returns a comparable ID for the specified location.- Parameters:
row
- Row index.column
- Column index.- Returns:
- Comparable ID for the specified location.
-
syncSelection
protected void syncSelection(boolean enforceNoAnimations)
Synchronizes the current selection state.- Parameters:
enforceNoAnimations
- Whether to force no animations.
-
getCellState
public ComponentState getCellState(SubstanceTableUI.TableCellId cellIndex)
Returns the current state for the specified cell.- Parameters:
cellIndex
- Cell index.- Returns:
- The current state for the specified cell.
-
getModelStateInfo
public StateTransitionTracker.ModelStateInfo getModelStateInfo(SubstanceTableUI.TableCellId cellId)
Returns the current state for the specified cell.- Parameters:
cellId
- Cell index.- Returns:
- The current state for the specified cell.
-
_hasAnimations
protected boolean _hasAnimations()
Checks whether the table has animations.- Returns:
true
if the table has animations,false
otherwise.
-
_hasSelectionAnimations
protected boolean _hasSelectionAnimations()
Checks whether the table has selection animations.- Returns:
true
if the table has selection animations,false
otherwise.
-
_hasRolloverAnimations
protected boolean _hasRolloverAnimations()
Checks whether the table has rollover animations.- Returns:
true
if the table has rollover animations,false
otherwise.
-
getRolloverColumnIndex
public int getRolloverColumnIndex()
Returns the index of the rollover column.- Returns:
- The index of the rollover column.
-
isFocusedCell
public boolean isFocusedCell(int row, int column)
Returns indication whether the specified cell has focus.- Parameters:
row
- Cell row index.column
- Cell column index.- Returns:
true
If the focus is on the specified cell,false
otherwise.
-
update
public void update(Graphics g, JComponent c)
- Overrides:
update
in classComponentUI
-
getCellRendererInsets
public Insets getCellRendererInsets()
Returns the cell renderer insets of this table. Is for internal use only.- Returns:
- The cell renderer insets of this table.
-
hasSelectionAnimations
public boolean hasSelectionAnimations()
-
hasRolloverAnimations
public boolean hasRolloverAnimations()
-
getUpdateOptimizationInfo
public UpdateOptimizationInfo getUpdateOptimizationInfo()
- Specified by:
getUpdateOptimizationInfo
in interfaceUpdateOptimizationAware
-
getStateTransitionTracker
public StateTransitionTracker getStateTransitionTracker(SubstanceTableUI.TableCellId tableId)
-
-