org.jfree.data.xy

Class DefaultHighLowDataset

public class DefaultHighLowDataset extends AbstractXYDataset implements OHLCDataset, PublicCloneable

A simple implementation of the OHLCDataset interface. See also the DefaultOHLCDataset class, which provides another implementation that is very similar.
Constructor Summary
DefaultHighLowDataset(Comparable seriesKey, Date[] date, double[] high, double[] low, double[] open, double[] close, double[] volume)
Constructs a new high/low/open/close dataset.
Method Summary
static Number[]createNumberArray(double[] data)
Constructs an array of Number objects from an array of doubles.
booleanequals(Object obj)
Tests this dataset for equality with an arbitrary instance.
NumbergetClose(int series, int item)
Returns the close-value for one item in a series.
doublegetCloseValue(int series, int item)
Returns the close-value (as a double primitive) for an item within a series.
NumbergetHigh(int series, int item)
Returns the high-value for one item in a series.
doublegetHighValue(int series, int item)
Returns the high-value (as a double primitive) for an item within a series.
intgetItemCount(int series)
Returns the number of items in the specified series.
NumbergetLow(int series, int item)
Returns the low-value for one item in a series.
doublegetLowValue(int series, int item)
Returns the low-value (as a double primitive) for an item within a series.
NumbergetOpen(int series, int item)
Returns the open-value for one item in a series.
doublegetOpenValue(int series, int item)
Returns the open-value (as a double primitive) for an item within a series.
intgetSeriesCount()
Returns the number of series in the dataset.
ComparablegetSeriesKey(int series)
Returns the key for the series stored in this dataset.
NumbergetVolume(int series, int item)
Returns the volume-value for one item in a series.
doublegetVolumeValue(int series, int item)
Returns the volume-value (as a double primitive) for an item within a series.
NumbergetX(int series, int item)
Returns the x-value for one item in a series.
DategetXDate(int series, int item)
Returns the x-value for one item in a series, as a Date.
NumbergetY(int series, int item)
Returns the y-value for one item in a series.

Constructor Detail

DefaultHighLowDataset

public DefaultHighLowDataset(Comparable seriesKey, 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.

Parameters: seriesKey the key for the series (null not permitted). date the dates (null not permitted). high the high values (null not permitted). low the low values (null not permitted). open the open values (null not permitted). close the close values (null not permitted). volume the volume values (null not permitted).

Method Detail

createNumberArray

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

Parameters: data the double values to convert (null not permitted).

Returns: The data as an array of Number objects.

equals

public boolean equals(Object obj)
Tests this dataset for equality with an arbitrary instance.

Parameters: obj the object (null permitted).

Returns: A boolean.

getClose

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

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The close-value.

See Also: DefaultHighLowDataset

getCloseValue

public double getCloseValue(int series, int item)
Returns the close-value (as a double primitive) for an item within a series.

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The close-value.

See Also: DefaultHighLowDataset

getHigh

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

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The high-value.

See Also: DefaultHighLowDataset

getHighValue

public double getHighValue(int series, int item)
Returns the high-value (as a double primitive) for an item within a series.

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The high-value.

See Also: DefaultHighLowDataset

getItemCount

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

Parameters: series the index (zero-based) of the series.

Returns: The number of items in the specified series.

getLow

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

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The low-value.

See Also: DefaultHighLowDataset

getLowValue

public double getLowValue(int series, int item)
Returns the low-value (as a double primitive) for an item within a series.

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The low-value.

See Also: DefaultHighLowDataset

getOpen

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

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The open-value.

See Also: DefaultHighLowDataset

getOpenValue

public double getOpenValue(int series, int item)
Returns the open-value (as a double primitive) for an item within a series.

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The open-value.

See Also: DefaultHighLowDataset

getSeriesCount

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

This implementation only allows one series.

Returns: The number of series.

getSeriesKey

public Comparable getSeriesKey(int series)
Returns the key for the series stored in this dataset.

Parameters: series the index of the series (ignored, this dataset supports only one series and this method always returns the key for series 0).

Returns: The series key (never null).

getVolume

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

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The volume-value.

See Also: DefaultHighLowDataset

getVolumeValue

public double getVolumeValue(int series, int item)
Returns the volume-value (as a double primitive) for an item within a series.

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The volume-value.

See Also: DefaultHighLowDataset

getX

public Number getX(int series, int item)
Returns the x-value for one item in a series. The value returned is a Long instance generated from the underlying Date object. To avoid generating a new object instance, you might prefer to call DefaultHighLowDataset.

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The x-value.

See Also: DefaultHighLowDataset DefaultHighLowDataset

getXDate

public Date getXDate(int series, int item)
Returns the x-value for one item in a series, as a Date.

This method is provided for convenience only.

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The x-value as a Date.

See Also: DefaultHighLowDataset

getY

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

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

Parameters: series the series (zero-based index). item the item (zero-based index).

Returns: The y-value.

See Also: DefaultHighLowDataset

Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.