EchoPoint
1.0

echopoint
Class ColorChooser

java.lang.Object
  extended bynextapp.echo.Component
      extended bynextapp.echo.Container
          extended byechopoint.EchoPointComponent
              extended byechopoint.ColorChooser
All Implemented Interfaces:
MouseCursorable, ReflectionSetter, java.io.Serializable, ToolTipPopUpSupport, nextapp.echo.ToolTipSupport

public class ColorChooser
extends EchoPointComponent

The ColorChooser class can be used to allow the user to select colors from a series of sample color cells.

The class uses the ColorSelectionModel interface to keep track of the currently selected color. If no color is provided on the the constructor, then Color.WHITE is used.

The class provides a default Color Preview Pane. A new Component can be used. It should implement the ChangeListener interface in order to be notified when the ColorSelectionModel has changed.

Author:
Brad Baker
See Also:
Serialized Form

Nested Class Summary
static class ColorChooser.NestedStyleInfo
          Nested public static StyleInfo class.
 
Field Summary
static java.lang.String BORDER_COLOR_CHANGED_PROPERTY
           
static java.lang.String BORDER_SIZE_CHANGED_PROPERTY
           
protected  nextapp.echo.Color borderColor
           
protected  int borderSize
           
static java.lang.String CELL_HEIGHT_CHANGED_PROPERTY
           
static java.lang.String CELL_SPACING_CHANGED_PROPERTY
           
static java.lang.String CELL_SPACING_COLOR_CHANGED_PROPERTY
           
static java.lang.String CELL_WIDTH_CHANGED_PROPERTY
           
protected  int cellHeight
           
static java.lang.String CELLS_PER_ROW_CHANGED_PROPERTY
           
protected  int cellSpacing
           
protected  nextapp.echo.Color cellSpacingColor
           
protected  int cellsPerRow
           
protected  int cellWidth
           
static java.lang.String COLOR_ARRAY_CHANGED_PROPERTY
           
protected  nextapp.echo.Color[] colorArray
           
static int defaultCellHeight
          Default cell height is 17
static int defaultCellSpacing
          Default cell spacing is 2
static nextapp.echo.Color defaultCellSpacingColor
          Default cell spacing color is Color.WHITE
static int defaultCellsPerRow
          Default number of cells per row is 8
static int defaultCellWidth
          Default cell width is 17
static nextapp.echo.Color[] defaultColorArray
          the default color array used by ColorChooser
static nextapp.echo.Insets defaultInsets
          Default Insets are 0 wide
static int defaultWebSafeCellsPerRow
          Default number of cells per row for the web safe color array is 18
protected  nextapp.echo.Insets insets
           
static java.lang.String INSETS_CHANGED_PROPERTY
           
static java.lang.String PREVIEW_PANEL_CHANGED_PROPERTY
           
protected  nextapp.echo.Component previewPanel
           
static java.lang.String SELECTION_MODEL_CHANGED_PROPERTY
           
protected  ColorSelectionModel selectionModel
           
static java.lang.String STYLE_BORDER_COLOR
          A style constant for the Border Color property.
static java.lang.String STYLE_BORDER_SIZE
          A style constant for the Border Size property.
static java.lang.String STYLE_CELL_HEIGHT
          A style constant for the Cell Height property.
static java.lang.String STYLE_CELL_SPACING
          A style constant for the Cell Spacing property.
static java.lang.String STYLE_CELL_SPACING_COLOR
          A style constant for the Cell Spacing Color property.
static java.lang.String STYLE_CELL_WIDTH
          A style constant for the Cell Width property.
static java.lang.String STYLE_CELLS_PER_ROW
          A style constant for the Cells Per Row property.
static java.lang.String STYLE_INSETS
          A style constant for the Insets property.
static java.lang.String STYLE_SELECTED_COLOR
          A style constant for the Selected Color property.
static java.lang.String TITLE_CHANGED_PROPERTY
           
protected  TitleBar titleBar
           
static nextapp.echo.Color[] web216ColorArray
          This Color array consists of the web safe 216 colors in a table 18 cells by 13 rows.
 
Fields inherited from class echopoint.EchoPointComponent
STYLE_TOOL_TIP_TEXT, TOOL_TIP_TEXT_CHANGED_PROPERTY, toolTipPopUp
 
