Package org.jfree.chart.renderer.xy
Class XYBezierRenderer
java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.xy.AbstractXYItemRenderer
org.jfree.chart.renderer.xy.XYLineAndShapeRenderer
org.jfree.chart.renderer.xy.XYBezierRenderer
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,AnnotationChangeListener
,LegendItemSource
,XYItemRenderer
,PublicCloneable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enumeration of the fill types for the renderer.static class
Represents state information that applies to a single rendering of a chart.Nested classes/interfaces inherited from class org.jfree.chart.renderer.xy.XYLineAndShapeRenderer
XYLineAndShapeRenderer.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate XYBezierRenderer.FillType
A flag that can be set to specify to fill the area under the Bezier curve.private GradientPaintTransformer
private int
Resolution of Bezier curves (number of line segments between points)private double
Tension defines how sharply does the curve bendsFields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_ITEM_LABEL_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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
(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.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. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addBezierPointsToSeriesPath
(Point2D[] segmentPoints, XYBezierRenderer.XYBezierState s) private Point2D[]
calcSegmentPointsFinal
(Point2D[] original3P) private Point2D[]
calcSegmentPointsInitial
(Point2D[] original3P) private Point2D[]
calculateSegmentPoints
(Point2D[] original4Points) private Point2D
calcUnitaryVector
(Point2D pOrigin, Point2D pEnd) 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).boolean
Tests this renderer for equality with an arbitrary object.Returns the type of fill that the renderer draws beneath the curve.private Point2D[]
Returns the gradient paint transformer, ornull
.private Point2D[]
int
Returns the number of line segments used to approximate the Bezier curve between data points.double
Returns the value of the tension which defines how sharply does the curve bendsinitialise
(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) Initialises the renderer.void
setFillType
(XYBezierRenderer.FillType fillType) Set the fill type and sends aRendererChangeEvent
to all registered listeners.void
Sets the gradient paint transformer and sends aRendererChangeEvent
to all registered listeners.void
setPrecision
(int p) Set the resolution of Bezier curves and sends aRendererChangeEvent
to all registered listeners.void
setTension
(double t) Set the value of the tension which defines how sharply does the curve bends and sends aRendererChangeEvent
to all registered listeners.Methods inherited from class org.jfree.chart.renderer.xy.XYLineAndShapeRenderer
clone, drawFirstPassShape, drawItem, drawPrimaryLine, drawSecondaryPass, getDefaultLinesVisible, getDefaultShapesFilled, getDefaultShapesVisible, getDrawOutlines, getDrawSeriesLineAsPath, getItemLineVisible, getItemShapeFilled, getItemShapeVisible, getLegendItem, getLegendLine, getPassCount, getSeriesLinesVisible, getSeriesShapesFilled, getSeriesShapesVisible, getUseFillPaint, getUseOutlinePaint, hashCode, isItemPass, isLinePass, setDefaultLinesVisible, setDefaultShapesFilled, setDefaultShapesVisible, setDrawOutlines, setDrawSeriesLineAsPath, setLegendLine, setSeriesLinesVisible, setSeriesLinesVisible, setSeriesShapesFilled, setSeriesShapesFilled, setSeriesShapesVisible, setSeriesShapesVisible, setUseFillPaint, setUseOutlinePaint
Methods inherited from class org.jfree.chart.renderer.xy.AbstractXYItemRenderer
addAnnotation, addAnnotation, addEntity, annotationChanged, beginElementGroup, calculateDomainMarkerTextAnchorPoint, drawAnnotations, drawDomainLine, drawDomainMarker, drawItemLabel, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, findDomainBounds, findRangeBounds, findRangeBounds, getAnnotations, getDefaultItemLabelGenerator, getDefaultToolTipGenerator, getDrawingSupplier, getItemLabelGenerator, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, lineTo, moveTo, removeAnnotation, removeAnnotations, setDefaultItemLabelGenerator, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesToolTipGenerator, setURLGenerator, updateCrosshairValues
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, beginElementGroup, calculateLabelAnchorPoint, clearSeriesPaints, clearSeriesStrokes, endElementGroup, fireChangeEvent, getAutoPopulateSeriesFillPaint, getAutoPopulateSeriesOutlinePaint, getAutoPopulateSeriesOutlineStroke, getAutoPopulateSeriesPaint, getAutoPopulateSeriesShape, getAutoPopulateSeriesStroke, getDataBoundsIncludesVisibleSeriesOnly, getDefaultCreateEntities, getDefaultEntityRadius, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultLegendShape, getDefaultLegendTextFont, getDefaultLegendTextPaint, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelInsets, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendShape, getLegendTextFont, getLegendTextPaint, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisibleInLegend, getTreatLegendShapeAsLine, hasListener, isComputeItemLabelContrastColor, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setComputeItemLabelContrastColor, setDataBoundsIncludesVisibleSeriesOnly, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultEntityRadius, setDefaultFillPaint, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelFont, setDefaultItemLabelPaint, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultLegendShape, setDefaultLegendTextFont, setDefaultLegendTextPaint, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setItemLabelAnchorOffset, setItemLabelInsets, setLegendShape, setLegendTextFont, setLegendTextPaint, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setTreatLegendShapeAsLine
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.chart.LegendItemSource
getLegendItems
Methods inherited from interface org.jfree.chart.renderer.xy.XYItemRenderer
addAnnotation, addAnnotation, addChangeListener, drawAnnotations, drawDomainLine, drawDomainMarker, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, findRangeBounds, getDefaultCreateEntities, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelGenerator, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getDefaultToolTipGenerator, getItemCreateEntity, getItemFillPaint, getItemLabelFont, getItemLabelGenerator, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getPlot, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelGenerator, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getSeriesVisible, getSeriesVisibleInLegend, getToolTipGenerator, getURLGenerator, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeAnnotation, removeAnnotations, removeChangeListener, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultFillPaint, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelGenerator, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setPlot, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelGenerator, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesToolTipGenerator, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setURLGenerator
-
Field Details
-
precision
private int precisionResolution of Bezier curves (number of line segments between points) -
tension
private double tensionTension defines how sharply does the curve bends -
fillType
A flag that can be set to specify to fill the area under the Bezier curve. -
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
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 bendsfillType
- 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 aRendererChangeEvent
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 aRendererChangeEvent
to all registered listeners.- Parameters:
t
- value of tension (must be > 0).- See Also:
-
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
Set the fill type and sends aRendererChangeEvent
to all registered listeners.- Parameters:
fillType
- the fill type (null
not permitted).- Since:
- 1.0.17
- See Also:
-
getGradientPaintTransformer
Returns the gradient paint transformer, ornull
.- Returns:
- The gradient paint transformer (possibly
null
). - Since:
- 1.0.17
-
setGradientPaintTransformer
Sets the gradient paint transformer and sends aRendererChangeEvent
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 interfaceXYItemRenderer
- Overrides:
initialise
in classXYLineAndShapeRenderer
- 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 classXYLineAndShapeRenderer
- 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
-
getFinalPoints
-
getInitalPoints
-
calculateSegmentPoints
-
calcSegmentPointsInitial
-
calcSegmentPointsFinal
-
calcUnitaryVector
-
equals
Tests this renderer for equality with an arbitrary object.- Overrides:
equals
in classXYLineAndShapeRenderer
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-