Class XYBezierRenderer

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

public class XYBezierRenderer extends XYLineAndShapeRenderer
A renderer that connects data points with Bezier cubic curves and/or draws shapes at each data point. This renderer is designed for use with the XYPlot class.

Since:
See Also:
  • Field Details

    • precision

      private int precision
      Resolution of Bezier curves (number of line segments between points)
    • tension

      private double tension
      Tension defines how sharply does the curve bends
    • fillType

      private XYBezierRenderer.FillType fillType
      A flag that can be set to specify to fill the area under the Bezier curve.
    • gradientPaintTransformer

      private GradientPaintTransformer gradientPaintTransformer
  • Constructor Details

    • XYBezierRenderer

      public XYBezierRenderer()
      Creates a new instance with the precision attribute defaulting to 5, the tension attribute defaulting to 2 and no fill of the area 'under' the Bezier curve.
    • XYBezierRenderer

      public XYBezierRenderer(int precision, double tension)
      Creates a new renderer with the specified precision and tension and no fill of the area 'under' (between '0' and) the Bezier curve.
      Parameters:
      precision - the number of points between data items.
      tension - value to define how sharply the curve bends
    • XYBezierRenderer

      public XYBezierRenderer(int precision, double tension, XYBezierRenderer.FillType fillType)
      Creates a new renderer with the specified precision and specified fill of the area 'under' (between '0' and) the Bezier curve.
      Parameters:
      precision - the number of points between data items.
      tension - value to define how sharply the Bezier curve bends
      fillType - the type of fill beneath the curve (null not permitted).
      Since:
      1.0.17
  • Method Details

    • getPrecision

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

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

      public double getTension()
      Returns the value of the tension which defines how sharply does the curve bends
      Returns:
      The value of tesion.
      See Also:
    • setTension

      public void setTension(double t)
      Set the value of the tension which defines how sharply does the curve bends and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      t - value of tension (must be > 0).
      See Also:
    • getFillType

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

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

      public GradientPaintTransformer getGradientPaintTransformer()
      Returns the gradient paint transformer, or null.
      Returns:
      The gradient paint transformer (possibly null).
      Since:
      1.0.17
    • 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).
      Since:
      1.0.17
    • 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:
      state - the renderer state.
      g2 - the graphics device.
      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.
    • addBezierPointsToSeriesPath

      private void addBezierPointsToSeriesPath(Point2D[] segmentPoints, XYBezierRenderer.XYBezierState s)
    • getFinalPoints

      private Point2D[] getFinalPoints(XYBezierRenderer.XYBezierState s)
    • getInitalPoints

      private Point2D[] getInitalPoints(XYBezierRenderer.XYBezierState s)
    • calculateSegmentPoints

      private Point2D[] calculateSegmentPoints(Point2D[] original4Points)
    • calcSegmentPointsInitial

      private Point2D[] calcSegmentPointsInitial(Point2D[] original3P)
    • calcSegmentPointsFinal

      private Point2D[] calcSegmentPointsFinal(Point2D[] original3P)
    • calcUnitaryVector

      private Point2D calcUnitaryVector(Point2D pOrigin, Point2D pEnd)
    • 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.