com.approximatrix.charting.model.threedimensional
Class AbstractDotPlotDataModel

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

public abstract class AbstractDotPlotDataModel
extends AbstractChartDataModel
implements IntegratedImageModel

Basis for models containing three dimensional scatter data (x,y,z) for use in Dot Plots, where Z values are simply represented by a color scale. This abstract implementation provides some data model necessities, stores the "image" of the data, and handles scanning for the largest observed x,y values.

Author:
armstrong

Field Summary
protected  ChartDataModelConstraints constraints
          The data model constraints
protected  java.awt.image.BufferedImage dataImage
          Image of the data ready for rendering
protected  double maxX
          The largest X value
protected  double maxY
          The largest Y value
protected  double minX
          The smallest X value
protected  double minY
          The smallest Y value
 
Fields inherited from class com.approximatrix.charting.model.AbstractChartDataModel
autoscale, listener, manualscale, maxcolumn, maxvalue, mincolumn, minvalue
 
Constructor Summary
protected AbstractDotPlotDataModel()
          Default constructor that enables autoscaling immediately
 
Method Summary
protected abstract  void buildImage()
          Constructs image from the data
 ChartDataModelConstraints getChartDataModelConstraints(int axis)
          Returns the chart data model constraints
 java.awt.image.BufferedImage getImage()
          Returns the complete image of the data
private  int getIndex(double datavalue, double minval, double maxval, int size)
          Private conversion method to perform data-space to image-space conversions
private  int[] getIndices(double[] datavalue, double minval, double maxval, int size)
          Private conversion method to perform data-space to image-space conversions.
 double getModelMaximumX()
          Returns the largest x value in the data model.
 double getModelMaximumY()
          Returns the largest y value in the data model.
 double getModelMinimumX()
          Returns the smallest x value in the data model.
 double getModelMinimumY()
          Returns the smallest y value in the data model.
 java.awt.Image getViewableImage()
          Returns a copy of the data image for plotting.
 int getXIndex(double datavalue)
          Conversion method to determine the data image X-index based on a double X value in data space
 int[] getXIndices(double[] datavalue)
          Conversion method to determine the data image X-indices based on an array of double X values in data space
 int getYIndex(double datavalue)
          Conversion method to determine the data image Y-index based on a double Y value in data space
 int[] getYIndices(double[] datavalue)
          Conversion method to determine the data image Y-indices based on an array of double Y values in data space
protected  void initializeImage(int w, int h)
          Initializes the data image to a specified width and height.
 boolean isColumnNumeric()
          Returns true because this model only uses numeric x-axis
protected  void scanRanges(double[] x, double[] y)
          Scans through arrays of x and y data to determine the largest and smallest values encountered and stores them appropriately.
 void setChartDataModelConstraints(int axis, ChartDataModelConstraints constraints)
          Assigns the chart data model constraints to this data model.
 
Methods inherited from class com.approximatrix.charting.model.AbstractChartDataModel
addChartDataModelListener, equals, fireChartDataModelChangedEvent, getAxisBinding, getColumnClass, getDataSetName, getFirstColumnValue, getLastColumnValue, getManualMaximumColumnValue, getManualMaximumValue, getManualMaximumX, getManualMaximumY, getManualMinimumColumnValue, getManualMinimumValue, getManualMinimumX, getManualMinimumY, getOrderedValues, 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, getColumnValueAt, getColumnValueAt, getDataSetLength, getDataSetName, getDataSetNumber, getManualMaximumColumnValue, getManualMaximumValue, getManualMaximumX, getManualMaximumY, getManualMinimumColumnValue, getManualMinimumValue, getManualMinimumX, getManualMinimumY, getValueAt, isAutoScale, isManualScale, removeChartDataModelListener, setAutoScale, setAxisBinding, setManualScale, setMaximumColumnValue, setMaximumValue, setMaximumValueX, setMaximumValueY, setMinimumColumnValue, setMinimumValue, setMinimumValueX, setMinimumValueY, setValueAt
 

Field Detail

dataImage

protected java.awt.image.BufferedImage dataImage
Image of the data ready for rendering


minX

protected double minX
The smallest X value


maxX

protected double maxX
The largest X value


minY

protected double minY
The smallest Y value


