visidia.misc.colorpalette
Class ColorPaletteManager

java.lang.Object
  extended by visidia.misc.colorpalette.ColorPaletteManager

public class ColorPaletteManager
extends java.lang.Object

ColorPaletteManager is used to manage color palettes.


Method Summary
 ColorPalette createAndUseNewPalette(int nbColors)
          Creates a new palette and sets it as current palette.
 java.util.Enumeration<java.lang.Object> getAllKeys()
          Returns custom palette keys if defined.
 java.awt.Color getColor(java.lang.Object key)
          Gets the color associated to key.
static ColorPaletteManager getInstance()
          Gets the single instance of ColorPaletteManager.
 java.util.Enumeration<java.lang.Object> getStandardKeys()
          Gets keys of standard palette.
 void resetPalette()
          Resets current palette to standard palette.
 void setCustomPalette(ColorPalette colorPalette)
          Sets the custom palette.
 int size()
          Returns the number of colors in current palette.
 boolean useCustomPalette()
          Tells if using a custom palette.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ColorPaletteManager getInstance()
Gets the single instance of ColorPaletteManager.

Returns:
single instance of ColorPaletteManager

resetPalette

public void resetPalette()
Resets current palette to standard palette.


useCustomPalette

public boolean useCustomPalette()
Tells if using a custom palette.

Returns:
true, if using a custom palette

createAndUseNewPalette

public ColorPalette createAndUseNewPalette(int nbColors)
Creates a new palette and sets it as current palette.

Parameters:
nbColors - the number of colors to generate
Returns:
the color palette

getColor

public java.awt.Color getColor(java.lang.Object key)
Gets the color associated to key. First search in custom palette. If not defined or if it does not contain the key, then search in standard palette. If no match found, return null.

Parameters:
key - the key
Returns:
the color

getAllKeys

public java.util.Enumeration<java.lang.Object> getAllKeys()
Returns custom palette keys if defined. Else returns standard palette keys.

Returns:
the keys

getStandardKeys

public java.util.Enumeration<java.lang.Object> getStandardKeys()
Gets keys of standard palette.

Returns:
the keys

size

public int size()
Returns the number of colors in current palette.

Returns:
the palette size

setCustomPalette

public void setCustomPalette(ColorPalette colorPalette)
Sets the custom palette.

Parameters:
colorPalette - the new custom palette