afreechart/src/main/java/org/afree/chart/renderer/xy/YIntervalRenderer.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 plot 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 (ignored here).
     */
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 plot 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 (ignored here).
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 plot 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 ( ignored here ) .
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) {
        EntityCollection entities = null;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
        }
        IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset;
        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);
        LineShape line = null;
        Shape shape = getItemShape(series, item);
        Shape top = null;
        Shape bottom = null;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            line = new LineShape(yyLow, xx, yyHigh, xx);
            top = ShapeUtilities.createTranslatedShape(shape, yyHigh, xx);
            bottom = ShapeUtilities.createTranslatedShape(shape, yyLow, xx);
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            line = new LineShape(xx, yyLow, xx, yyHigh);
            top = ShapeUtilities.createTranslatedShape(shape, xx, yyHigh);
            bottom = ShapeUtilities.createTranslatedShape(shape, xx, yyLow);
        }
        Paint paint = PaintUtility.createPaint(
                Paint.ANTI_ALIAS_FLAG,
                getItemPaintType(series, item),
                getItemStroke(series, item),
                getItemEffect(series, item));
        line.draw(canvas, paint);
        top.fill(canvas, paint);
        bottom.fill(canvas, paint);
        if (isItemLabelVisible(series, item)) {
            drawItemLabel(canvas, orientation, dataset, series, item, xx, yyHigh,
                    false);
            drawAdditionalItemLabel(canvas, orientation, dataset, series, item,
                    xx, yyLow);
        }
        if (entities != null) {
            RectShape rectShape = new RectShape();
            line.getBounds(rectShape);
            addEntity(entities, rectShape, dataset, series, item, 0.0,
                    0.0);
        }
    }
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 ) { EntityCollection entities = null ; if ( info != null ) { entities = info . getOwner ( ) . getEntityCollection ( ) ; } IntervalXYDataset intervalDataset = ( IntervalXYDataset ) dataset ; 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 ) ; LineShape line = null ; Shape shape = getItemShape ( series , item ) ; Shape top = null ; Shape bottom = null ; PlotOrientation orientation = plot . getOrientation ( ) ; if ( orientation == PlotOrientation . HORIZONTAL ) { line = new LineShape ( yyLow , xx , yyHigh , xx ) ; top = ShapeUtilities . createTranslatedShape ( shape , yyHigh , xx ) ; bottom = ShapeUtilities . createTranslatedShape ( shape , yyLow , xx ) ; } else if ( orientation == PlotOrientation . VERTICAL ) { line = new LineShape ( xx , yyLow , xx , yyHigh ) ; top = ShapeUtilities . createTranslatedShape ( shape , xx , yyHigh ) ; bottom = ShapeUtilities . createTranslatedShape ( shape , xx , yyLow ) ; } Paint paint = PaintUtility . createPaint ( Paint . ANTI_ALIAS_FLAG , getItemPaintType ( series , item ) , getItemStroke ( series , item ) , getItemEffect ( series , item ) ) ; line . draw ( canvas , paint ) ; top . fill ( canvas , paint ) ; bottom . fill ( canvas , paint ) ; if ( isItemLabelVisible ( series , item ) ) { drawItemLabel ( canvas , orientation , dataset , series , item , xx , yyHigh , false ) ; drawAdditionalItemLabel ( canvas , orientation , dataset , series , item , xx , yyLow ) ; } if ( entities != null ) { RectShape rectShape = new RectShape ( ) ; line . getBounds ( rectShape ) ; addEntity ( entities , rectShape , dataset , series , item , 0.0 , 0.0 ) ; } }
Draws the visual representation of a single data item.
Draws the visual representation of a single data item .
// setup for collecting optional entity info... // for item labels, we have a special case because there is the // possibility to draw (a) the regular item label near to just the // upper y-value, or (b) the regular item label near the upper y-value // PLUS an additional item label near the lower y-value. // add an entity for the item...