com.eliad.model.defaults
Class DefaultStyleModel

java.lang.Object
  |
  +--com.eliad.model.AbstractGenericModel
        |
        +--com.eliad.model.AbstractStyleModel
              |
              +--com.eliad.model.defaults.DefaultStyleModel

public class DefaultStyleModel
extends AbstractStyleModel

The DefaultStyleModel furnishes a way to manage a StyleModel which provides Editors and/or Renderers for cells or spans based on the class of the value. A default editor and renderer is always provided.

Note: The DefaultStyleModel is always used as the default unless another StyleModel is provided.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

Version:
1.0
Author:
Stephan Szymkowicz
See Also:
DefaultGridCellEditor, DefaultGridCellRenderer, GridCellEditor, GridCellRenderer, Serialized Form

Inner Class Summary
static class DefaultStyleModel.BooleanEditor
          A specific editor for truth values
static class DefaultStyleModel.BooleanRenderer
          A specific renderer for truth values
static class DefaultStyleModel.DateRenderer
          A Renderer specialized for date cells.
static class DefaultStyleModel.DoubleRenderer
          A Renderer further specialized for precision numeric cells.
static class DefaultStyleModel.GenericEditor
          A generic editor usable with most basic data types.
static class DefaultStyleModel.IconRenderer
          A Renderer specialized for image cells.
static class DefaultStyleModel.NumberEditor
          A variant, adapted for numeric entry
static class DefaultStyleModel.NumberRenderer
          A Renderer specialized for numeric cells.
static class DefaultStyleModel.ProxyLazyValue
          Variant of UIDefaults.ProxyLazyValue that allows you to specify a class loader.
 
Fields inherited from class com.eliad.model.AbstractGenericModel
listeners_
 
Constructor Summary
DefaultStyleModel()
           
DefaultStyleModel(boolean isLazyRequired)
           
 
Method Summary
protected  void createDefaultEditors(boolean isLazyRequired)
          Creates default cell editors for objects, numbers, and boolean values.
protected  void createDefaultRenderers(boolean isLazyRequired)
          Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.
 GridCellEditor getEditor(java.lang.Class clazz)
          Returns the editor to be used by default.
 GridCellEditor getEditor(java.lang.Class aClass, int row, int column, GridContext aGridContext)
          Returns an appropriate editor for the cell specified by this row and column.
protected  GridCellRenderer getRenderer(java.lang.Class aClass)
          Returns the cell renderer to be used when no renderer has been set in a StyleModel.
 GridCellRenderer getRenderer(java.lang.Class aClass, int row, int column, GridContext aGridContext)
          Returns an appropriate renderer for the cell specified by this row and column.
 void installUI(javax.swing.JComponent c)
          Installation of particular graphics attributes
 void setEditor(java.lang.Class clazz, GridCellEditor editor)
          Sets a default cell editor.
protected  void setLazyEditor(java.lang.Class c, java.lang.String s)
           
protected  void setLazyRenderer(java.lang.Class c, java.lang.String s)
           
protected  void setLazyValue(java.util.Hashtable h, java.lang.Class c, java.lang.String s)
           
 void setRenderer(java.lang.Class clazz, GridCellRenderer renderer)
          Sets a default class renderer to be used if no renderer has been set in a cell.
 void updateUI()
          Notification from the UIManager that the L&F has changed.
 
Methods inherited from class com.eliad.model.AbstractStyleModel
addStyleModelListener, fireStyleEditorChanged, fireStyleEditorModelChanged, fireStyleModelChanged, fireStyleRendererChanged, fireStyleRendererModelChanged, installUI, removeStyleModelListener
 
Methods inherited from class com.eliad.model.AbstractGenericModel
getListenerCount, getListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultStyleModel

public DefaultStyleModel()

DefaultStyleModel

public DefaultStyleModel(boolean isLazyRequired)
Method Detail

installUI

public void installUI(javax.swing.JComponent c)
Installation of particular graphics attributes

createDefaultRenderers

protected void createDefaultRenderers(boolean isLazyRequired)
Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.

createDefaultEditors

protected void createDefaultEditors(boolean isLazyRequired)
Creates default cell editors for objects, numbers, and boolean values.
See Also:
DefaultStyleModel.GenericEditor

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
See Also:
StyleModel.updateUI(), JSmartGrid.updateUI(), JComponent.updateUI()

setLazyValue

protected void setLazyValue(java.util.Hashtable h,
                            java.lang.Class c,
                            java.lang.String s)

setLazyRenderer

protected void setLazyRenderer(java.lang.Class c,
                               java.lang.String s)

setLazyEditor

protected void setLazyEditor(java.lang.Class c,
                             java.lang.String s)

getRenderer

protected GridCellRenderer getRenderer(java.lang.Class aClass)
Returns the cell renderer to be used when no renderer has been set in a StyleModel. During the rendering of cells the renderer is fetched from a Hashtable of entries according to the class of the cells in the column. If there is no entry for this class, the method returns the entry for the most specific superclass. The DefaultStyleModel installs entries for Object, Number, and Boolean, all of which can be modified or replaced.
Parameters:
clazz - return the default cell renderer for this class
Returns:
the renderer for this class

setRenderer

public void setRenderer(java.lang.Class clazz,
                        GridCellRenderer renderer)
Sets a default class renderer to be used if no renderer has been set in a cell. If the renderer is null, it removes the default renderer for this class.
Parameters:
clazz - set the default cell renderer for this class
renderer - default cell renderer to be used for this class

getEditor

public GridCellEditor getEditor(java.lang.Class clazz)
Returns the editor to be used by default. During the editing of cells the editor is fetched from a Hashtable of entries according to the class of the cell value. If there is no entry for this class, the method returns the entry for the most specific superclass. The DefaultStyleModel installs entries for Object, Number, and Boolean, all of which can be modified or replaced.
Parameters:
clazz - return the default cell editor for this class
Returns:
the default cell editor to be used for this class

setEditor

public void setEditor(java.lang.Class clazz,
                      GridCellEditor editor)
Sets a default cell editor. If no editing is required in a grid, or in a particular cell in a grid, uses the isCellEditable method in the GridModel interface to ensure that this JSmartGrid will not start an editor in these cells. If the editor is null, removes the default editor for this class.
Parameters:
clazz - set the default cell editor for this class
editor - default cell editor to be used for this class
See Also:
GridModel.isCellEditable(int, int)

getRenderer

public GridCellRenderer getRenderer(java.lang.Class aClass,
                                    int row,
                                    int column,
                                    GridContext aGridContext)
Returns an appropriate renderer for the cell specified by this row and column. Note: The renderer has to be an instance of the interface GridCellRenderer.
Parameters:
row - the row of the cell or top row of a span to render, where 0 is the first row.
column - the column of the cell ot left column of a span to render, where 0 is the first column.
Returns:
the assigned renderer as a GridCellRenderer; if null the DefaultGridCellRenderer will be used by the JSmartGrid for this cell.
See Also:
DefaultGridCellRenderer

getEditor

public GridCellEditor getEditor(java.lang.Class aClass,
                                int row,
                                int column,
                                GridContext aGridContext)
Returns an appropriate editor for the cell specified by this row and column. Note: The editor has to be an instance of the interface GridCellEditor.
Parameters:
row - the row of the cell or top row of a span to edit, where 0 is the first row.
column - the column of the cell ot left column of a span to edit, where 0 is the first column.
Returns:
the assigned editor as a GridCellEditor; if null the cell will not be edited.
See Also:
StyleModel