net.java.dev.colorchooser
Class Palette

java.lang.Object
  extended by net.java.dev.colorchooser.Palette

public abstract class Palette
extends Object

Model for a palette that can be painted, and from which colors may be selected. An array of palettes to use may be supplied to a ColorChooser via the setPalettes method.


Constructor Summary
Palette()
           
 
Method Summary
static Palette createContinuousPalette(String name, Dimension size, float saturation)
           
static Palette createPredefinedPalette(String name, Color[] colors, String[] names)
           
abstract  Color getColorAt(int x, int y)
          Returns the color at the specified point, or null if the point is beyond the bounds of the palette or in an area that does not indicate a color
static Palette[] getDefaultPalettes(boolean continuousFirst)
          Get the default set of 8 palettes used by the color chooser.
abstract  String getDisplayName()
          Get a localized name for this palette or null if a display name is not warranted
abstract  String getNameAt(int x, int y)
          Returns a string description of the color at the point.
abstract  Dimension getSize()
          Get the on-screen size of this palette
abstract  void paintTo(Graphics g)
          Paint this palette to a graphics context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Palette

public Palette()
Method Detail

getColorAt

public abstract Color getColorAt(int x,
                                 int y)
Returns the color at the specified point, or null if the point is beyond the bounds of the palette or in an area that does not indicate a color

Parameters:
x - - an horizontal coordinate in the coordinate space of the palette
y - - a vertical coordinate in the coordinate space of the palette
Returns:
- a color or null

getNameAt

public abstract String getNameAt(int x,
                                 int y)
Returns a string description of the color at the point. May be a name or a set of RGB values, but should not be longer than 30 characters. Returns null if the position is outside the bounds of the palette or has no description associated with it. Generally getNameAt() should return null from the same coordinates that getColorAt() would.

Parameters:
x - an horizontal coordinate in the coordinate space of the palette
y - a vertical coordinate in the coordinate space of the palette
Returns:
a string describing the color at this coordinate or null
See Also:
getColorAt(int, int)

paintTo

public abstract void paintTo(Graphics g)
Paint this palette to a graphics context.

Parameters:
g - - a graphics context to paint into

getSize

public abstract Dimension getSize()
Get the on-screen size of this palette

Returns:
the size of this palette - corresponding to the screen space required to display it and defining the coordinate space of this palette.

getDisplayName

public abstract String getDisplayName()
Get a localized name for this palette or null if a display name is not warranted

Returns:
the display name

getDefaultPalettes

public static final Palette[] getDefaultPalettes(boolean continuousFirst)
Get the default set of 8 palettes used by the color chooser. If continuousFirst is true, the first four will be continuous palettes and the second four swatches with named colors, system colors, etc.


createContinuousPalette

public static final Palette createContinuousPalette(String name,
                                                    Dimension size,
                                                    float saturation)

createPredefinedPalette

public static final Palette createPredefinedPalette(String name,
                                                    Color[] colors,
                                                    String[] names)