Package org.jfree.data.xy
Class DefaultTableXYDataset
- 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.xy.DefaultTableXYDataset
-
- 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 DefaultTableXYDataset extends AbstractIntervalXYDataset implements TableXYDataset, IntervalXYDataset, DomainInfo, PublicCloneable
AnXYDataset
where every series shares the same x-values (required for generating stacked area charts).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
autoPrune
A flag that controls auto pruning.private java.util.List
data
Storage for the data - this list will contain zero, one or many XYSeries objects.private IntervalXYDelegate
intervalDelegate
The delegate used to control the interval width.private boolean
propagateEvents
A flag that controls whether or not events are propogated.private java.util.HashSet
xPoints
Storage for the x values.
-
Constructor Summary
Constructors Constructor Description DefaultTableXYDataset()
Creates a new empty dataset.DefaultTableXYDataset(boolean autoPrune)
Creates a new empty dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSeries(XYSeries series)
Adds a series to the collection and sends aDatasetChangeEvent
to all registered listeners.protected boolean
canPrune(java.lang.Number x)
Returnstrue
if all the y-values for the specified x-value arenull
andfalse
otherwise.java.lang.Object
clone()
Returns an independent copy of this dataset.boolean
equals(java.lang.Object obj)
Tests this collection for equality with an arbitrary object.Range
getDomainBounds(boolean includeInterval)
Returns the range of the values in this dataset's domain.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.java.lang.Number
getEndY(int series, int item)
Returns the ending Y value for the specified series and item.double
getIntervalPositionFactor()
Returns the interval position factor.double
getIntervalWidth()
returns the full interval width.int
getItemCount()
Returns the number of x values in the dataset.int
getItemCount(int series)
Returns the number of items in the specified series.XYSeries
getSeries(int series)
Returns a series.int
getSeriesCount()
Returns the number of series in the collection.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.java.lang.Number
getStartY(int series, int item)
Returns the starting Y value for the specified series and item.java.lang.Number
getX(int series, int item)
Returns the x-value for the specified series and item.java.lang.Number
getY(int series, int index)
Returns the y-value for the specified series and item.int
hashCode()
Returns a hash code.boolean
isAutoPrune()
Returns the flag that controls whether or not x-values are removed from the dataset when the corresponding y-values are allnull
.boolean
isAutoWidth()
Returns whether the interval width is automatically calculated or not.void
prune()
Removes all x-values for which all the y-values arenull
.void
removeAllSeries()
Removes all the series from the collection and sends aDatasetChangeEvent
to all registered listeners.void
removeAllValuesForX(java.lang.Number x)
Removes the items from all series for a given x value.void
removeSeries(int series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.void
removeSeries(XYSeries series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.void
seriesChanged(SeriesChangeEvent event)
This method receives notification when a series belonging to the dataset changes.void
setAutoWidth(boolean b)
Sets the flag that indicates whether the interval width is automatically calculated or not.void
setIntervalPositionFactor(double d)
Sets the interval position factor.void
setIntervalWidth(double d)
Sets the interval width to a fixed value, and sends aDatasetChangeEvent
to all registered listeners.void
updateXPoints()
Updates the x-values for all the series in the dataset.private void
updateXPoints(XYSeries series)
Adds any unique x-values from 'series' to the dataset, and also adds any x-values that are in the dataset but not in 'series' to the series.-
Methods inherited from class org.jfree.data.xy.AbstractIntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValue
-
Methods inherited from class org.jfree.data.xy.AbstractXYDataset
getDomainOrder, getXValue, getYValue
-
Methods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf
-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, 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.data.xy.IntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValue
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
Methods inherited from interface org.jfree.data.xy.XYDataset
getDomainOrder, getXValue, getYValue
-
-
-
-
Field Detail
-
data
private java.util.List data
Storage for the data - this list will contain zero, one or many XYSeries objects.
-
xPoints
private java.util.HashSet xPoints
Storage for the x values.
-
propagateEvents
private boolean propagateEvents
A flag that controls whether or not events are propogated.
-
autoPrune
private boolean autoPrune
A flag that controls auto pruning.
-
intervalDelegate
private IntervalXYDelegate intervalDelegate
The delegate used to control the interval width.
-
-
Constructor Detail
-
DefaultTableXYDataset
public DefaultTableXYDataset()
Creates a new empty dataset.
-
DefaultTableXYDataset
public DefaultTableXYDataset(boolean autoPrune)
Creates a new empty dataset.- Parameters:
autoPrune
- a flag that controls whether or not x-values are removed whenever the corresponding y-values are allnull
.
-
-
Method Detail
-
isAutoPrune
public boolean isAutoPrune()
Returns the flag that controls whether or not x-values are removed from the dataset when the corresponding y-values are allnull
.- Returns:
- A boolean.
-
addSeries
public void addSeries(XYSeries series)
Adds a series to the collection and sends aDatasetChangeEvent
to all registered listeners. The series should be configured to NOT allow duplicate x-values.- Parameters:
series
- the series (null
not permitted).
-
updateXPoints
private void updateXPoints(XYSeries series)
Adds any unique x-values from 'series' to the dataset, and also adds any x-values that are in the dataset but not in 'series' to the series.- Parameters:
series
- the series (null
not permitted).
-
updateXPoints
public void updateXPoints()
Updates the x-values for all the series in the dataset.
-
getSeriesCount
public int getSeriesCount()
Returns the number of series in the collection.- Specified by:
getSeriesCount
in interfaceSeriesDataset
- Specified by:
getSeriesCount
in classAbstractSeriesDataset
- Returns:
- The series count.
-
getItemCount
public int getItemCount()
Returns the number of x values in the dataset.- Specified by:
getItemCount
in interfaceTableXYDataset
- Returns:
- The number of x values in the dataset.
-
getSeries
public XYSeries getSeries(int series)
Returns a series.- Parameters:
series
- the series (zero-based index).- Returns:
- The series (never
null
).
-
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 a series.
-
getItemCount
public int getItemCount(int series)
Returns the number of items in the specified series.- Specified by:
getItemCount
in interfaceXYDataset
- Parameters:
series
- the series (zero-based index).- Returns:
- The number of items in the specified series.
-
getX
public java.lang.Number getX(int series, int item)
Returns the x-value for the specified series and item.
-
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 (zero-based index).- Returns:
- The starting X value.
-
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 (zero-based index).- Returns:
- The ending X value.
-
getY
public java.lang.Number getY(int series, int index)
Returns the y-value for the specified series and item.
-
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 (zero-based index).- Returns:
- The starting Y value.
-
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 (zero-based index).- Returns:
- The ending Y value.
-
removeAllSeries
public void removeAllSeries()
Removes all the series from the collection and sends aDatasetChangeEvent
to all registered listeners.
-
removeSeries
public void removeSeries(XYSeries series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
series
- the series (null
not permitted).
-
removeSeries
public void removeSeries(int series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
series
- the series (zero based index).
-
removeAllValuesForX
public void removeAllValuesForX(java.lang.Number x)
Removes the items from all series for a given x value.- Parameters:
x
- the x-value.
-
canPrune
protected boolean canPrune(java.lang.Number x)
Returnstrue
if all the y-values for the specified x-value arenull
andfalse
otherwise.- Parameters:
x
- the x-value.- Returns:
- A boolean.
-
prune
public void prune()
Removes all x-values for which all the y-values arenull
.
-
seriesChanged
public void seriesChanged(SeriesChangeEvent event)
This method receives notification when a series belonging to the dataset changes. It responds by updating the x-points for the entire dataset and sending aDatasetChangeEvent
to all registered listeners.- Specified by:
seriesChanged
in interfaceSeriesChangeListener
- Overrides:
seriesChanged
in classAbstractSeriesDataset
- Parameters:
event
- information about the change.
-
equals
public boolean equals(java.lang.Object obj)
Tests this collection for equality with an arbitrary object.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code.- Overrides:
hashCode
in classAbstractDataset
- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns an independent copy of this dataset.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractDataset
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if there is some reason that cloning cannot be performed.
-
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 determines whether or not the x-interval is taken into account.- Returns:
- The range.
-
getIntervalPositionFactor
public double getIntervalPositionFactor()
Returns the interval position factor.- Returns:
- The interval position factor.
-
setIntervalPositionFactor
public void setIntervalPositionFactor(double d)
Sets the interval position factor. Must be between 0.0 and 1.0 inclusive. If the factor is 0.5, the gap is in the middle of the x values. If it is lesser than 0.5, the gap is farther to the left and if greater than 0.5 it gets farther to the right.- Parameters:
d
- the new interval position factor.
-
getIntervalWidth
public double getIntervalWidth()
returns the full interval width.- Returns:
- The interval width to use.
-
setIntervalWidth
public void setIntervalWidth(double d)
Sets the interval width to a fixed value, and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
d
- the new interval width (must be > 0).
-
isAutoWidth
public boolean isAutoWidth()
Returns whether the interval width is automatically calculated or not.- Returns:
- A flag that determines whether or not the interval width is automatically calculated.
-
setAutoWidth
public void setAutoWidth(boolean b)
Sets the flag that indicates whether the interval width is automatically calculated or not.- Parameters:
b
- a boolean.
-
-