afreechart/src/main/java/org/afree/chart/renderer/xy/DeviationRenderer.java
/**
     * Draws the visual representation of a single data item.
     *
     * @param canvas  the graphics device.
     * @param state  the renderer state.
     * @param dataArea  the area within which the data is being drawn.
     * @param info  collects information about the drawing.
     * @param plot  the plot (can be used to obtain standard color
     *              information etc).
     * @param domainAxis  the domain axis.
     * @param rangeAxis  the range axis.
     * @param dataset  the dataset.
     * @param series  the series index (zero-based).
     * @param item  the item index (zero-based).
     * @param crosshairState  crosshair information for the plot
     *                        (<code>null</code> permitted).
     * @param pass  the pass index.
     */
Draws the visual representation of a single data item.
@param canvas  the graphics device.
@param state  the renderer state.
@param dataArea  the area within which the data is being drawn.
@param info  collects information about the drawing.
@param plot  the plot (can be used to obtain standard color
information etc).
@param domainAxis  the domain axis.
@param rangeAxis  the range axis.
@param dataset  the dataset.
@param series  the series index (zero-based).
@param item  the item index (zero-based).
@param crosshairState  crosshair information for the plot
(null permitted).
@param pass  the pass index.
Draws the visual representation of a single data item . @param canvas the graphics device . @param state the renderer state . @param dataArea the area within which the data is being drawn . @param info collects information about the drawing . @param plot the plot ( can be used to obtain standard color information etc ) . @param domainAxis the domain axis . @param rangeAxis the range axis . @param dataset the dataset . @param series the series index ( zero - based ) . @param item the item index ( zero - based ) . @param crosshairState crosshair information for the plot ( null permitted ) . @param pass the pass index .
public void drawItem(Canvas canvas,
                         XYItemRendererState state,
                         RectShape dataArea,
                         PlotRenderingInfo info,
                         XYPlot plot,
                         ValueAxis domainAxis,
                         ValueAxis rangeAxis,
                         XYDataset dataset,
                         int series,
                         int item,
                         CrosshairState crosshairState,
                         int pass) {
        if (!getItemVisible(series, item)) {
            return;
        }
        if (pass == 0) {
            IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset;
            State drState = (State) state;
            double x = intervalDataset.getXValue(series, item);
            double yLow = intervalDataset.getStartYValue(series, item);
            double yHigh  = intervalDataset.getEndYValue(series, item);
            RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
            RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
            double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
            double yyLow = rangeAxis.valueToJava2D(yLow, dataArea,
                    yAxisLocation);
            double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea,
                    yAxisLocation);
            PlotOrientation orientation = plot.getOrientation();
            if (orientation == PlotOrientation.HORIZONTAL) {
                drState.lowerCoordinates.add(new double[] {yyLow, xx});
                drState.upperCoordinates.add(new double[] {yyHigh, xx});
            }
            else if (orientation == PlotOrientation.VERTICAL) {
                drState.lowerCoordinates.add(new double[] {xx, yyLow});
                drState.upperCoordinates.add(new double[] {xx, yyHigh});
            }
            if (item == (dataset.getItemCount(series) - 1)) {
                PathShape area = new PathShape();
                double[] coords = (double[]) drState.lowerCoordinates.get(0);
                area.moveTo((float) coords[0], (float) coords[1]);
                for (int i = 1; i < drState.lowerCoordinates.size(); i++) {
                    coords = (double[]) drState.lowerCoordinates.get(i);
                    area.lineTo((float) coords[0], (float) coords[1]);
                }
                int count = drState.upperCoordinates.size();
                coords = (double[]) drState.upperCoordinates.get(count - 1);
                area.lineTo((float) coords[0], (float) coords[1]);
                for (int i = count - 2; i >= 0; i--) {
                    coords = (double[]) drState.upperCoordinates.get(i);
                    area.lineTo((float) coords[0], (float) coords[1]);
                }
                area.closePath();
                Paint paint = PaintUtility.createPaint(
                        Paint.ANTI_ALIAS_FLAG,
                        getItemFillPaintType(series, item));
                paint.setAlpha((int)(255f * this.alpha));
                area.fill(canvas, paint);
                drState.lowerCoordinates.clear();
                drState.upperCoordinates.clear();
            }
        }
        if (isLinePass(pass)) {
            if (item == 0) {
                State s = (State) state;
                s.seriesPath.reset();
                s.setLastPointGood(false);
            }
            if (getItemLineVisible(series, item)) {
                drawPrimaryLineAsPath(state, canvas, plot, dataset, pass,
                        series, item, domainAxis, rangeAxis, dataArea);
            }
        }
        else if (isItemPass(pass)) {
            EntityCollection entities = null;
            if (info != null) {
                entities = info.getOwner().getEntityCollection();
            }
            drawSecondaryPass(canvas, plot, dataset, pass, series, item,
                    domainAxis, dataArea, rangeAxis, crosshairState, entities);
        }
    }
