com.approximatrix.charting.model.threedimensional
Class ColorDotPlotDataModel

java.lang.Object
  extended by com.approximatrix.charting.model.AbstractChartDataModel
      extended by com.approximatrix.charting.model.threedimensional.AbstractDotPlotDataModel
          extended by com.approximatrix.charting.model.threedimensional.ColorDotPlotDataModel
All Implemented Interfaces:
ChartDataModel, IntegratedImageModel
Direct Known Subclasses:
ColorScaleDotPlotDataModel

public class ColorDotPlotDataModel
extends AbstractDotPlotDataModel

A Dot Plot data model that stores Z-values directly as Color objects for plotting. The class also defines the data image as 500x500 by default. If using this class, the data image size should always be set appropriately.

Author:
armstrong

Field Summary
protected  java.awt.Color[] c
          The color values for plotting
private static int DEFAULT_HEIGHT
          The default data image height
private static int DEFAULT_WIDTH
          The default data image width
private  int h
          The actual data image height
private  int w
          The actual data image width
protected  double[] x
          The x data values
protected  double[] y
          The y data values
 
Fields inherited from class com.approximatrix.charting.model.threedimensional.AbstractDotPlotDataModel
constraints, dataImage, maxX, maxY, minX, minY
 
Fields inherited from class com.approximatrix.charting.model.AbstractChartDataModel
autoscale, listener, maxcolumn, maxvalue, mincolumn, minvalue
 
Constructor Summary
ColorDotPlotDataModel()
          Default constructor
ColorDotPlotDataModel(double[] x, double[] y, java.awt.Color[] color)
          Constructor that accepts coordinate data as (double,double,Color).
ColorDotPlotDataModel(int[] x, int[] y, java.awt.Color[] color)
          Constructor that accepts coordinate data as (int,int,Color).
 
Method Summary
protected  void buildImage()
          Constructs the data image based on the data.
 java.lang.Object getColumnValueAt(int col)
          Returns a specified X column value
 java.lang.Object getColumnValueAt(int set, int col)
          Returns a specified X column value
 int getDataSetLength(int set)
          Returns the data set length.
 int getDataSetNumber()
          This model will only ever have a single data set.
protected  double getFirstColumnValue()
          Returns the smallest X value
protected  double getLastColumnValue()
          Returns the largest X value
protected  java.util.TreeSet getOrderedValues(int axis)
          Returns null as this model does not provide ordered values
 java.lang.Number getValueAt(int set, int index)
          Returns the Color value at a given index.
private  void initialize()
          Initializes the model by scanning the data for the largest and smallest values, then assigning the appropriate constaints.
 void setResolution(int w, int h)
          Sets the resolution of the data image storing the pre-rendered data.
 void setValueAt(double x, double y, java.awt.Color value)
          Sets a Color at a given data-space coordinate
 void setValueAt(int x, int y, java.awt.Color value)
          Sets a Color at a given data-space coordinate
 
Methods inherited from class com.approximatrix.charting.model.threedimensional.AbstractDotPlotDataModel
getChartDataModelConstraints, getImage, getModelMaximumX, getModelMaximumY, getModelMinimumX, getModelMinimumY, getViewableImage, getXIndex, getXIndices, getYIndex, getYIndices, initializeImage, isColumnNumeric, scanRanges, setChartDataModelConstraints
 
Methods inherited from class com.approximatrix.charting.model.AbstractChartDataModel
addChartDataModelListener, equals, fireChartDataModelChangedEvent, getAxisBinding, getColumnClass, getDataSetName, getManualMaximumColumnValue, getManualMaximumValue, getManualMaximumX, getManualMaximumY, getManualMinimumColumnValue, getManualMinimumValue, getManualMinimumX, getManualMinimumY, isAutoScale, isManualScale, removeChartDataModelListener, setAutoScale, setAxisBinding, setManualScale, setMaximumColumnValue, setMaximumValue, setMaximumValueX, setMaximumValueY, setMinimumColumnValue, setMinimumValue, setMinimumValueX, setMinimumValueY, setValueAt
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.approximatrix.charting.model.ChartDataModel
addChartDataModelListener, fireChartDataModelChangedEvent, getAxisBinding, getColumnClass, getDataSetName, getManualMaximumColumnValue, getManualMaximumValue, getManualMaximumX, getManualMaximumY, getManualMinimumColumnValue, getManualMinimumValue, getManualMinimumX, getManualMinimumY, isAutoScale, isManualScale, removeChartDataModelListener, setAutoScale, setAxisBinding, setManualScale, setMaximumColumnValue, setMaximumValue, setMaximumValueX, setMaximumValueY, setMinimumColumnValue, setMinimumValue, setMinimumValueX, setMinimumValueY, setValueAt
 

