DESY ACOP Beans Home

com.cosylab.gui.components.util
Class ColorManager

java.lang.Object
  extended by com.cosylab.gui.components.util.ColorManager

public class ColorManager
extends java.lang.Object

ColorManager provides a sequence of colors which can be used for example in charts.

Version:
$Id: ColorManager.java,v 1.8 2008-08-14 11:01:56 jbobnar Exp $
Author:
Jaka Bobnar

Field Summary
static java.awt.Color[] DEFAULT_COLORS
           
 
Constructor Summary
ColorManager()
           
 
Method Summary
 void dropColor(java.awt.Color color)
          Drops the color into a container with unused colors.
 int getColorIndex()
          Returns the current index at which the color is picked from the array.
 void loadColors(java.awt.Color[] colors)
          Loads the colors among which manager will pick a color when requested.
 void loadDefaultColors()
          Loads Default colors as the colors used by this manager.
 java.awt.Color pickColor()
          Picks the next color in the sequence.
 java.awt.Color previewNextColor()
          Previews the next color that will be picked.
 void reset()
          Empties the container with all dropped colors.
 void setColorIndex(int index)
          Sets the index at which the next color will be picked from array.
 void setIndexByColor(java.awt.Color color)
          Sets the color which will be the next to be picked out from the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COLORS

public static final java.awt.Color[] DEFAULT_COLORS
Constructor Detail

ColorManager

public ColorManager()
Method Detail

loadDefaultColors

public void loadDefaultColors()
Loads Default colors as the colors used by this manager.


loadColors

public void loadColors(java.awt.Color[] colors)
Loads the colors among which manager will pick a color when requested.

Parameters:
colors - color bank (null or zero-length value not permitted)

pickColor

public java.awt.Color pickColor()
Picks the next color in the sequence.

Returns:
the next color

dropColor

public void dropColor(java.awt.Color color)
Drops the color into a container with unused colors. When a new color will be picked, the manager will first choose among the dropped color and when there will be no more, it will continue the normal sequence as stated in the loaded colors.

Parameters:
color - color to be dropped into the bank

getColorIndex

public int getColorIndex()
Returns the current index at which the color is picked from the array.

Returns:
color index

setColorIndex

public void setColorIndex(int index)
Sets the index at which the next color will be picked from array.

Parameters:
index - new color index

setIndexByColor

public void setIndexByColor(java.awt.Color color)
Sets the color which will be the next to be picked out from the array. It the provided color does not exist nothing will change.

Parameters:
color - the next color

reset

public void reset()
Empties the container with all dropped colors.


previewNextColor

public java.awt.Color previewNextColor()
Previews the next color that will be picked.

Returns:
the next color


Copyright © 2010. All Rights Reserved.