com.approximatrix.charting.model
Class MultiScatterDataModel

java.lang.Object
  extended by com.approximatrix.charting.model.MultiScatterDataModel
All Implemented Interfaces:
ChartDataModel

public class MultiScatterDataModel
extends java.lang.Object
implements ChartDataModel

Implements a ChartDataModel that is used for plotting true scatter plots where each series can have a different set of independent points. This data model also stores series properties, similar to the ScatterDataModel.

Author:
armstrong

Nested Class Summary
private  class MultiScatterDataModel.DataSet
          Implements a complete data set model that holds and manages X and Y values separately
private  class MultiScatterDataModel.SeriesProperties
          Stores all Series Properties, including marker and line preferences, for a data series (originally implemented in ScatterDataModel).
 
Field Summary
protected  boolean autoscale
          Flag defining the automatic scaling of max and min values.
protected  ChartDataModelConstraints constraints
          The constraints for the first y-axis.
private  java.util.ArrayList<MultiScatterDataModel.DataSet> data
          Stores all DataSet objects in the model
protected  javax.swing.event.EventListenerList listener
          The listener list.
protected  java.lang.Double manual_max_x
          Maximum and minimum manually-set column values to be displayed.
protected  java.lang.Double manual_max_y
          Maximum and minimum manually-set values to be displayed.
protected  java.lang.Double manual_min_x
          Maximum and minimum manually-set column values to be displayed.
protected  java.lang.Double manual_min_y
          Maximum and minimum manually-set values to be displayed.
private  java.lang.Double max_x
          Buffers for the maximum values
private  java.lang.Double max_y
          Buffers for the maximum values
private  java.lang.Double min_x
          Buffers for the maximum values
private  java.lang.Double min_y
          Buffers for the maximum values
private  java.util.ArrayList<java.lang.String> names
          Stores the names of all data sets
private  java.util.ArrayList<MultiScatterDataModel.SeriesProperties> properties
          Stores the properties of all data sets
 
Constructor Summary
MultiScatterDataModel()
          A default constructor for initializing the internal ArrayLists
 
Method Summary
 void addChartDataModelListener(ChartDataModelListener l)
          Adds a ChartDataModelListener.
 void addData(double[][] xy, java.lang.String name)
          Adds a data set of an array consisting of independent values in the first column and dependent values in the second column to the model.
 void addData(double[] x, double[] y, java.lang.String name)
          Adds a data set of an array of x values and an array of y values to the model.
private  void checkConstraintSafety()
          Checks the values of min and max being passed out of the routine for use by autoscaled graphs.
