org.jvnet.substance
Class SubstanceTableUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TableUI
          extended by javax.swing.plaf.basic.BasicTableUI
              extended by org.jvnet.substance.SubstanceTableUI

public class SubstanceTableUI
extends javax.swing.plaf.basic.BasicTableUI

UI for tables in Substance look and feel. Unfortunately, the entire painting stack has been copied from BasicTableUI since the methods are private. The animation effects are implemented in the BasicTableUI.paintCell(Graphics, Rectangle, int, int).

Author:
Kirill Grouchnikov

Nested Class Summary
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 static class SubstanceTableUI.TableColumnId
          ID of a single table column.
static interface SubstanceTableUI.TableId
           
protected static class SubstanceTableUI.TableRowId
          ID of a single table row.
protected  class SubstanceTableUI.TableStateListener
          State listener for tracking the selection changes.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTableUI
javax.swing.plaf.basic.BasicTableUI.FocusHandler, javax.swing.plaf.basic.BasicTableUI.KeyHandler, javax.swing.plaf.basic.BasicTableUI.MouseInputHandler
 
Field Summary
protected  java.util.Map<java.lang.Class<?>,javax.swing.table.TableCellRenderer> defaultRenderers
          Map of default renderers.
protected  int focusedColumn
          Column index of the focused cell.
protected  int focusedRow
          Row index of the focused cell.
protected  int rolledOverColumn
          Holds the currently rolled-over column index, or -1 if none such.
protected  SubstanceTableUI.TableId rolledOverId
          Holds the currently rolled-over row-column index, or null if none such.
protected  java.util.Map<SubstanceTableUI.TableCellId,java.lang.Object> selectedIndices
          Holds the list of currently selected row-column indexes.
protected  org.jvnet.substance.SubstanceTableUI.RolloverFadeListener substanceFadeRolloverListener
          Listener for fade animations on table rollovers.
protected  SubstanceTableUI.TableStateListener substanceFadeSelectionListener
          Listener for fade animations on list selections.
protected  java.beans.PropertyChangeListener substancePropertyChangeListener
          Listener that listens to changes on table properties.
 
Fields inherited from class javax.swing.plaf.basic.BasicTableUI
focusListener, keyListener, mouseInputListener, rendererPane, table
 
Constructor Summary
SubstanceTableUI()
          Creates a UI delegate for table.
 
Method Summary
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.ComponentUI createUI(javax.swing.JComponent comp)
           
 java.awt.Insets getCellRendererInsets()
          Returns the cell renderer insets of this table.
 ComponentState getCellState(SubstanceTableUI.TableCellId cellIndex)
          Returns the current state for the specified cell.
 SubstanceColorScheme getDefaultColorScheme()
           
 SubstanceColorScheme getHighlightColorScheme(ComponentState state)
           
 SubstanceTableUI.TableId getId(int row, int column)
          Returns a comparable ID for the specified location.
 ComponentState getPrevCellState(SubstanceTableUI.TableCellId cellIndex)
          Returns the previous state for the specified cell.
 int getRolloverColumnIndex()
          Returns the index of the rollover column.
 boolean hasRolloverAnimations()
           
 boolean hasSelectionAnimations()
           
protected  void installDefaults()
           
protected  void installListeners()
           
