Search in sources :

Example 6 with XYCrosshairState

use of org.jfree.chart.plot.XYCrosshairState in project graphcode2vec by graphcode2vec.

the class XYAreaRenderer method drawItem.

/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @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 pass  the pass index.
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, boolean selected, int pass) {
    if (!getItemVisible(series, item)) {
        return;
    }
    XYAreaRendererState areaState = (XYAreaRendererState) state;
    // get the data point...
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);
    if (Double.isNaN(y1)) {
        y1 = 0.0;
    }
    double transX1 = domainAxis.valueToJava2D(x1, dataArea, plot.getDomainAxisEdge());
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, plot.getRangeAxisEdge());
    // get the previous point and the next point so we can calculate a
    // "hot spot" for the area (used by the chart entity)...
    int itemCount = dataset.getItemCount(series);
    double x0 = dataset.getXValue(series, Math.max(item - 1, 0));
    double y0 = dataset.getYValue(series, Math.max(item - 1, 0));
    if (Double.isNaN(y0)) {
        y0 = 0.0;
    }
    double transX0 = domainAxis.valueToJava2D(x0, dataArea, plot.getDomainAxisEdge());
    double transY0 = rangeAxis.valueToJava2D(y0, dataArea, plot.getRangeAxisEdge());
    double x2 = dataset.getXValue(series, Math.min(item + 1, itemCount - 1));
    double y2 = dataset.getYValue(series, Math.min(item + 1, itemCount - 1));
    if (Double.isNaN(y2)) {
        y2 = 0.0;
    }
    double transX2 = domainAxis.valueToJava2D(x2, dataArea, plot.getDomainAxisEdge());
    double transY2 = rangeAxis.valueToJava2D(y2, dataArea, plot.getRangeAxisEdge());
    double transZero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge());
    Polygon hotspot = null;
    if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
        hotspot = new Polygon();
        hotspot.addPoint((int) transZero, (int) ((transX0 + transX1) / 2.0));
        hotspot.addPoint((int) ((transY0 + transY1) / 2.0), (int) ((transX0 + transX1) / 2.0));
        hotspot.addPoint((int) transY1, (int) transX1);
        hotspot.addPoint((int) ((transY1 + transY2) / 2.0), (int) ((transX1 + transX2) / 2.0));
        hotspot.addPoint((int) transZero, (int) ((transX1 + transX2) / 2.0));
    } else {
        // vertical orientation
        hotspot = new Polygon();
        hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) transZero);
        hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) ((transY0 + transY1) / 2.0));
        hotspot.addPoint((int) transX1, (int) transY1);
        hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) ((transY1 + transY2) / 2.0));
        hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) transZero);
    }
    if (item == 0) {
        // create a new area polygon for the series
        areaState.area = new Polygon();
        // the first point is (x, 0)
        double zero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge());
        if (plot.getOrientation() == PlotOrientation.VERTICAL) {
            areaState.area.addPoint((int) transX1, (int) zero);
        } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
            areaState.area.addPoint((int) zero, (int) transX1);
        }
    }
    // Add each point to Area (x, y)
    if (plot.getOrientation() == PlotOrientation.VERTICAL) {
        areaState.area.addPoint((int) transX1, (int) transY1);
    } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
        areaState.area.addPoint((int) transY1, (int) transX1);
    }
    PlotOrientation orientation = plot.getOrientation();
    Paint paint = getItemPaint(series, item, selected);
    Stroke stroke = getItemStroke(series, item, selected);
    g2.setPaint(paint);
    g2.setStroke(stroke);
    Shape shape = null;
    if (getPlotShapes()) {
        shape = getItemShape(series, item, selected);
        if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        } else if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        }
        g2.draw(shape);
    }
    if (getPlotLines()) {
        if (item > 0) {
            if (plot.getOrientation() == PlotOrientation.VERTICAL) {
                areaState.line.setLine(transX0, transY0, transX1, transY1);
            } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
                areaState.line.setLine(transY0, transX0, transY1, transX1);
            }
            g2.draw(areaState.line);
        }
    }
    // and number of items > 0.  We can't draw an area for a single point.
    if (getPlotArea() && item > 0 && item == (itemCount - 1)) {
        if (orientation == PlotOrientation.VERTICAL) {
            // Add the last point (x,0)
            areaState.area.addPoint((int) transX1, (int) transZero);
        } else if (orientation == PlotOrientation.HORIZONTAL) {
            // Add the last point (x,0)
            areaState.area.addPoint((int) transZero, (int) transX1);
        }
        if (this.useFillPaint) {
            paint = lookupSeriesFillPaint(series);
        }
        if (paint instanceof GradientPaint) {
            GradientPaint gp = (GradientPaint) paint;
            GradientPaint adjGP = this.gradientTransformer.transform(gp, dataArea);
            g2.setPaint(adjGP);
        }
        g2.fill(areaState.area);
        // draw an outline around the Area.
        if (isOutline()) {
            Shape area = areaState.area;
            // Java2D has some issues drawing dashed lines around "large"
            // geometrical shapes - for example, see bug 6620013 in the
            // Java bug database.  So, we'll check if the outline is
            // dashed and, if it is, do our own clipping before drawing
            // the outline...
            Stroke outlineStroke = lookupSeriesOutlineStroke(series);
            if (outlineStroke instanceof BasicStroke) {
                BasicStroke bs = (BasicStroke) outlineStroke;
                if (bs.getDashArray() != null) {
                    Area poly = new Area(areaState.area);
                    // we make the clip region slightly larger than the
                    // dataArea so that the clipped edges don't show lines
                    // on the chart
                    Area clip = new Area(new Rectangle2D.Double(dataArea.getX() - 5.0, dataArea.getY() - 5.0, dataArea.getWidth() + 10.0, dataArea.getHeight() + 10.0));
                    poly.intersect(clip);
                    area = poly;
                }
            }
            // end of workaround
            g2.setStroke(outlineStroke);
            g2.setPaint(lookupSeriesOutlinePaint(series));
            g2.draw(area);
        }
    }
    int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
    int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
    XYCrosshairState crosshairState = state.getCrosshairState();
    updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation);
    // collect entity and tool tip information...
    EntityCollection entities = state.getEntityCollection();
    if (entities != null && hotspot != null) {
        addEntity(entities, hotspot, dataset, series, item, selected, 0.0, 0.0);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) PlotOrientation(org.jfree.chart.plot.PlotOrientation) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Shape(java.awt.Shape) Rectangle2D(java.awt.geom.Rectangle2D) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Area(java.awt.geom.Area) EntityCollection(org.jfree.chart.entity.EntityCollection) Polygon(java.awt.Polygon) XYCrosshairState(org.jfree.chart.plot.XYCrosshairState)

