edu.neu.ccs.gui
Class VisualColorList

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
                      extended byedu.neu.ccs.gui.VisualColorList
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants

public class VisualColorList
extends DisplayPanel

Class VisualColorList displays the named colors as defined in class Colors using a square color swatch and 3 labels with the color name, the RGBA value, and the hex color value.

The class also provides a ColorView so one can experiment with colors defined by RGBA or hex. In particular, this permits a user to experiment with colors whose values are close to some particular named color.

The programmer has some control of the swatch size. See the constants:

The programmer also has some control of the pane height. See the constants:

Although this panel is intended primarily to provide information to the user, it is possible to use this panel as a control by querying the ColorView state or by attaching listeners to the ColorView that is returned by the method getColorView().

This class replaces an earlier version of the class that only provided the color names but not the numerical data. The earlier class also had no embedded ColorView.

Since:
2.3.2
Version:
2.6
See Also:
ColorView, MultiColorView, 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
private static Border BORDER
          The standard swatch border.
private static int BORDER_SIZE
          The standard border size.
private  JPTScrollPane colorPane
          The color scroll pane.
private  ColorView colorView
          The color view for experiments.
static int DEF_HEIGHT
          The default height of the viewport of the list scroll pane.
static int DEF_SWATCH
          The default swatch size.
private  String[] hexArray
          The array of color rgba values in hex.
private static int HGAP
          The internal table panel horizontal gap.
static int MAX_HEIGHT
          The maximum height of the viewport of the list scroll pane.
static int MAX_SWATCH
          The maximum swatch size.
private static int MAX_WIDTH
          The maximum width of the viewport of the list scroll pane.
static int MIN_HEIGHT
          The minimum height of the viewport of the list scroll pane.
static int MIN_SWATCH
          The minimum swatch size.
private  String[] nameArray
          The array of color names.
private  int paneHeight
          The pane height that must be between MIN_HEIGHT and MAX_HEIGHT.
private  String[] rgbaArray
          The array of color rgba values.
private  int swatchSize
          The swatch size that must be between MIN_SWATCH and MAX_SWATCH.
private static int VGAP
          The internal table panel vertical gap.
 
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
VisualColorList()
          The constructor that creates a VisualColorList using a swatch size of 25 and a scroll pane height of 525.
VisualColorList(int swatchSize)
          The constructor that creates a VisualColorList using the given swatch size and a scroll pane height of 525.
VisualColorList(int swatchSize, int paneHeight)
          The constructor that creates a VisualColorList using a the given swatch size and the given scroll pane height.
 
Method Summary
private  void adjustGeometricParameters(int swatchSize, int paneHeight)
          Adjust the geometric parameters.
private  void fillStringArrays()
          Fill the string arrays of color names, rgba values, and rgba values in hex.
 ColorView getColorView()
          Returns a reference to the ColorView object used within this panel.
static void main(String[] args)
           
private  JPTScrollPane makeColorPane()
          Make the scroll pane with named colors.
private  ColorView makeColorView()
          Make the color view pane for experiments.
private  PaintSwatch makeSwatch(String name)
          The method to create a swatch based on the given color name and the encapsulated swatch size.
private  TableGenerator makeTableGenerator(String[] nameArray, String[] rgbaArray, String[] hexArray)
          The method to construct the table generator for the color table.
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addBorder, addObject, addObject, addObject, addObject, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, compoundBorder, compoundBorder, dataMalformed, emptyBorder, emptyBorder, emptyBorder, endAlert, etchBorderLowered, etchBorderLowered, etchBorderLowered, etchBorderRaised, etchBorderRaised, etchBorderRaised, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewState, getDefaultViewStates, getDisplayables, getViewState, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, removeBorder, reset, sandwichBorder, setCodec, setDeepBackground, setDeepBackground, setDefaultViewState, setDefaultViewStates, setEnabled, setViewState, setViewStates, startAlert, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_SWATCH

public static final int MIN_SWATCH
The minimum swatch size.

See Also:
Constant Field Values