Fields inherited from class nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, listenerList, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopoint.positionable.MouseCursorable
borderStyleSymbolics, CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, STYLE_MOUSE_CURSOR, STYLE_MOUSE_CURSOR_URI
 
Constructor Summary
ColorChooser()
          Constructs a ColorChooser with Color.WHITE selected
ColorChooser(nextapp.echo.Color newSelectedColor)
          Constructs a ColorChooser with newSelectedColor selected using the ColorChooser.defaultColorArray color array.
ColorChooser(nextapp.echo.Color newSelectedColor, nextapp.echo.Color[] newColorArray)
          Constructs a ColorChooser with newSelectedColor selected and uses newColorArray to display sample color cells.
 
Method Summary
 void addChangeListener(nextapp.echo.event.ChangeListener l)
          Adds a ChangeListener to the color chooser.
 void applyStyle(nextapp.echo.Style style)
          Applies the provided style to the component.
protected  nextapp.echo.event.ChangeListener createChangeListener()
          Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.
 nextapp.echo.Color getBorderColor()
           
 int getBorderSize()
           
 int getCellHeight()
           
 int getCellSpacing()
           
 nextapp.echo.Color getCellSpacingColor()
           
 int getCellsPerRow()
           
 int getCellWidth()
           
 nextapp.echo.Color[] getColorArray()
           
 nextapp.echo.Insets getInsets()
           
 nextapp.echo.Component getPreviewPanel()
           
 nextapp.echo.Color getSelectedColor()
           
 ColorSelectionModel getSelectionModel()
           
 TitleBar getTitle()
           
 void removeChangeListener(nextapp.echo.event.ChangeListener l)
          Removes a ChangeListener from this component.
protected  void reRegisterComponents(nextapp.echo.Component oldValue, nextapp.echo.Component newValue)
           
 java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue)
          Called to save the old value of a field, set in a new value and return the old value of a field.
 void setBorderColor(nextapp.echo.Color newBorderColor)
          Sets the border Color of the ColorChooser.
 void setBorderSize(int newBorderSize)
          Sets the border size of the ColorChooser.
 void setCellHeight(int newHeight)
          Sets the height of the ColorChooser sample color cells.
 void setCellSpacing(int newSpacing)
          Sets the spacing between the ColorChooser sample color cells.
 void setCellSpacingColor(nextapp.echo.Color newCellSpacingColor)
          Sets the Color of the ColorChooser sample color cells.
 void setCellsPerRow(int newCellsPerRow)
          Sets the number of cells per row of the ColorChooser sample color cells.
 void setCellWidth(int newWidth)
          Sets the width of the ColorChooser sample color cells.
 void setColorArray(nextapp.echo.Color[] newColorArray)
          Sets the Color[] array used by the ColorChooser to display sample color cells.
 void setInsets(nextapp.echo.Insets newValue)
          Sets the Insets used by the ColorChooser
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.INSETS_CHANGED_PROPERTY
 void setPreviewPane(nextapp.echo.Component newPreviewPanel)
          Sets the Component used by the ColorChooser as a preview panel.
 void setSelectedColor(nextapp.echo.Color newSelectedColor)
          Sets the currently selected Color of the ColorChooser
This methods causes the underlying ColorSelectionModel to change.
 void setSelectedColor(int red, int green, int blue)
          Sets the currently selected Color of the ColorChooser in RGB format.
 void setSelectionModel(ColorSelectionModel newModel)
          Sets the ColorSelectionModel model used by the ColorChooser.
 void setTitle(java.lang.String newTitleText)
          Sets the text of the title TitleBar used by the ColorChooser.
 void setTitle(TitleBar newTitle)
          Sets the title used by the ColorChooser.
 void useDefaultColorArray()
          Resets the Color array used by then ColorChooser to ColorChooser.defaultColorArray and also changes the cells per row settings to the default values.
 void useWebSafeDefaultColorArray()
          Resets the Color array used by then ColorChooser to ColorChooser.web216ColorArray and also changes the cells per row settings to an appropriate value
 
Methods inherited from class echopoint.EchoPointComponent
getMouseCursor, getMouseCursorURI, getToolTipPopUp, getToolTipText, set, set, set, set, set, set, set, set, set, setEnabledAllChildren, setMouseCursor, setMouseCursorURI, setToolTipText, validate
 
