KavaChart 5.3.1 API

com.ve.kavachart.chart
Class Dataset

java.lang.Object
  extended by com.ve.kavachart.chart.Dataset
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Dataset
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A collection of Datum classes, along with a set of graphical attributes (Gc) and labelling information. In addition, Dataset provides methods for determining certain metrics about the overall collection. These methods are used by some of the graphical component classes (e.g. Pie percentages) as well as the Axis classes (max, min, etc.) Datasets are always initialized with a Gc, a dataset label color (black), and an initial label font (TimesRoman, 12)

See Also:
Datum, Chart, Serialized Form

Constructor Summary
Dataset()
          Constructs an unassigned Dataset class.
Dataset(java.lang.String name, double[] yarr, boolean individual, Globals g)
          Constructor for nonlabelled charts that use only Y values.
Dataset(java.lang.String name, double[] xarr, double[] yarr, double[] y2arr, double[] y3arr, int setNumber, Globals g)
          Constructor for HiLoClose charts.
Dataset(java.lang.String name, double[] xarr, double[] yarr, double[] y2arr, int setNumber, Globals g)
          Constructor for HiLo charts.
Dataset(java.lang.String name, double[] xarr, double[] yarr, double[] y2arr, java.lang.String[] label, int setNumber, Globals g)
          Constructor for HiLo charts.
Dataset(java.lang.String name, double[] xarr, double[] yarr, Globals g)
          Constructor for nonlabelled charts that use both X and Y observations.
Dataset(java.lang.String name, double[] xarr, double[] yarr, int setNumber, Globals g)
          Constructor for charts that use X and Y values, but have no labels.
Dataset(java.lang.String name, double[] xarr, double[] yarr, java.lang.String[] label, int setNumber, Globals g)
          Constructor for label charts that use both X and Y.
Dataset(java.lang.String name, double[] yarr, int setNumber, Globals g)
          Constructor for charts that use only 1 data element (Y values).
Dataset(java.lang.String name, double[] yarr, java.lang.String[] label, boolean individual, Globals g)
          Constructor for labelled charts that use only Y values.
Dataset(java.lang.String name, double[] yarr, java.lang.String[] label, int setNumber, Globals g)
          Constructor for label charts that use 1 data element.
 
Method Summary
 void addDatum(Datum d)
          Installs a Datum class into this Dataset.
 void addPoint(double x, double y, java.lang.String l)
          Adds an observation to this Dataset.
 java.lang.Object clone()
          Method
 void dump()
          Prints out all values of X and Y.
 java.util.Vector getData()
          Returns the current Datum classes.
 Datum getDataElementAt(int where)
          returns a specified Datum
 Gc getGc()
          Returns this Dataset's Gc class
 Globals getGlobals()
          Returns this Dataset's Globals class, which is presumably the same as the overall chart's Globals class.
 java.awt.Color getLabelColor()
          Returns the current labelColor.
 java.awt.Font getLabelFont()
          Returns the current labelFont.
 java.lang.String getName()
          Returns the name of current Dataset.
 double[] getXValues()
          Returns all values of X.
 double[] getY2Values()
          Returns all values of Y2.
 double[] getY3Values()
          Returns all values of Y3.
 double[] getYValues()
          Returns all values of Y.
 double maxX()
          Returns the maximum value of X in this dataset.
 double maxY()
          Returns the maximum value of Y in this dataset.
 double maxY2()
          Returns the maximum value of Y2 in this dataset.
 double maxY3()
          Returns the maximum value of Y3 in this dataset.
 double minX()
          Returns the minimum value of X in this dataset.
 double minY()
          Returns the minimum value of Y in this dataset.
 double minY2()
          Returns the minimum value of Y2 in this dataset.
 double minY3()
          Returns the minimum value of Y3 in this dataset.
 void replaceLabels(java.lang.String[] labels)
          Replaces labels in your dataset.
 void replaceXData(double[] xarr)
          Replaces X values in your dataset.
 void replaceY2Data(double[] yarr)
          Replaces Y2 values in your dataset.
 void replaceY3Data(double[] yarr)
          Replaces Y3 values in your dataset.
 void replaceYData(double[] yarr)
          Replaces Y values in your dataset.
 void setData(java.util.Vector d)
          Installs a new Vector of data classes
 void setGc(Gc g)
          Installs a new Gc class for this Dataset
 void setGlobals(Globals g)
          sets this Dataset's Globals class, which is presumably the same as the overall chart's Globals class.
 void setLabelColor(java.awt.Color c)
          Sets a new labelColor.
 void setLabelFont(java.awt.Font f)
          Sets a new labelFont.
 void setName(java.lang.String s)
          Rename the current Dataset.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dataset