private  void clearBuffers()
          Clears all the autoscale buffered max/min values
 void clearDataModel()
          Removes all data sets from the data model
 void fireChartDataModelChangedEvent(java.lang.Object src)
          Promotes a new ChartDataModelEvent.
 int getAxisBinding(int set)
          Returns the Axis binding of a specific DataSet.
 ChartDataModelConstraints getChartDataModelConstraints(int axis)
          Returns a ChartDataModelConstraints object for the given axis binding.
 java.lang.Class getColumnClass()
          Returns the class of the columns.
 java.lang.Object getColumnValueAt(int col)
          Returns a specific column value.
 java.lang.Object getColumnValueAt(int set, int col)
          Returns a specific column value.
 int getDataSetIndex(java.lang.String series)
          Returns the index of of the DataSet specified by the given DataSet name
 int getDataSetLength(int set)
          Returns the length of a certain dataset.
 java.lang.String getDataSetName(int set)
          Returns the title of the DataSet used for rendering the Legend.
 int getDataSetNumber()
          Returns the total amount of datasets.
 double getManualMaximumColumnValue()
          Returns the maximum manual scaling independent (x-axis) value
 java.lang.Number getManualMaximumValue()
          Returns the maximum manual scaling dependent (y-axis) value
 java.lang.Number getManualMaximumX()
          Returns the maximum manual x-axis scale
 java.lang.Number getManualMaximumY()
          Returns the maximum manual y-axis scale
 double getManualMinimumColumnValue()
          Returns the minimum manual scaling independent (x-axis) value
 java.lang.Number getManualMinimumValue()
          Returns the minimum manual scaling dependent (y-axis) value
 java.lang.Number getManualMinimumX()
          Returns the minimum manual x-axis scale
 java.lang.Number getManualMinimumY()
          Returns the minimum manual y-axis scale
 double getMaxXValue()
          Returns the maximum X value from all data sets
 double getMaxYValue()
          Returns the maximum Y value from all data sets
 double getMinXValue()
          Returns the minimum X value from all data sets
 double getMinYValue()
          Returns the minimum Y value from all data sets
 int getNumberSeries()
          Returns the number of series in the model
 boolean getSeriesLine(int set)
          Determines whether the series should be drawn with a line
 boolean getSeriesLine(java.lang.String series)
          Determines whether the series should be drawn with a line
 java.lang.String getSeriesLineStyle(int set)
          Returns the line style description
 boolean getSeriesMarker(int set)
          Determines whether the series should be drawn with markers
 boolean getSeriesMarker(java.lang.String series)
          Determines whether the series should be drawn with markers
 java.lang.Number getValueAt(int set, int index)
          Returns the Value in a specific dataset at a certain index.
 boolean isAutoScale()
          Returns whether autoscaling is enabled
 boolean isColumnNumeric()
          Defines whether the column values are numeric, that is, they can be casted to Number.
 boolean isManualScale()
          Deprecated. As of release 1.4, only autoscale flag will be considered
 boolean isSeries(java.lang.String name)
          Determines if a specified series exists in the model
 void removeChartDataModelListener(ChartDataModelListener l)
          Removes a ChartDataModelListener.
 void removeData(int i)
          Removes a series from the data model based on the passed index
 void removeData(java.lang.String name)
          Removes a series from the data model based on the series name
 void setAutoScale(boolean b)
          Sets whether the data model is using autoscale for constraints or specified values
 void setAxisBinding(int set, int axis)
          Sets the Axis binding of a DataSet.
 void setChartDataModelConstraints(int axis, ChartDataModelConstraints constraints)
          Sets the ChartDataModelConstraints object for the given axis binding.
 void setManualScale(boolean b)
          Deprecated. As of release 1.4, only autoscale flag will be considered
 void setMaximumColumnValue(double d)
          Deprecated. As of release 1.3, replaced by #setMaximumValueX()
 void setMaximumValue(java.lang.Number n)
          Deprecated. As of release 1.3, replaced by #setMaximumValueY()
 void setMaximumValueX(java.lang.Number n)
          Sets the maximum x-axis value.
 void setMaximumValueY(java.lang.Number n)
          Sets the maximum y-axis value.
 void setMinimumColumnValue(double d)
          Deprecated. As of release 1.3, replaced by #setMinimumValueX()
 void setMinimumValue(java.lang.Number n)
          Deprecated. As of release 1.3, replaced by #setMinimumValueY()
 void setMinimumValueX(java.lang.Number n)
          Sets the minimum x-axis value.
 void setMinimumValueY(java.lang.Number n)
          Sets the minimum y-axis value.
 void setSeriesLine(java.lang.String name, boolean on_or_off)
          Set the series line, specified by name, to be either displayed or hidden
 void setSeriesLineStyle(java.lang.String value, int set)
          Sets the line style description for the series of interest
 void setSeriesMarker(java.lang.String name, boolean on_or_off)
          Sets the series marker, specified by name, to be either displayed or hidden
 void setValueAt(int set, int index, java.lang.Object value)
          Sets the value in a specific dataset at the given index.
 void updateData(java.lang.String name, double[][] xy)
          Updates the x,y values for a dataset specified by its name
 void updateData(java.lang.String name, double[] x, double[] y)
          Updates the x,y values for a dataset specified by its name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

private java.util.ArrayList<MultiScatterDataModel.DataSet> data
Stores all DataSet objects in the model


names

private java.util.ArrayList<java.lang.String> names
Stores the names of all data sets


properties

private java.util.ArrayList<MultiScatterDataModel.SeriesProperties> properties
Stores the properties of all data sets


listener

protected javax.swing.event.EventListenerList listener
The listener list.


autoscale

protected boolean autoscale
Flag defining the automatic scaling of max and min values.


manual_max_x

protected java.lang.Double manual_max_x
Maximum and minimum manually-set column values to be displayed.


manual_min_x

protected java.lang.Double manual_min_x
Maximum and minimum manually-set column values to be displayed.


manual_max_y

protected java.lang.Double manual_max_y
Maximum and minimum manually-set values to be displayed.


manual_min_y

protected java.lang.Double manual_min_y
Maximum and minimum manually-set values to be displayed.


max_x

private java.lang.Double max_x
Buffers for the maximum values


max_y

private java.lang.Double max_y
Buffers for the maximum values


min_x