Methods inherited from class nextapp.echo.Component
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getLocale, getParent, indexOf, init, isAncestorOf, isEnabled, isRegistered, isShowing, isVisible, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setEnabled, setFont, setForeground, setIdentifier, setLocale, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_BORDER_COLOR

public static final java.lang.String STYLE_BORDER_COLOR
A style constant for the Border Color property. Values of this key must be of type nextapp.echo.Color.

See Also:
Constant Field Values

STYLE_BORDER_SIZE

public static final java.lang.String STYLE_BORDER_SIZE
A style constant for the Border Size property. Values of this key must be of type Integer.

See Also:
Constant Field Values

STYLE_INSETS

public static final java.lang.String STYLE_INSETS
A style constant for the Insets property. Values of this key must be of type nextapp.echo.Insets.

See Also:
Constant Field Values

STYLE_CELL_HEIGHT

public static final java.lang.String STYLE_CELL_HEIGHT
A style constant for the Cell Height property. Values of this key must be of type Integer.

See Also:
Constant Field Values

STYLE_CELL_WIDTH

public static final java.lang.String STYLE_CELL_WIDTH
A style constant for the Cell Width property. Values of this key must be of type Integer.

See Also:
Constant Field Values

STYLE_CELL_SPACING

public static final java.lang.String STYLE_CELL_SPACING
A style constant for the Cell Spacing property. Values of this key must be of type Integer.

See Also:
Constant Field Values

STYLE_CELL_SPACING_COLOR

public static final java.lang.String STYLE_CELL_SPACING_COLOR
A style constant for the Cell Spacing Color property. Values of this key must be of type nextapp.echo.Color.

See Also:
Constant Field Values

STYLE_CELLS_PER_ROW

public static final java.lang.String STYLE_CELLS_PER_ROW
A style constant for the Cells Per Row property. Values of this key must be of type Integer.

See Also:
Constant Field Values

STYLE_SELECTED_COLOR

public static final java.lang.String STYLE_SELECTED_COLOR
A style constant for the Selected Color property. Values of this key must be of type nextapp.echo.Color.

See Also:
Constant Field Values

SELECTION_MODEL_CHANGED_PROPERTY

public static final java.lang.String SELECTION_MODEL_CHANGED_PROPERTY
See Also:
Constant Field Values

PREVIEW_PANEL_CHANGED_PROPERTY

public static final java.lang.String PREVIEW_PANEL_CHANGED_PROPERTY
See Also:
Constant Field Values

COLOR_ARRAY_CHANGED_PROPERTY

public static final java.lang.String COLOR_ARRAY_CHANGED_PROPERTY
See Also:
Constant Field Values

TITLE_CHANGED_PROPERTY

public static final java.lang.String TITLE_CHANGED_PROPERTY
See Also:
Constant Field Values

BORDER_COLOR_CHANGED_PROPERTY

public static final java.lang.String BORDER_COLOR_CHANGED_PROPERTY
See Also:
Constant Field Values

BORDER_SIZE_CHANGED_PROPERTY

public static final java.lang.String BORDER_SIZE_CHANGED_PROPERTY
See Also:
Constant Field Values

INSETS_CHANGED_PROPERTY

public static final java.lang.String INSETS_CHANGED_PROPERTY
See Also:
Constant Field Values

CELL_SPACING_COLOR_CHANGED_PROPERTY

public static final java.lang.String CELL_SPACING_COLOR_CHANGED_PROPERTY
See Also:
Constant Field Values

CELL_WIDTH_CHANGED_PROPERTY

public static final java.lang.String CELL_WIDTH_CHANGED_PROPERTY
See Also:
Constant Field Values

CELL_HEIGHT_CHANGED_PROPERTY

public static final java.lang.String CELL_HEIGHT_CHANGED_PROPERTY
See Also:
Constant Field Values

CELL_SPACING_CHANGED_PROPERTY

public static final java.lang.String CELL_SPACING_CHANGED_PROPERTY
See Also:
Constant Field Values

CELLS_PER_ROW_CHANGED_PROPERTY

public static final java.lang.String CELLS_PER_ROW_CHANGED_PROPERTY
See Also:
Constant Field Values

defaultCellsPerRow

public static final int defaultCellsPerRow
Default number of cells per row is 8

See Also:
Constant Field Values

defaultWebSafeCellsPerRow

