org.processmining.analysis.performance.dottedchart.ui
Class ColorReference

java.lang.Object
  extended by org.processmining.analysis.performance.dottedchart.ui.ColorReference

public class ColorReference
extends java.lang.Object

ColorRepository. For assigning colors to keys automatically, and preserving these associations over time. Keeps string ids assigned to colors and preserves mappings. Provides a set of 10 standard colors for mappings, when full it will return random colors.

Author:
Minseok Song

Field Summary
protected  boolean[] assigned
           
protected  java.awt.Color[] colors
           
protected  java.util.HashMap mappings
           
protected  java.util.Random rnd
           
 
Constructor Summary
ColorReference()
          constructor
 
Method Summary
 void assignColor(java.lang.String key, java.awt.Color color)
           
 void freeColor(java.lang.String key)
          Frees a keyed color object for new assignment, i.e.
 java.awt.Color getColor(java.lang.String key)
          Retrieves the color mapped to the given key (identity preserved).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mappings

protected java.util.HashMap mappings

colors

protected java.awt.Color[] colors

assigned

protected boolean[] assigned

rnd

protected java.util.Random rnd
Constructor Detail

ColorReference

public ColorReference()
constructor

Method Detail

getColor

public java.awt.Color getColor(java.lang.String key)
Retrieves the color mapped to the given key (identity preserved). If no color was previously mapped, a new one is taken from the standard repository and, if all taken, a random color is assigned.

Parameters:
key - the key to map a color to
Returns:
mapped color instance

freeColor

public void freeColor(java.lang.String key)
Frees a keyed color object for new assignment, i.e. it is not used anymore.

Parameters:
key - previously assigned key

assignColor

public void assignColor(java.lang.String key,
                        java.awt.Color color)