Example usage for org.jfree.chart.plot XYPlot getOrientation

List of usage examples for org.jfree.chart.plot XYPlot getOrientation

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getOrientation.

Prototype

@Override
public PlotOrientation getOrientation() 

Source Link

Document

Returns the orientation of the plot.

Usage

From source file:org.openfaces.component.chart.impl.renderers.XYLineFillRenderer.java

private Paint getAreaFillPaint(XYPlot plot, Double plotWidth, Double plotHeight, Color mainColor,
        Color secondaryColor) {//from ww w  . ja va 2s .  co m
    return (plot.getOrientation() == PlotOrientation.VERTICAL)
            ? new GradientPaint(0.0f, 0.0f, mainColor, 0.0f, plotHeight.floatValue(), secondaryColor, true)
            : new GradientPaint(plotWidth.floatValue(), 0.0f, mainColor, 0.0f, 0.0f, secondaryColor, true);
}

From source file:org.openfaces.component.chart.impl.renderers.XYLineFillRenderer.java

private void addItemLine(XYPlot plot, Collection<Line2D> lines, double previousItemX, double previousItemY,
        double currentItemX, double currentItemY) {

    if (plot.getOrientation() == PlotOrientation.VERTICAL) {
        lines.add(new Line2D.Double(previousItemX, previousItemY, currentItemX, currentItemY));
    } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
        lines.add(new Line2D.Double(previousItemY, previousItemX, currentItemY, currentItemX));
    }//from w  w w . jav  a  2s  .co  m
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java

@Override
public void zoom(Rectangle2D selection) {
    // get the origin of the zoom selection in the Java2D space used for
    // drawing the chart (that is, before any scaling to fit the panel)
    Point2D selectOrigin = translateScreenToJava2D(
            new Point((int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY())));
    PlotRenderingInfo plotInfo = getChartRenderingInfo().getPlotInfo();
    Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY());
    if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

        double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        Plot p = getChart().getPlot();/*from w w w  .j  av a  2 s. c  o  m*/
        if (p instanceof LinkAndBrushPlot) {

            PlotOrientation orientation = null;
            if (p instanceof XYPlot) {
                XYPlot xyPlot = (XYPlot) p;
                orientation = xyPlot.getOrientation();
            }
            if (p instanceof CategoryPlot) {
                CategoryPlot categoryPlot = (CategoryPlot) p;
                orientation = categoryPlot.getOrientation();
            }

            // here we tweak the notify flag on the plot so that only
            // one notification happens even though we update multiple
            // axes...

            boolean savedNotify = p.isNotify();
            p.setNotify(false);
            LinkAndBrushPlot LABPlot = (LinkAndBrushPlot) p;

            List<Pair<Integer, Range>> zoomedDomainAxisRanges = new LinkedList<Pair<Integer, Range>>();
            List<Pair<Integer, Range>> zoomedRangeAxisRanges = new LinkedList<Pair<Integer, Range>>();

            if (orientation == PlotOrientation.HORIZONTAL) {
                zoomedDomainAxisRanges
                        .addAll(LABPlot.calculateDomainAxesZoom(vLower, vUpper, zoomOnLinkAndBrushSelection));
                zoomedRangeAxisRanges.addAll(LABPlot.calculateRangeAxesZoom(hLower, hUpper, plotInfo,
                        selectOrigin, zoomOnLinkAndBrushSelection));
            } else {
                zoomedDomainAxisRanges
                        .addAll(LABPlot.calculateDomainAxesZoom(hLower, hUpper, zoomOnLinkAndBrushSelection));
                zoomedRangeAxisRanges.addAll(LABPlot.calculateRangeAxesZoom(vLower, vUpper, plotInfo,
                        selectOrigin, zoomOnLinkAndBrushSelection));
            }
            p.setNotify(savedNotify);

            if (zoomOnLinkAndBrushSelection) {
                informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.ZOOM_IN,
                        zoomedDomainAxisRanges, zoomedRangeAxisRanges));
            } else {
                informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.SELECTION,
                        zoomedDomainAxisRanges, zoomedRangeAxisRanges));
            }

        } else {
            super.zoom(selection);
        }
    }
}

