com.threerings.opengl.gui
Class ColorPicker

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.ColorPicker
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, Selectable<com.threerings.media.image.ColorPository.ColorRecord>

public class ColorPicker
extends Component
implements Selectable<com.threerings.media.image.ColorPository.ColorRecord>

Allows the selection of a single color from a set of swatches.


Field Summary
 
Fields inherited from class com.threerings.opengl.gui.Component
DEFAULT, DISABLED, HOVER
 
Fields inherited from interface com.threerings.opengl.gui.Selectable
SELECT
 
Constructor Summary
ColorPicker(GlContext ctx)
          Creates an uninitialized color picker.
ColorPicker(GlContext ctx, String colorClass, int swatchWidth, int swatchHeight)
          Creates a new color picker.
 
Method Summary
 boolean dispatchEvent(Event event)
          Instructs this component to process the supplied event.
 com.threerings.media.image.ColorPository.ColorRecord getSelected()
          Get the selected item, if any.
 com.threerings.media.image.ColorPository.ColorRecord getSelectedColor()
          Deprecated. 
 int getSelectedIndex()
          Get the index of the selected item, or -1.
 void setColorClass(String colorClass)
          Sets the color class from which we select.
 void setColorClass(String colorClass, boolean starters)
          Sets the color class from which we select.
 void setSelected(com.threerings.media.image.ColorPository.ColorRecord color)
          Set the selected item.
 void setSelectedColor(com.threerings.media.image.ColorPository.ColorRecord color)
          Deprecated. 
 void setSelectedIndex(int sidx)
          Set the index of the selected item.
 void setSwatchSize(int swatchWidth, int swatchHeight)
          Sets the dimensions of the swatches.
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFocusTarget, getHeight, getHitComponent, getInsets, getParent, getPreferredSize, getProperty, getState, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getX, getY, hasFocus, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, requestFocus, scrollRectToVisible, setAlpha, setBackground, setBounds, setCursor, setEnabled, setHoverable, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorPicker

public ColorPicker(GlContext ctx,
                   String colorClass,
                   int swatchWidth,
                   int swatchHeight)
Creates a new color picker.

Parameters:
colorClass - the color class from which we select.
swatchWidth - the width of the swatches.
swatchHeight - the height of the swatches.

ColorPicker

public ColorPicker(GlContext ctx)
Creates an uninitialized color picker.

Method Detail

setColorClass

public void setColorClass(String colorClass)
Sets the color class from which we select.


setColorClass

public void setColorClass(String colorClass,
                          boolean starters)
Sets the color class from which we select.

Parameters:
starters - if true, only allow the starter colors.

setSwatchSize

public void setSwatchSize(int swatchWidth,
                          int swatchHeight)
Sets the dimensions of the swatches.


getSelected

public com.threerings.media.image.ColorPository.ColorRecord getSelected()
Description copied from interface: Selectable
Get the selected item, if any.

Specified by:
getSelected in interface Selectable<com.threerings.media.image.ColorPository.ColorRecord>

setSelected

public void setSelected(com.threerings.media.image.ColorPository.ColorRecord color)
Description copied from interface: Selectable
Set the selected item.

Specified by:
setSelected in interface Selectable<com.threerings.media.image.ColorPository.ColorRecord>

setSelectedColor

@Deprecated
public void setSelectedColor(com.threerings.media.image.ColorPository.ColorRecord color)
Deprecated. 


getSelectedColor

@Deprecated
public com.threerings.media.image.ColorPository.ColorRecord getSelectedColor()
Deprecated. 


setSelectedIndex

public void setSelectedIndex(int sidx)
Description copied from interface: Selectable
Set the index of the selected item.

Specified by:
setSelectedIndex in interface Selectable<com.threerings.media.image.ColorPository.ColorRecord>

getSelectedIndex

public int getSelectedIndex()
Description copied from interface: Selectable
Get the index of the selected item, or -1.

Specified by:
getSelectedIndex in interface Selectable<com.threerings.media.image.ColorPository.ColorRecord>

dispatchEvent

public boolean dispatchEvent(Event event)
Description copied from class: Component
Instructs this component to process the supplied event. If the event is not processed, it will be passed up to its parent component for processing. Derived classes should thus only call super.dispatchEvent for events that they did not "consume".

Overrides:
dispatchEvent in class Component
Returns:
true if this event was consumed, false if not.


Copyright © 2011. All Rights Reserved.