Search in sources :

Example 11 with RectangleInsets

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

the class CombinedRangeXYPlot method draw.

/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);
    // this.axisOffset.trim(dataArea);
    // set the width and height of non-shared axis of all sub-plots
    setFixedDomainAxisSpaceForSubplots(space);
    // draw the shared axis
    ValueAxis axis = getRangeAxis();
    RectangleEdge edge = getRangeAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);
    // draw all the charts
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState, subplotInfo);
    }
    if (info != null) {
        info.setDataArea(dataArea);
    }
}
Also used : AxisState(org.jfree.chart.axis.AxisState) ValueAxis(org.jfree.chart.axis.ValueAxis) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.chart.util.RectangleInsets) AxisSpace(org.jfree.chart.axis.AxisSpace) RectangleEdge(org.jfree.chart.util.RectangleEdge)

Example 12 with RectangleInsets

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

the class CompassPlot method draw.

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing.
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    int outerRadius = 0;
    int innerRadius = 0;
    int x1, y1, x2, y2;
    double a;
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    // draw the background
    if (this.drawBorder) {
        drawBackground(g2, area);
    }
    int midX = (int) (area.getWidth() / 2);
    int midY = (int) (area.getHeight() / 2);
    int radius = midX;
    if (midY < midX) {
        radius = midY;
    }
    --radius;
    int diameter = 2 * radius;
    midX += (int) area.getMinX();
    midY += (int) area.getMinY();
    this.circle1.setFrame(midX - radius, midY - radius, diameter, diameter);
    this.circle2.setFrame(midX - radius + 15, midY - radius + 15, diameter - 30, diameter - 30);
    g2.setPaint(this.rosePaint);
    this.a1 = new Area(this.circle1);
    this.a2 = new Area(this.circle2);
    this.a1.subtract(this.a2);
    g2.fill(this.a1);
    g2.setPaint(this.roseCenterPaint);
    x1 = diameter - 30;
    g2.fillOval(midX - radius + 15, midY - radius + 15, x1, x1);
    g2.setPaint(this.roseHighlightPaint);
    g2.drawOval(midX - radius, midY - radius, diameter, diameter);
    x1 = diameter - 20;
    g2.drawOval(midX - radius + 10, midY - radius + 10, x1, x1);
    x1 = diameter - 30;
    g2.drawOval(midX - radius + 15, midY - radius + 15, x1, x1);
    x1 = diameter - 80;
    g2.drawOval(midX - radius + 40, midY - radius + 40, x1, x1);
    outerRadius = radius - 20;
    innerRadius = radius - 32;
    for (int w = 0; w < 360; w += 15) {
        a = Math.toRadians(w);
        x1 = midX - ((int) (Math.sin(a) * innerRadius));
        x2 = midX - ((int) (Math.sin(a) * outerRadius));
        y1 = midY - ((int) (Math.cos(a) * innerRadius));
        y2 = midY - ((int) (Math.cos(a) * outerRadius));
        g2.drawLine(x1, y1, x2, y2);
    }
    g2.setPaint(this.roseHighlightPaint);
    innerRadius = radius - 26;
    outerRadius = 7;
    for (int w = 45; w < 360; w += 90) {
        a = Math.toRadians(w);
        x1 = midX - ((int) (Math.sin(a) * innerRadius));
        y1 = midY - ((int) (Math.cos(a) * innerRadius));
        g2.fillOval(x1 - outerRadius, y1 - outerRadius, 2 * outerRadius, 2 * outerRadius);
    }
    // / Squares
    for (int w = 0; w < 360; w += 90) {
        a = Math.toRadians(w);
        x1 = midX - ((int) (Math.sin(a) * innerRadius));
        y1 = midY - ((int) (Math.cos(a) * innerRadius));
        Polygon p = new Polygon();
        p.addPoint(x1 - outerRadius, y1);
        p.addPoint(x1, y1 + outerRadius);
        p.addPoint(x1 + outerRadius, y1);
        p.addPoint(x1, y1 - outerRadius);
        g2.fillPolygon(p);
    }
    // / Draw N, S, E, W
    innerRadius = radius - 42;
    Font f = getCompassFont(radius);
    g2.setFont(f);
    g2.drawString("N", midX - 5, midY - innerRadius + f.getSize());
    g2.drawString("S", midX - 5, midY + innerRadius - 5);
    g2.drawString("W", midX - innerRadius + 5, midY + 5);
    g2.drawString("E", midX + innerRadius - f.getSize(), midY + 5);
    // plot the data (unless the dataset is null)...
    y1 = radius / 2;
    x1 = radius / 6;
    Rectangle2D needleArea = new Rectangle2D.Double((midX - x1), (midY - y1), (2 * x1), (2 * y1));
    int x = this.seriesNeedle.length;
    int current = 0;
    double value = 0;
    int i = (this.datasets.length - 1);
    for (; i >= 0; --i) {
        ValueDataset data = this.datasets[i];
        if (data != null && data.getValue() != null) {
            value = (data.getValue().doubleValue()) % this.revolutionDistance;
            value = value / this.revolutionDistance * 360;
            current = i % x;
            this.seriesNeedle[current].draw(g2, needleArea, value);
        }
    }
    if (this.drawBorder) {
        drawOutline(g2, area);
    }
}
Also used : Area(java.awt.geom.Area) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.chart.util.RectangleInsets) ValueDataset(org.jfree.data.general.ValueDataset) DefaultValueDataset(org.jfree.data.general.DefaultValueDataset) Polygon(java.awt.Polygon) Paint(java.awt.Paint) Font(java.awt.Font)

