com.approximatrix.charting.render
Class RowColorModel

java.lang.Object
  extended by com.approximatrix.charting.render.RowColorModel

public class RowColorModel
extends java.lang.Object

This class implements the correspondence between the DataSets and the colors used for rendering the charts and the legend.

Version:
1.0
Author:
mueller

Field Summary
protected  java.util.HashMap customColors
           
protected  java.util.HashMap customShapes
           
static Diamond2D DIAMOND_SHAPE
          A diamond marker for plotting
static java.awt.geom.Ellipse2D ELLIPSE_SHAPE
          An ellipse marker for plotting
private static RowColorModel instance
           
protected  ChartDataModel model
           
protected static java.awt.Color[] predefinedColors
          Predefined colors for plotting lines and markers
protected  int predefinedColorsIdx
          Index holding the next predefined color to use for plotting
protected static java.awt.geom.RectangularShape[] predefinedShapes
          Array of predefined shapes for plot markers
static java.awt.geom.Rectangle2D SQUARE_SHAPE
          A square marker for plotting
static Triangle2D TRIANGLE_SHAPE
          A triangle marker for plotting
static Triangle2D TRIANGLEDOWN_SHAPE
          An upside-down triangle marker for plotting
 
Constructor Summary
RowColorModel(ChartDataModel model)
          Creates new RowColorModel.
 
Method Summary
 java.awt.Color getColor(int row)
          Computes the Color for a DataSet.
static RowColorModel getInstance(ChartDataModel model)
          Deprecated.  
 java.lang.String getRow(int i)
          Returns the row title of a specific DataSet.
 int getRowCount()
          Computes the amount of all Legend entries, ie.
 java.awt.geom.RectangularShape getShape(int row)
          Returns the Shape for a DataSet.
 void setColor(int row, java.awt.Color color)
          Force a certain color for a row
 void setShape(int row, java.awt.geom.RectangularShape shape)
          Force a certain Shape for a row
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static RowColorModel instance

model

protected ChartDataModel model

predefinedColors

protected static final java.awt.Color[] predefinedColors
Predefined colors for plotting lines and markers


ELLIPSE_SHAPE

public static final java.awt.geom.Ellipse2D ELLIPSE_SHAPE
An ellipse marker for plotting


SQUARE_SHAPE

public static final java.awt.geom.Rectangle2D SQUARE_SHAPE
A square marker for plotting


DIAMOND_SHAPE

public static final Diamond2D DIAMOND_SHAPE
A diamond marker for plotting


TRIANGLE_SHAPE

public static final Triangle2D TRIANGLE_SHAPE
A triangle marker for plotting


TRIANGLEDOWN_SHAPE

public static final Triangle2D TRIANGLEDOWN_SHAPE
An upside-down triangle marker for plotting


predefinedShapes

protected static final java.awt.geom.RectangularShape[] predefinedShapes
Array of predefined shapes for plot markers


predefinedColorsIdx

protected int predefinedColorsIdx
Index holding the next predefined color to use for plotting


customColors

protected java.util.HashMap customColors

customShapes

protected java.util.HashMap customShapes
Constructor Detail

RowColorModel

public RowColorModel(ChartDataModel model)
Creates new RowColorModel.

Parameters:
model - the ChartDataModel which contains the information about all the DataSets
Method Detail

getInstance

public static RowColorModel getInstance(ChartDataModel model)
Deprecated. 

Use this method to get an instance of the chart's RowColorModel.

Parameters:
model - the ChartDataModel whose data sets will be mapped to colors.
Returns:
a new instance of RowColorModel if there's no instance of if the model has changed (esp. useful if you create multiple charts after one another).

getRowCount

public int getRowCount()
Computes the amount of all Legend entries, ie. DataSets.

Returns:
the amount of all rows, ie. DataSets.

getRow

public java.lang.String getRow(int i)
Returns the row title of a specific DataSet.

Parameters:
i - the DataSet index
Returns:
the String title

getColor

public java.awt.Color getColor(int row)
Computes the Color for a DataSet. For the first DataSets the stored Colors like Color.red etc are used. If there are more DataSets than stored colors, random colors are used.

Parameters:
row - the row for which the Color should be returned
Returns:
the Color stored for the given row.

getShape

public java.awt.geom.RectangularShape getShape(int row)
Returns the Shape for a DataSet. By default, the Shapes from the predefinedShapes array are cycled through unless you define your own shape to data binding using setShape(int row, RectangularShape shape).

Parameters:
row - the row for which the Shape should be returned
Returns:
the Shape stored for the given row.

setColor

public void setColor(int row,
                     java.awt.Color color)
Force a certain color for a row

Parameters:
row - the row for which the Color should be set
color - the color that is associated with the row

setShape

public void setShape(int row,
                     java.awt.geom.RectangularShape shape)
Force a certain Shape for a row

Parameters:
row - the row for which the Shape should be set
shape - the RectangularShape that is associated with the row