From source file:gda.plots.TurboXYItemRenderer.java

/**
 * Draws the visual representation of a single data item. This mostly reproduces the code of StandardXYItemRenderer
 * but using the line by line information stored in the SimpleXYSeries instead of the series indexed information
 * stored in the Renderer itself./*from w w  w  . java 2 s . c  om*/
 * 
 * @param g2
 *            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 crosshairState
 *            crosshair information for the plot ( <code>null</code> permitted).
 * @param pass
 *            the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int _item,
        CrosshairState crosshairState, int pass) {

    if (_item > 0)
        return;
    SimpleXYSeries sxys = (SimpleXYSeries) ((SimpleXYSeriesCollection) dataset).getSeries(series);
    if (!sxys.isVisible()) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    g2.setPaint(sxys.getPaint());
    g2.setStroke(sxys.getStroke());

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();

    try {
        int x0 = -1; // the x position in pixels of the previous point
        int y0 = -1; // the y position in pixels of the previous point
        int x1 = -1; // the x position in pixels of the current point
        int y1 = -1; // the y position in pixels of the current point
        int xmin = (int) dataArea.getMinX();
        int xmax = (int) dataArea.getMaxX();
        int ymin = (int) dataArea.getMinY();
        int ymax = (int) dataArea.getMaxY();
        GeneralPath path = null;

        /*
         * To remove the time spent repeatedly calling domainAxis.valueToJava2D for linear axes use simple linear
         * maths
         */
        double xl = 0., mx = Double.NaN, cx = 0.;
        if (domainAxis instanceof SimpleNumberAxis) {
            xl = domainAxis.getRange().getLowerBound();
            mx = dataArea.getWidth() / (domainAxis.getRange().getUpperBound() - xl);
            cx = xmin;
        }
        double yl = 0., my = Double.NaN, cy = 0.;
        if (rangeAxis instanceof SimpleNumberAxis) {
            yl = rangeAxis.getRange().getLowerBound();
            my = -dataArea.getHeight() / (rangeAxis.getRange().getUpperBound() - yl);
            cy = ymax;
        }
        List<XYDataItem> list = sxys.getData();

        boolean MX_MY_NaN = Double.isNaN(mx) || Double.isNaN(my);
        Paint paint = sxys.getPaint();
        Stroke stroke = sxys.getStroke();
        Paint paint_symbol = sxys.getSymbolPaint();
        Stroke stroke_symbol = new BasicStroke();
        drawLines = sxys.isDrawLines();
        boolean filled = sxys.getFilled();
        Shape shape = sxys.getSymbol();
        boolean drawMarkers = sxys.isDrawMarkers() & shape != null;
        int tooltipThresholdCounts = -1; /* number of points to be shown below which markers are also to be drawn */
        if (drawLines && drawMarkers && shape != null && tooltipThreshold != 0) {
            Rectangle shapeBoundingBox = shape.getBounds();
            tooltipThresholdCounts = (int) dataArea.getWidth()
                    / (Math.max(1, shapeBoundingBox.width) * tooltipThreshold);
        }

        java.util.Vector<ddouble> markerPositions = null;
        Shape entityArea = null;
        EntityCollection entities = null;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
        }
        boolean prevLineAdded = false;
        // In case the iterator does not work then use the TODO comment iterator use and why not always
        // comment variables
        synchronized (list) {
            Iterator<XYDataItem> iter = list.iterator();
            /*
             * loop over all points calculating X1 and Y1. Store previous points positions into X0 and Y0 The
             * variable addThis determines if the current point is to be added to the path If previous line was
             * added that the current must be even if off the screen - but in this case the flag prevLineAdded is
             * set false so that the next does not have to be added.
             */
            for (int item = 0; iter.hasNext(); item++, x0 = x1, y0 = y1, x1 = -1, y1 = -1) {
                XYDataItem dataitem = iter.next();
                double x = dataitem.getX().doubleValue();
                double y = dataitem.getY().doubleValue();
                x = xValueTransformer.transformValue(x);

                x1 = MX_MY_NaN ? (int) domainAxis.valueToJava2D(x, dataArea, xAxisLocation)
                        : (int) ((x - xl) * mx + cx);
                y1 = MX_MY_NaN ? (int) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation)
                        : (int) ((y - yl) * my + cy);

                boolean addThis = true;
                if (item == 0) {
                    x0 = x1;
                    y0 = y1;
                    if ((x1 < xmin) || (x1 > xmax) || (y1 < ymin) || (y1 > ymax)) {
                        addThis = false;
                    }
                } else {
                    if (x1 == x0 && y1 == y0) {
                        addThis = false;
                    }
                    if ((x1 < xmin && x0 < xmin) || (x1 > xmax && x0 > xmax) || (y1 < ymin && y0 < ymin)
                            || (y1 > ymax && y0 > ymax)) {
                        if (prevLineAdded) {
                            path = addPointToLine(path, orientation, x1, y1);
                        }
                        addThis = false;
                    }
                }
                if (addThis) {
                    /*
                     * If the current point is to be added then ensure previous one is as well to prevent lines
                     * not crossing the edge of the screen
                     */
                    if (!prevLineAdded) {
                        path = addPointToLine(path, orientation, x0, y0);
                    }
                    path = addPointToLine(path, orientation, x1, y1);
                    prevLineAdded = true;
                }
                prevLineAdded = addThis;
                if (addThis && drawMarkers) {
                    if (markerPositions == null) {
                        markerPositions = new java.util.Vector<ddouble>();
                    }
                    markerPositions.add(new ddouble(item, x1, y1));
                    if (tooltipThresholdCounts != -1 && markerPositions.size() > tooltipThresholdCounts) {
                        drawMarkers = false;
                        markerPositions = null;
                    }
                }
            }
            if (path != null) {
                g2.setStroke(stroke);
                g2.setPaint(paint);
                g2.draw(path);
            }
            if (markerPositions != null) {
                if (drawMarkers) {
                    g2.setPaint(paint_symbol);
                    g2.setStroke(stroke_symbol);
                    for (ddouble dd : markerPositions) {
                        Shape shape_item = ShapeUtilities.createTranslatedShape(shape, dd.x, dd.y);
                        if (filled) {
                            g2.fill(shape_item);
                        } else {
                            g2.draw(shape_item);
                        }
                        entityArea = shape_item;
                        // add an entity for the item...
                        if (entities != null) {
                            addEntity(entities, entityArea, dataset, series, dd.item, dd.x, dd.y);
                        }
                    }
                    g2.setPaint(paint);
                    g2.setStroke(stroke);
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:ste.travian.world.TileRenderer.java

/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device./*  w w  w  .  j a v  a2 s  .  c  o m*/
 * @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 (horizontal) axis.
 * @param rangeAxis  the range (vertical) 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.
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {

    // get the data point...
    double x = dataset.getXValue(series, item);
    double y = dataset.getYValue(series, item);
    double adjx = (this.dotWidth - 1) / 2.0;
    double adjy = (this.dotHeight - 1) / 2.0;
    if (Double.isNaN(y)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation) - adjx;
    double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) - adjy;

    g2.setPaint(getItemPaint(series, item));
    if (orientation == PlotOrientation.HORIZONTAL) {
        g2.fillRect((int) transY, (int) transX, this.dotHeight, this.dotWidth);
    } else if (orientation == PlotOrientation.VERTICAL) {
        g2.fillRect((int) transX, (int) transY, this.dotWidth, this.dotHeight);
    }

    int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
    int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
    updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation);

    // add an entity for the item, but only if it falls within the data
    // area...
    EntityCollection entities = null;
    if (info != null) {
        entities = info.getOwner().getEntityCollection();
    }
    int xx = (int) transX;
    int yy = (int) transY;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx = (int) transY;
        yy = (int) transX;
    }
    if (entities != null && dataArea.contains(xx, yy)) {
        addEntity(entities, null, dataset, series, item, (int) xx, (int) yy);
    }

}