private java.lang.Double min_x
Buffers for the maximum values


min_y

private java.lang.Double min_y
Buffers for the maximum values


constraints

protected ChartDataModelConstraints constraints
The constraints for the first y-axis.

Constructor Detail

MultiScatterDataModel

public MultiScatterDataModel()
A default constructor for initializing the internal ArrayLists

Method Detail

addData

public void addData(double[] x,
                    double[] y,
                    java.lang.String name)
Adds a data set of an array of x values and an array of y values to the model.

Parameters:
x - independent values
y - dependent values
name - data set name for legend

addData

public void addData(double[][] xy,
                    java.lang.String name)
Adds a data set of an array consisting of independent values in the first column and dependent values in the second column to the model.

Parameters:
xy - data values
name - data set name for legend

removeData

public void removeData(java.lang.String name)
Removes a series from the data model based on the series name

Parameters:
name - name of the data set to remove

updateData

public void updateData(java.lang.String name,
                       double[] x,
                       double[] y)
Updates the x,y values for a dataset specified by its name

Parameters:
name - the name of the data set to update
x - the new independent values
y - the new dependent values

updateData

public void updateData(java.lang.String name,
                       double[][] xy)
Updates the x,y values for a dataset specified by its name

Parameters:
name - the name of the data set to update
xy - data values

isSeries

public boolean isSeries(java.lang.String name)
Determines if a specified series exists in the model

Parameters:
name - the series of interest
Returns:
true if the series exists, false otherwise

removeData

public void removeData(int i)
Removes a series from the data model based on the passed index

Parameters:
i - index of the series to remove

getNumberSeries

public int getNumberSeries()
Returns the number of series in the model

Returns:
Number of currently known data sets

removeChartDataModelListener

public void removeChartDataModelListener(ChartDataModelListener l)
Removes a ChartDataModelListener.

Specified by:
removeChartDataModelListener in interface ChartDataModel
Parameters:
l - the ChartDataListener

addChartDataModelListener

public void addChartDataModelListener(ChartDataModelListener l)
Adds a ChartDataModelListener.

Specified by:
addChartDataModelListener in interface ChartDataModel
Parameters:
l - the ChartDataModelListener

setAutoScale

public void setAutoScale(boolean b)
Sets whether the data model is using autoscale for constraints or specified values

Specified by:
setAutoScale in interface ChartDataModel
Parameters:
b - true to autoscale, false otherwise

isAutoScale

public boolean isAutoScale()
Returns whether autoscaling is enabled

Specified by:
isAutoScale in interface ChartDataModel
Returns:
true if autoscaling, false otherwise

setManualScale

public void setManualScale(boolean b)
Deprecated. As of release 1.4, only autoscale flag will be considered

Enables the manual axis scaling. Set the desired maximum and minimum values using the setMaximum...Value functions.

Specified by:
setManualScale in interface ChartDataModel
Parameters:
b - true to enable manual scaling, false otherwise

isManualScale

public boolean isManualScale()
Deprecated. As of release 1.4, only autoscale flag will be considered

Returns true if the manual axis scaling is enabled. This overrides the enabled automatic axis scaling.

Specified by:
isManualScale in interface ChartDataModel
Returns:
true if manual scaling, false otherwise

setMaximumColumnValue

public void setMaximumColumnValue(double d)
Deprecated. As of release 1.3, replaced by #setMaximumValueX()

Sets the maximum independent (x-axis) value. Has no effect if autoscaling is enabled

Specified by:
setMaximumColumnValue in interface ChartDataModel
Parameters:
d - the maximum independent value

setMinimumColumnValue

public void setMinimumColumnValue(double d)
Deprecated. As of release 1.3, replaced by #setMinimumValueX()

Sets the minimum independent (x-axis) value. Has no effect if autoscaling is enabled

Specified by:
setMinimumColumnValue in interface ChartDataModel
Parameters:
d - the minimum independent value

setMaximumValue

public void setMaximumValue(java.lang.Number n)
Deprecated. As of release 1.3, replaced by #setMaximumValueY()

Sets the maximum dependent (y-axis) value. Has no effect if autoscaling is enabled

Specified by:
setMaximumValue in interface ChartDataModel
Parameters:
n - a number of the maximum dependent value

setMinimumValue

public void setMinimumValue(java.lang.Number n)
Deprecated. As of release 1.3, replaced by #setMinimumValueY()

Sets the minimum dependent (y-axis) value. Has no effect if autoscaling is enabled

