ImageScience 3.0.0

imagescience.color
Class Palette

java.lang.Object
  extended by imagescience.color.Palette

public class Palette
extends java.lang.Object

A palette of 100 different colors.


Field Summary
static int ARBITRARY
          The arbitrary mode.
static int SPECTRUM
          The spectrum mode.
 
Constructor Summary
Palette()
          Default constructor.
Palette(int mode)
          Mode constructor.
 
Method Summary
 java.awt.Color get(int index)
          Returns the color at the given index (modulo 100).
 int index(java.awt.Color color)
          Returns the index of the given color.
 int mode()
          Returns the palette mode.
 java.awt.Color next()
          Returns the next color.
 void reset()
          Resets the counter used by the next() method.
 void used(java.awt.Color color)
          Marks the given color as used if it is in the palette.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPECTRUM

public static final int SPECTRUM
The spectrum mode. If the palette is operating in this mode, the get(int) method (with index running from 0 to 99) and the next() method both yield a 5x20 color spectrum (meaning 5 different tints of each of the 20 different colors sampled from the visible spectrum).

See Also:
Constant Field Values

ARBITRARY

public static final int ARBITRARY
The arbitrary mode. If the palette is operating in this mode, the get(int) method (with index running from 0 to 99) and the next() method both yield the same set of colors as in the spectrum mode, but put in arbitrary (yet fixed) order, such that the perceptual difference between successive colors is much larger.

See Also:
Constant Field Values
Constructor Detail

Palette

public Palette()
Default constructor. Results in a palette operating in the arbitrary mode.


Palette

public Palette(int mode)
Mode constructor. Results in a palette operating in the given mode.

Parameters:
mode - The palette mode. Must be one of the static fields of this class.
Throws:
java.lang.IllegalArgumentException - If mode is not one of the static fields of this class.
Method Detail

mode

public int mode()
Returns the palette mode.

Returns:
The palette mode. The returned value is equal to one of the static fields of this class.

get

public java.awt.Color get(int index)
Returns the color at the given index (modulo 100).

Parameters:
index - The index.
Returns:
The color at the given index (modulo 100). The actual color returned depends on the mode of the palette.

index

public int index(java.awt.Color color)
Returns the index of the given color.

Parameters:
color - The color.
Returns:
The index of the given color. The actual index returned depends on the mode of the palette. If color is null or it is not in the palette, the method returns -1.

next

public java.awt.Color next()
Returns the next color. Calling this method repeatedly yields a sequence of colors with a period of 100 colors. Colors that have been marked explicitly as used will first be skipped until all colors have been used and a new cycle is started.

Returns:
The next color. The actual color returned depends on the mode of the palette.

used

public void used(java.awt.Color color)
Marks the given color as used if it is in the palette. Colors that have been marked as used will first be skipped by the next() method until all colors have been used and a new cycle is started.

Parameters:
color - The color.

reset

public void reset()
Resets the counter used by the next() method.


ImageScience 3.0.0

Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.

IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.

IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.