protected  void installRendererIfNecessary(java.lang.Class<?> clazz, javax.swing.table.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(java.awt.Graphics g, javax.swing.JComponent c)
          Paint a representation of the table instance that was set in installUI().
protected  void paintCell(java.awt.Graphics g, java.awt.Rectangle cellRect, java.awt.Rectangle highlightCellRect, int row, int column)
           
protected  void syncSelection()
          Synchronizes the current selection state.
protected  void uninstallDefaults()
           
protected  void uninstallListeners()
           
protected  void uninstallRendererIfNecessary(java.lang.Class<?> clazz, javax.swing.table.TableCellRenderer renderer)
          Uninstalls default Substance renderers that were installed in installRendererIfNecessary(Class, TableCellRenderer).
 void update(java.awt.Graphics g, javax.swing.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectedIndices

protected java.util.Map<SubstanceTableUI.TableCellId,java.lang.Object> selectedIndices
Holds the list of currently selected row-column indexes.


rolledOverId

protected SubstanceTableUI.TableId rolledOverId
Holds the currently rolled-over row-column index, or null if none such.


focusedRow

protected int focusedRow
Row index of the focused cell.


focusedColumn

protected int focusedColumn
Column index of the focused cell.


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 java.util.Map<java.lang.Class<?>,javax.swing.table.TableCellRenderer> defaultRenderers
Map of default renderers.


substancePropertyChangeListener

protected java.beans.PropertyChangeListener substancePropertyChangeListener
Listener that listens to changes on table properties.


substanceFadeSelectionListener

protected SubstanceTableUI.TableStateListener substanceFadeSelectionListener
Listener for fade animations on list selections.


substanceFadeRolloverListener

protected org.jvnet.substance.SubstanceTableUI.RolloverFadeListener substanceFadeRolloverListener
Listener for fade animations on table rollovers.

Constructor Detail

SubstanceTableUI

public SubstanceTableUI()
Creates a UI delegate for table.

Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent comp)

installDefaults

protected void installDefaults()
Overrides:
installDefaults in class javax.swing.plaf.basic.BasicTableUI

installRendererIfNecessary

protected void installRendererIfNecessary(java.lang.Class<?> clazz,
                                          javax.swing.table.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.

uninstallDefaults

protected void uninstallDefaults()
Overrides:
uninstallDefaults in class javax.swing.plaf.basic.BasicTableUI

uninstallRendererIfNecessary

protected void uninstallRendererIfNecessary(java.lang.Class<?> clazz,
                                            javax.swing.table.TableCellRenderer renderer)
Uninstalls default Substance renderers that were installed in installRendererIfNecessary(Class, TableCellRenderer).

Parameters:
clazz - Column class.
renderer - Renderer to restore.

installListeners

protected void installListeners()
Overrides:
installListeners in class javax.swing.plaf.basic.BasicTableUI

uninstallListeners

protected void uninstallListeners()
Overrides:
uninstallListeners in class javax.swing.plaf.basic.BasicTableUI

paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent c)
Paint a representation of the table instance that was set in installUI().

Overrides:
paint in class javax.swing.plaf.basic.BasicTableUI

paintCell

protected void paintCell(java.awt.Graphics g,
                         java.awt.Rectangle cellRect,
                         java.awt.Rectangle highlightCellRect,
                         int row,
                         int column)

getId

public SubstanceTableUI.TableId getId(int row,
                                      int column)
Returns a comparable ID for the specified location. The result will be one of SubstanceTableUI.TableRowId, SubstanceTableUI.TableColumnId or SubstanceTableUI.TableCellId, based on the row and column selection modes of the table.

Parameters:
row - Row index.
column - Column index.
Returns:
Comparable ID for the specified location.

syncSelection

protected void syncSelection()
Synchronizes the current selection state.

Parameters:
e - Selection event.

getPrevCellState

public ComponentState getPrevCellState(SubstanceTableUI.TableCellId cellIndex)
Returns the previous state for the specified cell.

Parameters:
cellIndex - Cell index.
Returns:
The previous state for the specified cell.

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.

_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(java.awt.Graphics g,
                   javax.swing.JComponent c)
Overrides:
update in class javax.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.

getDefaultColorScheme

public SubstanceColorScheme getDefaultColorScheme()

getHighlightColorScheme

public SubstanceColorScheme getHighlightColorScheme(ComponentState state)

hasSelectionAnimations

public boolean hasSelectionAnimations()

hasRolloverAnimations

public boolean hasRolloverAnimations()