RePast
v. 2.0

uchicago.src.sim.gui
Class ColorMap

java.lang.Object
  |
  +--uchicago.src.sim.gui.ColorMap

public class ColorMap
extends Object

A customizable map of java.awt.Color(s) to Integers. Useful for displaying collections of Integers, such as an Object2DGrid, as colors.

Note that using the method that take int arguments is faster than those that take the Integer arguments.


Field Summary
static Color black
           
static Color blue
           
static Color cyan
           
static Color darkGray
           
static Color gray
           
static Color green
           
static Color lightGray
           
static Color magenta
           
static Color orange
           
static Color pink
           
static Color red
           
static Color white
           
static Color yellow
           
 
Constructor Summary
ColorMap()
           
 
Method Summary
 Color getColor(int i)
          Gets the color mapped to the specified int
 Color getColor(Integer i)
          Gets the color mapped to the specified Integer
 void mapColor(int i, Color c)
          Maps the specified color to the specified int
 void mapColor(int i, double red, double green, double blue)
          Maps the color specified by the red, green, and blue values to to the int i.
 void mapColor(Integer i, Color c)
          Maps the specified color to the specified Integer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

white

public static final Color white

lightGray

public static final Color lightGray

gray

public static final Color gray

darkGray

public static final Color darkGray

black

public static final Color black

red

public static final Color red

pink

public static final Color pink

orange

public static final Color orange

yellow

public static final Color yellow

green

public static final Color green

magenta

public static final Color magenta

cyan

public static final Color cyan

blue

public static final Color blue
Constructor Detail

ColorMap

public ColorMap()
Method Detail

mapColor

public void mapColor(Integer i,
                     Color c)
Maps the specified color to the specified Integer

Parameters:
i - the integer to map the color to
c - the color to map to the Integer

mapColor

public void mapColor(int i,
                     Color c)
Maps the specified color to the specified int

Parameters:
i - the int to map the color to
c - the color to map to the int

mapColor

public void mapColor(int i,
                     double red,
                     double green,
                     double blue)
Maps the color specified by the red, green, and blue values to to the int i. Red, green, and blue should be doubles in the range [0, 1] where 1 is the equivalent of the full color (255), and 0 is no color. This system makes it easy to set color values within a loop. For example,
 for (int i = 0; i < 64; i++) { 
map.setColor(i, i / 63.0, 0, 0)
}
This will set 64 shades of red.

Parameters:
i - the int to map the color to
red - a double in the range of [0, 1]
blue - a double in the range of [0, 1]
green - a double in the range of [0, 1]

getColor

public Color getColor(Integer i)
Gets the color mapped to the specified Integer


getColor

public Color getColor(int i)
Gets the color mapped to the specified int


RePast
v. 2.0

Bug reports and feature requests to RePast