JHotDraw 7.6

org.jhotdraw.color
Class DefaultColorSliderModel

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.color.AbstractColorSlidersModel
          extended by org.jhotdraw.color.DefaultColorSliderModel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ColorSliderModel
Direct Known Subclasses:
PaletteColorSliderModel

public class DefaultColorSliderModel
extends AbstractColorSlidersModel

DefaultColorSliderModel.

Version:
$Id: DefaultColorSliderModel.java 717 2010-11-21 12:30:57Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
protected  java.awt.color.ColorSpace colorSpace
           
protected  javax.swing.DefaultBoundedRangeModel[] componentModels
          Components of the color model.
protected  java.util.LinkedList<javax.swing.JSlider> sliders
          JSlider's associated to this model.
 
Fields inherited from class org.jhotdraw.color.AbstractColorSlidersModel
listeners
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Constructor Summary
DefaultColorSliderModel()
          Creates a color slider model with an ICC sRGB color space.
DefaultColorSliderModel(java.awt.color.ColorSpace sys)
          Creates a color slider model with the specified color space.
 
Method Summary
 void addColorSlider(javax.swing.JSlider slider)
           
 void configureSlider(int componentIndex, javax.swing.JSlider slider)
          Configures a JSlider for this model.
protected  void fireColorChanged(int componentIndex)
           
 javax.swing.DefaultBoundedRangeModel getBoundedRangeModel(int componentIndex)
          Returns the bounded range model of the specified color componentIndex.
 java.awt.Color getColor()
          Returns the color value of the model.
 java.awt.color.ColorSpace getColorSpace()
          Returns the ColorSpace used by this ColorSliderModel.
 float getComponent(int i)
          Gets a value of an individual component.
 int getComponentCount()
          Returns the number of components used by this ColorSliderModel.
 float[] getComponents()
          Gets all component values.
 int getInterpolatedRGB(int i, float componentValue)
          Returns an RGB value based on the value of the specified component index and value, based on the values of all other components of the model.
 int getSliderValue(int componentIndex)
          Returns the value of the specified color componentIndex.
 void removeColorSlider(javax.swing.JSlider slider)
           
 void setColor(java.awt.Color newValue)
          Sets the color value of the model.
 void setColorSpace(java.awt.color.ColorSpace newValue)
          Changes the ColorSpace used by this ColorSliderModel.
 void setComponent(int i, float newValue)
          Sets a value for an individual component.
 void setSliderValue(int componentIndex, int value)
          Sets the value of the specified color componentIndex.
 void unconfigureSlider(javax.swing.JSlider slider)
          Unconfigures a JSlider from this model.
 
Methods inherited from class org.jhotdraw.color.AbstractColorSlidersModel
addChangeListener, fireStateChanged, removeChangeListener
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorSpace

protected java.awt.color.ColorSpace colorSpace

sliders

protected java.util.LinkedList<javax.swing.JSlider> sliders
JSlider's associated to this model.


componentModels

protected javax.swing.DefaultBoundedRangeModel[] componentModels
Components of the color model.

Constructor Detail

DefaultColorSliderModel

public DefaultColorSliderModel()
Creates a color slider model with an ICC sRGB color space.


DefaultColorSliderModel

public DefaultColorSliderModel(java.awt.color.ColorSpace sys)
Creates a color slider model with the specified color space.

Method Detail

setColorSpace

public void setColorSpace(java.awt.color.ColorSpace newValue)
Description copied from interface: ColorSliderModel
Changes the ColorSpace used by this ColorSliderModel.

Parameters:
newValue - ColorSpace.

configureSlider

public void configureSlider(int componentIndex,
                            javax.swing.JSlider slider)
Configures a JSlider for this model. If the JSlider is already configured for another model, it is unconfigured first.


unconfigureSlider

public void unconfigureSlider(javax.swing.JSlider slider)
Unconfigures a JSlider from this model.


getBoundedRangeModel

public javax.swing.DefaultBoundedRangeModel getBoundedRangeModel(int componentIndex)
Returns the bounded range model of the specified color componentIndex.

Parameters:
componentIndex - .
Returns:
BoundedRangeModel.

getSliderValue

public int getSliderValue(int componentIndex)
Returns the value of the specified color componentIndex.


setSliderValue

public void setSliderValue(int componentIndex,
                           int value)
Sets the value of the specified color componentIndex.


addColorSlider

public void addColorSlider(javax.swing.JSlider slider)

removeColorSlider

public void removeColorSlider(javax.swing.JSlider slider)

fireColorChanged

protected void fireColorChanged(int componentIndex)

getColorSpace

public java.awt.color.ColorSpace getColorSpace()
Description copied from interface: ColorSliderModel
Returns the ColorSpace used by this ColorSliderModel.

Returns:
ColorSpace.

getComponentCount

public int getComponentCount()
Description copied from interface: ColorSliderModel
Returns the number of components used by this ColorSliderModel.

Returns:
Component count.

getColor

public java.awt.Color getColor()
Description copied from interface: ColorSliderModel
Returns the color value of the model. This is a convenience method for calling getCompositeColor().getColor().

Returns:
color.

getInterpolatedRGB

public int getInterpolatedRGB(int i,
                              float componentValue)
Description copied from interface: ColorSliderModel
Returns an RGB value based on the value of the specified component index and value, based on the values of all other components of the model.

Returns:
RGB value.

setComponent

public void setComponent(int i,
                         float newValue)
Description copied from interface: ColorSliderModel
Sets a value for an individual component.


getComponent

public float getComponent(int i)
Description copied from interface: ColorSliderModel
Gets a value of an individual component.

Returns:
Value

setColor

public void setColor(java.awt.Color newValue)
Description copied from interface: ColorSliderModel
Sets the color value of the model. This is a convenience method for calling setCompositeColor(new CompositeColor(getColorSpace(), color.getRGB());

Parameters:
newValue - .

getComponents

public float[] getComponents()
Description copied from interface: ColorSliderModel
Gets all component values.

Returns:
Values.

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.