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
implements JPTConstants

Class VisualColorList displays the named colors as defined in class Colors using a square color swatch and a label. The programmer has some control of the swatch size and pane height. This class is intended to provide color information not as a GUI control.

Since:
2.3.2
See Also:
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 static int DEFAULT_SWATCH_SIZE
          The default swatch size.
private static int HGAP
          The internal table panel horizontal gap.
private static int MAX_HEIGHT
          The maximum height of the viewport of the list scroll pane.
private static int MAX_SWATCH_SIZE
          The maximum swatch size.
private static int MAX_WIDTH
          The maximum width of the viewport of the list scroll pane.
private static int MIN_HEIGHT
          The minimum height of the viewport of the list scroll pane.
private static int MIN_SWATCH_SIZE
          The minimum swatch size.
private  int swatchSize
          The swatch size that must be between MIN_SWATCH_SIZE and MAX_SWATCH_SIZE.
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.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 edu.neu.ccs.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
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 20 and a pane height of 600.
VisualColorList(int swatchSize)
          The constructor that creates a VisualColorList using a the given swatch size and a maximum pane height of 600.
VisualColorList(int swatchSize, int paneHeight)
          The constructor that creates a VisualColorList using a the given swatch size and the given maximum pane height.
 
Method Summary
private  PaintSwatch makeSwatch(String name)
          The method to create a swatch based on the given color name and the encapsulated swatch size.
static void showVisualColorList()
          This static convenience method makes a default VisualColorList panel and displays the panel in a frame.
 
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_SIZE

private static final int MIN_SWATCH_SIZE
The minimum swatch size.

See Also:
Constant Field Values

DEFAULT_SWATCH_SIZE

private static final int DEFAULT_SWATCH_SIZE
The default swatch size.

See Also:
Constant Field Values

MAX_SWATCH_SIZE

private static final int MAX_SWATCH_SIZE
The maximum swatch size.

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

MAX_WIDTH

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

See Also:
Constant Field Values

MIN_HEIGHT

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

See Also:
Constant Field Values

MAX_HEIGHT

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

See Also:
Constant Field Values

swatchSize

private int swatchSize
The swatch size that must be between MIN_SWATCH_SIZE and MAX_SWATCH_SIZE.

Constructor Detail

VisualColorList

public VisualColorList()

The constructor that creates a VisualColorList using a swatch size of 20 and a pane height of 600.

Assuming the label font size is not too large, the vertical spacing of the color swatch blocks will be 20 + 10 = 30. This means that 600 / 30 = 20 colors will be visible at one time.


VisualColorList

public VisualColorList(int swatchSize)

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

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

Assuming the label font size is not too large, the vertical spacing of the color swatch blocks will be (swatchSize + 10). This means that 600 / (swatchSize + 10) colors will be visible at one time.

In particular, if the swatch size is set to its minimum of 20, then 24 colors will be visible at one time.

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 maximum 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-600 before usage.

Assuming the label font size is not too large, the vertical spacing of the color swatch blocks will be (swatchSize + 10). This means that paneHeight / (swatchSize + 10) colors will be visible at one time.

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

makeSwatch

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

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

showVisualColorList

public static void showVisualColorList()

This static convenience method makes a default VisualColorList panel and displays the panel in a frame.