Search in sources :

Example 76 with RectangleEdge

use of org.jfree.chart.util.RectangleEdge 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)

Example 77 with RectangleEdge

use of org.jfree.chart.util.RectangleEdge in project graphcode2vec by graphcode2vec.

the class StatisticalBarRenderer method drawHorizontalItem.

/**
 * Draws an item for a plot with a horizontal orientation.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the data area.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the data.
 * @param visibleRow  the visible row index.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 * @param selected  is the item selected?
 *
 * @since 1.2.0
 */
protected void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, StatisticalCategoryDataset dataset, int visibleRow, int row, int column, boolean selected) {
    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    // BAR Y
    double rectY = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, xAxisLocation);
    int seriesCount = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : getRowCount();
    int categoryCount = getColumnCount();
    if (seriesCount > 1) {
        double seriesGap = dataArea.getHeight() * getItemMargin() / (categoryCount * (seriesCount - 1));
        rectY = rectY + visibleRow * (state.getBarWidth() + seriesGap);
    } else {
        rectY = rectY + visibleRow * state.getBarWidth();
    }
    // BAR X
    Number meanValue = dataset.getMeanValue(row, column);
    if (meanValue == null) {
        return;
    }
    double value = meanValue.doubleValue();
    double base = 0.0;
    double lclip = rangeAxis.getLowerBound();
    double uclip = rangeAxis.getUpperBound();
    if (uclip <= 0.0) {
        // cases 1, 2, 3 and 4
        if (value >= uclip) {
            // bar is not visible
            return;
        }
        base = uclip;
        if (value <= lclip) {
            value = lclip;
        }
    } else if (lclip <= 0.0) {
        // cases 5, 6, 7 and 8
        if (value >= uclip) {
            value = uclip;
        } else {
            if (value <= lclip) {
                value = lclip;
            }
        }
    } else {
        // cases 9, 10, 11 and 12
        if (value <= lclip) {
            // bar is not visible
            return;
        }
        base = rangeAxis.getLowerBound();
        if (value >= uclip) {
            value = uclip;
        }
    }
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double transY1 = rangeAxis.valueToJava2D(base, dataArea, yAxisLocation);
    double transY2 = rangeAxis.valueToJava2D(value, dataArea, yAxisLocation);
    double rectX = Math.min(transY2, transY1);
    double rectHeight = state.getBarWidth();
    double rectWidth = Math.abs(transY2 - transY1);
    Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight);
    Paint itemPaint = getItemPaint(row, column, selected);
    GradientPaintTransformer t = getGradientPaintTransformer();
    if (t != null && itemPaint instanceof GradientPaint) {
        itemPaint = t.transform((GradientPaint) itemPaint, bar);
    }
    g2.setPaint(itemPaint);
    g2.fill(bar);
    // draw the outline...
    if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
        Stroke stroke = getItemOutlineStroke(row, column, selected);
        Paint paint = getItemOutlinePaint(row, column, selected);
        if (stroke != null && paint != null) {
            g2.setStroke(stroke);
            g2.setPaint(paint);
            g2.draw(bar);
        }
    }
    // standard deviation lines
    Number n = dataset.getStdDevValue(row, column);
    if (n != null) {
        double valueDelta = n.doubleValue();
        double highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + valueDelta, dataArea, yAxisLocation);
        double lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() - valueDelta, dataArea, yAxisLocation);
        if (this.errorIndicatorPaint != null) {
            g2.setPaint(this.errorIndicatorPaint);
        } else {
            g2.setPaint(getItemOutlinePaint(row, column, selected));
        }
        if (this.errorIndicatorStroke != null) {
            g2.setStroke(this.errorIndicatorStroke);
        } else {
            g2.setStroke(getItemOutlineStroke(row, column, selected));
        }
        Line2D line = null;
        line = new Line2D.Double(lowVal, rectY + rectHeight / 2.0d, highVal, rectY + rectHeight / 2.0d);
        g2.draw(line);
        line = new Line2D.Double(highVal, rectY + rectHeight * 0.25, highVal, rectY + rectHeight * 0.75);
        g2.draw(line);
        line = new Line2D.Double(lowVal, rectY + rectHeight * 0.25, lowVal, rectY + rectHeight * 0.75);
        g2.draw(line);
    }
    CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column, selected);
    if (generator != null && isItemLabelVisible(row, column, selected)) {
        drawItemLabelForBar(g2, plot, dataset, row, column, selected, generator, bar, (value < 0.0));
    }
    // add an item entity, if this information is being collected
    EntityCollection entities = state.getEntityCollection();
    if (entities != null) {
        addEntity(entities, bar, dataset, row, column, selected);
    }
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) GradientPaintTransformer(org.jfree.chart.util.GradientPaintTransformer) Rectangle2D(java.awt.geom.Rectangle2D) GradientPaint(java.awt.GradientPaint) CategoryItemLabelGenerator(org.jfree.chart.labels.CategoryItemLabelGenerator) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Line2D(java.awt.geom.Line2D) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) EntityCollection(org.jfree.chart.entity.EntityCollection) RectangleEdge(org.jfree.chart.util.RectangleEdge)

