Package org.jfree.data.xy
Class DefaultHighLowDataset
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.general.AbstractSeriesDataset
-
- org.jfree.data.xy.AbstractXYDataset
-
- org.jfree.data.xy.DefaultHighLowDataset
-
- All Implemented Interfaces:
java.io.ObjectInputValidation
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,PublicCloneable
,Dataset
,SeriesChangeListener
,SeriesDataset
,OHLCDataset
,XYDataset
public class DefaultHighLowDataset extends AbstractXYDataset implements OHLCDataset, PublicCloneable
A simple implementation of theOHLCDataset
interface. See also theDefaultOHLCDataset
class, which provides another implementation that is very similar.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Number[]
close
Storage for the close values.private java.util.Date[]
date
Storage for the dates.private java.lang.Number[]
high
Storage for the high values.private java.lang.Number[]
low
Storage for the low values.private java.lang.Number[]
open
Storage for the open values.private java.lang.Comparable
seriesKey
The series key.private java.lang.Number[]
volume
Storage for the volume values.
-
Constructor Summary
Constructors Constructor Description DefaultHighLowDataset(java.lang.Comparable seriesKey, java.util.Date[] date, double[] high, double[] low, double[] open, double[] close, double[] volume)
Constructs a new high/low/open/close dataset.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.Number[]
createNumberArray(double[] data)
Constructs an array of Number objects from an array of doubles.boolean
equals(java.lang.Object obj)
Tests this dataset for equality with an arbitrary instance.java.lang.Number
getClose(int series, int item)
Returns the close-value for one item in a series.double
getCloseValue(int series, int item)
Returns the close-value (as a double primitive) for an item within a series.java.lang.Number
getHigh(int series, int item)
Returns the high-value for one item in a series.double
getHighValue(int series, int item)
Returns the high-value (as a double primitive) for an item within a series.int
getItemCount(int series)
Returns the number of items in the specified series.java.lang.Number
getLow(int series, int item)
Returns the low-value for one item in a series.double
getLowValue(int series, int item)
Returns the low-value (as a double primitive) for an item within a series.java.lang.Number
getOpen(int series, int item)
Returns the open-value for one item in a series.double
getOpenValue(int series, int item)
Returns the open-value (as a double primitive) for an item within a series.int
getSeriesCount()
Returns the number of series in the dataset.java.lang.Comparable
getSeriesKey(int series)
Returns the key for the series stored in this dataset.java.lang.Number
getVolume(int series, int item)
Returns the volume-value for one item in a series.double
getVolumeValue(int series, int item)
Returns the volume-value (as a double primitive) for an item within a series.java.lang.Number
getX(int series, int item)
Returns the x-value for one item in a series.java.util.Date
getXDate(int series, int item)
Returns the x-value for one item in a series, as a Date.java.lang.Number
getY(int series, int item)
Returns the y-value for one item in a series.int
hashCode()
-
Methods inherited from class org.jfree.data.xy.AbstractXYDataset
getDomainOrder, getXValue, getYValue
-
Methods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf, seriesChanged
-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, clone, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObject
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Methods inherited from interface org.jfree.chart.util.PublicCloneable
clone
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
Methods inherited from interface org.jfree.data.xy.XYDataset
getDomainOrder, getXValue, getYValue
-
-
-
-
Field Detail
-
seriesKey
private final java.lang.Comparable seriesKey
The series key.
-
date
private java.util.Date[] date
Storage for the dates.
-
high
private java.lang.Number[] high
Storage for the high values.
-
low
private java.lang.Number[] low
Storage for the low values.
-
open
private java.lang.Number[] open
Storage for the open values.
-
close
private java.lang.Number[] close
Storage for the close values.
-
volume
private java.lang.Number[] volume
Storage for the volume values.
-
-
Constructor Detail
-
DefaultHighLowDataset
public DefaultHighLowDataset(java.lang.Comparable seriesKey, 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.
- 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
-
getSeriesKey
public java.lang.Comparable getSeriesKey(int series)
Returns the key for the series stored in this dataset.- Specified by:
getSeriesKey
in interfaceSeriesDataset
- Specified by:
getSeriesKey
in classAbstractSeriesDataset
- 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
).
-
getX
public java.lang.Number getX(int series, int item)
Returns the x-value for one item in a series. The value returned is aLong
instance generated from the underlyingDate
object. To avoid generating a new object instance, you might prefer to callAbstractXYDataset.getXValue(int, int)
.- Specified by:
getX
in interfaceXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The x-value.
- See Also:
AbstractXYDataset.getXValue(int, int)
,getXDate(int, int)
-
getXDate
public java.util.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:
getX(int, int)
-
getY
public java.lang.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 thegetCloseValue(int, int)
method.- Specified by:
getY
in interfaceXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The y-value.
- See Also:
AbstractXYDataset.getYValue(int, int)
-
getHigh
public java.lang.Number getHigh(int series, int item)
Returns the high-value for one item in a series.- Specified by:
getHigh
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The high-value.
- See Also:
getHighValue(int, int)
-
getHighValue
public double getHighValue(int series, int item)
Returns the high-value (as a double primitive) for an item within a series.- Specified by:
getHighValue
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The high-value.
- See Also:
getHigh(int, int)
-
getLow
public java.lang.Number getLow(int series, int item)
Returns the low-value for one item in a series.- Specified by:
getLow
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The low-value.
- See Also:
getLowValue(int, int)
-
getLowValue
public double getLowValue(int series, int item)
Returns the low-value (as a double primitive) for an item within a series.- Specified by:
getLowValue
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The low-value.
- See Also:
getLow(int, int)
-
getOpen
public java.lang.Number getOpen(int series, int item)
Returns the open-value for one item in a series.- Specified by:
getOpen
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The open-value.
- See Also:
getOpenValue(int, int)
-
getOpenValue
public double getOpenValue(int series, int item)
Returns the open-value (as a double primitive) for an item within a series.- Specified by:
getOpenValue
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The open-value.
- See Also:
getOpen(int, int)
-
getClose
public java.lang.Number getClose(int series, int item)
Returns the close-value for one item in a series.- Specified by:
getClose
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The close-value.
- See Also:
getCloseValue(int, int)
-
getCloseValue
public double getCloseValue(int series, int item)
Returns the close-value (as a double primitive) for an item within a series.- Specified by:
getCloseValue
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The close-value.
- See Also:
getClose(int, int)
-
getVolume
public java.lang.Number getVolume(int series, int item)
Returns the volume-value for one item in a series.- Specified by:
getVolume
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The volume-value.
- See Also:
getVolumeValue(int, int)
-
getVolumeValue
public double getVolumeValue(int series, int item)
Returns the volume-value (as a double primitive) for an item within a series.- Specified by:
getVolumeValue
in interfaceOHLCDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The volume-value.
- See Also:
getVolume(int, int)
-
getSeriesCount
public int getSeriesCount()
Returns the number of series in the dataset.This implementation only allows one series.
- Specified by:
getSeriesCount
in interfaceSeriesDataset
- Specified by:
getSeriesCount
in classAbstractSeriesDataset
- Returns:
- The number of series.
-
getItemCount
public int getItemCount(int series)
Returns the number of items in the specified series.- Specified by:
getItemCount
in interfaceXYDataset
- Parameters:
series
- the index (zero-based) of the series.- Returns:
- The number of items in the specified series.
-
equals
public boolean equals(java.lang.Object obj)
Tests this dataset for equality with an arbitrary instance.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractDataset
-
createNumberArray
public static java.lang.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.
-
-