|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.neu.ccs.gui.DisplayPanel
edu.neu.ccs.gui.ColorView
A for the input
of a TypedViewColor that contains an optional color swatch
on the left that displays the selected color and an optional
dropdown view on the right that allows for both
the direct input of numeric color data (rgba or hex) and for
the selection of certain colors using swatch-name pairs shown
in the dropdown.
The option to permit the color swatch on the left to be
optional was introduced in 2.6.0 without any change to the
public interface of this class. Instead, if a constructor is
passed a swatch width or height that is less than or equal to
zero then the swatch will exist but will not be installed in
the GUI. The same will be true if the width or height is
passed within a Dimension object. As in the past,
if a null Dimension object is passed,
then that will be treated as a signal for the default swatch
size not zero swatch size.
Whether or not the optional dropdown view is shown continues
to be controlled by the constructor parameter
showDropdown. If a constructor does not have this
parameter, then the default is true.
The currently selected color value may be changed through a
ColorPaneDialog dialog. As of 2.6.0, this dialog
replaced the use of JColorChooser since that Java
dialog did not permit the setting of the alpha parameter.
The ColorPaneDialog dialog is opened by clicking
on the color swatch in the main GUI.
The currently selected color value may be changed in the dropdown view by selecting a color swatch-name pair or by entering the color data into the editable text field in one of the following formats.
Data format 1: A comma and/or blank separated text
string with 3 int components:
red, green, blue
or 4 int components:
red, green, blue, alpha.
The int components should be in the range
[0, 255].
If the alpha component is omitted then it is assumed to be 255.
Data format 2: A String of the form
#rRgGbB or #rRgGbBaA
where r, R, g, G, b, B, a, A are hex digits with
red = rR,
green = gG,
blue = bB,
alpha = aA.
Data format 3: A String of the form
#rgb or #rgba that is interpreted as
#rrggbb or #rrggbbaa respectively.
Data format 4: A color name that is contained in
the internal static structure of the class
Colors. An array with the currently valid
installed color names can be obtained via the call:
Colors.getColorNamesAsArray()
Although the user can type in a color name in the dropdown view text area, the same result can be obtained more quickly by using the dropdown list.
Changes to the input state in the dropdown view take effect
when a swatch-name selection is made or when the user presses
the Return key in the dropdown view text area.
ColorPane,
ColorPaneDialog,
MultiColorView,
VisualColorList,
VisualColorSampler,
Serialized Form| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
static int |
BOX_SIZE
The default size for the color box. |
static String |
CHOOSER_CLICK_COUNT
Bound property name for the chooser click count property. |
private int |
chooserClickCount
The click count to trigger the color chooser. |
private PaintSwatch |
colorBox
The color box view to display the current color. |
private MouseAction |
colorBoxAction
The standard color box action. |
private MouseActionAdapter |
colorBoxActions
The mouse action adapter for the color box view. |
private DropdownView |
colorDropdownView
The dropdown view. |
private ColorPaneDialog |
colorPaneDialog
The color pane dialog for use if the swatch is clicked. |
private Color |
currentColor
The current color for this view. |
static int |
DEFAULT_CHOOSER_CLICK_COUNT
The default click count to trigger the color chooser. |
static Color |
DEFAULT_COLOR
The initial color and initial default color for the view. |
static Dimension |
DEFAULT_DIMENSION
The default dimension for the color view box. |
static int |
DEFAULT_WIDTH
The default width for the dropdown view. |
private Color |
defaultColor
The default color for this view. |
private SwatchNameRenderer |
renderer
The swatch-name renderer. |
static String |
SET_CURRENT_COLOR
Bound property name for set current color. |
static String |
SET_DEFAULT_COLOR
Bound property name for set default color. |
private ActionSequence |
setColorActions
The action sequence for handling set color action listeners. |
private Action |
setColorFromDropdownView
Action triggering the task of setting the current color to the color represented by input in the dropdown view. |
| Fields inherited from class edu.neu.ccs.gui.DisplayPanel |
background, codec, CODEC |
| Fields inherited from class javax.swing.JPanel |
|
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface edu.neu.ccs.gui.TypedView |
DATA_TYPE |
| Fields inherited from interface edu.neu.ccs.gui.Displayable |
DEFAULT_VIEW_STATE, VIEW_STATE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
ColorView()
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and a color dropdown for the precise entry of color data. |
|
ColorView(Color color)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color. |
|
ColorView(Color color,
boolean showDropdown)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and, if showDropdown is true,
a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color. |
|
ColorView(Color color,
boolean showDropdown,
Dimension dimension)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and, if showDropdown is true,
a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given dimension. |
|
ColorView(Color color,
boolean showDropdown,
Dimension dimension,
int minWidth)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and, if showDropdown is true,
a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given dimension;
the minimum width of the dropdown editable area is the given minWidth. |
|
ColorView(Color color,
boolean showDropdown,
int width,
int height)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and, if showDropdown is true,
a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given width and height. |
|
ColorView(Color color,
boolean showDropdown,
int width,
int height,
int minWidth)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and, if showDropdown is true,
a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given width and height;
the minimum width of the dropdown editable area is the given minWidth. |
|
ColorView(Color color,
Dimension dimension)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given dimension. |
|
ColorView(Color color,
Dimension dimension,
int minWidth)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given dimension;
the minimum width of the dropdown editable area is the given minWidth. |
|
ColorView(Color color,
int width,
int height)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given width and height. |
|
ColorView(Color color,
int width,
int height,
int minWidth)
Constructs a view displaying a color swatch with the default color (black) that when clicked will activate a JColorChooser
and a color dropdown for the precise entry of color data;
the initial color to be displayed is the given color;
the size of the color swatch is provided by the given width and height;
the minimum width of the dropdown editable area is the given minWidth. |
|
| Method Summary | |
void |
addAction(ActionListener action)
Append an action listener to be performed when the method setColor is called. |
void |
addAction(int index,
ActionListener action)
Add an action listener to be performed when the method setColor is called and place this action
listener at the given index in the set color actions
sequence. |
private void |
colorBoxAction(MouseEvent evt)
The standard color box action method. |
Stringable |
demandObject()
Returns an XColor object
whose state is set to the view state of this view. |
int |
getChooserClickCount()
Return the chooser click count. |
Color |
getColor()
Returns the current color. |
PaintSwatch |
getColorBox()
Returns the internal JPTComponent that represents
the color box in the view. |
DropdownView |
getColorDropdownView()
Returns the internal DropdownView that may be used
to choose the color via a String representation. |
Class |
getDataType()
Returns the XColor class object. |
Color |
getDefaultColor()
Returns the default color. |
String |
getDefaultViewState()
Returns a String encapsulation of the state
of the default Color for this view. |
InputProperties |
getInputProperties()
Returns the input properties of the internal color dropdown view. |
MouseActionAdapter |
getMouseActionAdapter()
Returns the mouse action adapter for the color box in this color view. |
ActionSequence |
getSetColorActions()
Returns the ActionSequence that holds the actions
to be performed when the method setColor is called. |
String |
getViewState()
Returns a String encapsulation of the state of
the current Color for this view. |
protected void |
installColorBox(Color color,
Dimension dimension)
Installs the color box for this view. |
protected void |
installColorBoxActions()
Installs the color box mouse actions triggered by mouse events targeted on the color box contained in this view. |
protected void |
installColorDropdownView(boolean showDropdown,
int minWidth)
Installs the color dropdown view. |
boolean |
removeAction(ActionListener action)
Remove an action listener that was to be performed when the method setColor is called. |
ActionListener |
removeAction(int index)
Remove an action listener at the given index position that was to be performed when the method setColor is
called. |
Stringable |
requestObject()
Returns an XColor object
whose state is set to the view state of this view. |
void |
reset()
Resets the color to the default color. |
void |
setChooserClickCount(int count)
Sets the number of mouse clicks required to bring up the color chooser dialog. |
void |
setColor(Color color)
Sets the current color to the given color. |
protected void |
setColorFromDropdownView()
Sets the current color for this view to the color represented by the input in its color dropdown view. |
void |
setColorHelper(Color color)
Sets the current color to the given color. |
void |
setDefaultColor(Color color)
Sets the default color to the given color. |
void |
setDefaultViewState(String data)
Sets the default view state for this view to the Color
represented by the given String data. |
void |
setInputProperties(InputProperties p)
Sets the input properties of the internal color dropdown view and fires a property change if the input properties have changed. |
void |
setViewState(String data)
Sets the current view state for this view to the Color
represented by the given String data. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface edu.neu.ccs.gui.Displayable |
setEnabled |
| Field Detail |
public static final String CHOOSER_CLICK_COUNT
public static final String SET_CURRENT_COLOR