de.unihalle.informatik.MiToBo.drawing
Class DynamicColorLUT

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.drawing.DynamicColorLUT

public class DynamicColorLUT
extends java.lang.Object

A color lookup table that generates colors dynamically and randomly for indices that do not exist.

Author:
Oliver Gress

Field Summary
private  int coffset
           
private  java.util.HashMap<java.lang.Integer,java.lang.Integer> colors
           
private  java.util.Random rand
           
 
Constructor Summary
DynamicColorLUT()
          Constructor with a (seeded) random generator and channel offset = 20.
DynamicColorLUT(java.util.Random rand)
          Constructor for a specific random generator and channel offset = 20..
DynamicColorLUT(java.util.Random rand, int channeloffset)
          Constructor for a specific random generator and a given channel offset
 
Method Summary
 int getColor(int key)
          Get the color for a given key.
 void setColor(int key, int color)
          Set the color for given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coffset

private int coffset

colors

private java.util.HashMap<java.lang.Integer,java.lang.Integer> colors

rand

private java.util.Random rand
Constructor Detail

DynamicColorLUT

public DynamicColorLUT()
Constructor with a (seeded) random generator and channel offset = 20.


DynamicColorLUT

public DynamicColorLUT(java.util.Random rand)
Constructor for a specific random generator and channel offset = 20..


DynamicColorLUT

public DynamicColorLUT(java.util.Random rand,
                       int channeloffset)
Constructor for a specific random generator and a given channel offset

Parameters:
rand - random generator
channeloffset - the minimum value of R, G and B
Method Detail

getColor

public int getColor(int key)
Get the color for a given key. Generates a random color if key is not present.

Parameters:
key - lookup table key (or index)
Returns:
color coded into an integer (lowest byte: blue, second-lowest byte: green, third-lowest byte: red)

setColor

public void setColor(int key,
                     int color)
Set the color for given key.