public class CandlestickRenderer extends AbstractXYItemRenderer implements XYItemRenderer, java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable
XYPlot
(requires a
OHLCDataset
). The example shown here is generated
by the CandlestickChartDemo1.java
program included in the
JFreeChart demo collection:
This renderer does not include code to calculate the crosshair point for the plot.
Modifier and Type | Field and Description |
---|---|
static int |
WIDTHMETHOD_AVERAGE
The average width method.
|
static int |
WIDTHMETHOD_INTERVALDATA
The interval data method.
|
static int |
WIDTHMETHOD_SMALLEST
The smallest width method.
|
DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone of the renderer.
|
void |
drawItem(java.awt.Graphics2D g2,
XYItemRendererState state,
java.awt.geom.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.
|
boolean |
drawVolume()
Deprecated.
As of 1.0.5, you should use the
getDrawVolume()
method. |
boolean |
equals(java.lang.Object obj)
Tests this renderer for equality with another object.
|
Range |
findRangeBounds(XYDataset dataset)
Returns the range of values the renderer requires to display all the
items from the specified dataset.
|
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.
|
double |
getAutoWidthGap()
Returns the amount of space to leave on the left and right of each
candle when automatically calculating widths.
|
int |
getAutoWidthMethod()
Returns the method of automatically calculating the candle width.
|
double |
getCandleWidth()
Returns the width of each candle.
|
java.awt.Paint |
getDownPaint()
Returns the paint used to fill candles when the price moves down from
open to close.
|
boolean |
getDrawVolume()
Returns a flag indicating whether or not volume bars are drawn on the
chart.
|
double |
getMaxCandleWidthInMilliseconds()
Returns the maximum width (in milliseconds) of each candle.
|
java.awt.Paint |
getUpPaint()
Returns the paint used to fill candles when the price moves up from open
to close.
|
boolean |
getUseOutlinePaint()
Returns the flag that controls whether or not the renderer's outline
paint is used to draw the candlestick outline.
|
java.awt.Paint |
getVolumePaint()
Returns the paint that is used to fill the volume bars if they are
visible.
|
XYItemRendererState |
initialise(java.awt.Graphics2D g2,
java.awt.geom.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).
|
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.
|
void |
setAutoWidthGap(double autoWidthGap)
Sets the amount of space to leave on the left and right of each candle
when automatically calculating widths and sends a
RendererChangeEvent to all registered listeners. |
void |
setAutoWidthMethod(int autoWidthMethod)
Sets the method of automatically calculating the candle width and
sends a
RendererChangeEvent to all registered listeners. |
void |
setCandleWidth(double width)
Sets the candle width and sends a
RendererChangeEvent to all
registered listeners. |
void |
setDownPaint(java.awt.Paint paint)
Sets the paint used to fill candles when the price moves down from open
to close and sends a
RendererChangeEvent to all registered
listeners. |
void |
setDrawVolume(boolean flag)
Sets a flag that controls whether or not volume bars are drawn in the
background and sends a
RendererChangeEvent to all registered
listeners. |
void |
setMaxCandleWidthInMilliseconds(double millis)
Sets the maximum candle width (in milliseconds) and sends a
RendererChangeEvent to all registered listeners. |
void |
setUpPaint(java.awt.Paint paint)
Sets the paint used to fill candles when the price moves up from open
to close and sends a
RendererChangeEvent to all registered
listeners. |
void |
setUseOutlinePaint(boolean use)
Sets the flag that controls whether or not the renderer's outline
paint is used to draw the candlestick outline, and sends a
RendererChangeEvent to all registered listeners. |
void |
setVolumePaint(java.awt.Paint paint)
Sets the paint used to fill the volume bars, and sends a
RendererChangeEvent to all registered listeners. |
addAnnotation, addAnnotation, addEntity, annotationChanged, calculateDomainMarkerTextAnchorPoint, drawAnnotations, drawDomainGridLine, drawDomainLine, drawDomainMarker, drawItemLabel, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, findDomainBounds, findRangeBounds, getAnnotations, getBaseItemLabelGenerator, getBaseToolTipGenerator, getDrawingSupplier, getItemLabelGenerator, getItemLabelGenerator, getLegendItem, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPassCount, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getToolTipGenerator, getURLGenerator, isPointInRect, lineTo, moveTo, removeAnnotation, removeAnnotations, setBaseItemLabelGenerator, setBaseToolTipGenerator, setItemLabelGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesToolTipGenerator, setToolTipGenerator, setURLGenerator, updateCrosshairValues, updateCrosshairValues
addChangeListener, calculateLabelAnchorPoint, clearSeriesPaints, clearSeriesStrokes, fireChangeEvent, getAutoPopulateSeriesFillPaint, getAutoPopulateSeriesOutlinePaint, getAutoPopulateSeriesOutlineStroke, getAutoPopulateSeriesPaint, getAutoPopulateSeriesShape, getAutoPopulateSeriesStroke, getBaseCreateEntities, getBaseFillPaint, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseLegendShape, getBaseLegendTextFont, getBaseLegendTextPaint, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseSeriesVisible, getBaseSeriesVisibleInLegend, getBaseShape, getBaseStroke, getCreateEntities, getDataBoundsIncludesVisibleSeriesOnly, getDefaultEntityRadius, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendShape, getLegendTextFont, getLegendTextPaint, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisible, getSeriesVisibleInLegend, getSeriesVisibleInLegend, getTreatLegendShapeAsLine, hashCode, hasListener, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setBaseCreateEntities, setBaseCreateEntities, setBaseFillPaint, setBaseFillPaint, setBaseItemLabelFont, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseLegendShape, setBaseLegendTextFont, setBaseLegendTextPaint, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlinePaint, setBaseOutlineStroke, setBaseOutlineStroke, setBasePaint, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseSeriesVisible, setBaseSeriesVisible, setBaseSeriesVisibleInLegend, setBaseSeriesVisibleInLegend, setBaseShape, setBaseShape, setBaseStroke, setBaseStroke, setCreateEntities, setCreateEntities, setDataBoundsIncludesVisibleSeriesOnly, setDefaultEntityRadius, setFillPaint, setFillPaint, setItemLabelAnchorOffset, setItemLabelFont, setItemLabelFont, setItemLabelPaint, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setLegendShape, setLegendTextFont, setLegendTextPaint, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlinePaint, setOutlineStroke, setOutlineStroke, setPaint, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, 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, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setShape, setShape, setStroke, setStroke, setTreatLegendShapeAsLine
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addAnnotation, addAnnotation, addChangeListener, drawAnnotations, drawDomainGridLine, drawDomainMarker, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, getBaseItemLabelFont, getBaseItemLabelGenerator, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseSeriesVisible, getBaseSeriesVisibleInLegend, getBaseShape, getBaseStroke, getBaseToolTipGenerator, getItemLabelFont, getItemLabelFont, getItemLabelGenerator, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendItem, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPassCount, getPlot, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelFont, getSeriesItemLabelGenerator, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getSeriesVisible, getSeriesVisible, getSeriesVisibleInLegend, getSeriesVisibleInLegend, getToolTipGenerator, getURLGenerator, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeAnnotation, removeAnnotations, removeChangeListener, setBaseItemLabelFont, setBaseItemLabelGenerator, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlineStroke, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseSeriesVisible, setBaseSeriesVisible, setBaseSeriesVisibleInLegend, setBaseSeriesVisibleInLegend, setBaseShape, setBaseStroke, setBaseToolTipGenerator, setItemLabelFont, setItemLabelGenerator, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setLegendItemLabelGenerator, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlineStroke, setPaint, setPlot, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesItemLabelFont, setSeriesItemLabelGenerator, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesStroke, setSeriesToolTipGenerator, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setShape, setStroke, setToolTipGenerator, setURLGenerator
getLegendItems
public static final int WIDTHMETHOD_AVERAGE
public static final int WIDTHMETHOD_SMALLEST
public static final int WIDTHMETHOD_INTERVALDATA
public CandlestickRenderer()
public CandlestickRenderer(double candleWidth)
Use -1 for the candle width if you prefer the width to be calculated automatically.
candleWidth
- The candle width.public CandlestickRenderer(double candleWidth, boolean drawVolume, XYToolTipGenerator toolTipGenerator)
Use -1 for the candle width if you prefer the width to be calculated automatically.
candleWidth
- the candle width.drawVolume
- a flag indicating whether or not volume bars should
be drawn.toolTipGenerator
- the tool tip generator. null
is
none.public double getCandleWidth()
setCandleWidth(double)
public void setCandleWidth(double width)
RendererChangeEvent
to all
registered listeners.
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.
width
- The width.setAutoWidthMethod(int)
,
setAutoWidthGap(double)
,
setAutoWidthFactor(double)
,
setMaxCandleWidthInMilliseconds(double)
public double getMaxCandleWidthInMilliseconds()
setMaxCandleWidthInMilliseconds(double)
public void setMaxCandleWidthInMilliseconds(double millis)
RendererChangeEvent
to all registered listeners.millis
- The maximum width.getMaxCandleWidthInMilliseconds()
,
setCandleWidth(double)
,
setAutoWidthMethod(int)
,
setAutoWidthGap(double)
,
setAutoWidthFactor(double)
public int getAutoWidthMethod()
setAutoWidthMethod(int)
public void setAutoWidthMethod(int autoWidthMethod)
RendererChangeEvent
to all registered listeners.
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.
autoWidthMethod
- The method of automatically calculating the
candle width.WIDTHMETHOD_AVERAGE
,
WIDTHMETHOD_SMALLEST
,
WIDTHMETHOD_INTERVALDATA
,
getAutoWidthMethod()
,
setCandleWidth(double)
,
setAutoWidthGap(double)
,
setAutoWidthFactor(double)
,
setMaxCandleWidthInMilliseconds(double)
public double getAutoWidthFactor()
setAutoWidthFactor(double)
public void setAutoWidthFactor(double autoWidthFactor)
autoWidthFactor
- The width factor (generally between 0.0 and 1.0).getAutoWidthFactor()
,
setCandleWidth(double)
,
setAutoWidthMethod(int)
,
setAutoWidthGap(double)
,
setMaxCandleWidthInMilliseconds(double)
public double getAutoWidthGap()
setAutoWidthGap(double)
public void setAutoWidthGap(double autoWidthGap)
RendererChangeEvent
to all registered listeners.autoWidthGap
- The gap.getAutoWidthGap()
,
setCandleWidth(double)
,
setAutoWidthMethod(int)
,
setAutoWidthFactor(double)
,
setMaxCandleWidthInMilliseconds(double)
public java.awt.Paint getUpPaint()
null
).setUpPaint(Paint)
public void setUpPaint(java.awt.Paint paint)
RendererChangeEvent
to all registered
listeners.paint
- the paint (null
permitted).getUpPaint()
public java.awt.Paint getDownPaint()
null
).setDownPaint(Paint)
public void setDownPaint(java.awt.Paint paint)
RendererChangeEvent
to all registered
listeners.paint
- The paint (null
permitted).public boolean getDrawVolume()
setDrawVolume(boolean)
public void setDrawVolume(boolean flag)
RendererChangeEvent
to all registered
listeners.flag
- the flag.getDrawVolume()
public java.awt.Paint getVolumePaint()
null
).setVolumePaint(Paint)
public void setVolumePaint(java.awt.Paint paint)
RendererChangeEvent
to all registered listeners.paint
- the paint (null
not permitted).getVolumePaint()
,
getDrawVolume()
public boolean getUseOutlinePaint()
false
.setUseOutlinePaint(boolean)
public void setUseOutlinePaint(boolean use)
RendererChangeEvent
to all registered listeners.use
- the new flag value.getUseOutlinePaint()
public Range findRangeBounds(XYDataset dataset)
findRangeBounds
in interface XYItemRenderer
findRangeBounds
in class AbstractXYItemRenderer
dataset
- the dataset (null
permitted).null
if the dataset is null
or empty).AbstractXYItemRenderer.findDomainBounds(XYDataset)
public XYItemRendererState initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info)
initialise
in interface XYItemRenderer
initialise
in class AbstractXYItemRenderer
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.public void drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass)
drawItem
in interface XYItemRenderer
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
(null
permitted).pass
- the pass index.public boolean equals(java.lang.Object obj)
equals
in class AbstractXYItemRenderer
obj
- the object (null
permitted).true
or false
.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface org.jfree.util.PublicCloneable
clone
in class AbstractXYItemRenderer
java.lang.CloneNotSupportedException
- if the renderer cannot be cloned.public boolean drawVolume()
getDrawVolume()
method.true
if volume bars are drawn on the chart.