org.jfree.chart.renderer
Class CandlestickRenderer

java.lang.Object
  |
  +--org.jfree.chart.renderer.AbstractRenderer
        |
        +--org.jfree.chart.renderer.AbstractXYItemRenderer
              |
              +--org.jfree.chart.renderer.CandlestickRenderer
All Implemented Interfaces:
Renderer, java.io.Serializable, XYItemRenderer

public class CandlestickRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, java.io.Serializable

A renderer that draws candlesticks on an XYPlot (requires a HighLowDataset).

Author:
Sylvain Vieujot
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE
 
Constructor Summary
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
 void drawItem(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, ChartRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int datasetIndex, int series, int item, CrosshairInfo crosshairInfo)
          Draws the visual representation of a single data item.
 boolean drawVolume()
          Returns a flag indicating whether or not volume bars are drawn on the chart.
 boolean equals(java.lang.Object obj)
          Tests this renderer for equality with another object.
 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.
 java.awt.Paint getUpPaint()
          Returns the paint used to fill candles when the price moves up from open to close.
 void setCandleWidth(double width)
          Sets the candle width.
 void setDownPaint(java.awt.Paint paint)
          Sets the paint used to fill candles when the price moves down from open to close.
 void setDrawVolume(boolean flag)
          Sets a flag that controls whether or not volume bars are drawn in the background.
 void setUpPaint(java.awt.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, getLegendItem, getToolTipGenerator, getURLGenerator, initialise, setToolTipGenerator, setURLGenerator
 
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addPropertyChangeListener, createTransformedShape, firePropertyChanged, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultShape, getDefaultStroke, getDrawingSupplier, getInfo, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getPlot, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesShape, getSeriesStroke, isOutlinePaintTableActive, isOutlineStrokeTableActive, isPaintTableActive, isShapeTableActive, isStrokeTableActive, removePropertyChangeListener, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultPaint, setDefaultShape, setDefaultStroke, setDrawingSupplier, setInfo, setOutlinePaintTableActive, setOutlineStrokeTableActive, setPaintTableActive, setPlot, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setShapeTableActive, setStrokeTableActive
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.chart.renderer.XYItemRenderer
addPropertyChangeListener, drawDomainGridLine, drawDomainMarker, drawRangeGridLine, drawRangeMarker, getItemOutlinePaint, getItemPaint, getItemShape, getItemStroke, getLegendItem, getPlot, getSeriesOutlinePaint, getSeriesPaint, getSeriesShape, getSeriesStroke, getToolTipGenerator, getURLGenerator, initialise, removePropertyChangeListener, setDrawingSupplier, setPlot, setSeriesPaint, setSeriesPaint, setToolTipGenerator, setURLGenerator
 
Methods inherited from interface org.jfree.chart.renderer.Renderer
getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultShape, getDefaultStroke, getDrawingSupplier, isOutlinePaintTableActive, isOutlineStrokeTableActive, isPaintTableActive, isShapeTableActive, isStrokeTableActive, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultPaint, setDefaultShape, setDefaultStroke, setOutlinePaintTableActive, setOutlineStrokeTableActive, setPaintTableActive, setSeriesStroke, setSeriesStroke, setShapeTableActive, setStrokeTableActive
 

Constructor Detail

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. null is none.
Method Detail

getCandleWidth

public double getCandleWidth()
Returns the width of each candle.

Returns:
The candle width.

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.

getUpPaint

public java.awt.Paint getUpPaint()
Returns the paint used to fill candles when the price moves up from open to close.

Returns:
The paint.

setUpPaint

public void setUpPaint(java.awt.Paint paint)
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

public java.awt.Paint getDownPaint()
Returns the paint used to fill candles when the price moves down from open to close.

Returns:
The paint.

setDownPaint

public void setDownPaint(java.awt.Paint paint)
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:
true if 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.

drawItem

public void drawItem(java.awt.Graphics2D g2,
                     java.awt.geom.Rectangle2D dataArea,
                     ChartRenderingInfo info,
                     XYPlot plot,
                     ValueAxis domainAxis,
                     ValueAxis rangeAxis,
                     XYDataset dataset,
                     int datasetIndex,
                     int series,
                     int item,
                     CrosshairInfo crosshairInfo)
Draws the visual representation of a single data item.

Specified by:
drawItem in interface XYItemRenderer
Parameters:
g2 - the graphics device.
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.
datasetIndex - the dataset index (zero-based).
series - the series index (zero-based).
item - the item index (zero-based).
crosshairInfo - information about crosshairs on a plot.

equals

public boolean equals(java.lang.Object obj)
Tests this renderer for equality with another object.

Overrides:
equals in class AbstractXYItemRenderer
Parameters:
obj - the object.
Returns:
true or false.