edu.washington.NVisF.plotter
Class ColoringStrategy

java.lang.Object
  |
  +--edu.washington.NVisF.plotter.ColoringStrategy
Direct Known Subclasses:
SandColoringStrategy, SSColoringStrategy

public class ColoringStrategy
extends java.lang.Object

A ColoringStrategy defines how to construct colors from the available data. This class uses a single customizable color for every object. Several predefined colors are available which can be accessed by handle or by name, and a default color is defined in case none is selected by the user. Subclasses of this class can override the get methods to provide different behavior. Two different methods for getting colors are provided. The idea is that a single data object could be displayed with a simple one-component representation or a multiple component representation. In the latter case, one could define multiple colors, one for each component. The PlotCommand provides only the number of data objects. The getColors method returns one color per object, while the getMultiColors method takes an extra argument, the number of colors per data object, and returns a array of length (#objects)*(#colors/object) where colors 0...m-1 are the m colors for the first data object, etc. The default behavior of this method is to simply duplicate the single colors to fill the desired array.


Field Summary
static Color3f blue
           
static Color3f DEFAULT_COLOR
          The default color, currently equal to white.
static Color3f green
           
static Color3f red
           
static Color3f white
           
static Color3f yellow
           
 
Constructor Summary
ColoringStrategy()
          Creates a new ColoringStrategy using the default color.
ColoringStrategy(Color3f color)
          Creates a new ColoringStrategy using the specified color.
 
Method Summary
 Color3f[] fillWithSingleColor(int numObjects)
          returns a Color3f[] of length numObjects where every color is the same as this ColoringStrategy's defined color.
 Color3f getColor()
          returns this ColoringStrategy's defined color.
static java.util.Map getColorNameMap()
          Returns a Map between names of colors and the colors.
 Color3f[] getColors(PlotCommand command)
          Returns an array containing one color for each data object according to the particular algorithm of this ColoringStrategy.
static java.util.List getKnownColors()
          Returns a List of Strings containing the names of all known colors.
 Color3f[] getMultiColors(PlotCommand command, int vCount)
          Returns an array containing vCount colors for each data object.
 Color3f setColor(Color3f color)
          sets the color used by this ColoringStrategy.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

white

public static final Color3f white

red

public static final Color3f red

blue

public static final Color3f blue

yellow

public static final Color3f yellow

green

public static final Color3f green

DEFAULT_COLOR

public static final Color3f DEFAULT_COLOR
The default color, currently equal to white.
Constructor Detail

ColoringStrategy

public ColoringStrategy()
Creates a new ColoringStrategy using the default color.

ColoringStrategy

public ColoringStrategy(Color3f color)
Creates a new ColoringStrategy using the specified color.
Method Detail

getColorNameMap

public static java.util.Map getColorNameMap()
Returns a Map between names of colors and the colors.

getKnownColors

public static java.util.List getKnownColors()
Returns a List of Strings containing the names of all known colors.

getColors

public Color3f[] getColors(PlotCommand command)
Returns an array containing one color for each data object according to the particular algorithm of this ColoringStrategy.
Parameters:
command - the PlotCommand providing data

getMultiColors

public Color3f[] getMultiColors(PlotCommand command,
                                int vCount)
Returns an array containing vCount colors for each data object.
Parameters:
command - the PlotCommand providing data
vCount - the desired number of colors per object
Returns:
Color3f[] an array of colors where 0...vCount-1 are for the first data object

fillWithSingleColor

public Color3f[] fillWithSingleColor(int numObjects)
returns a Color3f[] of length numObjects where every color is the same as this ColoringStrategy's defined color.

getColor

public Color3f getColor()
returns this ColoringStrategy's defined color.

setColor

public Color3f setColor(Color3f color)
sets the color used by this ColoringStrategy. The return value is the color used previously.