afreechart/src/main/java/org/afree/chart/renderer/xy/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.
     *
     * @param canvas  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.
     */
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.

@param canvas  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.
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 . @param canvas 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(Canvas canvas,
                                          RectShape dataArea,
                                          XYPlot plot,
                                          XYDataset dataset,
                                          PlotRenderingInfo info) {
        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);
        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);
    }
public XYItemRendererState initialise ( Canvas canvas , RectShape dataArea , XYPlot plot , XYDataset dataset , PlotRenderingInfo info ) { 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 ) ; 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 ) ; }
Initialises the renderer then returns the number of 'passes' through the
 data that the renderer will require (usually just one).
Initialises the renderer then returns the number of ' passes ' through the data that the renderer will require ( usually just one ) .
// calculate the maximum allowed candle width from the axis... // Absolute value, since the relative x // positions are reversed for horizontal orientation // calculate the highest volume in the dataset...