Example usage for java.awt.geom Rectangle2D getX

List of usage examples for java.awt.geom Rectangle2D getX

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getX.

Prototype

public abstract double getX();

Source Link

Document

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

Usage

From source file:LineGraphDrawable.java

/**
 * Draws the bar-graph into the given Graphics2D context in the given area.
 * This method will not draw a graph if the data given is null or empty.
 * /*from  w w  w .  j  a  va 2s .com*/
 * @param graphics
 *          the graphics context on which the bargraph should be rendered.
 * @param drawArea
 *          the area on which the bargraph should be drawn.
 */
public void draw(final Graphics2D graphics, final Rectangle2D drawArea) {
    if (graphics == null) {
        throw new NullPointerException();
    }
    if (drawArea == null) {
        throw new NullPointerException();
    }

    final int height = (int) drawArea.getHeight();
    if (height <= 0) {
        return;
    }

    final Graphics2D g2 = (Graphics2D) graphics.create();
    if (background != null) {
        g2.setPaint(background);
        g2.draw(drawArea);
    }

    if (data == null || data.length == 0) {
        g2.dispose();
        return;
    }

    g2.translate(drawArea.getX(), drawArea.getY());

    float d = getDivisor(data, height);
    final int spacing = getSpacing();
    final int w = (((int) drawArea.getWidth()) - (spacing * (data.length - 1))) / (data.length - 1);

    float min = Float.MAX_VALUE;
    for (int index = 0; index < data.length; index++) {
        Number i = data[index];
        if (i == null) {
            continue;
        }
        final float value = i.floatValue();
        if (value < min) {
            min = value;
        }
    }

    int x = 0;
    int y = -1;

    if (d == 0.0) {
        // special case -- a horizontal straight line
        d = 1.0f;
        y = -height / 2;
    }

    final Line2D.Double line = new Line2D.Double();
    for (int i = 0; i < data.length - 1; i++) {
        final int px1 = x;
        x += (w + spacing);
        final int px2 = x;

        g2.setPaint(color);

        final Number number = data[i];
        final Number nextNumber = data[i + 1];
        if (number == null && nextNumber == null) {
            final float delta = height - ((0 - min) / d);
            line.setLine(px1, y + delta, px2, y + delta);
        } else if (number == null) {
            line.setLine(px1, y + (height - ((0 - min) / d)), px2,
                    y + (height - ((nextNumber.floatValue() - min) / d)));
        } else if (nextNumber == null) {
            line.setLine(px1, y + (height - ((number.floatValue() - min) / d)), px2,
                    y + (height - ((0 - min) / d)));
        } else {
            line.setLine(px1, y + (height - ((number.floatValue() - min) / d)), px2,
                    y + (height - ((nextNumber.floatValue() - min) / d)));
        }
        g2.draw(line);

    }

    g2.dispose();

}

From source file:piramide.interaction.reasoner.FuzzyReasonerWizardFacade.java

private BufferedImage createErrorMessagesImage(String text) {
    final Font font = TextTitle.DEFAULT_FONT;
    final Font bigBold = new Font(font.getName(), Font.BOLD, 24);
    final FontRenderContext frc = new FontRenderContext(null, true, false);
    final TextLayout layout = new TextLayout(text, bigBold, frc);
    final Rectangle2D bounds = layout.getBounds();
    final int w = (int) Math.ceil(bounds.getWidth());
    final int h = (int) Math.ceil(bounds.getHeight());
    final BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    final Graphics2D g = image.createGraphics();
    g.setColor(Color.WHITE);//  w ww  .  j a  va 2 s .c o m
    g.fillRect(0, 0, w, h);
    g.setColor(Color.RED);
    g.setFont(bigBold);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
    g.drawString(text, (float) -bounds.getX(), (float) -bounds.getY());
    g.dispose();
    return image;
}

From source file:org.kalypsodeegree_impl.model.geometry.GM_Envelope_Impl.java

/**
 * returns a new GM_Envelope object representing the intersection of this GM_Envelope with the specified GM_Envelope.
 * * Note: If there is no intersection at all GM_Envelope will be null.
 * //from   www  .j  a  v a  2  s  .com
 * @param bb
 *          the GM_Envelope to be intersected with this GM_Envelope
 * @return the largest GM_Envelope contained in both the specified GM_Envelope and in this GM_Envelope.
 */
