Package org.jfree.data.xy
Class IntervalXYDelegate
java.lang.Object
org.jfree.data.xy.IntervalXYDelegate
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,PublicCloneable,DomainInfo,DatasetChangeListener
public class IntervalXYDelegate
extends Object
implements DatasetChangeListener, DomainInfo, Serializable, Cloneable, PublicCloneable
A delegate that handles the specification or automatic calculation of the
interval surrounding the x-values in a dataset. This is used to extend
a regular
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).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIntervalXYDelegate(XYDataset dataset) Creates a new delegate that.IntervalXYDelegate(XYDataset dataset, boolean autoWidth) Creates a new delegate for the specified dataset. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of the object.voidHandles events from the dataset by recalculating the interval if necessary.booleanTests the delegate for equality with an arbitrary object.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.doublegetDomainLowerBound(boolean includeInterval) Returns the minimum x-value in the dataset.doublegetDomainUpperBound(boolean includeInterval) Returns the maximum x-value in the dataset.getEndX(int series, int item) Returns the end value of the x-interval for an item within a series.doublegetEndXValue(int series, int item) Returns the end value of the x-interval for an item within a series.doubleReturns the fixed interval width.doubleReturns the interval position factor.doubleReturns the interval width.getStartX(int series, int item) Returns the start value of the x-interval for an item within a series.doublegetStartXValue(int series, int item) Returns the start value of the x-interval for an item within a series.inthashCode()Returns a hash code for this instance.booleanReturnstrueif the interval width is automatically calculated, andfalseotherwise.voidsetAutoWidth(boolean b) Sets the flag that indicates whether the interval width is automatically calculated.voidsetFixedIntervalWidth(double w) Sets the fixed interval width and, as a side effect, sets theautoWidthflag tofalse.voidsetIntervalPositionFactor(double d) Sets the interval position factor.
-
Constructor Details
-
IntervalXYDelegate
Creates a new delegate that.- Parameters:
dataset- the underlying dataset (nullnot permitted).
-
IntervalXYDelegate
Creates a new delegate for the specified dataset.- Parameters:
dataset- the underlying dataset (nullnot permitted).autoWidth- a flag that controls whether the interval width is calculated automatically.
-
-
Method Details
-
isAutoWidth
Returnstrueif the interval width is automatically calculated, andfalseotherwise.- Returns:
- A boolean.
-
setAutoWidth
Sets the flag that indicates whether the interval width is automatically calculated. If the flag is set totrue, 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.- Parameters:
b- a boolean.
-
getIntervalPositionFactor
Returns the interval position factor.- Returns:
- The interval position factor.
-
setIntervalPositionFactor
Sets the interval position factor. This controls how the interval is aligned to the x-value. For a value of 0.5, the interval is aligned with the x-value in the center. For a value of 0.0, the interval is aligned with the x-value at the lower end of the interval, and for a value of 1.0, the interval is aligned with the x-value at the upper end of the interval.
Note that changing the interval position factor amounts to changing the data values represented by the dataset. Therefore, the dataset that is using this delegate is responsible for generating the appropriateDatasetChangeEvent.- Parameters:
d- the new interval position factor (in the range0.0to1.0inclusive).
-
getFixedIntervalWidth
Returns the fixed interval width.- Returns:
- The fixed interval width.
-
setFixedIntervalWidth
Sets the fixed interval width and, as a side effect, sets theautoWidthflag tofalse.
Note that changing the interval width amounts to changing the data values represented by the dataset. Therefore, the dataset that is using this delegate is responsible for generating the appropriateDatasetChangeEvent.- Parameters:
w- the width (negative values not permitted).
-
getIntervalWidth
Returns the interval width. This method will return either the auto calculated interval width or the manually specified interval width, depending on theisAutoWidth()result.- Returns:
- The interval width to use.
-
getStartX
Returns the start value of the x-interval for an item within a series.- Parameters:
series- the series index.item- the item index.- Returns:
- The start value of the x-interval (possibly
null). - See Also:
-
getStartXValue
Returns the start value of the x-interval for an item within a series.- Parameters:
series- the series index.item- the item index.- Returns:
- The start value of the x-interval.
- See Also:
-
getEndX
Returns the end value of the x-interval for an item within a series.- Parameters:
series- the series index.item- the item index.- Returns:
- The end value of the x-interval (possibly
null). - See Also:
-
getEndXValue
Returns the end value of the x-interval for an item within a series.- Parameters:
series- the series index.item- the item index.- Returns:
- The end value of the x-interval.
- See Also:
-
getDomainLowerBound
Returns the minimum x-value in the dataset.- Specified by:
getDomainLowerBoundin interfaceDomainInfo- Parameters:
includeInterval- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The minimum value.
-
getDomainUpperBound
Returns the maximum x-value in the dataset.- Specified by:
getDomainUpperBoundin interfaceDomainInfo- Parameters:
includeInterval- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The maximum value.
-
getDomainBounds
Returns the range of the values in the dataset's domain, including or excluding the interval around each x-value as specified.- Specified by:
getDomainBoundsin interfaceDomainInfo- Parameters:
includeInterval- a flag that determines whether or not the x-interval should be taken into account.- Returns:
- The range.
-
datasetChanged
Handles events from the dataset by recalculating the interval if necessary.- Specified by:
datasetChangedin interfaceDatasetChangeListener- Parameters:
e- the event.
-
equals
Tests the delegate for equality with an arbitrary object. The equality test considers two delegates to be equal if they would calculate the same intervals for any given dataset (for this reason, the dataset itself is NOT included in the equality test, because it is just a reference back to the current 'owner' of the delegate). -
clone
Description copied from interface:PublicCloneableReturns a clone of the object.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classObject- Returns:
- A clone of this delegate.
- Throws:
CloneNotSupportedException- if the object cannot be cloned.
-
hashCode
Returns a hash code for this instance.
-