## org.jfree.data.xy
Class IntervalXYDelegate

    java.lang.Object
      org.jfree.data.xy.IntervalXYDelegate

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, java.util.EventListener, DomainInfo, DatasetChangeListener, org.jfree.util.PublicCloneable

    public class IntervalXYDelegate

extends java.lang.Object
implements DatasetChangeListener, DomainInfo, java.io.Serializable, java.lang.Cloneable, org.jfree.util.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:
  Serialized Form

Constructor Summary
`IntervalXYDelegate(XYDataset dataset)` Creates a new delegate that.
`IntervalXYDelegate(XYDataset dataset, boolean autoWidth)` Creates a new delegate for the specified dataset.

Method Summary
`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.
`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.

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### IntervalXYDelegate

    public IntervalXYDelegate(XYDataset dataset)

  Creates a new delegate that.

  Parameters:
    `dataset` - the underlying dataset (`null` not permitted).

### IntervalXYDelegate

    public IntervalXYDelegate(XYDataset dataset,
                              boolean autoWidth)

  Creates a new delegate for the specified dataset.

  Parameters:
    `dataset` - the underlying dataset (`null` not permitted).
    `autoWidth` - a flag that controls whether the interval width is calculated automatically.

Method Detail

### isAutoWidth

    public boolean isAutoWidth()

  Returns `true` if the interval width is automatically calculated, and `false` otherwise.

  Returns:
    A boolean.

### setAutoWidth

    public void setAutoWidth(boolean b)

  Sets the flag that indicates whether the interval width is automatically calculated. If the flag is set to `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`.

  Parameters:
    `b` - a boolean.

### 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. 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 appropriate `DatasetChangeEvent`.

  Parameters:
    `d` - the new interval position factor (in the range `0.0` to `1.0` inclusive).

### getFixedIntervalWidth

    public double getFixedIntervalWidth()

  Returns the fixed interval width.

  Returns:
    The fixed interval width.

### setFixedIntervalWidth

    public void setFixedIntervalWidth(double w)

  Sets the fixed interval width and, as a side effect, sets the `autoWidth` flag to `false`. 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 appropriate `DatasetChangeEvent`.

  Parameters:
    `w` - the width (negative values not permitted).

### getIntervalWidth

    public double getIntervalWidth()

  Returns the interval width. This method will return either the auto calculated interval width or the manually specified interval width, depending on the `isAutoWidth()` result.

  Returns:
    The interval width to use.

### getStartX

    public java.lang.Number getStartX(int series,
                                      int item)

  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(int, int)`

### getStartXValue

    public double getStartXValue(int series,
                                 int item)

  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:
    `getStartX(int, int)`

### getEndX

    public java.lang.Number getEndX(int series,
                                    int item)

  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(int, int)`

### getEndXValue

    public double getEndXValue(int series,
                               int item)

  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:
    `getEndX(int, int)`

### getDomainLowerBound

    public double getDomainLowerBound(boolean includeInterval)

  Returns the minimum x-value in the dataset.

  Specified by:
    `getDomainLowerBound` in interface `DomainInfo`
  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 interface `DomainInfo`
  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 the dataset's domain, including or excluding the interval around each x-value as specified.

  Specified by:
    `getDomainBounds` in interface `DomainInfo`
  Parameters:
    `includeInterval` - a flag that determines whether or not the x-interval should be taken into account.
  Returns:
    The range.

### datasetChanged

    public void datasetChanged(DatasetChangeEvent e)

  Handles events from the dataset by recalculating the interval if necessary.

  Specified by:
    `datasetChanged` in interface `DatasetChangeListener`
  Parameters:
    `e` - the event.

### equals

    public boolean equals(java.lang.Object obj)

  Tests the delegate for equality with an arbitrary object.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `obj` - the object (`null` permitted).
  Returns:
    A boolean.

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Specified by:
    `clone` in interface `org.jfree.util.PublicCloneable`
  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    A clone of this delegate.
  Throws:
    `java.lang.CloneNotSupportedException` - if the object cannot be cloned.