@Override
public GM_Envelope createIntersection(final GM_Envelope bb) {
    Rectangle2D rect = new Rectangle2D.Double(bb.getMin().getX(), bb.getMin().getY(), bb.getWidth(),
            bb.getHeight());
    final Rectangle2D rect2 = new Rectangle2D.Double(getMin().getX(), getMin().getY(), getWidth(), getHeight());

    if (rect2.intersects(bb.getMin().getX(), bb.getMin().getY(), bb.getWidth(), bb.getHeight())) {
        rect = rect.createIntersection(rect2);
    } else {
        rect = null;
    }

    if (rect == null) {
        return null;
    }

    final double xmin = rect.getX();
    final double ymin = rect.getY();
    final double xmax = rect.getX() + rect.getWidth();
    final double ymax = rect.getY() + rect.getHeight();

    // TODO Check coordinate systems, if equal.
    return new GM_Envelope_Impl(xmin, ymin, xmax, ymax, m_coordinateSystem);
}

From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java

private Shape convertObstacle(final Obstacle2D o) {
    final Rectangle2D r = o.getBounds2D();
    final Position[] points = new Position[] { new Continuous2DEuclidean(r.getX(), r.getY()),
            new Continuous2DEuclidean(r.getX() + r.getWidth(), r.getY()),
            new Continuous2DEuclidean(r.getX() + r.getWidth(), r.getY() + r.getHeight()),
            new Continuous2DEuclidean(r.getX(), r.getY() + r.getHeight()) };
    final Path2D path = new GeneralPath();
    for (int i = 0; i < points.length; i++) {
        final Point pt = wormhole.getViewPoint(points[i]);
        if (i == 0) {
            path.moveTo(pt.getX(), pt.getY());
        }//from w w w.j  a v a 2 s. co m
        path.lineTo(pt.getX(), pt.getY());
    }
    path.closePath();
    return path;
}

From source file:net.sourceforge.processdash.ui.lib.chart.DiscLegendAxis.java

/**
 * The superclass' drawAxisLine() method draws the axis line for the entire
 *  dataArea's length. Since we want the line to end at the height of the maximum
 *  shown tick, we create a new Rectangle2D with the appropriate dimensions.
 *///from  www .j av a 2  s  . c  o  m
@Override
protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) {

    // In the original flow of events, the refreshing of the ticks is made after
    //  drawing the axis line. Since this implementation needs the ticks to be
    //  set properly, we force a tick refresh.
    AxisState state = new AxisState(cursor);
    refreshTicks(g2, state, dataArea, edge);

    double amountBetweenTicks = getTickUnit().getSize();
    int tickCount = calculateVisibleTickCount() - 1;
    double lowestTickValue = calculateLowestVisibleTickValue();

    double minY = valueToJava2D(lowestTickValue + tickCount * amountBetweenTicks, dataArea, edge);
    double maxY = valueToJava2D(lowestTickValue, dataArea, edge);
    double height = maxY - minY;

    Rectangle2D axisLineArea = new Rectangle2D.Double(dataArea.getX(), minY, dataArea.getWidth(), height);

    super.drawAxisLine(g2, cursor, axisLineArea, edge);
}

From source file:org.tsho.dmc2.core.chart.AbstractDmcPlot.java

/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the screen or
 * a printer)./*from  w ww.  j  a v  a  2  s  .  c  o  m*/
 *
 * @param g2  the graphics device.
 * @param plotArea   the area within which the plot (including axis labels) should be drawn.
 * @param info  collects chart drawing information (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info) {
    //        if (data == null)
    //            return;

    // set up info collection...
    if (info != null) {
        info.setPlotArea(plotArea);
    }

    // adjust the drawing area for plot insets (if any)...
    Insets insets = getInsets();
    if (insets != null) {
        plotArea.setRect(plotArea.getX() + insets.left, plotArea.getY() + insets.top,
                plotArea.getWidth() - insets.left - insets.right,
                plotArea.getHeight() - insets.top - insets.bottom);
    }

    AxisSpace space = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, plotArea, RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, plotArea, RectangleEdge.LEFT, space);
    Rectangle2D dataArea = space.shrink(plotArea, null);

    if (info != null) {
        info.setDataArea(dataArea);
    }

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    /* if automatic bounds... */
    if (!isNoData()) {
        if (this instanceof DmcRenderablePlot) {
            DmcPlotRenderer renderer;
            renderer = ((DmcRenderablePlot) this).getPlotRenderer();
            if (renderer != null) {
                renderer.initialize();
                if (renderer.getState() == DmcPlotRenderer.STATE_STOPPED) {
                    return;
                }
            }
        }
    }

    AxisState domainAxisState = null, rangeAxisState = null;
    if (this.domainAxis != null) {
        double cursor;
        cursor = dataArea.getMaxY();
        domainAxisState = this.domainAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, info);
        // cursor = info.getCursor();
    }
    if (this.rangeAxis != null) {
        double cursor;
        cursor = dataArea.getMinX();
        rangeAxisState = this.rangeAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, info);
    }

    if (drawGridlines == true && domainAxisState != null && rangeAxisState != null) {
        drawGridlines(g2, dataArea, domainAxisState.getTicks(), rangeAxisState.getTicks());
    }

    Shape originalClip = g2.getClip();
    g2.clip(dataArea);

    //        Composite originalComposite = g2.getComposite();
    //        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
    //                                                   getForegroundAlpha()));
    //        g2.setStroke(new BasicStroke(12.0F));

    if (isNoData()) {
        drawNoDataMessage(g2, plotArea);
    } else {
        drawPlot(g2, dataArea, info);
    }

    g2.setClip(originalClip);
    drawOutline(g2, dataArea);
}