Specified by:
setMinimumValue in interface ChartDataModel
Parameters:
n - a number of the minimum dependent value

getManualMaximumColumnValue

public double getManualMaximumColumnValue()
Returns the maximum manual scaling independent (x-axis) value

Specified by:
getManualMaximumColumnValue in interface ChartDataModel
Returns:
the maximum manual scaling independent value

getManualMinimumColumnValue

public double getManualMinimumColumnValue()
Returns the minimum manual scaling independent (x-axis) value

Specified by:
getManualMinimumColumnValue in interface ChartDataModel
Returns:
the minimum manual scaling independent value

getManualMaximumValue

public java.lang.Number getManualMaximumValue()
Returns the maximum manual scaling dependent (y-axis) value

Specified by:
getManualMaximumValue in interface ChartDataModel
Returns:
the maximum manual scaling dependent value

getManualMinimumValue

public java.lang.Number getManualMinimumValue()
Returns the minimum manual scaling dependent (y-axis) value

Specified by:
getManualMinimumValue in interface ChartDataModel
Returns:
the minimum manual scaling dependent value

getManualMinimumX

public java.lang.Number getManualMinimumX()
Returns the minimum manual x-axis scale

Specified by:
getManualMinimumX in interface ChartDataModel
Returns:
the minimum x-axis value, or null if not assigned

getManualMaximumX

public java.lang.Number getManualMaximumX()
Returns the maximum manual x-axis scale

Specified by:
getManualMaximumX in interface ChartDataModel
Returns:
the maximum x-axis value, or null if not assigned

getManualMinimumY

public java.lang.Number getManualMinimumY()
Returns the minimum manual y-axis scale

Specified by:
getManualMinimumY in interface ChartDataModel
Returns:
the minimum y-axis value, or null if not assigned

getManualMaximumY

public java.lang.Number getManualMaximumY()
Returns the maximum manual y-axis scale

Specified by:
getManualMaximumY in interface ChartDataModel
Returns:
the maximum y-axis value, or null if not assigned

setMaximumValueX

public void setMaximumValueX(java.lang.Number n)
Sets the maximum x-axis value.

Specified by:
setMaximumValueX in interface ChartDataModel
Parameters:
n - the new maximum x value
See Also:
ChartDataModel.setMaximumValueX(java.lang.Number)

setMaximumValueY

public void setMaximumValueY(java.lang.Number n)
Sets the maximum y-axis value.

Specified by:
setMaximumValueY in interface ChartDataModel
Parameters:
n - the new maximum y value
See Also:
ChartDataModel.setMaximumValueY(java.lang.Number)

setMinimumValueX

public void setMinimumValueX(java.lang.Number n)
Sets the minimum x-axis value.

Specified by:
setMinimumValueX in interface ChartDataModel
Parameters:
n - the new minimum x value
See Also:
ChartDataModel.setMinimumValueX(java.lang.Number)

setMinimumValueY

public void setMinimumValueY(java.lang.Number n)
Sets the minimum y-axis value.

Specified by:
setMinimumValueY in interface ChartDataModel
Parameters:
n - the new minimum y value
See Also:
ChartDataModel.setMinimumValueY(java.lang.Number)

isColumnNumeric

public boolean isColumnNumeric()
Defines whether the column values are numeric, that is, they can be casted to Number.

Specified by:
isColumnNumeric in interface ChartDataModel
Returns:
true if the column value can be safely casted to Number type.

getDataSetLength

public int getDataSetLength(int set)
Returns the length of a certain dataset. Note that for proper rendering all datasets should have an equal length.

Specified by:
getDataSetLength in interface ChartDataModel
Parameters:
set - the DataSet index
Returns:
the int length of a DataSet

getDataSetName

public java.lang.String getDataSetName(int set)
Returns the title of the DataSet used for rendering the Legend.

Specified by:
getDataSetName in interface ChartDataModel
Parameters:
set - the DataSet index
Returns:
a String containing the Title.

getDataSetIndex

public int getDataSetIndex(java.lang.String series)
Returns the index of of the DataSet specified by the given DataSet name

Parameters:
series - the name of the DataSet
Returns:
the associated index or -1 if not found

getValueAt

public java.lang.Number getValueAt(int set,
                                   int index)
Returns the Value in a specific dataset at a certain index.

Specified by:
getValueAt in interface ChartDataModel
Parameters:
set - the DataSet index
index - the value index in the DataSet
Returns:
the value Object

setValueAt

public void setValueAt(int set,
                       int index,
                       java.lang.Object value)
