## org.jfree.chart.renderer
Class XYDifferenceRenderer

    java.lang.Object
      org.jfree.chart.renderer.AbstractRenderer
          org.jfree.chart.renderer.AbstractXYItemRenderer
              org.jfree.chart.renderer.XYDifferenceRenderer

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

public class XYDifferenceRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable

A renderer for an `XYPlot` that highlights the differences between two series. The renderer expects a dataset that:

- has exactly two series;
- each series has the same x-values;
- no `null` values;

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
`DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO`

Constructor Summary
`XYDifferenceRenderer()` Creates a new renderer with default attributes.
`XYDifferenceRenderer(java.awt.Paint positivePaint, java.awt.Paint negativePaint, boolean shapes)` Creates a new renderer.

Method Summary
`java.lang.Object` `clone()` Returns a clone of the renderer.
`void` `drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass)` Draws the visual representation of a single data item.
`protected void` `drawItemPass0(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState)` Draws the visual representation of a single data item, first pass.
`protected void` `drawItemPass1(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState)` Draws the visual representation of a single data item, second pass.
`protected java.awt.Shape` `getNegativeArea(float x0, float y0A, float y0B, float x1, float y1A, float y1B, PlotOrientation orientation)` Returns the negative area for a cross-over section.
`java.awt.Paint` `getNegativePaint()` Returns the paint used to highlight negative differences.
`int` `getPassCount()` Returns `2`, the number of passes required by the renderer.
`boolean` `getPlotShapes()` Returns a flag that controls whether or not shapes are drawn for each data value.
`protected java.awt.Shape` `getPositiveArea(float x0, float y0A, float y0B, float x1, float y1A, float y1B, PlotOrientation orientation)` Returns the positive area for a crossover point.
`java.awt.Paint` `getPositivePaint()` Returns the paint used to highlight positive differences.
`XYItemRendererState` `initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info)` Initialises the renderer and returns a state object that should be passed to subsequent calls to the drawItem() method.
`void` `setNegativePaint(java.awt.Paint paint)` Sets the paint used to highlight negative differences.
`void` `setPlotShapes(boolean flag)` Sets a flag that controls whether or not shapes are drawn for each data value.
`void` `setPositivePaint(java.awt.Paint paint)` Sets the paint used to highlight positive differences.

Methods inherited from class org.jfree.chart.renderer.AbstractXYItemRenderer

`drawDomainGridLine, drawDomainMarker, drawItemLabel, drawRangeGridLine, drawRangeMarker, equals, fillDomainGridBand, fillRangeGridBand, getBaseLabelGenerator, getBaseToolTipGenerator, getDrawingSupplier, getLabelGenerator, getLegendItem, getPlot, getRangeExtent, getRangeType, getSeriesLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, setBaseLabelGenerator, setBaseToolTipGenerator, setLabelGenerator, setPlot, setSeriesLabelGenerator, setSeriesToolTipGenerator, setToolTipGenerator, setURLGenerator, updateCrosshairValues`

Methods inherited from class org.jfree.chart.renderer.AbstractRenderer

`addChangeListener, calculateLabelAnchorPoint, createTransformedShape, getBaseItemLabelAnchor, getBaseItemLabelAngle, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelRotationAnchor, getBaseItemLabelsVisible, getBaseItemLabelTextAnchor, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseShape, getBaseStroke, getItemLabelAnchor, getItemLabelAnchorOffset, getItemLabelAngle, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemLabelRotationAnchor, getItemLabelTextAnchor, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelAnchor, getSeriesItemLabelAngle, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesItemLabelRotationAnchor, getSeriesItemLabelTextAnchor, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, hashCode, isItemLabelVisible, isSeriesItemLabelsVisible, notifyListeners, removeChangeListener, setBaseAngle, setBaseItemLabelAnchor, setBaseItemLabelFont, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelPaint, setBaseItemLabelRotationAnchor, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelTextAnchor, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlinePaint, setBaseOutlineStroke, setBaseOutlineStroke, setBasePaint, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseShape, setBaseShape, setBaseStroke, setBaseStroke, setItemLabelAnchor, setItemLabelAnchorOffset, setItemLabelAngle, setItemLabelFont, setItemLabelFont, setItemLabelPaint, setItemLabelPaint, setItemLabelRotationAnchor, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setItemLabelTextAnchor, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlinePaint, setOutlineStroke, setOutlineStroke, setPaint, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesAngle, setSeriesItemLabelAnchor, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelRotationAnchor, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelTextAnchor, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setShape, setShape, setStroke, setStroke`

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