From source file:org.apache.pdfbox.contentstream.PDFStreamEngine.java

/**
 * Process the given tiling pattern. Allows the pattern matrix to be overridden for custom
 * rendering./*from   w  ww.j  ava  2 s  .com*/
 *
 * @param tilingPattern the tiling pattern
 * @param color color to use, if this is an uncoloured pattern, otherwise null.
 * @param colorSpace color space to use, if this is an uncoloured pattern, otherwise null.
 * @param patternMatrix the pattern matrix, may be overridden for custom rendering.
 */
protected final void processTilingPattern(PDTilingPattern tilingPattern, PDColor color, PDColorSpace colorSpace,
        Matrix patternMatrix) throws IOException {
    PDResources parent = pushResources(tilingPattern);

    Matrix parentMatrix = initialMatrix;
    initialMatrix = Matrix.concatenate(initialMatrix, patternMatrix);

    // save the original graphics state
    Stack<PDGraphicsState> savedStack = saveGraphicsStack();

    // save a clean state (new clipping path, line path, etc.)
    Rectangle2D bbox = tilingPattern.getBBox().transform(patternMatrix).getBounds2D();
    PDRectangle rect = new PDRectangle((float) bbox.getX(), (float) bbox.getY(), (float) bbox.getWidth(),
            (float) bbox.getHeight());
    graphicsStack.push(new PDGraphicsState(rect));

    // non-colored patterns have to be given a color
    if (colorSpace != null) {
        color = new PDColor(color.getComponents(), colorSpace);
        getGraphicsState().setNonStrokingColorSpace(colorSpace);
        getGraphicsState().setNonStrokingColor(color);
        getGraphicsState().setStrokingColorSpace(colorSpace);
        getGraphicsState().setStrokingColor(color);
    }

    // transform the CTM using the stream's matrix
    getGraphicsState().getCurrentTransformationMatrix().concatenate(patternMatrix);

    // clip to bounding box
    clipToRect(tilingPattern.getBBox());

    processStreamOperators(tilingPattern);

    initialMatrix = parentMatrix;
    restoreGraphicsStack(savedStack);
    popResources(parent);
}

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();/*  w w w.  j  a  v a2s  .com*/
        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:org.tsho.dmc2.core.chart.LyapunovRenderer.java

