|
||||||||||
| 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.BasePane
edu.neu.ccs.gui.ColorPane
Class ColorPane provides a pane that may be
used to interactively set a color by setting the red, green,
blue, and alpha components using 4 SliderView
sliders. The sliders are set to a width of 256 pixels so
that there is a 1-to-1 correspondance between pixels and
color component values. The slider tracks use gradient
paints to reinforce which color component is being chosen.
The pane presents 2 color swatches. The upper swatch shows the initial color in the pane and the lower swatch shows the current color as it evolves under the movements of the 4 sliders or of the dropdown view.
The pane provides a ColorView with only its
dropdown list visible. This enables a user to start with a
specific named color or a specific color given by its color
components and to then make changes from there.
Buttons are provided to set the selected (lower) color from the original (upper) color and vice versa.
The caller may supply press, sliding, and release actions. Each such action will be installed in all 4 sliders. This allows the caller to listen to the changing color behavior in this pane and react accordingly.
| 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 | |
protected Color |
A_Color
The common color for the alpha slider. |
protected Annotation |
A_Label
The label for the alpha slider. |
protected Paint |
A_Paint
The gradient paint for the alpha slider track. |
protected SliderView |
A_Slider
The alpha slider. |
protected Color |
B_Color
The common color for the blue slider. |
protected Annotation |
B_Label
The label for the blue slider. |
protected Paint |
B_Paint
The gradient paint for the blue slider track. |
protected SliderView |
B_Slider
The blue slider. |
protected ColorView |
colorview
The color view with only the dropdown color name list. |
protected Annotation |
colorviewLabel
The label for the colorview. |
protected HTable |
colorviewPanel
The panel with the color view and its label. |
protected Object[] |
colorviewStuff
The array with the color view and its label. |
protected SimpleAction |
currentToInitialAction
The action to reset the current color to the initial color. |
protected JButton |
currentToInitialButton
The button to reset the current color to the initial color. |
protected Color |
G_Color
The common color for the green slider. |
protected Annotation |
G_Label
The label for the green slider. |
protected Paint |
G_Paint
The gradient paint for the green slider track. |
protected SliderView |
G_Slider
The green slider. |
protected SimpleAction |
initialToCurrentAction
The action to reset the current color to the initial color. |
protected JButton |
initialToCurrentButton
The button to reset the current color to the initial color. |
protected HTable |
labelSwatchPanel
The panel for the labels and swatch panel. |
protected Object[] |
labelSwatchStuff
The array for the labels and swatch panel. |
protected PaintSwatch |
lowerSwatch
The lower paint swatch for the current color. |
protected VTable |
mainPanel
The panel with the main GUI components. |
protected Object[] |
mainStuff
The array with the main GUI components. |
protected ActionSequence |
pressActions
The caller-defined actions performed when the slider thumb is pressed in any of the 4 sliders. |
protected Color |
R_Color
The common color for the red slider. |
protected Annotation |
R_Label
The label for the red slider. |
protected Paint |
R_Paint
The gradient paint for the red slider track. |
protected SliderView |
R_Slider
The red slider. |
protected ActionSequence |
releaseActions
The caller-defined actions performed when the slider thumb is released in any of the 4 sliders. |
protected SimpleAction |
setColorFromColorViewAction
The action to set the color using the color view. |
protected SimpleAction |
setColorFromSlidersAction
The action to set the color using the slider settings. |
static int |
SIZE
The size of the square that contains the upper and lower swatches: 200. |
protected TablePanel |
sliderPanel
The panel with sliders and their labels. |
protected Object[][] |
sliderStuff
The array with sliders and their labels. |
protected ActionSequence |
slidingActions
The caller-defined actions performed when the slider thumb is sliding in any of the 4 sliders. |
protected PaintableComponent |
swatchLabelComponent
The labels for the panel with the pair of swatches. |
protected VTable |
swatchPanel
The panel with the pair of swatches. |
protected Object[] |
swatchStuff
The array for the pair of swatches. |
static int |
THICK
The swatch border thickness: 2. |
protected PaintSwatch |
upperSwatch
The upper paint swatch for the initial color. |
| Fields inherited from class edu.neu.ccs.gui.BasePane |
baseFontSize, buttonFont, DEFAULT_BASE_FONT_SIZE, fieldFont, fontSize, gap, labelFont, largeFieldWidth, mediumFieldWidth, MINIMUM_FONT_SIZE, monospacedFontName, sansserifFontName, serifFontName, smallFieldWidth |
| 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.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 | |
ColorPane()
The default ColorPane constructor that sets
the initial color to white. |
|
ColorPane(Color color)
The ColorPane constructor that sets
the initial color to the given color. |
|
| Method Summary | |
void |
addPressAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when slider is pressed in its active area (thumb or track) in any of the 4 sliders. |
void |
addReleaseAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when slider is released after being pressed in its active area (thumb or track) in any of the 4 sliders. |
void |
addSlidingAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when slider is sliding after being pressed in its active area (thumb or track) in any of the 4 sliders. |
Color |
getColor()
Returns the current color. |
Color |
getInitialColor()
Returns the initial color which is the color of the upper swatch. |
static void |
main(String[] args)
For test purposes, this main program creates a ColorPane whose initial color has
random RGB components and has alpha=255. |
protected PaintableComponent |
makeSwatchPanelLabels()
Make the labels for the swatch panel. |
void |
removePressAction(ActionListener a)
Removes the given action listener from the press actions. |
void |
removeReleaseAction(ActionListener a)
Removes the given action listener from the release actions. |
void |
removeSlidingAction(ActionListener a)
Removes the given action listener from the sliding actions. |
void |
setColor(Color color)
Algorithmically sets the current color and adjusts the 4 sliders, the lower swatch, and the color view appropriately. |
protected void |
setColorFromColorView()
Sets the current color from the color view. |
protected void |
setColorFromSliders()
Sets the current color from the settings in the 4 sliders. |
void |
setCurrentFromInitial()
Set the current color from the initial color. |
void |
setInitialColor(Color color)
Sets the initial color which is the color of the upper swatch. |
void |
setInitialFromCurrent()
Set the initial color from the current color. |
| Methods inherited from class edu.neu.ccs.gui.BasePane |
getButtonFont, getFieldFont, getFontSize, getGap, getLabelFont, getLargeFieldWidth, getMediumFieldWidth, getSmallFieldWidth, initializeBasePane |
| 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 |
| Field Detail |
public static final int SIZE
public static final int THICK
protected PaintSwatch upperSwatch
protected PaintSwatch lowerSwatch
protected Object[] swatchStuff
protected VTable swatchPanel
protected PaintableComponent swatchLabelComponent
protected Object[] labelSwatchStuff
protected HTable labelSwatchPanel
protected Paint R_Paint
protected Paint G_Paint
protected Paint B_Paint
protected Paint A_Paint
protected Color R_Color
protected Color G_Color
protected Color B_Color
protected Color A_Color
protected SliderView R_Slider
protected SliderView G_Slider
protected SliderView B_Slider
protected SliderView A_Slider
protected Annotation R_Label
protected Annotation G_Label
protected Annotation B_Label
protected Annotation A_Label
protected Object[][] sliderStuff
protected TablePanel sliderPanel
protected ColorView colorview
protected Annotation colorviewLabel
protected Object[] colorviewStuff
protected HTable colorviewPanel
protected SimpleAction initialToCurrentAction
protected JButton initialToCurrentButton
protected SimpleAction currentToInitialAction
protected JButton currentToInitialButton
protected Object[] mainStuff
protected VTable mainPanel
protected SimpleAction setColorFromSlidersAction
protected SimpleAction setColorFromColorViewAction
protected ActionSequence pressActions
protected ActionSequence slidingActions
protected ActionSequence releaseActions
| Constructor Detail |
public ColorPane()
ColorPane constructor that sets
the initial color to white.
public ColorPane(Color color)
ColorPane constructor that sets
the initial color to the given color.
color - the initial color of the color pane| Method Detail |
public Color getColor()
public void setColor(Color color)
Algorithmically sets the current color and adjusts the 4 sliders, the lower swatch, and the color view appropriately.
color - the color to set as the current colorpublic Color getInitialColor()
Returns the initial color which is the color of the upper swatch.
The call resetColor() is equivalent to
setColor(getInitialColor()).
public void setInitialColor(Color color)
Sets the initial color which is the color of the upper swatch.
This method does not change the 4 sliders or the lower swatch. No actions are executed.
color - public void setCurrentFromInitial()
public void setInitialFromCurrent()
protected void setColorFromSliders()
protected void setColorFromColorView()
public void addPressAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when slider is pressed in its active area (thumb or track) in any of the 4 sliders.
a - the press action listener to addpublic void addSlidingAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when slider is sliding after being pressed in its active area (thumb or track) in any of the 4 sliders.
a - the sliding action listener to addpublic void addReleaseAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when slider is released after being pressed in its active area (thumb or track) in any of the 4 sliders.
a - the release action listener to addpublic void removePressAction(ActionListener a)
a - the press action listener to removepublic void removeSlidingAction(ActionListener a)
a - the sliding action listener to removepublic void removeReleaseAction(ActionListener a)
a - the release action listener to removeprotected PaintableComponent makeSwatchPanelLabels()
public static void main(String[] args)
ColorPane whose initial color has
random RGB components and has alpha=255. The
pane is then installed in a frame.
args - ignored
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||