com.jrefinery.data
Class DefaultHighLowDataset

java.lang.Object
  extended by com.jrefinery.data.AbstractDataset
      extended by com.jrefinery.data.AbstractSeriesDataset
          extended by com.jrefinery.data.DefaultHighLowDataset
All Implemented Interfaces:
Dataset, HighLowDataset, SeriesChangeListener, SeriesDataset, XYDataset

public class DefaultHighLowDataset
extends AbstractSeriesDataset
implements HighLowDataset

A simple implementation of the HighLowDataset.


Field Summary
protected  java.lang.Number[] close
          Storage for the close values.
protected  java.util.Date[] date
          Storage for the dates.
protected  java.lang.Number[] high
          Storage for the high values.
protected  java.lang.Number[] low
          Storage for the low values.
protected  java.lang.Number[] open
          Storage for the open values.
protected  java.lang.String seriesName
          The series name.
protected  java.lang.Number[] volume
          Storage for the volume values.
 
Fields inherited from class com.jrefinery.data.AbstractDataset
listeners
 
Constructor Summary
DefaultHighLowDataset(java.lang.String seriesName, java.util.Date[] date, double[] high, double[] low, double[] open, double[] close, double[] volume)
          Constructs a new high/low/open/close dataset.
 
Method Summary
static java.lang.Number[] createNumberArray(double[] data)
          Constructs an array of Number objects from an array of doubles.
 java.lang.Number getCloseValue(int series, int item)
          Returns the close-value for one item in a series.
 java.lang.Number getHighValue(int series, int item)
          Returns the high-value for one item in a series.
 int getItemCount(int series)
          Returns the number of items in the specified series.
 java.lang.Number getLowValue(int series, int item)
          Returns the low-value for one item in a series.
 java.lang.Number getOpenValue(int series, int item)
          Returns the open-value for one item in a series.
 int getSeriesCount()
          Returns the number of series in the dataset.
 java.lang.String getSeriesName(int i)
          Returns the name of the series stored in this dataset.
 java.lang.Number getVolumeValue(int series, int item)
          Returns the volume-value for one item in a series.
 java.lang.Number getXValue(int series, int item)
          Returns the x-value for one item in a series.
 java.lang.Number getYValue(int series, int item)
          Returns the y-value for one item in a series.
 
Methods inherited from class com.jrefinery.data.AbstractSeriesDataset
getLegendItemCount, getLegendItemLabels, seriesChanged
 
Methods inherited from class com.jrefinery.data.AbstractDataset
addChangeListener, fireDatasetChanged, notifyListeners, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jrefinery.data.Dataset
addChangeListener, removeChangeListener
 

Field Detail

seriesName

protected java.lang.String seriesName
The series name.


date

protected java.util.Date[] date
Storage for the dates.


high

protected java.lang.Number[] high
Storage for the high values.


low

protected java.lang.Number[] low
Storage for the low values.


open

protected java.lang.Number[] open
Storage for the open values.


close

protected java.lang.Number[] close
Storage for the close values.


volume

protected java.lang.Number[] volume
Storage for the volume values.

Constructor Detail

DefaultHighLowDataset

public DefaultHighLowDataset(java.lang.String seriesName,
                             java.util.Date[] date,
                             double[] high,
                             double[] low,
                             double[] open,
                             double[] close,
                             double[] volume)
Constructs a new high/low/open/close dataset.

The current implementation allows only one series in the dataset. This may be extended in a future version.

Method Detail

getSeriesName

public java.lang.String getSeriesName(int i)
Returns the name of the series stored in this dataset.

Specified by:
getSeriesName in interface SeriesDataset
Specified by:
getSeriesName in class AbstractSeriesDataset
Parameters:
i - The series (zero-based index).

getXValue

public java.lang.Number getXValue(int series,
                                  int item)
Returns the x-value for one item in a series.

The value returned is a Long object generated from the underlying Date object.

Specified by:
getXValue in interface XYDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
The x-value.

getYValue

public java.lang.Number getYValue(int series,
                                  int item)
Returns the y-value for one item in a series.

This method (from the XYDataset interface) is mapped to the getCloseValue(...) method.

Specified by:
getYValue in interface XYDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
The y-value.

getHighValue

public java.lang.Number getHighValue(int series,
                                     int item)
Returns the high-value for one item in a series.

Specified by:
getHighValue in interface HighLowDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
The high-value.

getLowValue

public java.lang.Number getLowValue(int series,
                                    int item)
Returns the low-value for one item in a series.

Specified by:
getLowValue in interface HighLowDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
The low-value.

getOpenValue

public java.lang.Number getOpenValue(int series,
                                     int item)
Returns the open-value for one item in a series.

Specified by:
getOpenValue in interface HighLowDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
The open-value.

getCloseValue

public java.lang.Number getCloseValue(int series,
                                      int item)
Returns the close-value for one item in a series.

Specified by:
getCloseValue in interface HighLowDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
The close-value.

getVolumeValue

public java.lang.Number getVolumeValue(int series,
                                       int item)
Returns the volume-value for one item in a series.

Specified by:
getVolumeValue in interface HighLowDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
The volume-value.

getSeriesCount

public int getSeriesCount()
Returns the number of series in the dataset.

This implementation only allows one series.

Specified by:
getSeriesCount in interface SeriesDataset
Specified by:
getSeriesCount in class AbstractSeriesDataset
Returns:
The number of series.

getItemCount

public int getItemCount(int series)
Returns the number of items in the specified series.

Specified by:
getItemCount in interface XYDataset
Parameters:
series - The index (zero-based) of the series;
Returns:
The number of items in the specified series.

createNumberArray

public static java.lang.Number[] createNumberArray(double[] data)
Constructs an array of Number objects from an array of doubles.



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.