Methods inherited from interface org.jfree.chart.renderer.XYItemRenderer

`addChangeListener, drawDomainGridLine, drawDomainMarker, drawRangeGridLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseLabelGenerator, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseShape, getBaseStroke, getBaseToolTipGenerator, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getLabelGenerator, getLegendItem, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPlot, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getRangeExtent, getRangeType, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesLabelGenerator, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, isItemLabelVisible, isSeriesItemLabelsVisible, removeChangeListener, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseLabelGenerator, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlineStroke, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseShape, setBaseStroke, setBaseToolTipGenerator, setItemLabelFont, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setLabelGenerator, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlineStroke, setPaint, setPlot, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesLabelGenerator, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesStroke, setSeriesToolTipGenerator, setShape, setStroke, setToolTipGenerator, setURLGenerator`

Constructor Detail

### XYDifferenceRenderer

    public XYDifferenceRenderer()

  Creates a new renderer with default attributes.

### XYDifferenceRenderer

    public XYDifferenceRenderer(java.awt.Paint positivePaint,
                                java.awt.Paint negativePaint,
                                boolean shapes)

  Creates a new renderer.

Parameters:
  `positivePaint` - the highlight color for positive differences (`null` not permitted).
  `negativePaint` - the highlight color for negative differences (`null` not permitted).
  `shapes` - draw shapes?

Method Detail

### getPositivePaint

    public java.awt.Paint getPositivePaint()

  Returns the paint used to highlight positive differences.

  Returns:
    the paint (never `null`).

### setPositivePaint

    public void setPositivePaint(java.awt.Paint paint)

  Sets the paint used to highlight positive differences.

  Parameters:
    `paint` - the paint (`null` not permitted).

### getNegativePaint

    public java.awt.Paint getNegativePaint()

  Returns the paint used to highlight negative differences.

  Returns:
    the paint (never `null`).

### setNegativePaint

    public void setNegativePaint(java.awt.Paint paint)

  Sets the paint used to highlight negative differences.

  Parameters:
    `paint` - the paint (`null` not permitted).

### getPlotShapes

    public boolean getPlotShapes()

  Returns a flag that controls whether or not shapes are drawn for each data value.

  Returns:
    a boolean.

### setPlotShapes

    public void setPlotShapes(boolean flag)

  Sets a flag that controls whether or not shapes are drawn for each data value.

  Parameters:
    `flag` - the flag.

### initialise

    public XYItemRendererState initialise(java.awt.Graphics2D g2,
                                          java.awt.geom.Rectangle2D dataArea,
                                          XYPlot plot,
                                          XYDataset data,
                                          PlotRenderingInfo info)

  Initialises the renderer and returns a state object that should be passed to subsequent calls to the drawItem() method. This method will be called before the first item is rendered, giving the renderer an opportunity to initialise any state information it wants to maintain. The renderer can do nothing if it chooses.

  Specified by:
    `initialise` in interface `XYItemRenderer`
  Overrides:
    `initialise` in class `AbstractXYItemRenderer`
  Parameters:
    `g2` - the graphics device.
    `dataArea` - the area inside the axes.
    `plot` - the plot.
    `data` - the data.
    `info` - an optional info collection object to return data back to the caller.
  Returns:
    a state object.

### getPassCount

    public int getPassCount()

  Returns `2`, the number of passes required by the renderer. The `XYPlot` will run through the dataset this number of times.

  Specified by:
    `getPassCount` in interface `XYItemRenderer`
  Overrides:
    `getPassCount` in class `AbstractXYItemRenderer`
  Returns:
    the number of passes required by the renderer.