public void drawItem ( Canvas canvas , XYItemRendererState state , RectShape dataArea , PlotRenderingInfo info , XYPlot plot , ValueAxis domainAxis , ValueAxis rangeAxis , XYDataset dataset , int series , int item , CrosshairState crosshairState , int pass ) { if ( ! getItemVisible ( series , item ) ) { return ; } if ( pass == 0 ) { IntervalXYDataset intervalDataset = ( IntervalXYDataset ) dataset ; State drState = ( State ) state ; double x = intervalDataset . getXValue ( series , item ) ; double yLow = intervalDataset . getStartYValue ( series , item ) ; double yHigh = intervalDataset . getEndYValue ( series , item ) ; RectangleEdge xAxisLocation = plot . getDomainAxisEdge ( ) ; RectangleEdge yAxisLocation = plot . getRangeAxisEdge ( ) ; double xx = domainAxis . valueToJava2D ( x , dataArea , xAxisLocation ) ; double yyLow = rangeAxis . valueToJava2D ( yLow , dataArea , yAxisLocation ) ; double yyHigh = rangeAxis . valueToJava2D ( yHigh , dataArea , yAxisLocation ) ; PlotOrientation orientation = plot . getOrientation ( ) ; if ( orientation == PlotOrientation . HORIZONTAL ) { drState . lowerCoordinates . add ( new double [ ] { yyLow , xx } ) ; drState . upperCoordinates . add ( new double [ ] { yyHigh , xx } ) ; } else if ( orientation == PlotOrientation . VERTICAL ) { drState . lowerCoordinates . add ( new double [ ] { xx , yyLow } ) ; drState . upperCoordinates . add ( new double [ ] { xx , yyHigh } ) ; } if ( item == ( dataset . getItemCount ( series ) - 1 ) ) { PathShape area = new PathShape ( ) ; double [ ] coords = ( double [ ] ) drState . lowerCoordinates . get ( 0 ) ; area . moveTo ( ( float ) coords [ 0 ] , ( float ) coords [ 1 ] ) ; for ( int i = 1 ; i < drState . lowerCoordinates . size ( ) ; i ++ ) { coords = ( double [ ] ) drState . lowerCoordinates . get ( i ) ; area . lineTo ( ( float ) coords [ 0 ] , ( float ) coords [ 1 ] ) ; } int count = drState . upperCoordinates . size ( ) ; coords = ( double [ ] ) drState . upperCoordinates . get ( count - 1 ) ; area . lineTo ( ( float ) coords [ 0 ] , ( float ) coords [ 1 ] ) ; for ( int i = count - 2 ; i >= 0 ; i -- ) { coords = ( double [ ] ) drState . upperCoordinates . get ( i ) ; area . lineTo ( ( float ) coords [ 0 ] , ( float ) coords [ 1 ] ) ; } area . closePath ( ) ; Paint paint = PaintUtility . createPaint ( Paint . ANTI_ALIAS_FLAG , getItemFillPaintType ( series , item ) ) ; paint . setAlpha ( ( int ) ( 255f * this . alpha ) ) ; area . fill ( canvas , paint ) ; drState . lowerCoordinates . clear ( ) ; drState . upperCoordinates . clear ( ) ; } } if ( isLinePass ( pass ) ) { if ( item == 0 ) { State s = ( State ) state ; s . seriesPath . reset ( ) ; s . setLastPointGood ( false ) ; } if ( getItemLineVisible ( series , item ) ) { drawPrimaryLineAsPath ( state , canvas , plot , dataset , pass , series , item , domainAxis , rangeAxis , dataArea ) ; } } else if ( isItemPass ( pass ) ) { EntityCollection entities = null ; if ( info != null ) { entities = info . getOwner ( ) . getEntityCollection ( ) ; } drawSecondaryPass ( canvas , plot , dataset , pass , series , item , domainAxis , dataArea , rangeAxis , crosshairState , entities ) ; } }
Draws the visual representation of a single data item.
Draws the visual representation of a single data item .
// do nothing if item is not visible // first pass draws the shading // last item in series, draw the lot... // set up the alpha-transparency... // TODO: implement Composite //                Composite originalComposite = canvas.getComposite(); //                canvas.setComposite(AlphaComposite.getInstance( //                        AlphaComposite.SRC_OVER, this.alpha)); //                canvas.setComposite(originalComposite); // the following code handles the line for the y-values...it's // all done by code in the super class // second pass adds shapes where the items are .. // setup for collecting optional entity info...