com.jrefinery.chart
Class CandlestickRenderer

java.lang.Object
  extended by com.jrefinery.chart.AbstractXYItemRenderer
      extended by com.jrefinery.chart.CandlestickRenderer
All Implemented Interfaces:
XYItemRenderer

public class CandlestickRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer

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


Field Summary
protected  double candleWidth
          The candle width.
protected  java.awt.Paint downPaint
          The paint used to fill the candle when the price moved down from open to close.
protected  boolean drawVolume
          A flag controlling whether or not volume bars are drawn on the chart.
protected  java.awt.Paint upPaint
          The paint used to fill the candle when the price moved up from open to close.
 
Fields inherited from class com.jrefinery.chart.AbstractXYItemRenderer
info, listeners, toolTipGenerator
 
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, com.jrefinery.chart.tooltips.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 data, 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.
 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)
           
 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 com.jrefinery.chart.AbstractXYItemRenderer
addPropertyChangeListener, firePropertyChanged, getToolTipGenerator, initialise, removePropertyChangeListener, setToolTipGenerator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jrefinery.chart.XYItemRenderer
addPropertyChangeListener, getToolTipGenerator, initialise, removePropertyChangeListener, setToolTipGenerator
 

Field Detail

candleWidth

protected double candleWidth
The candle width.


upPaint

protected java.awt.Paint upPaint
The paint used to fill the candle when the price moved up from open to close.


downPaint

protected java.awt.Paint downPaint
The paint used to fill the candle when the price moved down from open to close.


drawVolume

protected boolean drawVolume
A flag controlling whether or not volume bars are drawn on the chart.

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,
                           com.jrefinery.chart.tooltips.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.
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.


setDrawVolume

public void setDrawVolume(boolean flag)

drawItem

public void drawItem(java.awt.Graphics2D g2,
                     java.awt.geom.Rectangle2D dataArea,
                     ChartRenderingInfo info,
                     XYPlot plot,
                     ValueAxis domainAxis,
                     ValueAxis rangeAxis,
                     XYDataset data,
                     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.
data - The dataset.
series - The series index.
item - The item index.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.