List of usage examples for org.jfree.chart.renderer.xy XYItemRendererState XYItemRendererState
public XYItemRendererState(PlotRenderingInfo info)
From source file:org.trade.ui.chart.renderer.HeikinAshiRenderer.java
/** * Method initialise.//from w w w. j a v a 2 s .c o m * * @param g2 * Graphics2D * @param dataArea * Rectangle2D * @param plot * XYPlot * @param dataset * XYDataset * @param info * PlotRenderingInfo * @return XYItemRendererState * @see org.jfree.chart.renderer.xy.XYItemRenderer#initialise(Graphics2D, * Rectangle2D, XYPlot, XYDataset, PlotRenderingInfo) */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { ValueAxis axis = plot.getDomainAxis(); double x1 = axis.getLowerBound(); double x2 = x1 + getMaxCandleWidthInMilliseconds(); RectangleEdge edge = plot.getDomainAxisEdge(); double xx1 = axis.valueToJava2D(x1, dataArea, edge); double xx2 = axis.valueToJava2D(x2, dataArea, edge); maxCandleWidth = Math.abs(xx2 - xx1); return new XYItemRendererState(info); }
From source file:edu.dlnu.liuwenpeng.render.CandlestickRenderer.java
/** * 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. * //from w w w .ja v a 2 s .c o m * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param dataset the data. * @param info an optional info collection object to return data back to * the caller. * * @return The number of passes the renderer requires. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { // calculate the maximum allowed candle width from the axis... ValueAxis axis = plot.getDomainAxis(); double x1 = axis.getLowerBound(); double x2 = x1 + this.maxCandleWidthInMilliseconds; RectangleEdge edge = plot.getDomainAxisEdge(); double xx1 = axis.valueToJava2D(x1, dataArea, edge); double xx2 = axis.valueToJava2D(x2, dataArea, edge); this.maxCandleWidth = Math.abs(xx2 - xx1); // Absolute value, since the relative x // positions are reversed for horizontal orientation // calculate the highest volume in the dataset... if (this.drawVolume) { OHLCDataset highLowDataset = (OHLCDataset) dataset; this.maxVolume = 0.0; for (int series = 0; series < highLowDataset.getSeriesCount(); series++) { for (int item = 0; item < highLowDataset.getItemCount(series); item++) { double volume = highLowDataset.getVolumeValue(series, item); if (volume > this.maxVolume) { this.maxVolume = volume; } } } } return new XYItemRendererState(info); }