Example 7 with XYCrosshairState

use of org.jfree.chart.plot.XYCrosshairState in project graphcode2vec by graphcode2vec.

the class XYBarRenderer method drawItem.

/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot is being drawn.
 * @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 pass  the pass index.
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, boolean selected, int pass) {
    Rectangle2D bar = createBar(g2, dataArea, plot, domainAxis, rangeAxis, dataset, series, item, selected);
    if (bar == null) {
        return;
    }
    boolean positive = true;
    if (this.useYInterval) {
        positive = dataset.getYValue(series, item) >= 0.0;
    // FIXME:  the above line should look at the endYValue
    } else {
        positive = dataset.getYValue(series, item) >= 0.0;
    }
    boolean inverted = rangeAxis.isInverted();
    RectangleEdge barBase;
    if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
        if (positive && inverted || !positive && !inverted) {
            barBase = RectangleEdge.RIGHT;
        } else {
            barBase = RectangleEdge.LEFT;
        }
    } else {
        if (positive && !inverted || !positive && inverted) {
            barBase = RectangleEdge.BOTTOM;
        } else {
            barBase = RectangleEdge.TOP;
        }
    }
    if (getShadowsVisible()) {
        this.barPainter.paintBarShadow(g2, this, series, item, selected, bar, barBase, !this.useYInterval);
    }
    this.barPainter.paintBar(g2, this, series, item, selected, bar, barBase);
    if (isItemLabelVisible(series, item, selected)) {
        XYItemLabelGenerator generator = getItemLabelGenerator(series, item, selected);
        drawItemLabelForBar(g2, plot, dataset, series, item, selected, generator, bar, !positive);
    }
    // update the crosshair point
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);
    double transX1 = domainAxis.valueToJava2D(x1, dataArea, plot.getDomainAxisEdge());
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, plot.getRangeAxisEdge());
    int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
    int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
    XYCrosshairState crosshairState = state.getCrosshairState();
    updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, plot.getOrientation());
    EntityCollection entities = state.getEntityCollection();
    if (entities != null) {
        addEntity(entities, bar, dataset, series, item, selected, 0.0, 0.0);
    }
}
Also used : EntityCollection(org.jfree.chart.entity.EntityCollection) Rectangle2D(java.awt.geom.Rectangle2D) XYItemLabelGenerator(org.jfree.chart.labels.XYItemLabelGenerator) Paint(java.awt.Paint) RectangleEdge(org.jfree.chart.util.RectangleEdge) XYCrosshairState(org.jfree.chart.plot.XYCrosshairState)