public static final int defaultWebSafeCellsPerRow
Default number of cells per row for the web safe color array is 18

See Also:
Constant Field Values

defaultCellWidth

public static final int defaultCellWidth
Default cell width is 17

See Also:
Constant Field Values

defaultCellHeight

public static final int defaultCellHeight
Default cell height is 17

See Also:
Constant Field Values

defaultCellSpacing

public static final int defaultCellSpacing
Default cell spacing is 2

See Also:
Constant Field Values

defaultCellSpacingColor

public static final nextapp.echo.Color defaultCellSpacingColor
Default cell spacing color is Color.WHITE


defaultInsets

public static final nextapp.echo.Insets defaultInsets
Default Insets are 0 wide


borderColor

protected nextapp.echo.Color borderColor

borderSize

protected int borderSize

insets

protected nextapp.echo.Insets insets

cellsPerRow

protected int cellsPerRow

cellWidth

protected int cellWidth

cellHeight

protected int cellHeight

cellSpacing

protected int cellSpacing

cellSpacingColor

protected nextapp.echo.Color cellSpacingColor

previewPanel

protected nextapp.echo.Component previewPanel

colorArray

protected nextapp.echo.Color[] colorArray

selectionModel

protected ColorSelectionModel selectionModel

defaultColorArray

public static final nextapp.echo.Color[] defaultColorArray
the default color array used by ColorChooser


web216ColorArray

public static final nextapp.echo.Color[] web216ColorArray
This Color array consists of the web safe 216 colors in a table 18 cells by 13 rows.

The the last row is 9 white fillers followed by 9 white through grey to black colors.


titleBar

protected TitleBar titleBar
Constructor Detail

ColorChooser

public ColorChooser()
Constructs a ColorChooser with Color.WHITE selected


ColorChooser

public ColorChooser(nextapp.echo.Color newSelectedColor)
Constructs a ColorChooser with newSelectedColor selected using the ColorChooser.defaultColorArray color array.


ColorChooser

public ColorChooser(nextapp.echo.Color newSelectedColor,
                    nextapp.echo.Color[] newColorArray)
Constructs a ColorChooser with newSelectedColor selected and uses newColorArray to display sample color cells.

Method Detail

addChangeListener

public void addChangeListener(nextapp.echo.event.ChangeListener l)
Adds a ChangeListener to the color chooser.

Parameters:
l - The ChangeListener to be added.

applyStyle

public void applyStyle(nextapp.echo.Style style)
Applies the provided style to the component. The base nextapp.echo.Component style names can be used as well.

Specified by:
applyStyle in interface MouseCursorable
Overrides:
applyStyle in class EchoPointComponent
See Also:
Component.applyStyle(nextapp.echo.Style)

createChangeListener

protected nextapp.echo.event.ChangeListener createChangeListener()
Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.


getBorderColor

public nextapp.echo.Color getBorderColor()
Returns:
The Color of the ColorChooser's border.

getBorderSize

public int getBorderSize()
Returns:
The size of the ColorChooser's border.

getCellHeight

public int getCellHeight()
Returns:
The height of the ColorChooser's sample color cells.

getCellSpacing

public int getCellSpacing()
Returns:
The spacing between the ColorChooser's sample color cells.

getCellSpacingColor

public nextapp.echo.Color getCellSpacingColor()
Returns:
The Color of the ColorChooser's sample color cells.

getCellsPerRow

public int getCellsPerRow()
Returns:
The number of cells per row of ColorChooser's sample color cells.

getCellWidth

public int getCellWidth()
Returns:
The width of the ColorChooser's sample color cells.

getColorArray

public nextapp.echo.Color[] getColorArray()
Returns:
The Color[] array used to display the ColorChooser's sample color cells.

getInsets

public nextapp.echo.Insets getInsets()
Returns:
the Insets (margins) of the ColorChooser.

getPreviewPanel

public nextapp.echo.Component getPreviewPanel()
Returns:
the preview paneComponent currently used by the ColorChooser.

getSelectedColor

public nextapp.echo.Color getSelectedColor()
Returns:
the currently selected Color of the ColorChooser.

getSelectionModel

public ColorSelectionModel getSelectionModel()
Returns:
the ColorSelectionModel model of the ColorChooser.

getTitle

public TitleBar getTitle()
Returns:
the title of the ColorChooser.

removeChangeListener

