Package edu.wisc.ssec.mcidasv.ui
Class ColorSwatchComponent
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.wisc.ssec.mcidasv.ui.ColorSwatchComponent
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,PropertyChangeListener
,Serializable
,EventListener
,Accessible
This is largely the same as
GuiUtils.ColorSwatch
, but it remembers
the user's recently selected colors.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
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
Modifier and TypeFieldDescription(package private) JButton
"Clear" button.(package private) Color
Color of the swatch.(package private) boolean
Flag for alpha.(package private) String
Labelprivate static final org.slf4j.Logger
Logging object.private static final long
(package private) JButton
"Set" button.private XmlObjectStore
Application object store.Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
ConstructorDescriptionColorSwatchComponent
(XmlObjectStore store, Color c, String dialogLabel) Create a new ColorSwatch for the specified colorColorSwatchComponent
(XmlObjectStore store, Color c, String dialogLabel, boolean alphaOk) Create a new color swatch -
Method Summary
Modifier and TypeMethodDescriptionstatic Color
colorChooserDialog
(XmlObjectStore store, Component c, String label, Color color) Prompt the user to select aColor
using a dialog box.private JColorChooser
Get the clear button.getColor()
_more_getPanel()
Get the panelGet the set button.Get the panel that shows the swatch and the Set button.Get the Color of the swatch.void
Paint this swatch.void
popupNameMenu
(JButton popupBtn) Popup the named list menuvoid
Called fromPersistableSwatchChooserPanel
when the user has clicked on a color.void
Set the background to the color.private void
Set color from chooser.void
setColorName
(String name) Set the color based on nameprivate void
Show the color chooservoid
User chose a new color.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, 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
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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
serialVersionUID
- See Also:
-
logger
Logging object. -
doAlpha
boolean doAlphaFlag for alpha. -
color
Color of the swatch. -
clearBtn
"Clear" button. -
setBtn
"Set" button. -
label
Label -
store
Application object store.
-
-
Constructor Details
-
ColorSwatchComponent
Create a new ColorSwatch for the specified color- Parameters:
store
- Application object store. Cannot benull
.c
- ColordialogLabel
- Dialog title.
-
ColorSwatchComponent
Create a new color swatch- Parameters:
store
- Application object store. Cannot benull
.c
- ColordialogLabel
- Dialog title.alphaOk
- Whether or not to use alpha.
-
-
Method Details
-
colorChooserDialog
public static Color colorChooserDialog(XmlObjectStore store, Component c, String label, Color color) Prompt the user to select aColor
using a dialog box.- Parameters:
store
- Application object store. Cannot benull
.c
- Parent component.null
is allowed.label
- Title of the dialog box.color
- Initially selected color.null
will result in either the most recently used color, orColor.WHITE
if there are no persisted colors.- Returns:
- Either the user's selected
Color
, ornull
if the user closed the dialog or hit cancel.
-
showColorChooser
Show the color chooser -
createChooser
-
propertyChange
Called fromPersistableSwatchChooserPanel
when the user has clicked on a color. This is used to store the list of recent color selections.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
evt
- Event containing both the old list of colors and the new.
-
setColorFromChooser
Set color from chooser. -
getSetButton
Get the set button.- Returns:
- the set button
-
getClearButton
Get the clear button.- Returns:
- the clear button
-
getSwatchColor
Get the Color of the swatch.- Returns:
- the swatch color
-
userSelectedNewColor
User chose a new color. Set the background. This can be overwritted by client code to act on the color change.- Parameters:
c
- color
-
setBackground
Set the background to the color.- Overrides:
setBackground
in classJComponent
- Parameters:
c
- Color for background
-
paint
Paint this swatch.- Overrides:
paint
in classJComponent
- Parameters:
g
- Graphics
-
getPanel
Get the panel- Returns:
- the panel
-
getColor
_more_- Returns:
- _more_
-
getSetPanel
Get the panel that shows the swatch and the Set button.- Returns:
- the panel
-
popupNameMenu
Popup the named list menu- Parameters:
popupBtn
- Popup near this button
-
setColorName
Set the color based on name- Parameters:
name
- color name
-