afreechart/src/main/java/org/afree/chart/renderer/xy/SamplingXYLineRenderer.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;
        }
        RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
        RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
        double x1 = dataset.getXValue(series, item);
        double y1 = dataset.getYValue(series, item);
        double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
        double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
        State s = (State) state;
        if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) {
            float x = (float) transX1;
            float y = (float) transY1;
            PlotOrientation orientation = plot.getOrientation();
            if (orientation == PlotOrientation.HORIZONTAL) {
                x = (float) transY1;
                y = (float) transX1;
            }
            if (s.lastPointGood) {
                if ((Math.abs(x - s.lastX) > s.dX)) {
                    s.seriesPath.lineTo(x, y);
                    if (s.lowY < s.highY) {
                        s.intervalPath.moveTo((float) s.lastX, (float) s.lowY);
                        s.intervalPath.lineTo((float) s.lastX, (float) s.highY);
                    }
                    s.lastX = x;
                    s.openY = y;
                    s.highY = y;
                    s.lowY = y;
                    s.closeY = y;
                }
                else {
                    s.highY = Math.max(s.highY, y);
                    s.lowY = Math.min(s.lowY, y);
                    s.closeY = y;
                }
            }
            else {
                s.seriesPath.moveTo(x, y);
                s.lastX = x;
                s.openY = y;
                s.highY = y;
                s.lowY = y;
                s.closeY = y;
            }
            s.lastPointGood = true;
        }
        else {
            s.lastPointGood = false;
        }
        if (item == s.getLastItemIndex()) {
            Paint paint = PaintUtility.createPaint(
                    Paint.ANTI_ALIAS_FLAG,
                    getItemPaintType(series, item),
                    getItemStroke(series, item),
                    getItemEffect(series, item));
            s.seriesPath.draw(canvas, paint);
            s.intervalPath.draw(canvas, paint);
        }
    }
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 ; } RectangleEdge xAxisLocation = plot . getDomainAxisEdge ( ) ; RectangleEdge yAxisLocation = plot . getRangeAxisEdge ( ) ; double x1 = dataset . getXValue ( series , item ) ; double y1 = dataset . getYValue ( series , item ) ; double transX1 = domainAxis . valueToJava2D ( x1 , dataArea , xAxisLocation ) ; double transY1 = rangeAxis . valueToJava2D ( y1 , dataArea , yAxisLocation ) ; State s = ( State ) state ; if ( ! Double . isNaN ( transX1 ) && ! Double . isNaN ( transY1 ) ) { float x = ( float ) transX1 ; float y = ( float ) transY1 ; PlotOrientation orientation = plot . getOrientation ( ) ; if ( orientation == PlotOrientation . HORIZONTAL ) { x = ( float ) transY1 ; y = ( float ) transX1 ; } if ( s . lastPointGood ) { if ( ( Math . abs ( x - s . lastX ) > s . dX ) ) { s . seriesPath . lineTo ( x , y ) ; if ( s . lowY < s . highY ) { s . intervalPath . moveTo ( ( float ) s . lastX , ( float ) s . lowY ) ; s . intervalPath . lineTo ( ( float ) s . lastX , ( float ) s . highY ) ; } s . lastX = x ; s . openY = y ; s . highY = y ; s . lowY = y ; s . closeY = y ; } else { s . highY = Math . max ( s . highY , y ) ; s . lowY = Math . min ( s . lowY , y ) ; s . closeY = y ; } } else { s . seriesPath . moveTo ( x , y ) ; s . lastX = x ; s . openY = y ; s . highY = y ; s . lowY = y ; s . closeY = y ; } s . lastPointGood = true ; } else { s . lastPointGood = false ; } if ( item == s . getLastItemIndex ( ) ) { Paint paint = PaintUtility . createPaint ( Paint . ANTI_ALIAS_FLAG , getItemPaintType ( series , item ) , getItemStroke ( series , item ) , getItemEffect ( series , item ) ) ; s . seriesPath . draw ( canvas , paint ) ; s . intervalPath . draw ( canvas , paint ) ; } }
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 // get the data point... // update path to reflect latest point // if this is the last item, draw the path ... // draw path // Path path = s.seriesPath.getPath();