### drawItem

    public void drawItem(java.awt.Graphics2D g2,
                         XYItemRendererState state,
                         java.awt.geom.Rectangle2D dataArea,
                         PlotRenderingInfo info,
                         XYPlot plot,
                         ValueAxis domainAxis,
                         ValueAxis rangeAxis,
                         XYDataset dataset,
                         int series,
                         int item,
                         CrosshairState crosshairState,
                         int pass)

  Draws the visual representation of a single data item.

  Specified by:
    `drawItem` in interface `XYItemRenderer`
  Parameters:
    `g2` - the graphics device.
    `state` - the renderer state.
    `dataArea` - the area within which the data is being drawn.
    `info` - collects information about the drawing.
    `plot` - the plot (can be used to obtain standard color information etc).
    `domainAxis` - the domain (horizontal) axis.
    `rangeAxis` - the range (vertical) axis.
    `dataset` - the dataset.
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
    `crosshairState` - crosshair information for the plot (`null` permitted).
    `pass` - the pass index.

### drawItemPass0

    protected void drawItemPass0(java.awt.Graphics2D g2,
                                 java.awt.geom.Rectangle2D dataArea,
                                 PlotRenderingInfo info,
                                 XYPlot plot,
                                 ValueAxis domainAxis,
                                 ValueAxis rangeAxis,
                                 XYDataset dataset,
                                 int series,
                                 int item,
                                 CrosshairState crosshairState)

  Draws the visual representation of a single data item, first pass.

  Parameters:
    `g2` - the graphics device.
    `dataArea` - the area within which the data is being drawn.
    `info` - collects information about the drawing.
    `plot` - the plot (can be used to obtain standard color information etc).
    `domainAxis` - the domain (horizontal) axis.
    `rangeAxis` - the range (vertical) axis.
    `dataset` - the dataset.
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
    `crosshairState` - crosshair information for the plot (`null` permitted).

### drawItemPass1

    protected void drawItemPass1(java.awt.Graphics2D g2,
                                 java.awt.geom.Rectangle2D dataArea,
                                 PlotRenderingInfo info,
                                 XYPlot plot,
                                 ValueAxis domainAxis,
                                 ValueAxis rangeAxis,
                                 XYDataset dataset,
                                 int series,
                                 int item,
                                 CrosshairState crosshairState)

  Draws the visual representation of a single data item, second pass. In the second pass, the renderer draws the lines and shapes for the individual points in the two series.

  Parameters:
    `g2` - the graphics device.
    `dataArea` - the area within which the data is being drawn.
    `info` - collects information about the drawing.
    `plot` - the plot (can be used to obtain standard color information etc).
    `domainAxis` - the domain (horizontal) axis.
    `rangeAxis` - the range (vertical) axis.
    `dataset` - the dataset.
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
    `crosshairState` - crosshair information for the plot (`null` permitted).

### getPositiveArea

    protected java.awt.Shape getPositiveArea(float x0,
                                             float y0A,
                                             float y0B,
                                             float x1,
                                             float y1A,
                                             float y1B,
                                             PlotOrientation orientation)

  Returns the positive area for a crossover point.

  Parameters:
    `x0` - x coordinate.
    `y0A` - y coordinate A.
    `y0B` - y coordinate B.
    `x1` - x coordinate.
    `y1A` - y coordinate A.
    `y1B` - y coordinate B.
    `orientation` - the plot orientation.
  Returns:
    The positive area.

### getNegativeArea

    protected java.awt.Shape getNegativeArea(float x0,
                                             float y0A,
                                             float y0B,
                                             float x1,
                                             float y1A,
                                             float y1B,
                                             PlotOrientation orientation)

  Returns the negative area for a cross-over section.

  Parameters:
    `x0` - x coordinate.
    `y0A` - y coordinate A.
    `y0B` - y coordinate B.
    `x1` - x coordinate.
    `y1A` - y coordinate A.
    `y1B` - y coordinate B.
    `orientation` - the plot orientation.
  Returns:
    The negative area.

### clone

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

  Returns a clone of the renderer.

  Specified by:
    `clone` in interface `org.jfree.util.PublicCloneable`
  Overrides:
    `clone` in class `AbstractXYItemRenderer`
  Returns:
    A clone.
  Throws:
    `java.lang.CloneNotSupportedException` - if the renderer cannot be cloned.