Class XYDifferenceRenderer

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

public class XYDifferenceRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, Cloneable, org.jfree.util.PublicCloneable, 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
  • Constructor Details

    • XYDifferenceRenderer

      public XYDifferenceRenderer()
      Creates a new renderer with default attributes.
    • XYDifferenceRenderer

      public XYDifferenceRenderer​(Paint positivePaint, 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 Details

    • getPositivePaint

      public Paint getPositivePaint()
      Returns the paint used to highlight positive differences.
      Returns:
      the paint (never null).
    • setPositivePaint

      public void setPositivePaint​(Paint paint)
      Sets the paint used to highlight positive differences.
      Parameters:
      paint - the paint (null not permitted).
    • getNegativePaint

      public Paint getNegativePaint()
      Returns the paint used to highlight negative differences.
      Returns:
      the paint (never null).
    • setNegativePaint

      public void setNegativePaint​(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​(Graphics2D g2, 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​(Graphics2D g2, XYItemRendererState state, 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.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a clone of the renderer.
      Specified by:
      clone in interface org.jfree.util.PublicCloneable
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - if the renderer cannot be cloned.