Field Detail

DEFAULT_WIDTH

private static final int DEFAULT_WIDTH
The default data image width

See Also:
Constant Field Values

DEFAULT_HEIGHT

private static final int DEFAULT_HEIGHT
The default data image height

See Also:
Constant Field Values

w

private int w
The actual data image width


h

private int h
The actual data image height


x

protected double[] x
The x data values


y

protected double[] y
The y data values


c

protected java.awt.Color[] c
The color values for plotting

Constructor Detail

ColorDotPlotDataModel

public ColorDotPlotDataModel()
Default constructor


ColorDotPlotDataModel

public ColorDotPlotDataModel(int[] x,
                             int[] y,
                             java.awt.Color[] color)
Constructor that accepts coordinate data as (int,int,Color). All int values passed in as arrays are converted and stored as double values.

Parameters:
x - the array of x data points
y - the array of y data points
color - the array of Color objects representing z data

ColorDotPlotDataModel

public ColorDotPlotDataModel(double[] x,
                             double[] y,
                             java.awt.Color[] color)
                      throws java.lang.NullPointerException
Constructor that accepts coordinate data as (double,double,Color).

Parameters:
x - the array of x data points
y - the array of y data points
color - the array of Color objects representing z data
Throws:
java.lang.NullPointerException
Method Detail

initialize

private void initialize()
Initializes the model by scanning the data for the largest and smallest values, then assigning the appropriate constaints.


setResolution

public void setResolution(int w,
                          int h)
Sets the resolution of the data image storing the pre-rendered data. The values should reflect, ideally, the range of value so that each pixel represents one increment in the data.

Parameters:
w - the width of the data image
h - the height of the data image

buildImage

protected void buildImage()
Constructs the data image based on the data.

Specified by:
buildImage in class AbstractDotPlotDataModel

getFirstColumnValue

protected double getFirstColumnValue()
Returns the smallest X value

Specified by:
getFirstColumnValue in class AbstractChartDataModel

getLastColumnValue

protected double getLastColumnValue()
Returns the largest X value

Specified by:
getLastColumnValue in class AbstractChartDataModel

getOrderedValues

protected java.util.TreeSet getOrderedValues(int axis)
Returns null as this model does not provide ordered values

Specified by:
getOrderedValues in class AbstractChartDataModel

getColumnValueAt

public java.lang.Object getColumnValueAt(int col)
Returns a specified X column value

Parameters:
col - the column index
Returns:
the column value. In case of numeric columns this is always a Number object.

getColumnValueAt

public java.lang.Object getColumnValueAt(int set,
                                         int col)
Returns a specified X column value

Parameters:
set - must be zero - this model only supports a single series
the -
Returns:
the column value. In case of numeric columns this is always a Number object.

getDataSetLength

public int getDataSetLength(int set)
                     throws java.lang.IndexOutOfBoundsException
Returns the data set length.

Parameters:
set - must be zero - this model only supports a single series
Returns:
the int length of a DataSet
Throws:
java.lang.IndexOutOfBoundsException

getDataSetNumber

public int getDataSetNumber()
This model will only ever have a single data set.

Returns:
the total amount of DataSets

getValueAt

public java.lang.Number getValueAt(int set,
                                   int index)
                            throws java.lang.IndexOutOfBoundsException
Returns the Color value at a given index. Note that this does not return the y value.

Parameters:
set - the DataSet index
index - the value index in the DataSet
Returns:
the value Object
Throws:
java.lang.IndexOutOfBoundsException

setValueAt

public void setValueAt(int x,
                       int y,
                       java.awt.Color value)
Sets a Color at a given data-space coordinate

Parameters:
x - the data space x coordinate
y - the data space y coordinate
value - the desired color

setValueAt

public void setValueAt(double x,
                       double y,
                       java.awt.Color value)
Sets a Color at a given data-space coordinate

Parameters:
x - the data space x coordinate
y - the data space y coordinate
value - the desired color