Package org.jfree.data.time
Class TimeTableXYDataset
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.general.AbstractSeriesDataset
-
- org.jfree.data.xy.AbstractXYDataset
-
- org.jfree.data.xy.AbstractIntervalXYDataset
-
- org.jfree.data.time.TimeTableXYDataset
-
- All Implemented Interfaces:
java.io.ObjectInputValidation
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,PublicCloneable
,DomainInfo
,Dataset
,SeriesChangeListener
,SeriesDataset
,IntervalXYDataset
,TableXYDataset
,XYDataset
public class TimeTableXYDataset extends AbstractIntervalXYDataset implements java.lang.Cloneable, PublicCloneable, IntervalXYDataset, DomainInfo, TableXYDataset
A dataset for regular time periods that implements theTableXYDataset
interface. Note that theTableXYDataset
interface requires all series to share the same set of x-values. When adding a new item(x, y)
to one series, all other series automatically get a new item(x, null)
unless a non-null item has already been specified.- See Also:
TableXYDataset
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
domainIsPointsInTime
A flag that indicates that the domain is 'points in time'.private DefaultKeyedValues2D
values
The data structure to store the values.private java.util.Calendar
workingCalendar
A working calendar (to recycle)private TimePeriodAnchor
xPosition
The point within each time period that is used for the X value when this collection is used as anXYDataset
.
-
Constructor Summary
Constructors Constructor Description TimeTableXYDataset()
Creates a new dataset.TimeTableXYDataset(java.util.TimeZone zone)
Creates a new dataset with the given time zone.TimeTableXYDataset(java.util.TimeZone zone, java.util.Locale locale)
Creates a new dataset with the given time zone and locale.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(TimePeriod period, double y, java.lang.Comparable seriesName)
Adds a new data item to the dataset and sends aDatasetChangeEvent
to all registered listeners.void
add(TimePeriod period, java.lang.Number y, java.lang.Comparable seriesName, boolean notify)
Adds a new data item to the dataset and, if requested, sends aDatasetChangeEvent
to all registered listeners.void
clear()
Removes all data items from the dataset and sends aDatasetChangeEvent
to all registered listeners.java.lang.Object
clone()
Returns a clone of this dataset.boolean
equals(java.lang.Object obj)
Tests this dataset for equality with an arbitrary object.Range
getDomainBounds(boolean includeInterval)
Returns the range of the values in this dataset's domain.boolean
getDomainIsPointsInTime()
Returns a flag that controls whether the domain is treated as 'points in time'.double
getDomainLowerBound(boolean includeInterval)
Returns the minimum x-value in the dataset.double
getDomainUpperBound(boolean includeInterval)
Returns the maximum x-value in the dataset.java.lang.Number
getEndX(int series, int item)
Returns the ending X value for the specified series and item.double
getEndXValue(int series, int item)
Returns the end x-value (as a double primitive) for an item within a series.java.lang.Number
getEndY(int series, int item)
Returns the ending Y value for the specified series and item.int
getItemCount()
Returns the number of items in ALL series.int
getItemCount(int series)
Returns the number of items in a series.int
getSeriesCount()
Returns the number of series in the dataset.java.lang.Comparable
getSeriesKey(int series)
Returns the key for a series.java.lang.Number
getStartX(int series, int item)
Returns the starting X value for the specified series and item.double
getStartXValue(int series, int item)
Returns the start x-value (as a double primitive) for an item within a series.java.lang.Number
getStartY(int series, int item)
Returns the starting Y value for the specified series and item.TimePeriod
getTimePeriod(int item)
Returns the time period for the specified item.java.lang.Number
getX(int series, int item)
Returns the x-value for an item within a series.TimePeriodAnchor
getXPosition()
Returns the position within each time period that is used for the X value.double
getXValue(int series, int item)
Returns the x-value (as a double primitive) for an item within a series.private long
getXValue(TimePeriod period)
Returns the x-value for a time period.java.lang.Number
getY(int series, int item)
Returns the y-value for an item within a series.void
remove(TimePeriod period, java.lang.Comparable seriesName)
Removes an existing data item from the dataset.void
remove(TimePeriod period, java.lang.Comparable seriesName, boolean notify)
Removes an existing data item from the dataset and, if requested, sends aDatasetChangeEvent
to all registered listeners.void
setDomainIsPointsInTime(boolean flag)
Sets a flag that controls whether the domain is treated as 'points in time', or time periods.void
setXPosition(TimePeriodAnchor anchor)
Sets the position within each time period that is used for the X values, then sends aDatasetChangeEvent
to all registered listeners.-
Methods inherited from class org.jfree.data.xy.AbstractIntervalXYDataset
getEndYValue, getStartYValue
-
Methods inherited from class org.jfree.data.xy.AbstractXYDataset
getDomainOrder, getYValue
-
Methods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf, seriesChanged
-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, fireDatasetChanged, getGroup, getNotify, hashCode, 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.data.xy.IntervalXYDataset
getEndYValue, getStartYValue
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
Methods inherited from interface org.jfree.data.xy.XYDataset
getDomainOrder, getYValue
-
-
-
-
Field Detail
-
values
private DefaultKeyedValues2D values
The data structure to store the values. Each column represents a series (elsewhere in JFreeChart rows are typically used for series, but it doesn't matter that much since this data structure is private and symmetrical anyway), each row contains values for the sameRegularTimePeriod
(the rows are sorted into ascending order).
-
domainIsPointsInTime
private boolean domainIsPointsInTime
A flag that indicates that the domain is 'points in time'. If this flag is true, only the x-value (and not the x-interval) is used to determine the range of values in the domain.
-
xPosition
private TimePeriodAnchor xPosition
The point within each time period that is used for the X value when this collection is used as anXYDataset
. This can be the start, middle or end of the time period.
-
workingCalendar
private java.util.Calendar workingCalendar
A working calendar (to recycle)
-
-
Constructor Detail
-
TimeTableXYDataset
public TimeTableXYDataset()
Creates a new dataset.
-
TimeTableXYDataset
public TimeTableXYDataset(java.util.TimeZone zone)
Creates a new dataset with the given time zone.- Parameters:
zone
- the time zone to use (null
not permitted).
-
TimeTableXYDataset
public TimeTableXYDataset(java.util.TimeZone zone, java.util.Locale locale)
Creates a new dataset with the given time zone and locale.- Parameters:
zone
- the time zone to use (null
not permitted).locale
- the locale to use (null
not permitted).
-
-
Method Detail
-
getDomainIsPointsInTime
public boolean getDomainIsPointsInTime()
Returns a flag that controls whether the domain is treated as 'points in time'.This flag is used when determining the max and min values for the domain. If true, then only the x-values are considered for the max and min values. If false, then the start and end x-values will also be taken into consideration.
- Returns:
- The flag.
- See Also:
setDomainIsPointsInTime(boolean)
-
setDomainIsPointsInTime
public void setDomainIsPointsInTime(boolean flag)
Sets a flag that controls whether the domain is treated as 'points in time', or time periods. ADatasetChangeEvent
is sent to all registered listeners.- Parameters:
flag
- the new value of the flag.- See Also:
getDomainIsPointsInTime()
-
getXPosition
public TimePeriodAnchor getXPosition()
Returns the position within each time period that is used for the X value.- Returns:
- The anchor position (never
null
). - See Also:
setXPosition(TimePeriodAnchor)
-
setXPosition
public void setXPosition(TimePeriodAnchor anchor)
Sets the position within each time period that is used for the X values, then sends aDatasetChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor position (null
not permitted).- See Also:
getXPosition()
-
add
public void add(TimePeriod period, double y, java.lang.Comparable seriesName)
Adds a new data item to the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
period
- the time period.y
- the value for this period.seriesName
- the name of the series to add the value.- See Also:
remove(TimePeriod, Comparable)
-
add
public void add(TimePeriod period, java.lang.Number y, java.lang.Comparable seriesName, boolean notify)
Adds a new data item to the dataset and, if requested, sends aDatasetChangeEvent
to all registered listeners.- Parameters:
period
- the time period (null
not permitted).y
- the value for this period (null
permitted).seriesName
- the name of the series to add the value (null
not permitted).notify
- whether dataset listener are notified or not.- See Also:
remove(TimePeriod, Comparable, boolean)
-
remove
public void remove(TimePeriod period, java.lang.Comparable seriesName)
Removes an existing data item from the dataset.- Parameters:
period
- the (existing!) time period of the value to remove (null
not permitted).seriesName
- the (existing!) series name to remove the value (null
not permitted).- See Also:
add(TimePeriod, double, Comparable)
-
remove
public void remove(TimePeriod period, java.lang.Comparable seriesName, boolean notify)
Removes an existing data item from the dataset and, if requested, sends aDatasetChangeEvent
to all registered listeners.- Parameters:
period
- the (existing!) time period of the value to remove (null
not permitted).seriesName
- the (existing!) series name to remove the value (null
not permitted).notify
- whether dataset listener are notified or not.- See Also:
add(TimePeriod, double, Comparable)
-
clear
public void clear()
Removes all data items from the dataset and sends aDatasetChangeEvent
to all registered listeners.
-
getTimePeriod
public TimePeriod getTimePeriod(int item)
Returns the time period for the specified item. Bear in mind that all series share the same set of time periods.- Parameters:
item
- the item index (0 <= i <=getItemCount()
).- Returns:
- The time period.
-
getItemCount
public int getItemCount()
Returns the number of items in ALL series.- Specified by:
getItemCount
in interfaceTableXYDataset
- Returns:
- The item count.
-
getItemCount
public int getItemCount(int series)
Returns the number of items in a series. This is the same value that is returned bygetItemCount()
since all series share the same x-values (time periods).- Specified by:
getItemCount
in interfaceXYDataset
- Parameters:
series
- the series (zero-based index, ignored).- Returns:
- The number of items within the series.
-
getSeriesCount
public int getSeriesCount()
Returns the number of series in the dataset.- Specified by:
getSeriesCount
in interfaceSeriesDataset
- Specified by:
getSeriesCount
in classAbstractSeriesDataset
- Returns:
- The series count.
-
getSeriesKey
public java.lang.Comparable getSeriesKey(int series)
Returns the key for a series.- Specified by:
getSeriesKey
in interfaceSeriesDataset
- Specified by:
getSeriesKey
in classAbstractSeriesDataset
- Parameters:
series
- the series (zero-based index).- Returns:
- The key for the series.
-
getX
public java.lang.Number getX(int series, int item)
Returns the x-value for an item within a series. The x-values may or may not be returned in ascending order, that is up to the class implementing the interface.
-
getXValue
public double getXValue(int series, int item)
Returns the x-value (as a double primitive) for an item within a series.- Specified by:
getXValue
in interfaceXYDataset
- Overrides:
getXValue
in classAbstractXYDataset
- Parameters:
series
- the series index (zero-based).item
- the item index (zero-based).- Returns:
- The value.
-
getStartX
public java.lang.Number getStartX(int series, int item)
Returns the starting X value for the specified series and item.- Specified by:
getStartX
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item within a series (zero-based index).- Returns:
- The starting X value for the specified series and item.
- See Also:
getStartXValue(int, int)
-
getStartXValue
public double getStartXValue(int series, int item)
Returns the start x-value (as a double primitive) for an item within a series.- Specified by:
getStartXValue
in interfaceIntervalXYDataset
- Overrides:
getStartXValue
in classAbstractIntervalXYDataset
- Parameters:
series
- the series index (zero-based).item
- the item index (zero-based).- Returns:
- The value.
- See Also:
IntervalXYDataset.getStartX(int, int)
-
getEndX
public java.lang.Number getEndX(int series, int item)
Returns the ending X value for the specified series and item.- Specified by:
getEndX
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item within a series (zero-based index).- Returns:
- The ending X value for the specified series and item.
- See Also:
getEndXValue(int, int)
-
getEndXValue
public double getEndXValue(int series, int item)
Returns the end x-value (as a double primitive) for an item within a series.- Specified by:
getEndXValue
in interfaceIntervalXYDataset
- Overrides:
getEndXValue
in classAbstractIntervalXYDataset
- Parameters:
series
- the series index (zero-based).item
- the item index (zero-based).- Returns:
- The value.
- See Also:
IntervalXYDataset.getEndX(int, int)
-
getY
public java.lang.Number getY(int series, int item)
Returns the y-value for an item within a series.
-
getStartY
public java.lang.Number getStartY(int series, int item)
Returns the starting Y value for the specified series and item.- Specified by:
getStartY
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item within a series (zero-based index).- Returns:
- The starting Y value for the specified series and item.
-
getEndY
public java.lang.Number getEndY(int series, int item)
Returns the ending Y value for the specified series and item.- Specified by:
getEndY
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item within a series (zero-based index).- Returns:
- The ending Y value for the specified series and item.
-
getXValue
private long getXValue(TimePeriod period)
Returns the x-value for a time period.- Parameters:
period
- the time period.- Returns:
- The x-value.
-
getDomainLowerBound
public double getDomainLowerBound(boolean includeInterval)
Returns the minimum x-value in the dataset.- Specified by:
getDomainLowerBound
in interfaceDomainInfo
- Parameters:
includeInterval
- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The minimum value.
-
getDomainUpperBound
public double getDomainUpperBound(boolean includeInterval)
Returns the maximum x-value in the dataset.- Specified by:
getDomainUpperBound
in interfaceDomainInfo
- Parameters:
includeInterval
- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The maximum value.
-
getDomainBounds
public Range getDomainBounds(boolean includeInterval)
Returns the range of the values in this dataset's domain.- Specified by:
getDomainBounds
in interfaceDomainInfo
- Parameters:
includeInterval
- a flag that controls whether or not the x-intervals are taken into account.- Returns:
- The range.
-
equals
public boolean equals(java.lang.Object obj)
Tests this dataset for equality with an arbitrary object.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of this dataset.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractDataset
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if the dataset cannot be cloned.
-
-