Example 8 with XYCrosshairState

use of org.jfree.chart.plot.XYCrosshairState in project graphcode2vec by graphcode2vec.

the class XYBubbleRenderer method drawItem.

/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @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 (an {@link XYZDataset} is expected).
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, boolean selected, int pass) {
    // return straight away if the item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }
    PlotOrientation orientation = plot.getOrientation();
    // get the data point...
    double x = dataset.getXValue(series, item);
    double y = dataset.getYValue(series, item);
    double z = Double.NaN;
    if (dataset instanceof XYZDataset) {
        XYZDataset xyzData = (XYZDataset) dataset;
        z = xyzData.getZValue(series, item);
    }
    if (!Double.isNaN(z)) {
        RectangleEdge domainAxisLocation = plot.getDomainAxisEdge();
        RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();
        double transX = domainAxis.valueToJava2D(x, dataArea, domainAxisLocation);
        double transY = rangeAxis.valueToJava2D(y, dataArea, rangeAxisLocation);
        double transDomain = 0.0;
        double transRange = 0.0;
        double zero;
        switch(getScaleType()) {
            case SCALE_ON_DOMAIN_AXIS:
                zero = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation);
                transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero;
                transRange = transDomain;
                break;
            case SCALE_ON_RANGE_AXIS:
                zero = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation);
                transRange = zero - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation);
                transDomain = transRange;
                break;
            default:
                double zero1 = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation);
                double zero2 = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation);
                transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero1;
                transRange = zero2 - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation);
        }
        transDomain = Math.abs(transDomain);
        transRange = Math.abs(transRange);
        Ellipse2D circle = null;
        if (orientation == PlotOrientation.VERTICAL) {
            circle = new Ellipse2D.Double(transX - transDomain / 2.0, transY - transRange / 2.0, transDomain, transRange);
        } else if (orientation == PlotOrientation.HORIZONTAL) {
            circle = new Ellipse2D.Double(transY - transRange / 2.0, transX - transDomain / 2.0, transRange, transDomain);
        }
        g2.setPaint(getItemPaint(series, item, selected));
        g2.fill(circle);
        g2.setStroke(getItemOutlineStroke(series, item, selected));
        g2.setPaint(getItemOutlinePaint(series, item, selected));
        g2.draw(circle);
        if (isItemLabelVisible(series, item, selected)) {
            if (orientation == PlotOrientation.VERTICAL) {
                drawItemLabel(g2, orientation, dataset, series, item, selected, transX, transY, false);
            } else if (orientation == PlotOrientation.HORIZONTAL) {
                drawItemLabel(g2, orientation, dataset, series, item, selected, transY, transX, false);
            }
        }
        // add an entity if this info is being collected
        EntityCollection entities = null;
        if (state.getInfo() != null) {
            entities = state.getInfo().getOwner().getEntityCollection();
            if (entities != null && circle.intersects(dataArea)) {
                addEntity(entities, circle, dataset, series, item, selected, circle.getCenterX(), circle.getCenterY());
            }
        }
        int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
        int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
        XYCrosshairState crosshairState = state.getCrosshairState();
        updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation);
    }
}
Also used : PlotOrientation(org.jfree.chart.plot.PlotOrientation) EntityCollection(org.jfree.chart.entity.EntityCollection) XYZDataset(org.jfree.data.xy.XYZDataset) Ellipse2D(java.awt.geom.Ellipse2D) Paint(java.awt.Paint) RectangleEdge(org.jfree.chart.util.RectangleEdge) XYCrosshairState(org.jfree.chart.plot.XYCrosshairState)