From source file:com.newatlanta.bluedragon.CustomXYAreaRenderer.java

public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {
    super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item,
            crosshairState, pass);/*from ww  w .ja v  a 2 s .c  o  m*/

    // The complete area chart is drawn when drawItem() is called for the last
    // item
    // so we need to draw all of the item labels after the last item so they'll
    // be
    // visible if they overlap the area chart.
    int itemCount = dataset.getItemCount(series);
    if (getPlotArea() && item > 0 && item == (itemCount - 1)) {
        // this is the last item so draw the item labels
        PlotOrientation orientation = plot.getOrientation();

        for (int i = 0; i < itemCount; i++) {
            if (isItemLabelVisible(series, i)) {
                double xValue = dataset.getXValue(series, i);
                double yValue = dataset.getYValue(series, i);
                if (Double.isNaN(yValue)) {
                    yValue = 0.0;
                }
                double transXValue = domainAxis.valueToJava2D(xValue, dataArea, plot.getDomainAxisEdge());
                double transYValue = rangeAxis.valueToJava2D(yValue, dataArea, plot.getRangeAxisEdge());

                double xx = transXValue;
                double yy = transYValue;
                if (orientation == PlotOrientation.HORIZONTAL) {
                    xx = transYValue;
                    yy = transXValue;
                }
                drawItemLabel(g2, orientation, dataset, series, i, xx, yy, (yValue < 0.0));
            }
        }
    }
}