public Dataset()
Constructs an unassigned Dataset class. This is primarily useful for KavaChart data feed beans, as all Chart datasets must include the Chart's Globals class


Dataset

public Dataset(java.lang.String name,
               double[] xarr,
               double[] yarr,
               double[] y2arr,
               double[] y3arr,
               int setNumber,
               Globals g)
Constructor for HiLoClose charts. Initializes everything but labels: x, y, y2, and y3 values. Sets an initial Gc determined by the set number.

Parameters:
name - Dataset name
xarr - Array of X values
yarr - Array of Y values
y2arr - Array of Y2 values
y3arr - Array of Y3 values
setNumber - This Dataset's position in an array
g - this chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] xarr,
               double[] yarr,
               double[] y2arr,
               java.lang.String[] label,
               int setNumber,
               Globals g)
Constructor for HiLo charts. Initializes everything: x, y, y2, and label values. Sets an initial Gc determined by the set number. Builds an incomplete Dataset if one of the arrays is incomplete (Data truncated to last complete value)

Parameters:
name - Dataset name
xarr - Array of X values
yarr - Array of Y values
y2arr - Array of Y2 values
label - Label values
setNumber - This Dataset's position in an array
g - This chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] xarr,
               double[] yarr,
               double[] y2arr,
               int setNumber,
               Globals g)
Constructor for HiLo charts. Initializes everything but labels: x, y, and y2 values. Sets an initial Gc determined by the set number.

Parameters:
name - Dataset name
xarr - Array of X values
yarr - Array of Y values
y2arr - Array of Y2 values
setNumber - This Dataset's position in an array
g - this chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] xarr,
               double[] yarr,
               java.lang.String[] label,
               int setNumber,
               Globals g)
Constructor for label charts that use both X and Y. Sets initial Gc determined by set number. Also initializes labels for each data point.

Parameters:
name - Dataset name
xarr - Array of X values
yarr - Array of Y values
label - Label values
setNumber - This Dataset's position in an array
g - This chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] xarr,
               double[] yarr,
               int setNumber,
               Globals g)
Constructor for charts that use X and Y values, but have no labels. Sets initial Gc determined by set number.

Parameters:
name - Dataset name
xarr - Array of X values
yarr - Array of Y values
setNumber - This Dataset's position in an array
g - This chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] xarr,
               double[] yarr,
               Globals g)
Constructor for nonlabelled charts that use both X and Y observations. Sets a default initial Gc.

Parameters:
name - Dataset name
xarr - Array of X values
yarr - Array of Y values
g - This chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] yarr,
               java.lang.String[] label,
               int setNumber,
               Globals g)
Constructor for label charts that use 1 data element. Sets initial Gc determined by set number. Also initializes the label.

Parameters:
name - Dataset name
yarr - Array of chart data
label - Label values
setNumber - This Dataset's position in an array
g - This chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] yarr,
               java.lang.String[] label,
               boolean individual,
               Globals g)
Constructor for labelled charts that use only Y values. Sets the default initial Gc.

Parameters:
name - Dataset name
yarr - Array of chart data
label - Label values
individual - Use unique color for each data element's Gc

Dataset

public Dataset(java.lang.String name,
               double[] yarr,
               int setNumber,
               Globals g)
Constructor for charts that use only 1 data element (Y values). For example, this is appropriate for Pie charts. Sets an initial Gc determined by set number.

Parameters:
name - Dataset name
yarr - Array of chart data
setNumber - This Dataset's position in an array
g - This chart's Globals class

Dataset

public Dataset(java.lang.String name,
               double[] yarr,
               boolean individual,
               Globals g)
Constructor for nonlabelled charts that use only Y values. Sets the default initial Gc.

Parameters:
name - Dataset name
yarr - Array of chart data
individual - Use unique or random color for each data element
g - this chart's Globals class
Method Detail

addDatum

public void addDatum(Datum d)
Installs a Datum class into this Dataset. Also assigns this Dataset's Globals class to this Datum.

Parameters:
d - com.ve.kavachart.chart.Datum

addPoint

public void addPoint(double x,
                     double y,
                     java.lang.String l)
Adds an observation to this Dataset. Creates a new Datum class containing the X, Y, and label values specified. Adds that class to the Dataset's data Vector.

Parameters:
x - double
y - double
l - java.lang.String

clone

public java.lang.Object clone()
Method

