de.matthiasmann.twl
Class ColorSelector

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.DialogLayout
          extended by de.matthiasmann.twl.ColorSelector

public class ColorSelector
extends DialogLayout

A color selector widget


Nested Class Summary
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.DialogLayout
DialogLayout.Gap, DialogLayout.Group
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
 
Fields inherited from class de.matthiasmann.twl.DialogLayout
addDefaultGaps, blockInvalidateLayoutTree, DEFAULT_GAP, defaultGap, includeInvisibleWidgets, isPrepared, LARGE_GAP, largeGap, MEDIUM_GAP, mediumGap, namedGaps, redoDefaultGaps, SMALL_GAP, smallGap, warnOnIncomplete
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
ColorSelector(ColorSpace colorSpace)
           
 
Method Summary
 void addCallback(java.lang.Runnable cb)
           
protected  void afterAddToGUI(GUI gui)
          Called after this widget has been added to a GUI tree.
protected  void beforeRemoveFromGUI(GUI gui)
          Called when this widget is removed from the GUI tree.
protected  void colorChanged()
           
protected  void createColorAreas()
           
 Color getColor()
           
 ColorSpace getColorSpace()
           
 int getMinHeight()
          Returns the minimum height of the widget.
 int getMinWidth()
          Returns the minimum width of the widget.
 ColorModel getModel()
           
protected  int getNumComponents()
           
 int getPreferredInnerHeight()
          Computes the preferred inner height (the size of the widget without the border) The default implementation uses the current position of the children.
 int getPreferredInnerWidth()
          Computes the preferred inner width (the size of the widget without the border) The default implementation uses the current position of the children.
 boolean isShowAlphaAdjuster()
           
 boolean isShowHexEditField()
           
 boolean isShowNativeAdjuster()
           
 boolean isShowPreview()
           
 boolean isShowRGBAdjuster()
           
 boolean isUseColorArea2D()
           
 boolean isUseLabels()
           
 void layout()
          Called when the layoutInvalid flag is set.
 void removeCallback(java.lang.Runnable cb)
           
 void setColor(Color color)
           
protected  void setColor(int argb)
           
 void setColorSpace(ColorSpace colorModel)
           
 void setDefaultColor()
           
 void setModel(ColorModel model)
           
 void setShowAlphaAdjuster(boolean showAlphaAdjuster)
           
 void setShowHexEditField(boolean showHexEditField)
          Includes an edit field which allows to edit the color hex values in ARGB.
 void setShowNativeAdjuster(boolean showNativeAdjuster)
          Includes adjuster for each clor component of the specified color space.
 void setShowPreview(boolean showPreview)
          Show the currently selected color in a preview widget.
 void setShowRGBAdjuster(boolean showRGBAdjuster)
           
 void setUseColorArea2D(boolean useColorArea2D)
          Use 2D color areas.
 void setUseLabels(boolean useLabels)
          Show labels infront of the value adjusters for the color components.
protected  void updateAllColorAreas()
           
protected  void updateModel()
           
 
Methods inherited from class de.matthiasmann.twl.DialogLayout
addDefaultGaps, adjustSize, applyTheme, applyThemeDialogLayout, childVisibilityChanged, createParallelGroup, createParallelGroup, createParallelGroup, createSequentialGroup, createSequentialGroup, createSequentialGroup, doLayout, getDefaultGap, getHorizontalGroup, getLargeGap, getMediumGap, getSmallGap, getVerticalGroup, insertChild, invalidateLayout, isAddDefaultGaps, isIncludeInvisibleWidgets, layoutGroupsChanged, maybeInvalidateLayoutTree, paintWidget, prepare, recheckWidgets, removeAllChildren, removeChild, removeDefaultGaps, setAddDefaultGaps, setDefaultGap, setHorizontalGroup, setIncludeInvisibleWidgets, setLargeGap, setMediumGap, setSmallGap, setVerticalGroup, setWidgetAlignment, sizeChanged
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, computeSize, destroy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleEvent, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, positionChanged, reapplyTheme, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorSelector

public ColorSelector(ColorSpace colorSpace)
Method Detail

getColorSpace

public ColorSpace getColorSpace()

setColorSpace

public void setColorSpace(ColorSpace colorModel)

getModel

public ColorModel getModel()

setModel

public void setModel(ColorModel model)

getColor

public Color getColor()

setColor