public boolean renderArea(Graphics2D g2, Rectangle2D dataArea) {

    g2.setPaint(plot.paint);//from   w  w w  .ja  v a 2s  .  co  m

    if (pass == 1) {
        if (image != null) {
            double x = dataArea.getX();
            double y = dataArea.getY();
            //there is a problem when using Graphics2D with affine transform 
            //and BufferedImage; using subclass of Image returned below.
            //rescaling needed because adding legend causes dataArea to change.
            Image scaledImage = image.getScaledInstance((int) dataArea.getWidth() - 1,
                    (int) dataArea.getHeight() - 1, Image.SCALE_DEFAULT);
            g2.drawImage(scaledImage, (int) x + 1, (int) y + 1, (int) dataArea.getWidth() - 1,
                    (int) dataArea.getHeight() - 1, this);
            //g2.translate(-1,-1);
            //g2.drawRect((int) x, (int) y, (int) dataArea.getWidth(),(int) dataArea.getHeight());
            //g2.translate(1,1);
        }
        return true;
    }

    final double parHStep, parVStep;
    double parHLower = plot.getDomainAxis().getRange().getLowerBound();
    double parHUpper = plot.getDomainAxis().getRange().getUpperBound();
    double parVLower = plot.getRangeAxis().getRange().getLowerBound();
    double parVUpper = plot.getRangeAxis().getRange().getUpperBound();

    parHStep = Math.abs(parHUpper - parHLower) / dataArea.getWidth();
    parVStep = Math.abs(parVUpper - parVLower) / dataArea.getHeight();

    image = new BufferedImage((int) dataArea.getWidth(), (int) dataArea.getHeight(),
            BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = image.getRaster();
    DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();
    int[] data = dataBuffer.getData();

    final double parHStart = parHLower + parHStep / 2;
    final double parVStart = parVUpper - parVStep / 2;

    if (model instanceof ODE) {
        double step = stepSize; // stepSize and timeStep probably mean the same thing, one for discrete another for ODE
        double[] result = new double[model.getNVar()];

        for (int i = 0; i < (int) dataArea.getWidth(); i++) {
            for (int j = 0; j < (int) dataArea.getHeight(); j++) {

                parameters.put(firstParLabel, parHStart + i * parHStep);
                parameters.put(secondParLabel, parVStart - j * parVStep);

                int color;
                result = Lua.evaluateLyapunovExponentsODE(model, parameters, initialPoint, timePeriod,
                        stepSize);

                if (result == null) {
                    System.out.println("i: " + i + " j: " + j);
                    System.out.println("par1: " + parHStart + i * parHStep);
                    System.out.println("par2: " + parVStart + j * parVStep);
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                    return false;
                }

                int zer = 0;
                int pos = 0;
                int neg = 0;
                int nan = 0;
                for (int ii = 0; ii < result.length; ii++) {
                    if (Math.abs(result[ii]) == (1.0 / 0.0))
                        nan++;
                    else if (Math.abs(result[ii]) <= epsilon)
                        zer++;
                    else if (result[ii] > epsilon)
                        pos++;
                    else if (result[ii] < (-epsilon))
                        neg++;
                    else
                        nan++;
                }

                color = (lyapunovColors.getColor(zer, pos, neg, nan)).getRGB();
                ExpsSigns es = new ExpsSigns(zer, pos, neg, nan);
                if (!signsSet.contains(es))
                    signsSet.add(es);

                data[i + j * (int) dataArea.getWidth()] = color;

                if (stopped == true)
                    return false;

                if (j == (int) dataArea.getHeight() - 1) {
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                }
            } //end for
        } //end for
    } //end if ODE
    else {
        for (int i = 0; i < (int) dataArea.getWidth(); i++) {
            for (int j = 0; j < (int) dataArea.getHeight(); j++) {

                parameters.put(firstParLabel, parHStart + i * parHStep);
                parameters.put(secondParLabel, parVStart - j * parVStep);

                double[] result;
                int color;

                result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, iterations);

                if (result == null) {
                    System.out.println("i: " + i + " j: " + j);
                    System.out.println("par1: " + parHStart + i * parHStep);
                    System.out.println("par2: " + parVStart + j * parVStep);
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                    return false;
                }

                int zer = 0;
                int pos = 0;
                int neg = 0;
                int nan = 0;
                for (int ii = 0; ii < result.length; ii++) {
                    if (Math.abs(result[ii]) == (1.0 / 0.0))
                        nan++;
                    else if (Math.abs(result[ii]) <= epsilon)
                        zer++;
                    else if (result[ii] > epsilon)
                        pos++;
                    else if (result[ii] < (-epsilon))
                        neg++;
                    else
                        nan++;
                }

                color = (lyapunovColors.getColor(zer, pos, neg, nan)).getRGB();
                ExpsSigns es = new ExpsSigns(zer, pos, neg, nan);
                if (!signsSet.contains(es))
                    signsSet.add(es);

                data[i + j * (int) dataArea.getWidth()] = color;

                if (stopped == true)
                    return false;

                if (j == (int) dataArea.getHeight() - 1)
                    g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
            } //end for
        } //end for
    } //end else
    return true;
}

From source file:net.sourceforge.processdash.ui.web.reports.RadarPlot.java