Example 78 with RectangleEdge

use of org.jfree.chart.util.RectangleEdge in project graphcode2vec by graphcode2vec.

the class WaterfallBarRenderer method drawItem.

/**
 * Draws the bar for a single (series, category) data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the data area.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 * @param selected  is the item selected?
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, boolean selected, int pass) {
    double previous = state.getSeriesRunningTotal();
    if (column == dataset.getColumnCount() - 1) {
        previous = 0.0;
    }
    double current = 0.0;
    Number n = dataset.getValue(row, column);
    if (n != null) {
        current = previous + n.doubleValue();
    }
    state.setSeriesRunningTotal(current);
    int categoryCount = getColumnCount();
    PlotOrientation orientation = plot.getOrientation();
    double rectX = 0.0;
    double rectY = 0.0;
    RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();
    // Y0
    double j2dy0 = rangeAxis.valueToJava2D(previous, dataArea, rangeAxisLocation);
    // Y1
    double j2dy1 = rangeAxis.valueToJava2D(current, dataArea, rangeAxisLocation);
    double valDiff = current - previous;
    if (j2dy1 < j2dy0) {
        double temp = j2dy1;
        j2dy1 = j2dy0;
        j2dy0 = temp;
    }
    // BAR WIDTH
    double rectWidth = state.getBarWidth();
    // BAR HEIGHT
    double rectHeight = Math.max(getMinimumBarLength(), Math.abs(j2dy1 - j2dy0));
    Comparable seriesKey = dataset.getRowKey(row);
    Comparable categoryKey = dataset.getColumnKey(column);
    if (orientation == PlotOrientation.HORIZONTAL) {
        rectY = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, dataset, getItemMargin(), dataArea, RectangleEdge.LEFT);
        rectX = j2dy0;
        rectHeight = state.getBarWidth();
        rectY = rectY - rectHeight / 2.0;
        rectWidth = Math.max(getMinimumBarLength(), Math.abs(j2dy1 - j2dy0));
    } else if (orientation == PlotOrientation.VERTICAL) {
        rectX = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, dataset, getItemMargin(), dataArea, RectangleEdge.TOP);
        rectX = rectX - rectWidth / 2.0;
        rectY = j2dy0;
    }
    Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight);
    Paint seriesPaint = getFirstBarPaint();
    if (column == 0) {
        seriesPaint = getFirstBarPaint();
    } else if (column == categoryCount - 1) {
        seriesPaint = getLastBarPaint();
    } else {
        if (valDiff < 0.0) {
            seriesPaint = getNegativeBarPaint();
        } else if (valDiff > 0.0) {
            seriesPaint = getPositiveBarPaint();
        } else {
            seriesPaint = getLastBarPaint();
        }
    }
    if (getGradientPaintTransformer() != null && seriesPaint instanceof GradientPaint) {
        GradientPaint gp = (GradientPaint) seriesPaint;
        seriesPaint = getGradientPaintTransformer().transform(gp, bar);
    }
    g2.setPaint(seriesPaint);
    g2.fill(bar);
    // draw the outline...
    if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
        Stroke stroke = getItemOutlineStroke(row, column, selected);
        Paint paint = getItemOutlinePaint(row, column, selected);
        if (stroke != null && paint != null) {
            g2.setStroke(stroke);
            g2.setPaint(paint);
            g2.draw(bar);
        }
    }
    CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column, selected);
    if (generator != null && isItemLabelVisible(row, column, selected)) {
        drawItemLabelForBar(g2, plot, dataset, row, column, selected, generator, bar, (valDiff < 0.0));
    }
    // add an item entity, if this information is being collected
    EntityCollection entities = state.getEntityCollection();
    if (entities != null) {
        addEntity(entities, bar, dataset, row, column, selected);
    }
}
Also used : PlotOrientation(org.jfree.chart.plot.PlotOrientation) Stroke(java.awt.Stroke) Rectangle2D(java.awt.geom.Rectangle2D) GradientPaint(java.awt.GradientPaint) CategoryItemLabelGenerator(org.jfree.chart.labels.CategoryItemLabelGenerator) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) EntityCollection(org.jfree.chart.entity.EntityCollection) RectangleEdge(org.jfree.chart.util.RectangleEdge)

Example 79 with RectangleEdge

use of org.jfree.chart.util.RectangleEdge in project graphcode2vec by graphcode2vec.

the class DeviationRenderer 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) {
    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }
    // first pass draws the shading
    if (pass == 0) {
        IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset;
        State drState = (State) state;
        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);
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            drState.lowerCoordinates.add(new double[] { yyLow, xx });
            drState.upperCoordinates.add(new double[] { yyHigh, xx });
        } else if (orientation == PlotOrientation.VERTICAL) {
            drState.lowerCoordinates.add(new double[] { xx, yyLow });
            drState.upperCoordinates.add(new double[] { xx, yyHigh });
        }
        if (item == (dataset.getItemCount(series) - 1)) {
            // last item in series, draw the lot...
            // set up the alpha-transparency...
            Composite originalComposite = g2.getComposite();
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.alpha));
            g2.setPaint(getItemFillPaint(series, item, selected));
            GeneralPath area = new GeneralPath();
            double[] coords = (double[]) drState.lowerCoordinates.get(0);
            area.moveTo((float) coords[0], (float) coords[1]);
            for (int i = 1; i < drState.lowerCoordinates.size(); i++) {
                coords = (double[]) drState.lowerCoordinates.get(i);
                area.lineTo((float) coords[0], (float) coords[1]);
            }
            int count = drState.upperCoordinates.size();
            coords = (double[]) drState.upperCoordinates.get(count - 1);
            area.lineTo((float) coords[0], (float) coords[1]);
            for (int i = count - 2; i >= 0; i--) {
                coords = (double[]) drState.upperCoordinates.get(i);
                area.lineTo((float) coords[0], (float) coords[1]);
            }
            area.closePath();
            g2.fill(area);
            g2.setComposite(originalComposite);
            drState.lowerCoordinates.clear();
            drState.upperCoordinates.clear();
        }
    }
    if (isLinePass(pass)) {
        // all done by code in the super class
        if (item == 0) {
            State s = (State) state;
            s.seriesPath.reset();
            s.setLastPointGood(false);
        }
        if (getItemLineVisible(series, item)) {
            drawPrimaryLineAsPath(state, g2, plot, dataset, pass, series, item, selected, domainAxis, rangeAxis, dataArea);
        }
    } else // second pass adds shapes where the items are ..
    if (isItemPass(pass)) {
        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (state.getInfo() != null) {
            entities = state.getInfo().getOwner().getEntityCollection();
        }
        drawShape2(g2, dataArea, plot, dataset, pass, series, item, selected, domainAxis, rangeAxis, null, entities);
    }
}
Also used : PlotOrientation(org.jfree.chart.plot.PlotOrientation) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) GeneralPath(java.awt.geom.GeneralPath) EntityCollection(org.jfree.chart.entity.EntityCollection) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) RectangleEdge(org.jfree.chart.util.RectangleEdge)

Example 80 with RectangleEdge

use of org.jfree.chart.util.RectangleEdge in project graphcode2vec by graphcode2vec.

the class StackedXYAreaRenderer2 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) {
    // setup for collecting optional entity info...
    Shape entityArea = null;
    EntityCollection entities = null;
    if (state.getInfo() != null) {
        entities = state.getInfo().getOwner().getEntityCollection();
    }
    TableXYDataset tdataset = (TableXYDataset) dataset;
    PlotOrientation orientation = plot.getOrientation();
    // get the data point...
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);
    if (Double.isNaN(y1)) {
        y1 = 0.0;
    }
    double[] stack1 = getStackValues(tdataset, series, item);
    // get the previous point and the next point so we can calculate a
    // "hot spot" for the area (used by the chart entity)...
    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[] stack0 = getStackValues(tdataset, series, Math.max(item - 1, 0));
    int itemCount = dataset.getItemCount(series);
    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[] stack2 = getStackValues(tdataset, series, Math.min(item + 1, itemCount - 1));
    double xleft = (x0 + x1) / 2.0;
    double xright = (x1 + x2) / 2.0;
    double[] stackLeft = averageStackValues(stack0, stack1);
    double[] stackRight = averageStackValues(stack1, stack2);
    double[] adjStackLeft = adjustedStackValues(stack0, stack1);
    double[] adjStackRight = adjustedStackValues(stack1, stack2);
    RectangleEdge edge0 = plot.getDomainAxisEdge();
    float transX1 = (float) domainAxis.valueToJava2D(x1, dataArea, edge0);
    float transXLeft = (float) domainAxis.valueToJava2D(xleft, dataArea, edge0);
    float transXRight = (float) domainAxis.valueToJava2D(xright, dataArea, edge0);
    if (this.roundXCoordinates) {
        transX1 = Math.round(transX1);
        transXLeft = Math.round(transXLeft);
        transXRight = Math.round(transXRight);
    }
    float transY1;
    RectangleEdge edge1 = plot.getRangeAxisEdge();
    GeneralPath left = new GeneralPath();
    GeneralPath right = new GeneralPath();
    if (y1 >= 0.0) {
        // handle positive value
        transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[1], dataArea, edge1);
        float transStack1 = (float) rangeAxis.valueToJava2D(stack1[1], dataArea, edge1);
        float transStackLeft = (float) rangeAxis.valueToJava2D(adjStackLeft[1], dataArea, edge1);
        // LEFT POLYGON
        if (y0 >= 0.0) {
            double yleft = (y0 + y1) / 2.0 + stackLeft[1];
            float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1);
            if (orientation == PlotOrientation.VERTICAL) {
                left.moveTo(transX1, transY1);
                left.lineTo(transX1, transStack1);
                left.lineTo(transXLeft, transStackLeft);
                left.lineTo(transXLeft, transYLeft);
            } else {
                left.moveTo(transY1, transX1);
                left.lineTo(transStack1, transX1);
                left.lineTo(transStackLeft, transXLeft);
                left.lineTo(transYLeft, transXLeft);
            }
            left.closePath();
        } else {
            if (orientation == PlotOrientation.VERTICAL) {
                left.moveTo(transX1, transStack1);
                left.lineTo(transX1, transY1);
                left.lineTo(transXLeft, transStackLeft);
            } else {
                left.moveTo(transStack1, transX1);
                left.lineTo(transY1, transX1);
                left.lineTo(transStackLeft, transXLeft);
            }
            left.closePath();
        }
        float transStackRight = (float) rangeAxis.valueToJava2D(adjStackRight[1], dataArea, edge1);
        // RIGHT POLYGON
        if (y2 >= 0.0) {
            double yright = (y1 + y2) / 2.0 + stackRight[1];
            float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1);
            if (orientation == PlotOrientation.VERTICAL) {
                right.moveTo(transX1, transStack1);
                right.lineTo(transX1, transY1);
                right.lineTo(transXRight, transYRight);
                right.lineTo(transXRight, transStackRight);
            } else {
                right.moveTo(transStack1, transX1);
                right.lineTo(transY1, transX1);
                right.lineTo(transYRight, transXRight);
                right.lineTo(transStackRight, transXRight);
            }
            right.closePath();
        } else {
            if (orientation == PlotOrientation.VERTICAL) {
                right.moveTo(transX1, transStack1);
                right.lineTo(transX1, transY1);
                right.lineTo(transXRight, transStackRight);
            } else {
                right.moveTo(transStack1, transX1);
                right.lineTo(transY1, transX1);
                right.lineTo(transStackRight, transXRight);
            }
            right.closePath();
        }
    } else {
        // handle negative value
        transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[0], dataArea, edge1);
        float transStack1 = (float) rangeAxis.valueToJava2D(stack1[0], dataArea, edge1);
        float transStackLeft = (float) rangeAxis.valueToJava2D(adjStackLeft[0], dataArea, edge1);
        // LEFT POLYGON
        if (y0 >= 0.0) {
            if (orientation == PlotOrientation.VERTICAL) {
                left.moveTo(transX1, transStack1);
                left.lineTo(transX1, transY1);
                left.lineTo(transXLeft, transStackLeft);
            } else {
                left.moveTo(transStack1, transX1);
                left.lineTo(transY1, transX1);
                left.lineTo(transStackLeft, transXLeft);
            }
            left.clone();
        } else {
            double yleft = (y0 + y1) / 2.0 + stackLeft[0];
            float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1);
            if (orientation == PlotOrientation.VERTICAL) {
                left.moveTo(transX1, transY1);
                left.lineTo(transX1, transStack1);
                left.lineTo(transXLeft, transStackLeft);
                left.lineTo(transXLeft, transYLeft);
            } else {
                left.moveTo(transY1, transX1);
                left.lineTo(transStack1, transX1);
                left.lineTo(transStackLeft, transXLeft);
                left.lineTo(transYLeft, transXLeft);
            }
            left.closePath();
        }
        float transStackRight = (float) rangeAxis.valueToJava2D(adjStackRight[0], dataArea, edge1);
        // RIGHT POLYGON
        if (y2 >= 0.0) {
            if (orientation == PlotOrientation.VERTICAL) {
                right.moveTo(transX1, transStack1);
                right.lineTo(transX1, transY1);
                right.lineTo(transXRight, transStackRight);
            } else {
                right.moveTo(transStack1, transX1);
                right.lineTo(transY1, transX1);
                right.lineTo(transStackRight, transXRight);
            }
            right.closePath();
        } else {
            double yright = (y1 + y2) / 2.0 + stackRight[0];
            float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1);
            if (orientation == PlotOrientation.VERTICAL) {
                right.moveTo(transX1, transStack1);
                right.lineTo(transX1, transY1);
                right.lineTo(transXRight, transYRight);
                right.lineTo(transXRight, transStackRight);
            } else {
                right.moveTo(transStack1, transX1);
                right.lineTo(transY1, transX1);
                right.lineTo(transYRight, transXRight);
                right.lineTo(transStackRight, transXRight);
            }
            right.closePath();
        }
    }
    // Get series Paint and Stroke
    Paint itemPaint = getItemPaint(series, item, selected);
    if (pass == 0) {
        g2.setPaint(itemPaint);
        g2.fill(left);
        g2.fill(right);
    }
    // add an entity for the item...
    if (entities != null) {
        GeneralPath gp = new GeneralPath(left);
        gp.append(right, false);
        entityArea = gp;
        addEntity(entities, entityArea, dataset, series, item, selected, transX1, transY1);
    }
}
Also used : PlotOrientation(org.jfree.chart.plot.PlotOrientation) Shape(java.awt.Shape) GeneralPath(java.awt.geom.GeneralPath) EntityCollection(org.jfree.chart.entity.EntityCollection) TableXYDataset(org.jfree.data.xy.TableXYDataset) Paint(java.awt.Paint) Paint(java.awt.Paint) RectangleEdge(org.jfree.chart.util.RectangleEdge)

Aggregations

RectangleEdge (org.jfree.chart.util.RectangleEdge)88 Rectangle2D (java.awt.geom.Rectangle2D)48 Paint (java.awt.Paint)45 PlotOrientation (org.jfree.chart.plot.PlotOrientation)44 EntityCollection (org.jfree.chart.entity.EntityCollection)33 Stroke (java.awt.Stroke)20 Shape (java.awt.Shape)18 Line2D (java.awt.geom.Line2D)17 AxisSpace (org.jfree.chart.axis.AxisSpace)15 ValueAxis (org.jfree.chart.axis.ValueAxis)15 CategoryItemLabelGenerator (org.jfree.chart.labels.CategoryItemLabelGenerator)12 GeneralPath (java.awt.geom.GeneralPath)10 AxisLocation (org.jfree.chart.axis.AxisLocation)7 IntervalXYDataset (org.jfree.data.xy.IntervalXYDataset)7 Point2D (java.awt.geom.Point2D)6 AxisState (org.jfree.chart.axis.AxisState)6 CategoryAxis (org.jfree.chart.axis.CategoryAxis)6 XYCrosshairState (org.jfree.chart.plot.XYCrosshairState)6 RectangleInsets (org.jfree.chart.util.RectangleInsets)6 GradientPaint (java.awt.GradientPaint)5