From source file:org.openfaces.component.chart.impl.renderers.XYLineFillRenderer.java

private Shape renderShapeAndLabel(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataSet,
        int series, int item, double yValue, double currentItemX, double currentItemY, double previousItemX,
        double previousItemY, double nextItemX, double nextItemY, double zeroRangePoint) {
    boolean isVerticallyOrientedPlot = plot.getOrientation() == PlotOrientation.VERTICAL;
    Shape entityShape;/*from www.j  a  va 2 s . c  om*/

    if (getItemShapeVisible(series, item)) {
        entityShape = getItemShape(series, item);
        if (isVerticallyOrientedPlot) {
            entityShape = ShapeUtilities.createTranslatedShape(entityShape, currentItemX, currentItemY);
        } else {
            entityShape = ShapeUtilities.createTranslatedShape(entityShape, currentItemY, currentItemX);
        }

        if (entityShape.intersects(dataArea)) {
            drawItemShape(g2, series, item, entityShape);
        }
    } else {
        entityShape = createEntityArea(plot, previousItemX, previousItemY, currentItemX, currentItemY,
                nextItemX, nextItemY, zeroRangePoint);
    }

    if (isItemLabelVisible(series, item)) {
        drawLabel(g2, dataSet, series, item, currentItemX, currentItemY, yValue < 0, plot.getOrientation());
    }

    return entityShape;
}

From source file:edu.ucla.stat.SOCR.motionchart.MotionBubbleRenderer.java

/**
 * Translates the shape so that it displays correctly given the plot and dataArea.
 *
 * @param shape     the shape to translate
 * @param plot      the plot that will be used to translate the shape
 * @param dataArea  the dataArea that the shape will be translated to
 * @return          The translated shape
 *//*from  ww w.j a  va  2s. co  m*/