protected void drawRadar(Graphics2D g2, Rectangle2D plotArea, PlotRenderingInfo info, int pieIndex,
        PieDataset data) {//from   w ww  .  java2  s  .c o  m

    // adjust the plot area by the interior spacing value
    double gapHorizontal = plotArea.getWidth() * this.interiorGap;
    double gapVertical = plotArea.getHeight() * this.interiorGap;
    double radarX = plotArea.getX() + gapHorizontal / 2;
    double radarY = plotArea.getY() + gapVertical / 2;
    double radarW = plotArea.getWidth() - gapHorizontal;
    double radarH = plotArea.getHeight() - gapVertical;

    // make the radar area a square if the radar chart is to be circular...
    // NOTE that non-circular radar charts are not currently supported.
    if (true) { //circular) {
        double min = Math.min(radarW, radarH) / 2;
        radarX = (radarX + radarX + radarW) / 2 - min;
        radarY = (radarY + radarY + radarH) / 2 - min;
        radarW = 2 * min;
        radarH = 2 * min;
    }

    double radius = radarW / 2;
    double centerX = radarX + radarW / 2;
    double centerY = radarY + radarH / 2;

    Rectangle2D radarArea = new Rectangle2D.Double(radarX, radarY, radarW, radarH);

    // plot the data (unless the dataset is null)...
    if ((data != null) && (data.getKeys().size() > 0)) {

        // get a list of categories...
        List keys = data.getKeys();
        int numAxes = keys.size();

        // draw each of the axes on the radar chart, and register
        // the shape of the radar line.

        double multiplier = 1.0;
        GeneralPath lineShape = new GeneralPath(GeneralPath.WIND_NON_ZERO, numAxes + 1);
        GeneralPath gridShape = new GeneralPath(GeneralPath.WIND_NON_ZERO, numAxes + 1);

        int axisNumber = -1;
        Iterator iterator = keys.iterator();
        while (iterator.hasNext()) {
            Comparable currentKey = (Comparable) iterator.next();
            axisNumber++;
            Number dataValue = data.getValue(currentKey);

            double value = (dataValue != null ? dataValue.doubleValue() : 0);
            if (value > 1 || Double.isNaN(value) || Double.isInfinite(value))
                value = 1.0;
            if (value < 0)
                value = 0.0;
            multiplier *= value;

            double angle = 2 * Math.PI * axisNumber / numAxes;
            double deltaX = Math.sin(angle) * radius;
            double deltaY = -Math.cos(angle) * radius;

            // draw the spoke
            g2.setPaint(axisPaint);
            g2.setStroke(axisStroke);
            Line2D line = new Line2D.Double(centerX, centerY, centerX + deltaX, centerY + deltaY);
            g2.draw(line);

            // register the grid line and the shape line
            if (axisNumber == 0) {
                gridShape.moveTo((float) deltaX, (float) deltaY);
                lineShape.moveTo((float) (deltaX * value), (float) (deltaY * value));
            } else {
                gridShape.lineTo((float) deltaX, (float) deltaY);
                lineShape.lineTo((float) (deltaX * value), (float) (deltaY * value));
            }

            if (showAxisLabels) {
                // draw the label
                double labelX = centerX + deltaX * (1 + axisLabelGap);
                double labelY = centerY + deltaY * (1 + axisLabelGap);
                String label = currentKey.toString();
                drawLabel(g2, radarArea, label, axisNumber, labelX, labelY);
            }

        }
        gridShape.closePath();
        lineShape.closePath();

        // draw five gray concentric gridlines
        g2.translate(centerX, centerY);
        g2.setPaint(gridLinePaint);
        g2.setStroke(gridLineStroke);
        for (int i = 5; i > 0; i--) {
            Shape scaledGrid = gridShape
                    .createTransformedShape(AffineTransform.getScaleInstance(i / 5.0, i / 5.0));
            g2.draw(scaledGrid);
        }

        // get the color for the plot shape.
        Paint dataPaint = plotLinePaint;
        if (dataPaint == ADAPTIVE_COLORING) {
            //multiplier = Math.exp(Math.log(multiplier) * 2 / numAxes);
            dataPaint = getMultiplierColor((float) multiplier);
        }

        // compute a slightly transparent version of the plot color for
        // the fill.
        Paint dataFill = null;
        if (dataPaint instanceof Color && getForegroundAlpha() != 1.0)
            dataFill = new Color(((Color) dataPaint).getRed() / 255f, ((Color) dataPaint).getGreen() / 255f,
                    ((Color) dataPaint).getBlue() / 255f, getForegroundAlpha());
        else
            dataFill = dataPaint;

        // draw the plot shape.  First fill with a parially
        // transparent color, then stroke with the opaque color.
        g2.setPaint(dataFill);
        g2.fill(lineShape);
        g2.setPaint(dataPaint);
        g2.setStroke(plotLineStroke);
        g2.draw(lineShape);

        // cleanup the graphics context.
        g2.translate(-centerX, -centerY);
    }
}