DEF_SWATCH

public static final int DEF_SWATCH
The default swatch size.

See Also:
Constant Field Values

MAX_SWATCH

public static final int MAX_SWATCH
The maximum swatch size.

See Also:
Constant Field Values

MIN_HEIGHT

public static final int MIN_HEIGHT
The minimum height of the viewport of the list scroll pane.

See Also:
Constant Field Values

DEF_HEIGHT

public static final int DEF_HEIGHT
The default height of the viewport of the list scroll pane.

See Also:
Constant Field Values

MAX_HEIGHT

public static final int MAX_HEIGHT
The maximum height of the viewport of the list scroll pane.

See Also:
Constant Field Values

MAX_WIDTH

private static final int MAX_WIDTH
The maximum width of the viewport of the list scroll pane.

See Also:
Constant Field Values

BORDER_SIZE

private static final int BORDER_SIZE
The standard border size.

See Also:
Constant Field Values

BORDER

private static final Border BORDER
The standard swatch border.


HGAP

private static final int HGAP
The internal table panel horizontal gap.

See Also:
Constant Field Values

VGAP

private static final int VGAP
The internal table panel vertical gap.

See Also:
Constant Field Values

swatchSize

private int swatchSize
The swatch size that must be between MIN_SWATCH and MAX_SWATCH.


paneHeight

private int paneHeight
The pane height that must be between MIN_HEIGHT and MAX_HEIGHT.


nameArray

private String[] nameArray
The array of color names.


rgbaArray

private String[] rgbaArray
The array of color rgba values.


hexArray

private String[] hexArray
The array of color rgba values in hex.


colorPane

private JPTScrollPane colorPane
The color scroll pane.


colorView

private ColorView colorView
The color view for experiments.

Constructor Detail

VisualColorList

public VisualColorList()

The constructor that creates a VisualColorList using a swatch size of 25 and a scroll pane height of 525.

Additional height is used for the color view.


VisualColorList

public VisualColorList(int swatchSize)

The constructor that creates a VisualColorList using the given swatch size and a scroll pane height of 525.

The swatch size will be forced to the range 20-50 before usage.

Additional height is used for the color view.

Parameters:
swatchSize - the desired swatch size

VisualColorList

public VisualColorList(int swatchSize,
                       int paneHeight)

The constructor that creates a VisualColorList using a the given swatch size and the given scroll pane height.

The swatch size will be forced to the range 20-50 before usage.

The pane height will be forced to the range 120-800 before usage.

Additional height is used for the color view.

Parameters:
swatchSize - the desired swatch size
paneHeight - the desired pane height
Method Detail

getColorView

public ColorView getColorView()

Returns a reference to the ColorView object used within this panel.

Although this panel is intended primarily for user information, it is possible to use this panel as a control by querying the ColorView state or by attaching listeners to the ColorView that is returned by this method.


adjustGeometricParameters

private void adjustGeometricParameters(int swatchSize,
                                       int paneHeight)
Adjust the geometric parameters.

Parameters:
swatchSize - the desired swatch size
paneHeight - the desired pane height

fillStringArrays

private void fillStringArrays()
Fill the string arrays of color names, rgba values, and rgba values in hex. This information produced by this method is used by makeTableGenerator.


makeColorPane

private JPTScrollPane makeColorPane()
Make the scroll pane with named colors.


makeColorView

private ColorView makeColorView()
Make the color view pane for experiments.


makeSwatch

private PaintSwatch makeSwatch(String name)
The method to create a swatch based on the given color name and the encapsulated swatch size. This method is used by makeTableGenerator.

Parameters:
name - a color name in the table in class Colors

makeTableGenerator

private TableGenerator makeTableGenerator(String[] nameArray,
                                          String[] rgbaArray,
                                          String[] hexArray)
The method to construct the table generator for the color table.

Parameters:
nameArray - the array of color names
rgbaArray - the array of color rgba values
hexArray - the array of color rgba values in hex
Returns:
the table generator for the color table

main

public static void main(String[] args)