public class IntervalXYDelegate extends java.lang.Object implements DatasetChangeListener, DomainInfo, java.io.Serializable, java.lang.Cloneable, org.jfree.util.PublicCloneable
XYDataset
to support the IntervalXYDataset
interface.
The decorator pattern was not used because of the several possibly
implemented interfaces of the decorated instance (e.g.
TableXYDataset
, RangeInfo
, DomainInfo
etc.).
The width can be set manually or calculated automatically. The switch autoWidth allows to determine which behavior is used. The auto width calculation tries to find the smallest gap between two x-values in the dataset. If there is only one item in the series, the auto width calculation fails and falls back on the manually set interval width (which is itself defaulted to 1.0).
Constructor and Description |
---|
IntervalXYDelegate(XYDataset dataset)
Creates a new delegate that.
|
IntervalXYDelegate(XYDataset dataset,
boolean autoWidth)
Creates a new delegate for the specified dataset.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
void |
datasetChanged(DatasetChangeEvent e)
Handles events from the dataset by recalculating the interval if
necessary.
|
boolean |
equals(java.lang.Object obj)
Tests the delegate for equality with an arbitrary object.
|
Range |
getDomainBounds(boolean includeInterval)
Returns the range of the values in the dataset's domain, including
or excluding the interval around each x-value as specified.
|
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 end value of the x-interval for an item within a series.
|
double |
getEndXValue(int series,
int item)
Returns the end value of the x-interval for an item within a series.
|
double |
getFixedIntervalWidth()
Returns the fixed interval width.
|
double |
getIntervalPositionFactor()
Returns the interval position factor.
|
double |
getIntervalWidth()
Returns the interval width.
|
java.lang.Number |
getStartX(int series,
int item)
Returns the start value of the x-interval for an item within a series.
|
double |
getStartXValue(int series,
int item)
Returns the start value of the x-interval for an item within a series.
|
int |
hashCode()
Returns a hash code for this instance.
|
boolean |
isAutoWidth()
Returns
true if the interval width is automatically
calculated, and false otherwise. |
void |
setAutoWidth(boolean b)
Sets the flag that indicates whether the interval width is automatically
calculated.
|
void |
setFixedIntervalWidth(double w)
Sets the fixed interval width and, as a side effect, sets the
autoWidth flag to false . |
void |
setIntervalPositionFactor(double d)
Sets the interval position factor.
|
public IntervalXYDelegate(XYDataset dataset)
dataset
- the underlying dataset (null
not permitted).public IntervalXYDelegate(XYDataset dataset, boolean autoWidth)
dataset
- the underlying dataset (null
not permitted).autoWidth
- a flag that controls whether the interval width is
calculated automatically.public boolean isAutoWidth()
true
if the interval width is automatically
calculated, and false
otherwise.public void setAutoWidth(boolean b)
true
, the interval is
recalculated.
Note: recalculating the interval amounts to changing the data values
represented by the dataset. The calling dataset must fire an
appropriate DatasetChangeEvent
.
b
- a boolean.public double getIntervalPositionFactor()
public void setIntervalPositionFactor(double d)
DatasetChangeEvent
.d
- the new interval position factor (in the range
0.0
to 1.0
inclusive).public double getFixedIntervalWidth()
public void setFixedIntervalWidth(double w)
autoWidth
flag to false
.
DatasetChangeEvent
.w
- the width (negative values not permitted).public double getIntervalWidth()
isAutoWidth()
result.public java.lang.Number getStartX(int series, int item)
series
- the series index.item
- the item index.null
).getStartXValue(int, int)
public double getStartXValue(int series, int item)
series
- the series index.item
- the item index.getStartX(int, int)
public java.lang.Number getEndX(int series, int item)
series
- the series index.item
- the item index.null
).getEndXValue(int, int)
public double getEndXValue(int series, int item)
series
- the series index.item
- the item index.getEndX(int, int)
public double getDomainLowerBound(boolean includeInterval)
getDomainLowerBound
in interface DomainInfo
includeInterval
- a flag that determines whether or not the
x-interval is taken into account.public double getDomainUpperBound(boolean includeInterval)
getDomainUpperBound
in interface DomainInfo
includeInterval
- a flag that determines whether or not the
x-interval is taken into account.public Range getDomainBounds(boolean includeInterval)
getDomainBounds
in interface DomainInfo
includeInterval
- a flag that determines whether or not the
x-interval should be taken into account.public void datasetChanged(DatasetChangeEvent e)
datasetChanged
in interface DatasetChangeListener
e
- the event.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object (null
permitted).public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface org.jfree.util.PublicCloneable
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if the object cannot be cloned.public int hashCode()
hashCode
in class java.lang.Object