Module platform

Class XYSplineRenderer

All Implemented Interfaces:
Serializable, Cloneable, EventListener, AnnotationChangeListener, LegendItemSource, XYItemRenderer, PublicCloneable

public class XYSplineRenderer extends XYLineAndShapeRenderer
A renderer that connects data points with natural cubic splines and/or draws shapes at each data point. This renderer is designed for use with the XYPlot class. The example shown here is generated by the XYSplineRendererDemo1.java program included in the JFreeChart demo collection:

XYSplineRendererSample.png
See Also:
  • Constructor Details

    • XYSplineRenderer

      public XYSplineRenderer()
      Creates a new instance with the precision attribute defaulting to 5 and no fill of the area 'under' the spline.
    • XYSplineRenderer

      public XYSplineRenderer(int precision)
      Creates a new renderer with the specified precision and no fill of the area 'under' (between '0' and) the spline.
      Parameters:
      precision - the number of points between data items.
    • XYSplineRenderer

      public XYSplineRenderer(int precision, XYSplineRenderer.FillType fillType)
      Creates a new renderer with the specified precision and specified fill of the area 'under' (between '0' and) the spline.
      Parameters:
      precision - the number of points between data items.
      fillType - the type of fill beneath the curve (null not permitted).
  • Method Details

    • getPrecision

      public int getPrecision()
      Returns the number of line segments used to approximate the spline curve between data points.
      Returns:
      The number of line segments.
      See Also:
    • setPrecision

      public void setPrecision(int p)
      Set the resolution of splines and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      p - number of line segments between points (must be > 0).
      See Also:
    • getFillType

      public XYSplineRenderer.FillType getFillType()
      Returns the type of fill that the renderer draws beneath the curve.
      Returns:
      The type of fill (never null).
      See Also:
    • setFillType

      public void setFillType(XYSplineRenderer.FillType fillType)
      Set the fill type and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      fillType - the fill type (null not permitted).
      See Also:
    • getGradientPaintTransformer

      public GradientPaintTransformer getGradientPaintTransformer()
      Returns the gradient paint transformer, or null.
      Returns:
      The gradient paint transformer (possibly null).
    • setGradientPaintTransformer

      public void setGradientPaintTransformer(GradientPaintTransformer gpt)
      Sets the gradient paint transformer and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      gpt - the transformer (null permitted).
    • initialise

      public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info)
      Initialises the renderer.

      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 XYLineAndShapeRenderer
      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:
      The renderer state.
    • drawPrimaryLineAsPath

      protected void drawPrimaryLineAsPath(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis xAxis, ValueAxis yAxis, Rectangle2D dataArea)
      Draws the item (first pass). This method draws the lines connecting the items. Instead of drawing separate lines, a GeneralPath is constructed and drawn at the end of the series painting.
      Overrides:
      drawPrimaryLineAsPath in class XYLineAndShapeRenderer
      Parameters:
      g2 - the graphics device.
      state - the renderer state.
      plot - the plot (can be used to obtain standard color information etc).
      dataset - the dataset.
      pass - the pass.
      series - the series index (zero-based).
      item - the item index (zero-based).
      xAxis - the domain axis.
      yAxis - the range axis.
      dataArea - the area within which the data is being drawn.
    • equals

      public boolean equals(Object obj)
      Tests this renderer for equality with an arbitrary object.
      Overrides:
      equals in class XYLineAndShapeRenderer
      Parameters:
      obj - the object (null permitted).
      Returns:
      A boolean.