afreechart/src/main/java/org/afree/chart/renderer/xy/XYErrorRenderer.java
/**
     * Draws the visual representation for one data item.
     *
     * @param canvas  the graphics output target.
     * @param state  the renderer state.
     * @param dataArea  the data area.
     * @param info  the plot rendering info.
     * @param plot  the plot.
     * @param domainAxis  the domain axis.
     * @param rangeAxis  the range axis.
     * @param dataset  the dataset.
     * @param series  the series index.
     * @param item  the item index.
     * @param crosshairState  the crosshair state.
     * @param pass  the pass index.
     */
Draws the visual representation for one data item.
@param canvas  the graphics output target.
@param state  the renderer state.
@param dataArea  the data area.
@param info  the plot rendering info.
@param plot  the plot.
@param domainAxis  the domain axis.
@param rangeAxis  the range axis.
@param dataset  the dataset.
@param series  the series index.
@param item  the item index.
@param crosshairState  the crosshair state.
@param pass  the pass index.
Draws the visual representation for one data item . @param canvas the graphics output target . @param state the renderer state . @param dataArea the data area . @param info the plot rendering info . @param plot the plot . @param domainAxis the domain axis . @param rangeAxis the range axis . @param dataset the dataset . @param series the series index . @param item the item index . @param crosshairState the crosshair state . @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 (pass == 0 && dataset instanceof IntervalXYDataset
                && getItemVisible(series, item)) {
            IntervalXYDataset ixyd = (IntervalXYDataset) dataset;
            PlotOrientation orientation = plot.getOrientation();
            if (this.drawXError) {
                double x0 = ixyd.getStartXValue(series, item);
                double x1 = ixyd.getEndXValue(series, item);
                double y = ixyd.getYValue(series, item);
                RectangleEdge edge = plot.getDomainAxisEdge();
                double xx0 = domainAxis.valueToJava2D(x0, dataArea, edge);
                double xx1 = domainAxis.valueToJava2D(x1, dataArea, edge);
                double yy = rangeAxis.valueToJava2D(y, dataArea,
                        plot.getRangeAxisEdge());
                LineShape line;
                LineShape cap1 = null;
                LineShape cap2 = null;
                double adj = this.capLength / 2.0;
                if (orientation == PlotOrientation.VERTICAL) {
                    line = new LineShape(xx0, yy, xx1, yy);
                    cap1 = new LineShape(xx0, yy - adj, xx0, yy + adj);
                    cap2 = new LineShape(xx1, yy - adj, xx1, yy + adj);
                }
                else {  
                    line = new LineShape(yy, xx0, yy, xx1);
                    cap1 = new LineShape(yy - adj, xx0, yy + adj, xx0);
                    cap2 = new LineShape(yy - adj, xx1, yy + adj, xx1);
                }
                PaintType paintType;
                float stroke;
                if (this.errorPaintType != null) {
                    paintType = this.errorPaintType;
                }
                else {
                    paintType = getItemPaintType(series, item);
                }
                if (this.errorStroke != 0.0f) {
                    stroke = this.errorStroke;
                }
                else {
                    stroke = getItemStroke(series, item);
                }
                Paint paint = PaintUtility.createPaint(
                        Paint.ANTI_ALIAS_FLAG,
                        paintType,
                        stroke,
                        getItemEffect(series, item));
                line.draw(canvas, paint);
                cap1.draw(canvas, paint);
                cap2.draw(canvas, paint);
            }
            if (this.drawYError) {
                double y0 = ixyd.getStartYValue(series, item);
                double y1 = ixyd.getEndYValue(series, item);
                double x = ixyd.getXValue(series, item);
                RectangleEdge edge = plot.getRangeAxisEdge();
                double yy0 = rangeAxis.valueToJava2D(y0, dataArea, edge);
                double yy1 = rangeAxis.valueToJava2D(y1, dataArea, edge);
                double xx = domainAxis.valueToJava2D(x, dataArea,
                        plot.getDomainAxisEdge());
                LineShape line;
                LineShape cap1 = null;
                LineShape cap2 = null;
                double adj = this.capLength / 2.0;
                if (orientation == PlotOrientation.VERTICAL) {
                    line = new LineShape(xx, yy0, xx, yy1);
                    cap1 = new LineShape(xx - adj, yy0, xx + adj, yy0);
                    cap2 = new LineShape(xx - adj, yy1, xx + adj, yy1);
                }
                else {  
                    line = new LineShape(yy0, xx, yy1, xx);
                    cap1 = new LineShape(yy0, xx - adj, yy0, xx + adj);
                    cap2 = new LineShape(yy1, xx - adj, yy1, xx + adj);
                }
                PaintType paintType;
                float stroke;
                if (this.errorPaintType != null) {
                  paintType = this.errorPaintType;
                }
                else {
                  paintType = getItemPaintType(series, item);
                }
                if (this.errorStroke != 0.0f) {
                    stroke = this.errorStroke;
                }
                else {
                    stroke = getItemStroke(series, item);
                }
                Paint paint = PaintUtility.createPaint(
                        Paint.ANTI_ALIAS_FLAG,
                        paintType,
                        stroke,
                        getItemEffect(series, item));
                line.draw(canvas, paint);
                cap1.draw(canvas, paint);
                cap2.draw(canvas, paint);
            }
        }
        super.drawItem(canvas, state, dataArea, info, plot, domainAxis, rangeAxis,
                dataset, series, item, crosshairState, pass);
    }
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 ( pass == 0 && dataset instanceof IntervalXYDataset && getItemVisible ( series , item ) ) { IntervalXYDataset ixyd = ( IntervalXYDataset ) dataset ; PlotOrientation orientation = plot . getOrientation ( ) ; if ( this . drawXError ) { double x0 = ixyd . getStartXValue ( series , item ) ; double x1 = ixyd . getEndXValue ( series , item ) ; double y = ixyd . getYValue ( series , item ) ; RectangleEdge edge = plot . getDomainAxisEdge ( ) ; double xx0 = domainAxis . valueToJava2D ( x0 , dataArea , edge ) ; double xx1 = domainAxis . valueToJava2D ( x1 , dataArea , edge ) ; double yy = rangeAxis . valueToJava2D ( y , dataArea , plot . getRangeAxisEdge ( ) ) ; LineShape line ; LineShape cap1 = null ; LineShape cap2 = null ; double adj = this . capLength / 2.0 ; if ( orientation == PlotOrientation . VERTICAL ) { line = new LineShape ( xx0 , yy , xx1 , yy ) ; cap1 = new LineShape ( xx0 , yy - adj , xx0 , yy + adj ) ; cap2 = new LineShape ( xx1 , yy - adj , xx1 , yy + adj ) ; } else { line = new LineShape ( yy , xx0 , yy , xx1 ) ; cap1 = new LineShape ( yy - adj , xx0 , yy + adj , xx0 ) ; cap2 = new LineShape ( yy - adj , xx1 , yy + adj , xx1 ) ; } PaintType paintType ; float stroke ; if ( this . errorPaintType != null ) { paintType = this . errorPaintType ; } else { paintType = getItemPaintType ( series , item ) ; } if ( this . errorStroke != 0.0f ) { stroke = this . errorStroke ; } else { stroke = getItemStroke ( series , item ) ; } Paint paint = PaintUtility . createPaint ( Paint . ANTI_ALIAS_FLAG , paintType , stroke , getItemEffect ( series , item ) ) ; line . draw ( canvas , paint ) ; cap1 . draw ( canvas , paint ) ; cap2 . draw ( canvas , paint ) ; } if ( this . drawYError ) { double y0 = ixyd . getStartYValue ( series , item ) ; double y1 = ixyd . getEndYValue ( series , item ) ; double x = ixyd . getXValue ( series , item ) ; RectangleEdge edge = plot . getRangeAxisEdge ( ) ; double yy0 = rangeAxis . valueToJava2D ( y0 , dataArea , edge ) ; double yy1 = rangeAxis . valueToJava2D ( y1 , dataArea , edge ) ; double xx = domainAxis . valueToJava2D ( x , dataArea , plot . getDomainAxisEdge ( ) ) ; LineShape line ; LineShape cap1 = null ; LineShape cap2 = null ; double adj = this . capLength / 2.0 ; if ( orientation == PlotOrientation . VERTICAL ) { line = new LineShape ( xx , yy0 , xx , yy1 ) ; cap1 = new LineShape ( xx - adj , yy0 , xx + adj , yy0 ) ; cap2 = new LineShape ( xx - adj , yy1 , xx + adj , yy1 ) ; } else { line = new LineShape ( yy0 , xx , yy1 , xx ) ; cap1 = new LineShape ( yy0 , xx - adj , yy0 , xx + adj ) ; cap2 = new LineShape ( yy1 , xx - adj , yy1 , xx + adj ) ; } PaintType paintType ; float stroke ; if ( this . errorPaintType != null ) { paintType = this . errorPaintType ; } else { paintType = getItemPaintType ( series , item ) ; } if ( this . errorStroke != 0.0f ) { stroke = this . errorStroke ; } else { stroke = getItemStroke ( series , item ) ; } Paint paint = PaintUtility . createPaint ( Paint . ANTI_ALIAS_FLAG , paintType , stroke , getItemEffect ( series , item ) ) ; line . draw ( canvas , paint ) ; cap1 . draw ( canvas , paint ) ; cap2 . draw ( canvas , paint ) ; } } super . drawItem ( canvas , state , dataArea , info , plot , domainAxis , rangeAxis , dataset , series , item , crosshairState , pass ) ; }
Draws the visual representation for one data item.
Draws the visual representation for one data item .
// draw the error bar for the x-interval // PlotOrientation.HORIZONTAL //                    canvas.setPaint(this.errorPaint); //                    canvas.setPaint(getItemPaint(series, item)); //                    canvas.setStroke(this.errorStroke); //                    canvas.setStroke(getItemStroke(series, item)); //                canvas.draw(line); //                canvas.draw(cap1); //                canvas.draw(cap2); // draw the error bar for the y-interval // PlotOrientation.HORIZONTAL //                  canvas.setPaint(this.errorPaint); //                  canvas.setPaint(getItemPaint(series, item)); //                  canvas.setStroke(this.errorStroke); //                  canvas.setStroke(getItemStroke(series, item)); //                canvas.draw(line); //                canvas.draw(cap1); //                canvas.draw(cap2);