JIDE 3.5.15

com.jidesoft.chart.model
Class LeanMemoryChartModel

java.lang.Object
  extended by com.jidesoft.chart.model.LeanMemoryChartModel
All Implemented Interfaces:
ChartModel, LeanChartModel, Named, Iterable<Chartable>

public final class LeanMemoryChartModel
extends Object
implements LeanChartModel

The LeanMemoryChartModel is designed for cases where you have a large data set that is read-only. You cannot change the points of the model after you have created it. The internal representation of the points uses less memory than a conventional ChartModel such as a DefaultChartModel, which is why this class is well-suited to large data sets. This class is a good choice, for example, if you are retrieving data from a database for display purposes only.


Constructor Summary
LeanMemoryChartModel(double[][] points)
          Constructs a ChartModel from an array of x, y double pairs
LeanMemoryChartModel(List<double[]> points)
          Constructs a ChartModel from a list of x, y double pairs
LeanMemoryChartModel(String name, double[][] points)
          Constructs a ChartModel from an array of x, y double pairs
LeanMemoryChartModel(String name, List<double[]> points)
          Constructs a ChartModel from a list of x, y double pairs
 
Method Summary
 void addChartModelListener(ChartModelListener listener)
          Register the listener's interest in this chart model.
 boolean equals(Object obj)
           
protected  void fireModelChanged()
           
 String getName()
          The name of a ChartModel is important, as different chart models are assumed to have different names.
 Chartable getPoint(int n)
          Gets the nth point.
 int getPointCount()
          Gets the number of points in the data set
 double[] getPointPositions(int n)
          Returns the x and y coordinates of the nth point
 int hashCode()
           
protected  void init()
           
 boolean isCyclical()
          Should a line be drawn from the last to the first point?
 Iterator<Chartable> iterator()
          
 void removeChartModelListener(ChartModelListener listener)
          De-register the listener's interest in this chart model.
 void setCyclical(boolean cyclical)
          Specify whether the chart model is cyclical.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LeanMemoryChartModel

public LeanMemoryChartModel(List<double[]> points)
Constructs a ChartModel from a list of x, y double pairs

Parameters:
points - a list of x, y double coordinates

LeanMemoryChartModel

public LeanMemoryChartModel(double[][] points)
Constructs a ChartModel from an array of x, y double pairs

Parameters:
points - an array of x, y double coordinates

LeanMemoryChartModel

public LeanMemoryChartModel(String name,
                            List<double[]> points)
Constructs a ChartModel from a list of x, y double pairs

Parameters:
name - the name of the model
points - a list of x, y double coordinates

LeanMemoryChartModel

public LeanMemoryChartModel(String name,
                            double[][] points)
Constructs a ChartModel from an array of x, y double pairs

Parameters:
name - the name of the model
points - an array of x, y double coordinates
Method Detail

init

protected void init()

getName

public String getName()
The name of a ChartModel is important, as different chart models are assumed to have different names. If you're adding multiple models to a Chart, make sure they have different names.

Specified by:
getName in interface ChartModel
Specified by:
getName in interface Named
Returns:
a distinct name for this data set

getPoint

public Chartable getPoint(int n)
Gets the nth point. The first point has index 0.

Specified by:
getPoint in interface ChartModel
Parameters:
n - the index
Returns:
the nth point in the ChartModel.

getPointPositions

public double[] getPointPositions(int n)
Returns the x and y coordinates of the nth point

Specified by:
getPointPositions in interface LeanChartModel
Parameters:
n - the index of the point of interest
Returns:
an array of doubles: the first element is the x coordinate and the second element is the y coordinate

getPointCount

public int getPointCount()
Gets the number of points in the data set

Specified by:
getPointCount in interface ChartModel
Returns:
the number of points

setCyclical

public void setCyclical(boolean cyclical)
Specify whether the chart model is cyclical. A cyclical chart model is one in which the first and last points are 'next to' one another. So when points of the model are connected with lines, the first and last points of a cyclical model will also be connected, whereas the same points of a model that is not cyclical will not be connected.

Parameters:
cyclical - a boolean to indicate whether the chart model is cyclical

isCyclical

public boolean isCyclical()
Should a line be drawn from the last to the first point?

Specified by:
isCyclical in interface ChartModel
Returns:
whether the model represents a cycle of values

fireModelChanged

protected void fireModelChanged()

addChartModelListener

public void addChartModelListener(ChartModelListener listener)
Register the listener's interest in this chart model.

Specified by:
addChartModelListener in interface ChartModel
Parameters:
listener - the listener that will receive events

removeChartModelListener

public void removeChartModelListener(ChartModelListener listener)
De-register the listener's interest in this chart model.

Specified by:
removeChartModelListener in interface ChartModel
Parameters:
listener - the listener that will no longer receive events

iterator

public Iterator<Chartable> iterator()

Specified by:
iterator in interface Iterable<Chartable>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

JIDE 3.5.15