dsto.dfc.swing.controls
Class ColorChooserPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by dsto.dfc.swing.forms.AbstractFormEditorComponent
                  extended by dsto.dfc.swing.controls.ColorChooserPanel
All Implemented Interfaces:
FormEditor, ImageObserver, MenuContainer, Customizer, PropertyChangeListener, Serializable, EventListener

public class ColorChooserPanel
extends AbstractFormEditorComponent
implements PropertyChangeListener

This is the main Panel. Contains a ColorSchemePanel and other components. It is the User Interface for the Color Scheme Chooser that displays different schemes of color as ToolButtons. It can be placed inside any Frame or other Panel to be used. Whenever a color is selected a propertyChangeEvent is fired with the property name "color".

Version:
$Revision$
Author:
Luke Marsh
See Also:
ColorScheme, ColorSchemePanel, ColorChooserCombo, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  ToolButton BackwardToolButton
           
protected  BorderLayout borderLayout1
           
protected  List colorschemeList
           
protected  JLabel colorSchemeName
           
protected  ToolButton colorsToolButton
           
protected  int currentScheme
           
protected  ToolButton ForwardToolButton
           
protected  GridBagLayout gridBagLayout1
           
protected  Color selectedColor
           
protected  ColorSchemePanel selectorPanel
           
protected  JPanel titlePanel
           
 
Fields inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
description
 
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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ColorChooserPanel()
          Initializes variables and creates the predefined color schemes.
ColorChooserPanel(List colorschemeList)
          Uses a user defined List of colorschemeList instead of the predefined ones.
 
Method Summary
 void commitEdits()
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
protected  void disarm()
          Disarms the "Other..." button and calls disarm () on the ColorSchemePanel.
 void displayNextScheme(String direction)
          Determines if the next or previous scheme should be displayed, and Calls displayScheme (currentScheme) on the ColorSchemePanel.
 Color getColor()
          Return the chosen color.
 List getColorSchemeList()
          Return the List of colorschemeList.
 ColorSchemePanel getColorSchemePanel()
          Returns the instance of ColorSchemePanel.
 Object getEditorValue()
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
 boolean isDirectEdit()
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
 void propertyChange(PropertyChangeEvent evt)
          Assigns the event new value to selectedColor.
 void setColor(Color c)
          Sets the selected color to c.
protected  void setColorButton()
          Sets the "More Colors..." button's icon to the color chosen in the JColorChooser.
 void setEditorValue(Object value)
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
 void setScheme(int current)
          Sets the scheme to be loaded as the scheme the current color belongs to.
 void setSelectedButton(Color color)
          Calls the ColorSchemePanel to set the selected color button.
 
Methods inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
addFormEditorListener, fireEditComitted, fireEditCommitRequested, fireEditCommitted, getEditorComponent, getEditorDescription, getPreferredValueType, removeFormEditorListener, setEditorDescription, setObject
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 
Methods inherited from interface java.beans.Customizer
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

currentScheme

protected int currentScheme

colorsToolButton

protected ToolButton colorsToolButton

titlePanel

protected JPanel titlePanel

BackwardToolButton

protected ToolButton BackwardToolButton

ForwardToolButton

protected ToolButton ForwardToolButton

colorSchemeName

protected JLabel colorSchemeName

selectorPanel

protected ColorSchemePanel selectorPanel

gridBagLayout1

protected GridBagLayout gridBagLayout1

borderLayout1

protected BorderLayout borderLayout1

selectedColor

protected Color selectedColor

colorschemeList

protected List colorschemeList
Constructor Detail

ColorChooserPanel

public ColorChooserPanel()
Initializes variables and creates the predefined color schemes.


ColorChooserPanel

public ColorChooserPanel(List colorschemeList)
Uses a user defined List of colorschemeList instead of the predefined ones.

Method Detail

getColorSchemeList

public List getColorSchemeList()
Return the List of colorschemeList.


propertyChange

public void propertyChange(PropertyChangeEvent evt)
Assigns the event new value to selectedColor.

Specified by:
propertyChange in interface PropertyChangeListener

getColor

public Color getColor()
Return the chosen color.


setColor

public void setColor(Color c)
Sets the selected color to c.


setScheme

public void setScheme(int current)
Sets the scheme to be loaded as the scheme the current color belongs to.


setSelectedButton

public void setSelectedButton(Color color)
Calls the ColorSchemePanel to set the selected color button.


isDirectEdit

public boolean isDirectEdit()
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. This control is not direct-editable.

Specified by:
isDirectEdit in interface FormEditor
Specified by:
isDirectEdit in class AbstractFormEditorComponent

setEditorValue

public void setEditorValue(Object value)
                    throws IllegalFormatException
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. Sets value to the current Color, and throws an exception if value is not a real Color.

Specified by:
setEditorValue in interface FormEditor
Specified by:
setEditorValue in class AbstractFormEditorComponent
Parameters:
value - The value to display.
Throws:
IllegalFormatException - if the value was not in the correct format for display by this editor. The source specified by the exception should be this FormEditor instance or a child.

getEditorValue

public Object getEditorValue()
                      throws IllegalFormatException
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. Returns the current color.

Specified by:
getEditorValue in interface FormEditor
Specified by:
getEditorValue in class AbstractFormEditorComponent
Throws:
IllegalFormatException

commitEdits

public void commitEdits()
                 throws IllegalFormatException
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. Commit the selection.

Specified by:
commitEdits in interface FormEditor
Overrides:
commitEdits in class AbstractFormEditorComponent
Throws:
IllegalFormatException - if the commit failed because of an illegal input or other error. The source specified by the exception should be the FormEditor instance that caused the error (ie either this editor or a child).

getColorSchemePanel

public ColorSchemePanel getColorSchemePanel()
Returns the instance of ColorSchemePanel.


displayNextScheme

public void displayNextScheme(String direction)
Determines if the next or previous scheme should be displayed, and Calls displayScheme (currentScheme) on the ColorSchemePanel.

Parameters:
direction - Can be backward or forward.

setColorButton

protected void setColorButton()
Sets the "More Colors..." button's icon to the color chosen in the JColorChooser.


disarm

protected void disarm()
Disarms the "Other..." button and calls disarm () on the ColorSchemePanel.



Copyright © 2008 Commonwealth of Australia