Example 13 with RectangleInsets

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

the class XYPlot method draw.

/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }
    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);
    this.axisOffset.trim(dataArea);
    dataArea = integerise(dataArea);
    if (dataArea.isEmpty()) {
        return;
    }
    createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null);
    if (info != null) {
        info.setDataArea(dataArea);
    }
    // draw the plot background and axes...
    drawBackground(g2, dataArea);
    Map axisStateMap = drawAxes(g2, area, dataArea, info);
    PlotOrientation orient = getOrientation();
    // clicked - the crosshairs will be driven off this point...
    if (anchor != null && !dataArea.contains(anchor)) {
        anchor = null;
    }
    CrosshairState crosshairState = new CrosshairState();
    crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY);
    crosshairState.setAnchor(anchor);
    crosshairState.setAnchorX(Double.NaN);
    crosshairState.setAnchorY(Double.NaN);
    if (anchor != null) {
        ValueAxis domainAxis = getDomainAxis();
        if (domainAxis != null) {
            double x;
            if (orient == PlotOrientation.VERTICAL) {
                x = domainAxis.java2DToValue(anchor.getX(), dataArea, getDomainAxisEdge());
            } else {
                x = domainAxis.java2DToValue(anchor.getY(), dataArea, getDomainAxisEdge());
            }
            crosshairState.setAnchorX(x);
        }
        ValueAxis rangeAxis = getRangeAxis();
        if (rangeAxis != null) {
            double y;
            if (orient == PlotOrientation.VERTICAL) {
                y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge());
            } else {
                y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge());
            }
            crosshairState.setAnchorY(y);
        }
    }
    crosshairState.setCrosshairX(getDomainCrosshairValue());
    crosshairState.setCrosshairY(getRangeCrosshairValue());
    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();
    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));
    AxisState domainAxisState = (AxisState) axisStateMap.get(getDomainAxis());
    if (domainAxisState == null) {
        if (parentState != null) {
            domainAxisState = (AxisState) parentState.getSharedAxisStates().get(getDomainAxis());
        }
    }
    AxisState rangeAxisState = (AxisState) axisStateMap.get(getRangeAxis());
    if (rangeAxisState == null) {
        if (parentState != null) {
            rangeAxisState = (AxisState) parentState.getSharedAxisStates().get(getRangeAxis());
        }
    }
    if (domainAxisState != null) {
        drawDomainTickBands(g2, dataArea, domainAxisState.getTicks());
    }
    if (rangeAxisState != null) {
        drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks());
    }
    if (domainAxisState != null) {
        drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
        drawZeroDomainBaseline(g2, dataArea);
    }
    if (rangeAxisState != null) {
        drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());
        drawZeroRangeBaseline(g2, dataArea);
    }
    Graphics2D savedG2 = g2;
    Rectangle2D savedDataArea = dataArea;
    BufferedImage dataImage = null;
    if (this.shadowGenerator != null) {
        dataImage = new BufferedImage((int) dataArea.getWidth(), (int) dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB);
        g2 = dataImage.createGraphics();
        g2.setRenderingHints(savedG2.getRenderingHints());
        dataArea = new Rectangle(0, 0, dataImage.getWidth(), dataImage.getHeight());
    }
    // draw the markers that are associated with a specific renderer...
    for (int i = 0; i < this.renderers.size(); i++) {
        drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND);
    }
    for (int i = 0; i < this.renderers.size(); i++) {
        drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND);
    }
    // now draw annotations and render data items...
    boolean foundData = false;
    DatasetRenderingOrder order = getDatasetRenderingOrder();
    if (order == DatasetRenderingOrder.FORWARD) {
        // draw background annotations
        int rendererCount = this.renderers.size();
        for (int i = 0; i < rendererCount; i++) {
            XYItemRenderer r = getRenderer(i);
            if (r != null) {
                ValueAxis domainAxis = getDomainAxisForDataset(i);
                ValueAxis rangeAxis = getRangeAxisForDataset(i);
                r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info);
            }
        }
        // render data items...
        for (int i = 0; i < getDatasetCount(); i++) {
            foundData = render(g2, dataArea, i, info, crosshairState) || foundData;
        }
        // draw foreground annotations
        for (int i = 0; i < rendererCount; i++) {
            XYItemRenderer r = getRenderer(i);
            if (r != null) {
                ValueAxis domainAxis = getDomainAxisForDataset(i);
                ValueAxis rangeAxis = getRangeAxisForDataset(i);
                r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info);
            }
        }
    } else if (order == DatasetRenderingOrder.REVERSE) {
        // draw background annotations
        int rendererCount = this.renderers.size();
        for (int i = rendererCount - 1; i >= 0; i--) {
            XYItemRenderer r = getRenderer(i);
            if (i >= getDatasetCount()) {
                // a link to the axes
                continue;
            }
            if (r != null) {
                ValueAxis domainAxis = getDomainAxisForDataset(i);
                ValueAxis rangeAxis = getRangeAxisForDataset(i);
                r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info);
            }
        }
        for (int i = getDatasetCount() - 1; i >= 0; i--) {
            foundData = render(g2, dataArea, i, info, crosshairState) || foundData;
        }
        // draw foreground annotations
        for (int i = rendererCount - 1; i >= 0; i--) {
            XYItemRenderer r = getRenderer(i);
            if (i >= getDatasetCount()) {
                // a link to the axes
                continue;
            }
            if (r != null) {
                ValueAxis domainAxis = getDomainAxisForDataset(i);
                ValueAxis rangeAxis = getRangeAxisForDataset(i);
                r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info);
            }
        }
    }
    // draw domain crosshair if required...
    int xAxisIndex = crosshairState.getDomainAxisIndex();
    ValueAxis xAxis = getDomainAxis(xAxisIndex);
    RectangleEdge xAxisEdge = getDomainAxisEdge(xAxisIndex);
    if (!this.domainCrosshairLockedOnData && anchor != null) {
        double xx;
        if (orient == PlotOrientation.VERTICAL) {
            xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge);
        } else {
            xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge);
        }
        crosshairState.setCrosshairX(xx);
    }
    setDomainCrosshairValue(crosshairState.getCrosshairX(), false);
    if (isDomainCrosshairVisible()) {
        double x = getDomainCrosshairValue();
        Paint paint = getDomainCrosshairPaint();
        Stroke stroke = getDomainCrosshairStroke();
        drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint);
    }
    // draw range crosshair if required...
    int yAxisIndex = crosshairState.getRangeAxisIndex();
    ValueAxis yAxis = getRangeAxis(yAxisIndex);
    RectangleEdge yAxisEdge = getRangeAxisEdge(yAxisIndex);
    if (!this.rangeCrosshairLockedOnData && anchor != null) {
        double yy;
        if (orient == PlotOrientation.VERTICAL) {
            yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge);
        } else {
            yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge);
        }
        crosshairState.setCrosshairY(yy);
    }
    setRangeCrosshairValue(crosshairState.getCrosshairY(), false);
    if (isRangeCrosshairVisible()) {
        double y = getRangeCrosshairValue();
        Paint paint = getRangeCrosshairPaint();
        Stroke stroke = getRangeCrosshairStroke();
        drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint);
    }
    if (!foundData) {
        drawNoDataMessage(g2, dataArea);
    }
    for (int i = 0; i < this.renderers.size(); i++) {
        drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND);
    }
    for (int i = 0; i < this.renderers.size(); i++) {
        drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND);
    }
    drawAnnotations(g2, dataArea, info);
    if (this.shadowGenerator != null) {
        BufferedImage shadowImage = this.shadowGenerator.createDropShadow(dataImage);
        g2 = savedG2;
        dataArea = savedDataArea;
        g2.drawImage(shadowImage, (int) savedDataArea.getX() + this.shadowGenerator.calculateOffsetX(), (int) savedDataArea.getY() + this.shadowGenerator.calculateOffsetY(), null);
        g2.drawImage(dataImage, (int) savedDataArea.getX(), (int) savedDataArea.getY(), null);
    }
    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) Shape(java.awt.Shape) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Rectangle2D(java.awt.geom.Rectangle2D) Rectangle(java.awt.Rectangle) Paint(java.awt.Paint) BufferedImage(java.awt.image.BufferedImage) Paint(java.awt.Paint) Graphics2D(java.awt.Graphics2D) AxisState(org.jfree.chart.axis.AxisState) ValueAxis(org.jfree.chart.axis.ValueAxis) RectangleInsets(org.jfree.chart.util.RectangleInsets) AxisSpace(org.jfree.chart.axis.AxisSpace) AbstractXYItemRenderer(org.jfree.chart.renderer.xy.AbstractXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) RectangleEdge(org.jfree.chart.util.RectangleEdge)

