## org.jfree.data.xy
Class IntervalXYDelegate

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

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

    public class IntervalXYDelegate

extends java.lang.Object
implements DomainInfo, java.io.Serializable, java.lang.Cloneable, org.jfree.util.PublicCloneable

A class for delegating xy-interval issues to. Enhances a XYDataset to an XYIntervalDataset. The decorator pattern was not used because of the several possibly implemented interfaces of the decorated instance (e.g. TableXYDataset, RangeInfo, DomainInfo etc.).

This class calculates the minimal interval width between two items. This width influences the width of bars displayed with this dataset.

The width can be set manually or calculated automatically. The switch autoWidth allows to determine which behavior is used. The behavior is transparent: The width is always calculated automatically in the background without affecting the manually set width. The switch simply determines which value is used.
As default manually set width, 1.0 is used.
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).

Author:
  andreas.schroeder
See Also:
  Serialized Form

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

Method Summary
`java.lang.Object` `clone()`
`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 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 end x value based on the intervalWidth and the intervalPositionFactor.
`double` `getIntervalPositionFactor()` Returns the interval position factor.
`double` `getIntervalWidth()` Returns the full interval width.
`java.lang.Number` `getStartX(int series, int item)` Returns the start x value based on the intervalWidth and the intervalPositionFactor.
`boolean` `isAutoWidth()` Returns whether the interval width is automatically calculated or not.
`void` `itemAdded(int series, int item)` Updates the interval width if an item is added.
`void` `itemRemoved(double x)` Updates the interval width if an item is removed.
`void` `seriesAdded(int series)` Convenience method for XYSeriesCollection.
`void` `seriesRemoved()` A convenience method for `XYSeriesCollection` which is called whenever a series is removed - the interval width is recalculated.
`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 w)` Sets the manual interval width.

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

Constructor Detail

### IntervalXYDelegate

    public IntervalXYDelegate(XYDataset dataset)

  Creates an XYIntervalDelegate.

  Parameters:
    `dataset` - the dataset for which this interval delegate works.

### IntervalXYDelegate

    public IntervalXYDelegate(XYDataset dataset,
                              boolean autoWidth)

  Creates a new delegate for the specified dataset.

  Parameters:
    `dataset` - the dataset for which this interval delegate works.
    `autoWidth` - a flag that controls whether the interval width is calculated automatically.

Method Detail

### isAutoWidth

    public boolean isAutoWidth()

  Returns whether the interval width is automatically calculated or not.

  Returns:
    Whether the width is automatically calculated or not.

### setAutoWidth

    public void setAutoWidth(boolean b)

  Sets the flag that indicates whether the interval width is automatically calculated or not.

  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. 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 (in the range `0.0` to `1.0` inclusive).

### setIntervalWidth

    public void setIntervalWidth(double w)

  Sets the manual interval width.

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

### getIntervalWidth

    public double getIntervalWidth()

  Returns the full interval width. For behavior of this method, see the class comments.

  Returns:
    the interval width to use.

### getStartX

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

  Returns the start x value based on the intervalWidth and the intervalPositionFactor.

  Parameters:
    `series` - the series index.
    `item` - the item index.
  Returns:
    The start value based on the intervalWidth and the intervalPositionFactor.

### getEndX

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

  Returns the end x value based on the intervalWidth and the intervalPositionFactor.

  Parameters:
    `series` - the series index.
    `item` - the item index.
  Returns:
    The end value based on the intervalWidth and the intervalPositionFactor.

### 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 this dataset's domain.

  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.

### itemAdded

    public void itemAdded(int series,
                          int item)

  Updates the interval width if an item is added. That is, relaxes the interval width to the minimum of the actual interval width, the distance between the actual x value and the previous x value and the distance between the next x value and the actual x value.

  Parameters:
    `item` - the number of the item.
    `series` - the number of the series

### itemRemoved

    public void itemRemoved(double x)

  Updates the interval width if an item is removed. That is, enlarges the interval width to the new interval minimum if the removed value was part of the minimum. For performance reason this method should be called only if the x value was definitely removed from the series.

  Parameters:
    `x` - the x value of the removed item (that doesn't occur twice)

### seriesAdded

    public void seriesAdded(int series)

  Convenience method for XYSeriesCollection.

  Parameters:
    `series` - the series index.

### seriesRemoved

    public void seriesRemoved()

  A convenience method for `XYSeriesCollection` which is called whenever a series is removed - the interval width is recalculated.

### 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.