maxY

protected double maxY
The largest Y value


constraints

protected ChartDataModelConstraints constraints
The data model constraints

Constructor Detail

AbstractDotPlotDataModel

protected AbstractDotPlotDataModel()
Default constructor that enables autoscaling immediately

Method Detail

getImage

public java.awt.image.BufferedImage getImage()
Returns the complete image of the data

Returns:
the Image of the data, or null if it has not yet been created

getViewableImage

public java.awt.Image getViewableImage()
Returns a copy of the data image for plotting. If manual scaling is enabled, a subimage is sampled and returned.

Specified by:
getViewableImage in interface IntegratedImageModel
Returns:
the viewable image

getXIndex

public int getXIndex(double datavalue)
Conversion method to determine the data image X-index based on a double X value in data space

Parameters:
datavalue - a data-space x value
Returns:
the equivalent image coordinate

getYIndex

public int getYIndex(double datavalue)
Conversion method to determine the data image Y-index based on a double Y value in data space

Parameters:
datavalue - a data-space y value
Returns:
the equivalent image coordinate

getIndex

private int getIndex(double datavalue,
                     double minval,
                     double maxval,
                     int size)
Private conversion method to perform data-space to image-space conversions

Parameters:
datavalue - the data space value
minval - the minimum data-space value along a dimension of interest
maxval - the maximum data-space value along a dimension of interest
size - the image size along a dimension of interest
Returns:
the equivalent image coordinate

getXIndices

public int[] getXIndices(double[] datavalue)
Conversion method to determine the data image X-indices based on an array of double X values in data space

Parameters:
datavalue - an array data-space x values
Returns:
the equivalent image coordinates

getYIndices

public int[] getYIndices(double[] datavalue)
Conversion method to determine the data image Y-indices based on an array of double Y values in data space

Parameters:
datavalue - an array data-space y values
Returns:
the equivalent image coordinates

getIndices

private int[] getIndices(double[] datavalue,
                         double minval,
                         double maxval,
                         int size)
                  throws java.lang.NullPointerException
Private conversion method to perform data-space to image-space conversions. All calculations are implemented here locally to avoid repetive math in calling getIndex().

Parameters:
datavalue - the array data space values
minval - the minimum data-space value along a dimension of interest
maxval - the maximum data-space value along a dimension of interest
size - the image size along a dimension of interest
Returns:
an array of the equivalent image coordinates
Throws:
java.lang.NullPointerException

scanRanges

protected void scanRanges(double[] x,
                          double[] y)
Scans through arrays of x and y data to determine the largest and smallest values encountered and stores them appropriately.

Parameters:
x - the array of x data values
y - the array of y data values

initializeImage

protected void initializeImage(int w,
                               int h)
Initializes the data image to a specified width and height. Image is by default blank.

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

buildImage

protected abstract void buildImage()
Constructs image from the data


setChartDataModelConstraints

public void setChartDataModelConstraints(int axis,
                                         ChartDataModelConstraints constraints)
Assigns the chart data model constraints to this data model.

Specified by:
setChartDataModelConstraints in interface ChartDataModel
Parameters:
axis - the Axis constant
constraints - the ChartDataModelConstraints object

getChartDataModelConstraints

public ChartDataModelConstraints getChartDataModelConstraints(int axis)
Returns the chart data model constraints

Specified by:
getChartDataModelConstraints in interface ChartDataModel
Parameters:
axis - the Axis constant
Returns:
a ChartDataModelConstraints object.

getModelMaximumX

public double getModelMaximumX()
Returns the largest x value in the data model.

Returns:
the largest x value

getModelMinimumX

public double getModelMinimumX()
Returns the smallest x value in the data model.

Returns:
the smallest x value

getModelMaximumY

public double getModelMaximumY()
Returns the largest y value in the data model.

Returns:
the largest y value

getModelMinimumY

public double getModelMinimumY()
Returns the smallest y value in the data model.

Returns:
the smallest y value

isColumnNumeric

public boolean isColumnNumeric()
Returns true because this model only uses numeric x-axis

Specified by:
isColumnNumeric in interface ChartDataModel
Overrides:
isColumnNumeric in class AbstractChartDataModel
Returns:
true always