@SuppressWarnings({ "SuspiciousNameCombination" })
protected Ellipse2D.Double translateShape(Ellipse2D.Double shape, XYPlot plot, Rectangle2D dataArea) {
    Ellipse2D.Double circle = null;

    //double x = shape.getCenterX();
    //double y = shape.getCenterY();
    double z = shape.getWidth();

    PlotOrientation orientation = plot.getOrientation();

    ValueAxis domainAxis = plot.getDomainAxis();
    ValueAxis rangeAxis = plot.getRangeAxis();
    RectangleEdge domainAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();

    double transX1 = domainAxis.valueToJava2D(shape.getX(), dataArea, domainAxisLocation);
    double transX2 = domainAxis.valueToJava2D(shape.getX() + shape.getWidth(), dataArea, domainAxisLocation);
    //The upper-left corner is the lower-left on the graph (screen origin vs. graph origin)
    double transY1 = rangeAxis.valueToJava2D(shape.getY() + shape.getHeight(), dataArea, rangeAxisLocation);
    double transY2 = rangeAxis.valueToJava2D(shape.getY(), dataArea, rangeAxisLocation);

    double width = z * domainAxis.getRange().getLength() * domainZoomMultiplier * SIZE_MULTIPLIER;
    double height = z * rangeAxis.getRange().getLength() * rangeZoomMultiplier * SIZE_MULTIPLIER;
    double transWidth = domainAxis.lengthToJava2D(width, dataArea, domainAxisLocation);//transX2 - transX1;
    double transHeight = rangeAxis.lengthToJava2D(height, dataArea, rangeAxisLocation);//transY2 - transY1;

    double transX = (transX1 + transX2) / 2.0;
    double transY = (transY1 + transY2) / 2.0;

    switch (getScaleType()) {
    case SCALE_ON_DOMAIN_AXIS:
        transHeight = transWidth;
        break;
    case SCALE_ON_RANGE_AXIS:
        transWidth = transHeight;
        break;
    default:
        break;
    }
    transWidth = Math.abs(transWidth);
    transHeight = Math.abs(transHeight);

    if (orientation == PlotOrientation.VERTICAL) {
        circle = new Ellipse2D.Double(transX - transWidth / 2.0, transY - transHeight / 2.0, transWidth,
                transHeight);
    } else if (orientation == PlotOrientation.HORIZONTAL) {
        circle = new Ellipse2D.Double(transY - transHeight / 2.0, transX - transWidth / 2.0, transHeight,
                transWidth);
    }

    return circle;
}

From source file:org.mwc.cmap.grideditor.chart.RendererWithDynamicFeedback.java

/**
 * @see drawSecondaryPass//from  w w  w.ja  va 2 s  . c  o  m
 */
private void drawFeedBackNode(final Graphics2D g2, final XYPlot plot, final XYDataset dataset, final int pass, //
        final int series, final int item, final ValueAxis domainAxis, final Rectangle2D dataArea,
        final ValueAxis rangeAxis, //
        final CrosshairState crosshairState, final EntityCollection entities) {

    // get the data point...
    final double x1 = myFeedBackValue != null ? myFeedBackValue.x : dataset.getXValue(series, item);
    final double y1 = myFeedBackValue != null ? myFeedBackValue.y : dataset.getYValue(series, item);
    if (Double.isNaN(y1) || Double.isNaN(x1)) {
        return;
    }

    final PlotOrientation orientation = plot.getOrientation();
    final RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    final RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    final double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    final double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

    if (getItemShapeVisible(series, item)) {
        Shape shape = getItemShape(series, item);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        }
        if (shape.intersects(dataArea)) {
            g2.setPaint(getFeedbackNodePaint());
            g2.fill(shape);
        }
    }

    double xx = transX1;
    double yy = transY1;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx = transY1;
        yy = transX1;
    }
    drawFeedbackItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0));
}

From source file:org.rdv.viz.chart.FastXYItemRenderer.java