public void removeChangeListener(nextapp.echo.event.ChangeListener l)
Removes a ChangeListener from this component.

Parameters:
l - the ChangeListener to remove

reRegisterComponents

protected void reRegisterComponents(nextapp.echo.Component oldValue,
                                    nextapp.echo.Component newValue)

setBorderColor

public void setBorderColor(nextapp.echo.Color newBorderColor)
Sets the border Color of the ColorChooser.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.BORDER_COLOR_CHANGED_PROPERTY


setBorderSize

public void setBorderSize(int newBorderSize)
Sets the border size of the ColorChooser.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.BORDER_SIZE_CHANGED_PROPERTY


setCellHeight

public void setCellHeight(int newHeight)
Sets the height of the ColorChooser sample color cells.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.CELL_HEIGHT_CHANGED_PROPERTY


setCellSpacing

public void setCellSpacing(int newSpacing)
Sets the spacing between the ColorChooser sample color cells.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.CELL_SPACING_CHANGED_PROPERTY


setCellSpacingColor

public void setCellSpacingColor(nextapp.echo.Color newCellSpacingColor)
Sets the Color of the ColorChooser sample color cells.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.CELL_SPACING_COLOR_CHANGED_PROPERTY


setCellsPerRow

public void setCellsPerRow(int newCellsPerRow)
Sets the number of cells per row of the ColorChooser sample color cells.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.CELLS_PER_ROW_CHANGED_PROPERTY


setCellWidth

public void setCellWidth(int newWidth)
Sets the width of the ColorChooser sample color cells.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.CELL_WIDTH_CHANGED_PROPERTY


setColorArray

public void setColorArray(nextapp.echo.Color[] newColorArray)
Sets the Color[] array used by the ColorChooser to display sample color cells.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.COLOR_ARRAY_CHANGED_PROPERTY


setInsets

public void setInsets(nextapp.echo.Insets newValue)
Sets the Insets used by the ColorChooser
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.INSETS_CHANGED_PROPERTY


setPreviewPane

public void setPreviewPane(nextapp.echo.Component newPreviewPanel)
Sets the Component used by the ColorChooser as a preview panel.
This Component should implement ChangeEventListener and then call addChangeListener to ensure it is notified of changes to the underlying ColorSelectionModel model.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.PREVIEW_PANEL_CHANGED_PROPERTY


setSelectedColor

public void setSelectedColor(int red,
                             int green,
                             int blue)
Sets the currently selected Color of the ColorChooser in RGB format.
This methods causes the underlying ColorSelectionModel to change.


setSelectedColor

public void setSelectedColor(nextapp.echo.Color newSelectedColor)
Sets the currently selected Color of the ColorChooser
This methods causes the underlying ColorSelectionModel to change.


setSelectionModel

public void setSelectionModel(ColorSelectionModel newModel)
Sets the ColorSelectionModel model used by the ColorChooser.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.SELECTION_MODEL_CHANGED_PROPERTY


setTitle

public void setTitle(TitleBar newTitle)
Sets the title used by the ColorChooser.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.TITLE_CHANGED_PROPERTY


setTitle

public void setTitle(java.lang.String newTitleText)
Sets the text of the title TitleBar used by the ColorChooser.
This methods fires a PropertyChangeEvent with a getPropertyName() value of ColorChooser.TITLE_CHANGED_PROPERTY


useDefaultColorArray

public void useDefaultColorArray()
Resets the Color array used by then ColorChooser to ColorChooser.defaultColorArray and also changes the cells per row settings to the default values.


useWebSafeDefaultColorArray

public void useWebSafeDefaultColorArray()
Resets the Color array used by then ColorChooser to ColorChooser.web216ColorArray and also changes the cells per row settings to an appropriate value


set

public java.lang.Object set(java.lang.reflect.Field field,
                            java.lang.Object newValue)
                     throws java.lang.Exception
Description copied from interface: ReflectionSetter
Called to save the old value of a field, set in a new value and return the old value of a field. This interface allows a field set operation to be "delegated" back into the class that has permission to perform the field set.

 public Object set(Field f, Object newValue) throws Exception {
      Object oldValue = f.get(this);
      f.set(this,newValue);
      return oldValue;
 }
 

Parameters:
field - - the field to be set
newValue - - the new value to be set
Returns:
the oldValue of the field
Throws:
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

EchoPoint
1.0