Overrides:
clone in class java.lang.Object
Returns:
java.lang.Object

dump

public void dump()
Prints out all values of X and Y.


getData

public java.util.Vector getData()
Returns the current Datum classes.

Returns:
Vector containing Datum classes

getDataElementAt

public Datum getDataElementAt(int where)
returns a specified Datum

Returns:
Vector containing this Dataset's Datum classes

getGc

public Gc getGc()
Returns this Dataset's Gc class

Returns:
Graphic context

getGlobals

public Globals getGlobals()
Returns this Dataset's Globals class, which is presumably the same as the overall chart's Globals class.


getLabelColor

public java.awt.Color getLabelColor()
Returns the current labelColor.

Returns:
Current labelColor

getLabelFont

public java.awt.Font getLabelFont()
Returns the current labelFont.

Returns:
Current labelFont

getName

public java.lang.String getName()
Returns the name of current Dataset.

Returns:
Dataset name

getXValues

public double[] getXValues()
Returns all values of X.

Returns:
Array of X values

getY2Values

public double[] getY2Values()
Returns all values of Y2.

Returns:
Array of Y2 values

getY3Values

public double[] getY3Values()
Returns all values of Y3.

Returns:
Array of Y3 values

getYValues

public double[] getYValues()
Returns all values of Y.

Returns:
Array of Y values

maxX

public double maxX()
Returns the maximum value of X in this dataset.

Returns:
Maximum value of X

maxY

public double maxY()
Returns the maximum value of Y in this dataset.

Returns:
Maximum value of Y

maxY2

public double maxY2()
Returns the maximum value of Y2 in this dataset.

Returns:
Maximum value of Y2

maxY3

public double maxY3()
Returns the maximum value of Y3 in this dataset.

Returns:
Maximum value of Y3

minX

public double minX()
Returns the minimum value of X in this dataset.

Returns:
Minimum value of X

minY

public double minY()
Returns the minimum value of Y in this dataset.

Returns:
Minimum value of Y

minY2

public double minY2()
Returns the minimum value of Y2 in this dataset.

Returns:
Minimum value of Y2

minY3

public double minY3()
Returns the minimum value of Y3 in this dataset.

Returns:
Minimum value of Y3

replaceLabels

public void replaceLabels(java.lang.String[] labels)
Replaces labels in your dataset.

Parameters:
xarr - Array of new X values

replaceXData

public void replaceXData(double[] xarr)
Replaces X values in your dataset. If the X value array is larger than the current size of this Dataset, the Dataset is extended to accomodate the additional entries. If the X value array is smaller than the size of the data Vector, the Vector is trimmed to the size of the X value array. If the new array is smaller than the current array, the extra entries at the end of the current array are not changed.

Parameters:
xarr - Array of new X values

replaceY2Data

public void replaceY2Data(double[] yarr)
Replaces Y2 values in your dataset. If the Y value array is larger than the current size of this Dataset, the Dataset is extended to accomodate the additional entries. If the new array is smaller than the current array, the extra entries at the end of the current array are not changed.

Parameters:
yarr - Array of new Y2 values

replaceY3Data

public void replaceY3Data(double[] yarr)
Replaces Y3 values in your dataset. If the Y value array is larger than the current size of this Dataset, the Dataset is extended to accomodate the additional entries. If the new array is smaller than the current array, the extra entries at the end of the current array are not changed.

Parameters:
yarr - Array of new Y3 values

replaceYData

public void replaceYData(double[] yarr)
Replaces Y values in your dataset. If the Y value array is larger than the current size of this Dataset, the Dataset is extended to accomodate the additional entries. If the new array is smaller than the current array, the extra entries at the end of the current array are not changed.

Parameters:
yarr - Array of new Y values

setData

public void setData(java.util.Vector d)
Installs a new Vector of data classes

Parameters:
d - data vector

setGc

public void setGc(Gc g)
Installs a new Gc class for this Dataset

Parameters:
g - New graphic context

setGlobals

public void setGlobals(Globals g)
sets this Dataset's Globals class, which is presumably the same as the overall chart's Globals class. Also installs this Globals class into all Datum classes contained within this Dataset.


setLabelColor

public void setLabelColor(java.awt.Color c)
Sets a new labelColor.

Parameters:
New - labelColor

setLabelFont

public void setLabelFont(java.awt.Font f)
Sets a new labelFont.

Parameters:
New - labelFont

setName

public void setName(java.lang.String s)
Rename the current Dataset.

Parameters:
s - New name for Dataset

KavaChart 5.3.1 API