public void setColor(Color color)

setDefaultColor

public void setDefaultColor()

isUseColorArea2D

public boolean isUseColorArea2D()

setUseColorArea2D

public void setUseColorArea2D(boolean useColorArea2D)
Use 2D color areas. Color component 0 is the X axis and component 1 the Y axis of the first 2D area, etc. If the number of color components is odd then the last component is displayed with a 1D. If disabled all components are displayed using 1D color areas.

Parameters:
useColorArea2D - true if 2D areas should be used

isShowPreview

public boolean isShowPreview()

setShowPreview

public void setShowPreview(boolean showPreview)
Show the currently selected color in a preview widget. Default is false.

Parameters:
showPreview - true if the preview widget should be displayed

isShowHexEditField

public boolean isShowHexEditField()

setShowHexEditField

public void setShowHexEditField(boolean showHexEditField)
Includes an edit field which allows to edit the color hex values in ARGB. Default is false.

Parameters:
showHexEditField - true if the edit field should be shown

isShowAlphaAdjuster

public boolean isShowAlphaAdjuster()

setShowAlphaAdjuster

public void setShowAlphaAdjuster(boolean showAlphaAdjuster)

isShowNativeAdjuster

public boolean isShowNativeAdjuster()

setShowNativeAdjuster

public void setShowNativeAdjuster(boolean showNativeAdjuster)
Includes adjuster for each clor component of the specified color space. Default is true.

Parameters:
showNativeAdjuster - true if the native adjuster should be displayed

isShowRGBAdjuster

public boolean isShowRGBAdjuster()

setShowRGBAdjuster

public void setShowRGBAdjuster(boolean showRGBAdjuster)

isUseLabels

public boolean isUseLabels()

setUseLabels

public void setUseLabels(boolean useLabels)
Show labels infront of the value adjusters for the color components. Default is true.

Parameters:
useLabels - true if labels should be displayed

addCallback

public void addCallback(java.lang.Runnable cb)

removeCallback

public void removeCallback(java.lang.Runnable cb)

updateModel

protected void updateModel()

colorChanged

protected void colorChanged()

setColor

protected void setColor(int argb)

getNumComponents

protected int getNumComponents()

layout

public void layout()
Description copied from class: Widget
Called when the layoutInvalid flag is set. The default implementation does nothing.

Overrides:
layout in class DialogLayout

getMinWidth

public int getMinWidth()
Description copied from class: Widget
Returns the minimum width of the widget. Layout manager will allocate atleast the minimum width to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinWidth in class DialogLayout
Returns:
the minimum width of the widget

getMinHeight

public int getMinHeight()
Description copied from class: Widget
Returns the minimum height of the widget. Layout manager will allocate atleast the minimum height to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinHeight in class DialogLayout
Returns:
the minimum height of the widget

getPreferredInnerWidth

public int getPreferredInnerWidth()
Description copied from class: Widget
Computes the preferred inner width (the size of the widget without the border) The default implementation uses the current position of the children. It is highly recommended to override this method as the default implementation lead to unstable layouts. The default behavior might change in the future to provide a better default behavior.

Overrides:
getPreferredInnerWidth in class DialogLayout
Returns:
the preferred inner width

getPreferredInnerHeight

public int getPreferredInnerHeight()
Description copied from class: Widget
Computes the preferred inner height (the size of the widget without the border) The default implementation uses the current position of the children. It is highly recommended to override this method as the default implementation lead to unstable layouts. The default behavior might change in the future to provide a better default behavior.

Overrides:
getPreferredInnerHeight in class DialogLayout
Returns:
the preferred inner height

createColorAreas

protected void createColorAreas()

updateAllColorAreas

protected void updateAllColorAreas()

afterAddToGUI

protected void afterAddToGUI(GUI gui)
Description copied from class: Widget
Called after this widget has been added to a GUI tree.

Overrides:
afterAddToGUI in class DialogLayout
Parameters:
gui - the GUI object - same as getGUI()
See Also:
Widget.getGUI()

beforeRemoveFromGUI

protected void beforeRemoveFromGUI(GUI gui)
Description copied from class: Widget
Called when this widget is removed from the GUI tree. After this call getGUI() will return null.

Overrides:
beforeRemoveFromGUI in class Widget
Parameters:
gui - the GUI object - same as getGUI()
See Also:
Widget.getGUI()