Example 9 with XYCrosshairState

use of org.jfree.chart.plot.XYCrosshairState in project graphcode2vec by graphcode2vec.

the class XYDifferenceRenderer method drawItemPass1.

/**
 * Draws the visual representation of a single data item, second pass.  In
 * the second pass, the renderer draws the lines and shapes for the
 * individual points in the two series.
 *
 * @param x_graphics  the graphics device.
 * @param state  the rendering state.
 * @param x_dataArea  the area within which the data is being drawn.
 * @param x_plot  the plot (can be used to obtain standard color
 *         information etc).
 * @param x_domainAxis  the domain (horizontal) axis.
 * @param x_rangeAxis  the range (vertical) axis.
 * @param x_dataset  the dataset.
 * @param x_series  the series index (zero-based).
 * @param x_item  the item index (zero-based).
 * @param selected  is the data item selected?
 *
 * @since 1.2.0
 */
protected void drawItemPass1(Graphics2D x_graphics, XYItemRendererState state, Rectangle2D x_dataArea, XYPlot x_plot, ValueAxis x_domainAxis, ValueAxis x_rangeAxis, XYDataset x_dataset, int x_series, int x_item, boolean selected) {
    Shape l_entityArea = null;
    EntityCollection l_entities = null;
    if (state.getInfo() != null) {
        l_entities = state.getInfo().getOwner().getEntityCollection();
    }
    Paint l_seriesPaint = getItemPaint(x_series, x_item, selected);
    Stroke l_seriesStroke = getItemStroke(x_series, x_item, selected);
    x_graphics.setPaint(l_seriesPaint);
    x_graphics.setStroke(l_seriesStroke);
    PlotOrientation l_orientation = x_plot.getOrientation();
    RectangleEdge l_domainAxisLocation = x_plot.getDomainAxisEdge();
    RectangleEdge l_rangeAxisLocation = x_plot.getRangeAxisEdge();
    double l_x0 = x_dataset.getXValue(x_series, x_item);
    double l_y0 = x_dataset.getYValue(x_series, x_item);
    double l_x1 = x_domainAxis.valueToJava2D(l_x0, x_dataArea, l_domainAxisLocation);
    double l_y1 = x_rangeAxis.valueToJava2D(l_y0, x_dataArea, l_rangeAxisLocation);
    if (getShapesVisible()) {
        Shape l_shape = getItemShape(x_series, x_item, selected);
        if (l_orientation == PlotOrientation.HORIZONTAL) {
            l_shape = ShapeUtilities.createTranslatedShape(l_shape, l_y1, l_x1);
        } else {
            l_shape = ShapeUtilities.createTranslatedShape(l_shape, l_x1, l_y1);
        }
        if (l_shape.intersects(x_dataArea)) {
            x_graphics.setPaint(getItemPaint(x_series, x_item, selected));
            x_graphics.fill(l_shape);
        }
        l_entityArea = l_shape;
    }
    // add an entity for the item...
    if (null != l_entities) {
        if (null == l_entityArea) {
            l_entityArea = new Rectangle2D.Double((l_x1 - 2), (l_y1 - 2), 4, 4);
        }
        String l_tip = null;
        XYToolTipGenerator l_tipGenerator = getToolTipGenerator(x_series, x_item, selected);
        if (null != l_tipGenerator) {
            l_tip = l_tipGenerator.generateToolTip(x_dataset, x_series, x_item);
        }
        String l_url = null;
        XYURLGenerator l_urlGenerator = getURLGenerator(x_series, x_item, selected);
        if (null != l_urlGenerator) {
            l_url = l_urlGenerator.generateURL(x_dataset, x_series, x_item);
        }
        XYItemEntity l_entity = new XYItemEntity(l_entityArea, x_dataset, x_series, x_item, l_tip, l_url);
        l_entities.add(l_entity);
    }
    // draw the item label if there is one...
    if (isItemLabelVisible(x_series, x_item, selected)) {
        drawItemLabel(x_graphics, l_orientation, x_dataset, x_series, x_item, selected, l_x1, l_y1, (l_y1 < 0.0));
    }
    int l_domainAxisIndex = x_plot.getDomainAxisIndex(x_domainAxis);
    int l_rangeAxisIndex = x_plot.getRangeAxisIndex(x_rangeAxis);
    XYCrosshairState crosshairState = state.getCrosshairState();
    updateCrosshairValues(crosshairState, l_x0, l_y0, l_domainAxisIndex, l_rangeAxisIndex, l_x1, l_y1, l_orientation);
    if (0 == x_item) {
        return;
    }
    double l_x2 = x_domainAxis.valueToJava2D(x_dataset.getXValue(x_series, (x_item - 1)), x_dataArea, l_domainAxisLocation);
    double l_y2 = x_rangeAxis.valueToJava2D(x_dataset.getYValue(x_series, (x_item - 1)), x_dataArea, l_rangeAxisLocation);
    Line2D l_line = null;
    if (PlotOrientation.HORIZONTAL == l_orientation) {
        l_line = new Line2D.Double(l_y1, l_x1, l_y2, l_x2);
    } else if (PlotOrientation.VERTICAL == l_orientation) {
        l_line = new Line2D.Double(l_x1, l_y1, l_x2, l_y2);
    }
    if ((null != l_line) && l_line.intersects(x_dataArea)) {
        x_graphics.setPaint(getItemPaint(x_series, x_item, selected));
        x_graphics.setStroke(getItemStroke(x_series, x_item, selected));
        x_graphics.draw(l_line);
    }
}
Also used : Stroke(java.awt.Stroke) PlotOrientation(org.jfree.chart.plot.PlotOrientation) Shape(java.awt.Shape) XYURLGenerator(org.jfree.chart.urls.XYURLGenerator) Rectangle2D(java.awt.geom.Rectangle2D) Paint(java.awt.Paint) Line2D(java.awt.geom.Line2D) Paint(java.awt.Paint) XYItemEntity(org.jfree.chart.entity.XYItemEntity) EntityCollection(org.jfree.chart.entity.EntityCollection) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) RectangleEdge(org.jfree.chart.util.RectangleEdge) XYCrosshairState(org.jfree.chart.plot.XYCrosshairState)