Sets the value in a specific dataset at the given index. At this time, this function has no effect.

Specified by:
setValueAt in interface ChartDataModel
Parameters:
set - the DataSet index
index - the value index in the DataSet
value - the value to be stored

getColumnClass

public java.lang.Class getColumnClass()
Returns the class of the columns.

Specified by:
getColumnClass in interface ChartDataModel
Returns:
the class of the column values. In case of numeric columns this is always Number.class.

getColumnValueAt

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

Specified by:
getColumnValueAt in interface ChartDataModel
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 specific column value.

Specified by:
getColumnValueAt in interface ChartDataModel
Parameters:
set - the data set index
col - the column index
Returns:
the column value. In case of numeric columns this is always a Number object.

getDataSetNumber

public int getDataSetNumber()
Returns the total amount of datasets.

Specified by:
getDataSetNumber in interface ChartDataModel
Returns:
the total amount of DataSets

getAxisBinding

public int getAxisBinding(int set)
Returns the Axis binding of a specific DataSet.

Specified by:
getAxisBinding in interface ChartDataModel
Parameters:
set - the DataSet index
Returns:
an integer constant defining the Axis binding

setAxisBinding

public void setAxisBinding(int set,
                           int axis)
Sets the Axis binding of a DataSet.

Specified by:
setAxisBinding in interface ChartDataModel
Parameters:
set - the DataSet index
axis - the Axis binding constant

getChartDataModelConstraints

public ChartDataModelConstraints getChartDataModelConstraints(int axis)
Returns a ChartDataModelConstraints object for the given axis binding.

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

setChartDataModelConstraints

public void setChartDataModelConstraints(int axis,
                                         ChartDataModelConstraints constraints)
Sets the ChartDataModelConstraints object for the given axis binding.

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

getMaxXValue

public double getMaxXValue()
Returns the maximum X value from all data sets

Returns:
The maximum value of all X values

getMaxYValue

public double getMaxYValue()
Returns the maximum Y value from all data sets

Returns:
The maximum value of all Y values

getMinXValue

public double getMinXValue()
Returns the minimum X value from all data sets

Returns:
The minimum value of all X values

getMinYValue

public double getMinYValue()
Returns the minimum Y value from all data sets

Returns:
The minimum value of all Y values

setSeriesMarker

public void setSeriesMarker(java.lang.String name,
                            boolean on_or_off)
Sets the series marker, specified by name, to be either displayed or hidden

Parameters:
name - line series name
on_or_off - true to show markers, false otherwise

setSeriesLine

public void setSeriesLine(java.lang.String name,
                          boolean on_or_off)
Set the series line, specified by name, to be either displayed or hidden

Parameters:
name - line series name
on_or_off - true to display the line, false otherwise

getSeriesMarker

public boolean getSeriesMarker(java.lang.String series)
Determines whether the series should be drawn with markers

Parameters:
series - the name of the desired series
Returns:
true if markers should be drawn

getSeriesMarker

public boolean getSeriesMarker(int set)
Determines whether the series should be drawn with markers

Parameters:
set - the specified series
Returns:
true if markers should be drawn

getSeriesLine

public boolean getSeriesLine(java.lang.String series)
Determines whether the series should be drawn with a line

Parameters:
series - the name of the series
Returns:
true if a line should be drawn

getSeriesLine

public boolean getSeriesLine(int set)
Determines whether the series should be drawn with a line

Parameters:
set - the specified series
Returns:
true if a line should be drawn

getSeriesLineStyle

public java.lang.String getSeriesLineStyle(int set)
Returns the line style description

Parameters:
set - the series of interest
Returns:
string containing the line style description for use with de.progra.charting.SimpleStrokeDefs

setSeriesLineStyle

public void setSeriesLineStyle(java.lang.String value,
                               int set)
Sets the line style description for the series of interest

Parameters:
value - the description string
set - the series of interest

clearDataModel

public void clearDataModel()
Removes all data sets from the data model


fireChartDataModelChangedEvent

public void fireChartDataModelChangedEvent(java.lang.Object src)
Promotes a new ChartDataModelEvent.

Specified by:
fireChartDataModelChangedEvent in interface ChartDataModel
Parameters:
src - the source object of the event.

clearBuffers

private void clearBuffers()
Clears all the autoscale buffered max/min values


checkConstraintSafety

private void checkConstraintSafety()
Checks the values of min and max being passed out of the routine for use by autoscaled graphs.