vitro
Class ColorScheme

java.lang.Object
  extended by vitro.ColorScheme

public class ColorScheme
extends Object

ColorSchemes collect a group of Colors together and provide an easy way to make Views customizable.


Field Summary
 Color background
           
 Color inactive
           
 Color outline
           
 Color secondary
           
 Map<Object,Color> uniqueColors
           
 
Constructor Summary
ColorScheme()
          Create a new ColorScheme with a default grayscale palette.
ColorScheme(Color outline, Color secondary, Color background)
          Create a new ColorScheme with specified theme colors.
 
Method Summary
 void drawKey(Graphics g, int x, int y)
          Draw a key representing the color mappings in this ColorScheme at a specified location onscreen.
 void setColor(Object o, Color color)
          Manually configure the key color for a specific object.
 Color unique(Object o)
          Produce a unique, consistent color based on an object reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outline

public Color outline

secondary

public Color secondary

background

public Color background

inactive

public Color inactive

uniqueColors

public final Map<Object,Color> uniqueColors
Constructor Detail

ColorScheme

public ColorScheme()
Create a new ColorScheme with a default grayscale palette.


ColorScheme

public ColorScheme(Color outline,
                   Color secondary,
                   Color background)
Create a new ColorScheme with specified theme colors.

Parameters:
outline - the color to use for drawing shapes and text.
secondary - the color to use for less important or prominent information.
background - the background color for the associated View.
Method Detail

setColor

public void setColor(Object o,
                     Color color)
Manually configure the key color for a specific object.

Parameters:
o - the object to associate with a color.
color - the color to assign to the object.

unique

public Color unique(Object o)
Produce a unique, consistent color based on an object reference. Colors will attempt to be as visually distinct as possible. If an object already as an associated color stored, that color will be returned. Otherwise a new mapping will be created.

Parameters:
o - the object to associate with a color.
Returns:
a unique color.

drawKey

public void drawKey(Graphics g,
                    int x,
                    int y)
Draw a key representing the color mappings in this ColorScheme at a specified location onscreen. If the subject of any mappings is a Class object, this method will additionally attempt to normalize the class name, discarding package names and outer class names.

Parameters:
g - the destination Graphics surface.
x - the x-offset of the key, in pixels.
y - the y-offset of the key, in pixels.