org.geotoolkit.gui.swing.image
Class PaletteComboBox

Object
  extended by Component
      extended by Container
          extended by JComponent
              extended by PaletteComboBox
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class PaletteComboBox
extends JComponent

A combo box for selecting a color palette. The choices of available palettes is provided by a palette factory given to the constructor.

This combo box can also be used as a cell editor in a JTable, by invoking the useAsTableCellEditor(TableColumn) method.

Since:
3.13
Version:
3.17
Author:
Martin Desruisseaux (Geomatys)
See Also:
Serialized Form
Module:
display/geotk-widgets-swing (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class 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 Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PaletteComboBox()
          Creates a new combo box using the default palette factory.
PaletteComboBox(PaletteFactory factory)
          Creates a new combo box using the given palette factory.
 
Method Summary
 void addColor(Color color)
          Adds a uniform color (typically opaque) to the list of proposed choices.
 void addDefaultColors()
          Adds a default set of colors to the list of proposed choices.
 Color[] getSelectedColors()
          Returns the colors for the currently selected item, or null if none.
 String getSelectedItem()
          Returns the name of the currently selected item, or null if none.
 void setSelectedColors(Color... colors)
          Sets the currently selected item by its color.
 void setSelectedItem(String name)
          Sets the currently selected item by its color code or palette name.
 void useAsTableCellEditor(TableColumn column)
          Uses this PaletteComboBox as the table cell editor and the table cell renderer of the given table column.
 
Methods inherited from class 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 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 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PaletteComboBox

public PaletteComboBox()
Creates a new combo box using the default palette factory.


PaletteComboBox

public PaletteComboBox(PaletteFactory factory)
Creates a new combo box using the given palette factory. The combo box content will be initialized to the available names.

Parameters:
factory - The factory to use for loading colors from a palette name, or null for the default.
Method Detail

addColor

public void addColor(Color color)
Adds a uniform color (typically opaque) to the list of proposed choices. The color will be inserted before the gradients.

Parameters:
color - The uniform color to add.

addDefaultColors

public void addDefaultColors()
Adds a default set of colors to the list of proposed choices. The colors added are the constants declared in the Color class.


getSelectedItem

public String getSelectedItem()
Returns the name of the currently selected item, or null if none.

Returns:
The name of the currently selected item, or null if none.

setSelectedItem

public void setSelectedItem(String name)
Sets the currently selected item by its color code or palette name.

If no color or palette is found for the given name, then this method selects the "none" choice (same as if the name is null).

Parameters:
name - The color code or palette name to select, or null if none.

getSelectedColors

public Color[] getSelectedColors()
Returns the colors for the currently selected item, or null if none.

Returns:
The colors of the currently selected item, or null if none.
Since:
3.14

setSelectedColors

public void setSelectedColors(Color... colors)
Sets the currently selected item by its color. This method searches for a choices providing the same colors than the given array. If such choices is found, it is selected. Otherwise this method selects the "none" choice.

Parameters:
colors - The colors to select, or null if none.
Since:
3.14

useAsTableCellEditor

public void useAsTableCellEditor(TableColumn column)
Uses this PaletteComboBox as the table cell editor and the table cell renderer of the given table column.

This PaletteComboBox instance should not be used for any other purpose after this method call.

Parameters:
column - The table column on which to set this combo box as the editor and renderer.
Since:
3.14


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.