org.processmining.mining.dmcscanning.ui
Class ColorRepository

java.lang.Object
  extended by org.processmining.mining.dmcscanning.ui.ColorRepository

public class ColorRepository
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:
Christian W. Guenther (christian at deckfour dot org)

Field Summary
protected  boolean[] assigned
           
protected  java.awt.Color[] colors
           
protected  java.util.HashMap mappings
           
protected  java.util.Random rnd
           
 
Constructor Summary
ColorRepository()
          constructor
 
Method Summary
 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

ColorRepository

public ColorRepository()
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