Class CandlestickRenderer
- All Implemented Interfaces:
Serializable,Cloneable,XYItemRenderer,org.jfree.util.PublicCloneable
public class CandlestickRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, org.jfree.util.PublicCloneable, Serializable
XYPlot (requires a
HighLowDataset).
This renderer does not include code to calculate the crosshair point for the plot.
- Author:
- Sylvain Vieujot
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static intWIDTHMETHOD_AVERAGEThe average width method.static intWIDTHMETHOD_INTERVALDATAThe interval data method.static intWIDTHMETHOD_SMALLESTThe smallest width method.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
Constructors Constructor Description CandlestickRenderer()Creates a new renderer for candlestick charts.CandlestickRenderer(double candleWidth)Creates a new renderer for candlestick charts.CandlestickRenderer(double candleWidth, boolean drawVolume, XYToolTipGenerator toolTipGenerator)Creates a new renderer for candlestick charts. -
Method Summary
Modifier and Type Method Description Objectclone()Returns a clone of the renderer.voiddrawItem(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.booleandrawVolume()Returns a flag indicating whether or not volume bars are drawn on the chart.booleanequals(Object obj)Tests this renderer for equality with another object.doublegetAutoWidthFactor()Returns the factor by which the available space automatically calculated for the candles will be multiplied to determine the actual width to use.doublegetAutoWidthGap()Returns the amount of space to leave on the left and right of each candle when automatically calculating widths.intgetAutoWidthMethod()Returns the method of automatically calculating the candle width.doublegetCandleWidth()Returns the width of each candle.PaintgetDownPaint()Returns the paint used to fill candles when the price moves down from open to close.doublegetMaxCandleWidthInMilliseconds()Returns the maximum width (in milliseconds) of each candle.PaintgetUpPaint()Returns the paint used to fill candles when the price moves up from open to close.XYItemRendererStateinitialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info)Initialises the renderer then returns the number of 'passes' through the data that the renderer will require (usually just one).voidsetAutoWidthFactor(double autoWidthFactor)Sets the factor by which the available space automatically calculated for the candles will be multiplied to determine the actual width to use.voidsetAutoWidthGap(double autoWidthGap)Sets the amount of space to leave on the left and right of each candle when automatically calculating widths.voidsetAutoWidthMethod(int autoWidthMethod)Sets the method of automatically calculating the candle width.voidsetCandleWidth(double width)Sets the candle width.voidsetDownPaint(Paint paint)Sets the paint used to fill candles when the price moves down from open to close.voidsetDrawVolume(boolean flag)Sets a flag that controls whether or not volume bars are drawn in the background.voidsetMaxCandleWidthInMilliseconds(double millis)Sets the maximum candle width (in milliseconds).voidsetUpPaint(Paint paint)Sets the paint used to fill candles when the price moves up from open to close.Methods inherited from class org.jfree.chart.renderer.AbstractXYItemRenderer
drawDomainGridLine, drawDomainMarker, drawRangeGridLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, getBaseLabelGenerator, getBaseToolTipGenerator, getDrawingSupplier, getLabelGenerator, getLegendItem, getPassCount, getPlot, getRangeExtent, getRangeType, getSeriesLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, setBaseLabelGenerator, setBaseToolTipGenerator, setLabelGenerator, setPlot, setSeriesLabelGenerator, setSeriesToolTipGenerator, setToolTipGenerator, setURLGeneratorMethods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, 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, setStrokeMethods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, waitMethods 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, getPassCount, 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
-
Field Details
-
WIDTHMETHOD_AVERAGE
public static final int WIDTHMETHOD_AVERAGEThe average width method.- See Also:
- Constant Field Values
-
WIDTHMETHOD_SMALLEST
public static final int WIDTHMETHOD_SMALLESTThe smallest width method.- See Also:
- Constant Field Values
-
WIDTHMETHOD_INTERVALDATA
public static final int WIDTHMETHOD_INTERVALDATAThe interval data method.- See Also:
- Constant Field Values
-
-
Constructor Details
-
CandlestickRenderer
public CandlestickRenderer()Creates a new renderer for candlestick charts. -
CandlestickRenderer
public CandlestickRenderer(double candleWidth)Creates a new renderer for candlestick charts.Use -1 for the candle width if you prefer the width to be calculated automatically.
- Parameters:
candleWidth- The candle width.
-
CandlestickRenderer
public CandlestickRenderer(double candleWidth, boolean drawVolume, XYToolTipGenerator toolTipGenerator)Creates a new renderer for candlestick charts.Use -1 for the candle width if you prefer the width to be calculated automatically.
- Parameters:
candleWidth- the candle width.drawVolume- a flag indicating whether or not volume bars should be drawn.toolTipGenerator- the tool tip generator.nullis none.
-
-
Method Details
-
getCandleWidth
public double getCandleWidth()Returns the width of each candle.- Returns:
- the candle width.
- See Also:
setCandleWidth(double)
-
setCandleWidth
public void setCandleWidth(double width)Sets the candle width.If you set the width to a negative value, the renderer will calculate the candle width automatically based on the space available on the chart.
- Parameters:
width- The width.- See Also:
setAutoWidthMethod(int),setAutoWidthGap(double),setAutoWidthFactor(double),setMaxCandleWidthInMilliseconds(double)
-
getMaxCandleWidthInMilliseconds
public double getMaxCandleWidthInMilliseconds()Returns the maximum width (in milliseconds) of each candle.- Returns:
- The maximum candle width in milliseconds.
-
setMaxCandleWidthInMilliseconds
public void setMaxCandleWidthInMilliseconds(double millis)Sets the maximum candle width (in milliseconds).- Parameters:
millis- The maximum width.- See Also:
setCandleWidth(double),setAutoWidthMethod(int),setAutoWidthGap(double),setAutoWidthFactor(double)
-
getAutoWidthMethod
public int getAutoWidthMethod()Returns the method of automatically calculating the candle width.- Returns:
- The method of automatically calculating the candle width.
-
setAutoWidthMethod
public void setAutoWidthMethod(int autoWidthMethod)Sets the method of automatically calculating the candle width.WIDTHMETHOD_AVERAGE: Divides the entire display (ignoring scale factor) by the number of items, and uses this as the available width.
WIDTHMETHOD_SMALLEST: Checks the interval between each item, and uses the smallest as the available width.
WIDTHMETHOD_INTERVALDATA: Assumes that the dataset supports the IntervalXYDataset interface, and uses the startXValue - endXValue as the available width.- Parameters:
autoWidthMethod- The method of automatically calculating the candle width.- See Also:
WIDTHMETHOD_AVERAGE,WIDTHMETHOD_SMALLEST,WIDTHMETHOD_INTERVALDATA,setCandleWidth(double),setAutoWidthGap(double),setAutoWidthFactor(double),setMaxCandleWidthInMilliseconds(double)
-
getAutoWidthFactor
public double getAutoWidthFactor()Returns the factor by which the available space automatically calculated for the candles will be multiplied to determine the actual width to use.- Returns:
- The width factor (generally between 0.0 and 1.0).
-
setAutoWidthFactor
public void setAutoWidthFactor(double autoWidthFactor)Sets the factor by which the available space automatically calculated for the candles will be multiplied to determine the actual width to use.- Parameters:
autoWidthFactor- The width factor (generally between 0.0 and 1.0).- See Also:
setCandleWidth(double),setAutoWidthMethod(int),setAutoWidthGap(double),setMaxCandleWidthInMilliseconds(double)
-
getAutoWidthGap
public double getAutoWidthGap()Returns the amount of space to leave on the left and right of each candle when automatically calculating widths.- Returns:
- The gap.
-
setAutoWidthGap
public void setAutoWidthGap(double autoWidthGap)Sets the amount of space to leave on the left and right of each candle when automatically calculating widths.- Parameters:
autoWidthGap- The gap.- See Also:
setCandleWidth(double),setAutoWidthMethod(int),setAutoWidthFactor(double),setMaxCandleWidthInMilliseconds(double)
-
getUpPaint
Returns the paint used to fill candles when the price moves up from open to close.- Returns:
- The paint.
-
setUpPaint
Sets the paint used to fill candles when the price moves up from open to close.Registered property change listeners are notified that the "CandleStickRenderer.upPaint" property has changed.
- Parameters:
paint- The paint.
-
getDownPaint
Returns the paint used to fill candles when the price moves down from open to close.- Returns:
- The paint.
-
setDownPaint
Sets the paint used to fill candles when the price moves down from open to close.Registered property change listeners are notified that the "CandleStickRenderer.downPaint" property has changed.
- Parameters:
paint- The paint.
-
drawVolume
public boolean drawVolume()Returns a flag indicating whether or not volume bars are drawn on the chart.- Returns:
trueif volume bars are drawn on the chart.
-
setDrawVolume
public void setDrawVolume(boolean flag)Sets a flag that controls whether or not volume bars are drawn in the background.- Parameters:
flag- The flag.
-
initialise
public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info)Initialises the renderer then returns the number of 'passes' through the data that the renderer will require (usually just one). 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:
initialisein interfaceXYItemRenderer- Overrides:
initialisein classAbstractXYItemRenderer- Parameters:
g2- the graphics device.dataArea- the area inside the axes.plot- the plot.dataset- the data.info- an optional info collection object to return data back to the caller.- Returns:
- The number of passes the renderer requires.
-
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:
drawItemin interfaceXYItemRenderer- Parameters:
g2- the graphics device.state- the renderer state.dataArea- the area within which the plot is being drawn.info- collects info about the drawing.plot- the plot (can be used to obtain standard color information etc).domainAxis- the domain axis.rangeAxis- the range axis.dataset- the dataset.series- the series index (zero-based).item- the item index (zero-based).crosshairState- crosshair information for the plot (nullpermitted).pass- the pass index.
-
equals
Tests this renderer for equality with another object.- Overrides:
equalsin classAbstractXYItemRenderer- Parameters:
obj- the object.- Returns:
trueorfalse.
-
clone
Returns a clone of the renderer.- Specified by:
clonein interfaceorg.jfree.util.PublicCloneable- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if the renderer cannot be cloned.
-