Class RadianceTableUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.TableUI
-
- javax.swing.plaf.basic.BasicTableUI
-
- org.pushingpixels.radiance.theming.internal.ui.RadianceTableUI
-
- All Implemented Interfaces:
UpdateOptimizationAware
public class RadianceTableUI extends javax.swing.plaf.basic.BasicTableUI implements UpdateOptimizationAware
UI for tables in Radiance look and feel.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classRadianceTableUI.BooleanEditorprotected classRadianceTableUI.CellRepaintCallbackRepaints a single cell during the fade animation cycle.private classRadianceTableUI.RolloverFadeListenerListener for fade animations on table rollovers.static classRadianceTableUI.TableCellIdID of a single table cell.protected classRadianceTableUI.TableStateListenerState listener for tracking the selection changes.private classRadianceTableUI.TableUpdateOptimizationInfo
-
Field Summary
Fields Modifier and Type Field Description (package private) RadianceTableUI.TableCellIdcellIdprivate java.awt.InsetscellRendererInsetsCell renderer insets.private java.util.Map<java.lang.Class<?>,javax.swing.table.TableCellEditor>defaultEditorsMap of default editors.private java.util.Map<java.lang.Class<?>,javax.swing.table.TableCellRenderer>defaultRenderersMap of default renderers.private RadianceTableUI.TableCellIdfocusedCellIdprivate RadianceTableUI.RolloverFadeListenerradianceFadeRolloverListenerListener for transition animations on table rollovers.private java.awt.event.FocusListenerradianceFocusListenerprivate java.beans.PropertyChangeListenerradiancePropertyChangeListenerListener that listens to changes on table properties.private RadianceTableUI.TableStateListenerradianceTableStateListenerListener for transition animations on list selections.private introlledOverColumnHolds the currently rolled-over column index, or-1if none such.private java.util.Set<RadianceTableUI.TableCellId>rolledOverIndicesHolds the currently rolled-over row-column index, ornullif none such.private introlledOverRowprivate java.util.Map<RadianceTableUI.TableCellId,java.lang.Object>selectedIndicesHolds the list of currently selected row-column indexes.private StateTransitionMultiTracker<RadianceTableUI.TableCellId>stateTransitionMultiTrackerprivate RadianceTableUI.TableUpdateOptimizationInfoupdateInfo
-
Constructor Summary
Constructors Modifier Constructor Description protectedRadianceTableUI()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 javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent comp)private java.awt.RectangleextendRect(java.awt.Rectangle rect, boolean horizontal)private java.awt.RectanglegetCellRectangleForRepaint(int row, int column)java.awt.InsetsgetCellRendererInsets()Returns the cell renderer insets of this table.ComponentStategetCellState(RadianceTableUI.TableCellId cellIndex)Returns the current state for the specified cell.private java.awt.RectanglegetHDropLineRect(javax.swing.JTable.DropLocation loc)RadianceTableUI.TableCellIdgetId(int row, int column)Returns a comparable ID for the specified location.StateTransitionTracker.ModelStateInfogetModelStateInfo(RadianceTableUI.TableCellId cellId)Returns the current state for the specified cell.intgetRolloverColumnIndex()Returns the index of the rollover column.StateTransitionTrackergetStateTransitionTracker(RadianceTableUI.TableCellId tableId)private StateTransitionTrackergetTracker(RadianceTableUI.TableCellId tableCellId, boolean initialRollover, boolean initialSelected)UpdateOptimizationInfogetUpdateOptimizationInfo()private java.awt.RectanglegetVDropLineRect(javax.swing.JTable.DropLocation loc)private booleanhasLeadingVerticalGridLine(int column)booleanhasRolloverAnimations()booleanhasSelectionAnimations()private booleanhasTrailingVerticalGridLine(javax.swing.table.TableColumnModel cm, int column)protected voidinstallDefaults()protected voidinstallEditorIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellEditor editor)Installs Radiance-specific renderers for column classes that don't have application-specific renderers installed by the user code.protected voidinstallListeners()protected voidinstallRendererIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellRenderer renderer)Installs Radiance-specific renderers for column classes that don't have application-specific renderers installed by the user code.booleanisFocusedCell(int row, int column)Returns indication whether the specified cell has focus.private booleanisRadianceDefaultEditor(javax.swing.table.TableCellEditor editor)private booleanisRadianceDefaultRenderer(java.lang.Object instance)voidpaint(java.awt.Graphics g, javax.swing.JComponent c)Paint a representation of thetableinstance that was set in installUI().protected voidpaintCell(java.awt.Graphics g, java.awt.Rectangle cellRect, java.awt.Rectangle highlightCellRect, int row, int column)protected voidpaintCells(java.awt.Graphics g, int rMin, int rMax, int cMin, int cMax)protected voidpaintDraggedArea(java.awt.Graphics g, int rMin, int rMax, javax.swing.table.TableColumn draggedColumn, int distance)protected voidpaintDropLines(java.awt.Graphics g)protected voidpaintGrid(java.awt.Graphics g, int rMin, int rMax, int cMin, int cMax)Paints the grid lines within aRect, using the grid color set with setGridColor.protected voidsyncSelection(boolean enforceNoAnimations)Synchronizes the current selection state.protected voiduninstallDefaults()protected voiduninstallEditorIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellEditor editor)Uninstalls default Radiance editors that were installed ininstallEditorIfNecessary(Class, TableCellEditor).protected voiduninstallListeners()protected voiduninstallRendererIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellRenderer renderer)Uninstalls default Radiance renderers that were installed ininstallRendererIfNecessary(Class, TableCellRenderer).voidupdate(java.awt.Graphics g, javax.swing.JComponent c)private intviewIndexForColumn(javax.swing.table.TableColumn aColumn)-
Methods inherited from class javax.swing.plaf.basic.BasicTableUI
createFocusListener, createKeyListener, createMouseInputListener, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installKeyboardActions, installUI, uninstallKeyboardActions, uninstallUI
-
-
-
-
Field Detail
-
selectedIndices
private java.util.Map<RadianceTableUI.TableCellId,java.lang.Object> selectedIndices
Holds the list of currently selected row-column indexes.
-
rolledOverIndices
private java.util.Set<RadianceTableUI.TableCellId> rolledOverIndices
Holds the currently rolled-over row-column index, ornullif none such.
-
focusedCellId
private RadianceTableUI.TableCellId focusedCellId
-
rolledOverColumn
private int rolledOverColumn
Holds the currently rolled-over column index, or-1if none such. This is used for the table header animations.
-
rolledOverRow
private int rolledOverRow
-
defaultRenderers
private java.util.Map<java.lang.Class<?>,javax.swing.table.TableCellRenderer> defaultRenderers
Map of default renderers.
-
defaultEditors
private java.util.Map<java.lang.Class<?>,javax.swing.table.TableCellEditor> defaultEditors
Map of default editors.
-
radiancePropertyChangeListener
private java.beans.PropertyChangeListener radiancePropertyChangeListener
Listener that listens to changes on table properties.
-
radianceTableStateListener
private RadianceTableUI.TableStateListener radianceTableStateListener
Listener for transition animations on list selections.
-
radianceFadeRolloverListener
private RadianceTableUI.RolloverFadeListener radianceFadeRolloverListener
Listener for transition animations on table rollovers.
-
radianceFocusListener
private java.awt.event.FocusListener radianceFocusListener
-
stateTransitionMultiTracker
private StateTransitionMultiTracker<RadianceTableUI.TableCellId> stateTransitionMultiTracker
-
cellRendererInsets
private java.awt.Insets cellRendererInsets
Cell renderer insets. Is computed ininstallDefaults()and reused inRadianceDefaultTableCellRenderer.getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)andRadianceDefaultTableHeaderCellRenderer.getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)for performance optimizations.
-
cellId
RadianceTableUI.TableCellId cellId
-
updateInfo
private RadianceTableUI.TableUpdateOptimizationInfo updateInfo
-
-
Method Detail
-
createUI
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent comp)
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaultsin classjavax.swing.plaf.basic.BasicTableUI
-
installRendererIfNecessary
protected void installRendererIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellRenderer renderer)Installs Radiance-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(java.lang.Class<?> clazz, javax.swing.table.TableCellEditor editor)Installs Radiance-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:
uninstallDefaultsin classjavax.swing.plaf.basic.BasicTableUI
-
uninstallRendererIfNecessary
protected void uninstallRendererIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellRenderer renderer)Uninstalls default Radiance renderers that were installed ininstallRendererIfNecessary(Class, TableCellRenderer).- Parameters:
clazz- Column class.renderer- Renderer to restore.
-
uninstallEditorIfNecessary
protected void uninstallEditorIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellEditor editor)Uninstalls default Radiance editors that were installed ininstallEditorIfNecessary(Class, TableCellEditor).- Parameters:
clazz- Column class.editor- Editor to restore.
-
installListeners
protected void installListeners()
- Overrides:
installListenersin classjavax.swing.plaf.basic.BasicTableUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListenersin classjavax.swing.plaf.basic.BasicTableUI
-
paint
public void paint(java.awt.Graphics g, javax.swing.JComponent c)Paint a representation of thetableinstance that was set in installUI().- Overrides:
paintin classjavax.swing.plaf.basic.BasicTableUI
-
paintGrid
protected void paintGrid(java.awt.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.
-
hasTrailingVerticalGridLine
private boolean hasTrailingVerticalGridLine(javax.swing.table.TableColumnModel cm, int column)
-
hasLeadingVerticalGridLine
private boolean hasLeadingVerticalGridLine(int column)
-
viewIndexForColumn
private int viewIndexForColumn(javax.swing.table.TableColumn aColumn)
-
paintCells
protected void paintCells(java.awt.Graphics g, int rMin, int rMax, int cMin, int cMax)
-
paintDraggedArea
protected void paintDraggedArea(java.awt.Graphics g, int rMin, int rMax, javax.swing.table.TableColumn draggedColumn, int distance)
-
paintCell
protected void paintCell(java.awt.Graphics g, java.awt.Rectangle cellRect, java.awt.Rectangle highlightCellRect, int row, int column)
-
paintDropLines
protected void paintDropLines(java.awt.Graphics g)
-
getHDropLineRect
private java.awt.Rectangle getHDropLineRect(javax.swing.JTable.DropLocation loc)
-
getVDropLineRect
private java.awt.Rectangle getVDropLineRect(javax.swing.JTable.DropLocation loc)
-
extendRect
private java.awt.Rectangle extendRect(java.awt.Rectangle rect, boolean horizontal)
-
getId
public RadianceTableUI.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.
-
getCellState
public ComponentState getCellState(RadianceTableUI.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(RadianceTableUI.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:
trueif the table has animations,falseotherwise.
-
_hasSelectionAnimations
protected boolean _hasSelectionAnimations()
Checks whether the table has selection animations.- Returns:
trueif the table has selection animations,falseotherwise.
-
_hasRolloverAnimations
protected boolean _hasRolloverAnimations()
Checks whether the table has rollover animations.- Returns:
trueif the table has rollover animations,falseotherwise.
-
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:
trueIf the focus is on the specified cell,falseotherwise.
-
update
public void update(java.awt.Graphics g, javax.swing.JComponent c)- Overrides:
updatein classjavax.swing.plaf.ComponentUI
-
getCellRendererInsets
public java.awt.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:
getUpdateOptimizationInfoin interfaceUpdateOptimizationAware
-
isRadianceDefaultRenderer
private boolean isRadianceDefaultRenderer(java.lang.Object instance)
-
isRadianceDefaultEditor
private boolean isRadianceDefaultEditor(javax.swing.table.TableCellEditor editor)
-
getCellRectangleForRepaint
private java.awt.Rectangle getCellRectangleForRepaint(int row, int column)
-
getTracker
private StateTransitionTracker getTracker(RadianceTableUI.TableCellId tableCellId, boolean initialRollover, boolean initialSelected)
-
getStateTransitionTracker
public StateTransitionTracker getStateTransitionTracker(RadianceTableUI.TableCellId tableId)
-
-