Example 14 with RectangleInsets

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

the class PiePlot method draw.

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing
 *              (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    if (info != null) {
        info.setPlotArea(area);
        info.setDataArea(area);
    }
    drawBackground(g2, area);
    drawOutline(g2, area);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));
    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        Graphics2D savedG2 = g2;
        Rectangle2D savedDataArea = area;
        BufferedImage dataImage = null;
        if (this.shadowGenerator != null) {
            dataImage = new BufferedImage((int) area.getWidth(), (int) area.getHeight(), BufferedImage.TYPE_INT_ARGB);
            g2 = dataImage.createGraphics();
            g2.setRenderingHints(savedG2.getRenderingHints());
            area = new Rectangle(0, 0, dataImage.getWidth(), dataImage.getHeight());
        }
        drawPie(g2, area, info);
        if (this.shadowGenerator != null) {
            BufferedImage shadowImage = this.shadowGenerator.createDropShadow(dataImage);
            g2 = savedG2;
            area = savedDataArea;
            g2.drawImage(shadowImage, (int) savedDataArea.getX() + this.shadowGenerator.calculateOffsetX(), (int) savedDataArea.getY() + this.shadowGenerator.calculateOffsetY(), null);
            g2.drawImage(dataImage, (int) savedDataArea.getX(), (int) savedDataArea.getY(), null);
        }
    } else {
        drawNoDataMessage(g2, area);
    }
    g2.setClip(savedClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, area);
}
Also used : Shape(java.awt.Shape) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Rectangle2D(java.awt.geom.Rectangle2D) Rectangle(java.awt.Rectangle) RectangleInsets(org.jfree.chart.util.RectangleInsets) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 15 with RectangleInsets

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