Example 10 with XYCrosshairState

use of org.jfree.chart.plot.XYCrosshairState in project graphcode2vec by graphcode2vec.

the class XYDotRenderer method drawItem.

/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @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 pass  the pass index.
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, boolean selected, int pass) {
    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }
    // 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)) {
        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, selected));
        PlotOrientation orientation = plot.getOrientation();
        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);
        XYCrosshairState crosshairState = state.getCrosshairState();
        updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation);
    }
}
Also used : PlotOrientation(org.jfree.chart.plot.PlotOrientation) Paint(java.awt.Paint) RectangleEdge(org.jfree.chart.util.RectangleEdge) XYCrosshairState(org.jfree.chart.plot.XYCrosshairState)

Aggregations

Paint (java.awt.Paint)10 XYCrosshairState (org.jfree.chart.plot.XYCrosshairState)10 EntityCollection (org.jfree.chart.entity.EntityCollection)9 PlotOrientation (org.jfree.chart.plot.PlotOrientation)9 Stroke (java.awt.Stroke)7 Rectangle2D (java.awt.geom.Rectangle2D)6 RectangleEdge (org.jfree.chart.util.RectangleEdge)6 Shape (java.awt.Shape)5 Polygon (java.awt.Polygon)4 Point (java.awt.Point)2 BasicStroke (java.awt.BasicStroke)1 GradientPaint (java.awt.GradientPaint)1 Image (java.awt.Image)1 Area (java.awt.geom.Area)1 Ellipse2D (java.awt.geom.Ellipse2D)1 Line2D (java.awt.geom.Line2D)1 Stack (java.util.Stack)1 XYItemEntity (org.jfree.chart.entity.XYItemEntity)1 XYItemLabelGenerator (org.jfree.chart.labels.XYItemLabelGenerator)1 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)1