JSci.awt
Class DefaultGraph2DModel

java.lang.Object
  extended by JSci.awt.AbstractGraphModel
      extended by JSci.awt.DefaultGraph2DModel
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.TableModelListener, Graph2DModel

public final class DefaultGraph2DModel
extends AbstractGraphModel
implements Graph2DModel, javax.swing.event.TableModelListener

The DefaultGraph2DModel class provides a default implementation of the Graph2DModel interface.


Nested Class Summary
static class DefaultGraph2DModel.DataSeries
          The DataSeries class encapsulates a data series for a graph.
 
Constructor Summary
DefaultGraph2DModel()
           
 
Method Summary
 void addSeries(DefaultGraph2DModel.DataSeries newSeries)
          Adds a data series.
 void addSeries(double[] newSeries)
          Adds a data series using the default values for the x-axis.
 void addSeries(float[] newSeries)
          Adds a data series using the default values for the x-axis.
 void addSeries(float[] newXAxis, double[] newSeries)
          Adds a data series.
 void addSeries(float[] newXAxis, float[] newSeries)
          Adds a data series.
 void changeSeries(int i, DefaultGraph2DModel.DataSeries newSeries)
          Changes a data series.
 void changeSeries(int i, double[] newSeries)
          Changes a data series.
 void changeSeries(int i, float[] newSeries)
          Changes a data series.
 void firstSeries()
          Selects the first data series.
 DefaultGraph2DModel.DataSeries getSeries(int i)
           
 float getXCoord(int i)
          Returns the x coordinate for the ith point.
 float getYCoord(int i)
          Returns the y coordinate for the ith point.
 boolean nextSeries()
          Selects the next data series.
 void removeSeries(int i)
          Remove a data series.
 int seriesLength()
          Returns the number of data points in the current series.
 void setSeriesVisible(int i, boolean flag)
          Convenience method.
 void setXAxis(double[] x)
          Sets the default x-axis values.
 void setXAxis(float[] x)
          Sets the default x-axis values.
 void setXAxis(float a, float b, int n)
          Sets the default x-axis values.
 void tableChanged(javax.swing.event.TableModelEvent evt)
          Implementation of TabelModelListener.
 
Methods inherited from class JSci.awt.AbstractGraphModel
addGraphDataListener, fireGraphChanged, fireGraphDataChanged, fireGraphSeriesUpdated, removeGraphDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface JSci.awt.Graph2DModel
addGraphDataListener, removeGraphDataListener
 

Constructor Detail

DefaultGraph2DModel

public DefaultGraph2DModel()
Method Detail

setXAxis

public void setXAxis(float[] x)
Sets the default x-axis values. A copy of the values is made. This method does not change the x-axis values of any data series and so does not fire any events.


setXAxis

public void setXAxis(double[] x)
Sets the default x-axis values. A copy of the values is made. This method does not change the x-axis values of any data series and so does not fire any events.


setXAxis

public void setXAxis(float a,
                     float b,
                     int n)
Sets the default x-axis values. This method does not change the x-axis values of any data series and so does not fire any events.

Parameters:
a - start of interval.
b - end of interval.
n - number of values.

addSeries

public void addSeries(float[] newSeries)
Adds a data series using the default values for the x-axis. Be sure to call setXAxis first.


addSeries

public void addSeries(double[] newSeries)
Adds a data series using the default values for the x-axis. Be sure to call setXAxis first.


addSeries

public void addSeries(DefaultGraph2DModel.DataSeries newSeries)
Adds a data series.


addSeries

public void addSeries(float[] newXAxis,
                      float[] newSeries)
Adds a data series. Convenience method.


addSeries

public void addSeries(float[] newXAxis,
                      double[] newSeries)
Adds a data series. Convenience method.


changeSeries

public void changeSeries(int i,
                         DefaultGraph2DModel.DataSeries newSeries)
Changes a data series.


changeSeries

public void changeSeries(int i,
                         float[] newSeries)
Changes a data series. Convenience method.


changeSeries

public void changeSeries(int i,
                         double[] newSeries)
Changes a data series. Convenience method.


removeSeries

public void removeSeries(int i)
Remove a data series.


getSeries

public DefaultGraph2DModel.DataSeries getSeries(int i)

setSeriesVisible

public void setSeriesVisible(int i,
                             boolean flag)
Convenience method.


tableChanged

public void tableChanged(javax.swing.event.TableModelEvent evt)
Implementation of TabelModelListener. Application code will not use this method explicitly, it is used internally.

Specified by:
tableChanged in interface javax.swing.event.TableModelListener

getXCoord

public float getXCoord(int i)
Description copied from interface: Graph2DModel
Returns the x coordinate for the ith point.

Specified by:
getXCoord in interface Graph2DModel

getYCoord

public float getYCoord(int i)
Description copied from interface: Graph2DModel
Returns the y coordinate for the ith point.

Specified by:
getYCoord in interface Graph2DModel

seriesLength

public int seriesLength()
Description copied from interface: Graph2DModel
Returns the number of data points in the current series.

Specified by:
seriesLength in interface Graph2DModel

firstSeries

public void firstSeries()
Description copied from interface: Graph2DModel
Selects the first data series.

Specified by:
firstSeries in interface Graph2DModel

nextSeries

public boolean nextSeries()
Description copied from interface: Graph2DModel
Selects the next data series. Returns false if there is no next series.

Specified by:
nextSeries in interface Graph2DModel