the class SpiderWebPlot method draw.

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing.
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    if (info != null) {
        info.setPlotArea(area);
        info.setDataArea(area);
    }
    drawBackground(g2, area);
    drawOutline(g2, area);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));
    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        int seriesCount = 0, catCount = 0;
        if (this.dataExtractOrder == TableOrder.BY_ROW) {
            seriesCount = this.dataset.getRowCount();
            catCount = this.dataset.getColumnCount();
        } else {
            seriesCount = this.dataset.getColumnCount();
            catCount = this.dataset.getRowCount();
        }
        // ensure we have a maximum value to use on the axes
        if (this.maxValue == DEFAULT_MAX_VALUE)
            calculateMaxValue(seriesCount, catCount);
        // Next, setup the plot area
        // adjust the plot area by the interior spacing value
        double gapHorizontal = area.getWidth() * getInteriorGap();
        double gapVertical = area.getHeight() * getInteriorGap();
        double X = area.getX() + gapHorizontal / 2;
        double Y = area.getY() + gapVertical / 2;
        double W = area.getWidth() - gapHorizontal;
        double H = area.getHeight() - gapVertical;
        double headW = area.getWidth() * this.headPercent;
        double headH = area.getHeight() * this.headPercent;
        // make the chart area a square
        double min = Math.min(W, H) / 2;
        X = (X + X + W) / 2 - min;
        Y = (Y + Y + H) / 2 - min;
        W = 2 * min;
        H = 2 * min;
        Point2D centre = new Point2D.Double(X + W / 2, Y + H / 2);
        Rectangle2D radarArea = new Rectangle2D.Double(X, Y, W, H);
        // draw the axis and category label
        for (int cat = 0; cat < catCount; cat++) {
            double angle = getStartAngle() + (getDirection().getFactor() * cat * 360 / catCount);
            Point2D endPoint = getWebPoint(radarArea, angle, 1);
            // 1 = end of axis
            Line2D line = new Line2D.Double(centre, endPoint);
            g2.setPaint(this.axisLinePaint);
            g2.setStroke(this.axisLineStroke);
            g2.draw(line);
            drawLabel(g2, radarArea, 0.0, cat, angle, 360.0 / catCount);
        }
        // Now actually plot each of the series polygons..
        for (int series = 0; series < seriesCount; series++) {
            drawRadarPoly(g2, radarArea, centre, info, series, catCount, headH, headW);
        }
    } else {
        drawNoDataMessage(g2, area);
    }
    g2.setClip(savedClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, area);
}
Also used : Shape(java.awt.Shape) AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) Point2D(java.awt.geom.Point2D) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.chart.util.RectangleInsets) Line2D(java.awt.geom.Line2D) Paint(java.awt.Paint)

Aggregations

RectangleInsets (org.jfree.chart.util.RectangleInsets)44 Rectangle2D (java.awt.geom.Rectangle2D)21 Shape (java.awt.Shape)13 Font (java.awt.Font)11 FontMetrics (java.awt.FontMetrics)10 AlphaComposite (java.awt.AlphaComposite)8 Composite (java.awt.Composite)8 Paint (java.awt.Paint)8 AxisState (org.jfree.chart.axis.AxisState)8 AxisSpace (org.jfree.chart.axis.AxisSpace)7 ValueAxis (org.jfree.chart.axis.ValueAxis)7 FontRenderContext (java.awt.font.FontRenderContext)6 LineMetrics (java.awt.font.LineMetrics)6 Iterator (java.util.Iterator)6 StandardPieToolTipGenerator (org.jfree.chart.labels.StandardPieToolTipGenerator)6 RectangleEdge (org.jfree.chart.util.RectangleEdge)6 BasicStroke (java.awt.BasicStroke)4 Rectangle (java.awt.Rectangle)4 Stroke (java.awt.Stroke)4 Point2D (java.awt.geom.Point2D)4