@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {

    boolean itemVisible = getItemVisible(series, item);

    // setup for collecting optional entity info...
    Shape entityArea = null;//from  w  w  w.  ja  va  2  s .co m
    EntityCollection entities = null;
    if (info != null) {
        entities = info.getOwner().getEntityCollection();
    }

    PlotOrientation orientation = plot.getOrientation();
    Paint paint = getItemPaint(series, item);
    Stroke seriesStroke = getItemStroke(series, item);
    g2.setPaint(paint);
    g2.setStroke(seriesStroke);

    // get the data point...
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);
    if (Double.isNaN(x1) || Double.isNaN(y1)) {
        itemVisible = false;
    }

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

    if (getPlotLines()) {
        if (item == 0) {
            previousDrawnItem = 1;
        }

        if (getDrawSeriesLineAsPath()) {
            State s = (State) state;
            if (s.getSeriesIndex() != series) {
                // we are starting a new series path
                s.seriesPath.reset();
                s.setLastPointGood(false);
                s.setSeriesIndex(series);
            }

            // update path to reflect latest point
            if (itemVisible && !Double.isNaN(transX1) && !Double.isNaN(transY1)) {
                float x = (float) transX1;
                float y = (float) transY1;
                if (orientation == PlotOrientation.HORIZONTAL) {
                    x = (float) transY1;
                    y = (float) transX1;
                }
                if (s.isLastPointGood()) {
                    // TODO: check threshold
                    s.seriesPath.lineTo(x, y);
                } else {
                    s.seriesPath.moveTo(x, y);
                }
                s.setLastPointGood(true);
            } else {
                s.setLastPointGood(false);
            }
            if (item == dataset.getItemCount(series) - 1) {
                if (s.getSeriesIndex() == series) {
                    // draw path
                    g2.setStroke(lookupSeriesStroke(series));
                    g2.setPaint(lookupSeriesPaint(series));
                    g2.draw(s.seriesPath);
                }
            }
        }

        else if (item != 0 && itemVisible) {
            // get the previous data point...
            double x0 = dataset.getXValue(series, item - previousDrawnItem);
            double y0 = dataset.getYValue(series, item - previousDrawnItem);
            if (!Double.isNaN(x0) && !Double.isNaN(y0)) {
                boolean drawLine = true;
                if (getPlotDiscontinuous()) {
                    // only draw a line if the gap between the current and
                    // previous data point is within the threshold
                    int numX = dataset.getItemCount(series);
                    double minX = dataset.getXValue(series, 0);
                    double maxX = dataset.getXValue(series, numX - 1);
                    if (getGapThresholdType() == UnitType.ABSOLUTE) {
                        drawLine = Math.abs(x1 - x0) <= getGapThreshold();
                    } else {
                        drawLine = Math.abs(x1 - x0) <= ((maxX - minX) / numX * getGapThreshold());
                    }
                }
                if (drawLine) {
                    double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
                    double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

                    // only draw if we have good values
                    if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1)
                            || Double.isNaN(transY1)) {
                        return;
                    }

                    // Only draw line if it is more than a pixel away from the
                    // previous one
                    if ((transX1 - transX0 > 2 || transX1 - transX0 < -2 || transY1 - transY0 > 2
                            || transY1 - transY0 < -2)) {
                        previousDrawnItem = 1;

                        if (orientation == PlotOrientation.HORIZONTAL) {
                            state.workingLine.setLine(transY0, transX0, transY1, transX1);
                        } else if (orientation == PlotOrientation.VERTICAL) {
                            state.workingLine.setLine(transX0, transY0, transX1, transY1);
                        }

                        if (state.workingLine.intersects(dataArea)) {
                            g2.draw(state.workingLine);
                        }
                    } else {
                        // Increase counter for the previous drawn item.
                        previousDrawnItem++;
                    }
                }
            }
        }
    }

    // we needed to get this far even for invisible items, to ensure that
    // seriesPath updates happened, but now there is nothing more we need
    // to do for non-visible items...
    if (!itemVisible) {
        return;
    }

    // add a cursor to indicate the position of the last data item
    if (getCursorVisible() && item == dataset.getItemCount(series) - 1) {
        Line2D cursorX = new Line2D.Double(transX1 - DEFAULT_CURSOR_SIZE, transY1,
                transX1 + DEFAULT_CURSOR_SIZE, transY1);
        g2.draw(cursorX);
        Line2D cursorY = new Line2D.Double(transX1, transY1 - DEFAULT_CURSOR_SIZE, transX1,
                transY1 + DEFAULT_CURSOR_SIZE);
        g2.draw(cursorY);
    }

    if (getBaseShapesVisible()) {

        Shape shape = getItemShape(series, item);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        }
        if (shape.intersects(dataArea)) {
            if (getItemShapeFilled(series, item)) {
                g2.fill(shape);
            } else {
                g2.draw(shape);
            }
        }
        entityArea = shape;

    }

    if (getPlotImages()) {
        Image image = getImage(plot, series, item, transX1, transY1);
        if (image != null) {
            Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image);
            g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null);
            entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(),
                    image.getWidth(null), image.getHeight(null));
        }

    }

    double xx = transX1;
    double yy = transY1;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx = transY1;
        yy = transX1;
    }

    // draw the item label if there is one...
    if (isItemLabelVisible(series, item)) {
        drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0));
    }

    int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
    int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
    updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1,
            orientation);

    // add an entity for the item...
    if (entities != null && dataArea.contains(xx, yy)) {
        addEntity(entities, entityArea, dataset, series, item, xx, yy);
    }
}