Example usage for java.awt Graphics2D getClip

List of usage examples for java.awt Graphics2D getClip

Introduction

In this page you can find the example usage for java.awt Graphics2D getClip.

Prototype

public abstract Shape getClip();

Source Link

Document

Gets the current clipping area.

Usage

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

@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
        PlotRenderingInfo info) {//from w w w  .ja  va 2s.  co  m

    // 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 (!getDiscDistributor().isDatasetEmpty()) {
        Rectangle2D dataArea = getDataArea(area);
        drawDiscs(g2, dataArea, info);
        drawLegendAxis(g2, dataArea, info);
    } else {
        drawNoDataMessage(g2, area);
    }

    g2.setClip(savedClip);
    g2.setComposite(originalComposite);

    drawOutline(g2, area);
}

From source file:org.jfree.experimental.chart.plot.dial.DialPlot.java

/**
 * Draws the plot.  This method is usually called by the {@link JFreeChart}
 * instance that manages the plot./* w w w. ja  v  a  2s. c  o m*/
 * 
 * @param g2  the graphics target.
 * @param area  the area in which the plot should be drawn.
 * @param anchor  the anchor point (typically the last point that the 
 *     mouse clicked on, <code>null</code> is permitted).
 * @param parentState  the state for the parent plot (if any).
 * @param info  used to collect plot rendering info (<code>null</code> 
 *     permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
        PlotRenderingInfo info) {

    // first, expand the viewing area into a drawing frame
    Rectangle2D frame = viewToFrame(area);

    // draw the background if there is one...
    if (this.background != null && this.background.isVisible()) {
        if (this.background.isClippedToWindow()) {
            Shape savedClip = g2.getClip();
            g2.setClip(this.dialFrame.getWindow(frame));
            this.background.draw(g2, this, frame, area);
            g2.setClip(savedClip);
        } else {
            this.background.draw(g2, this, frame, area);
        }
    }

    Iterator iterator = this.layers.iterator();
    while (iterator.hasNext()) {
        DialLayer current = (DialLayer) iterator.next();
        if (current.isVisible()) {
            if (current.isClippedToWindow()) {
                Shape savedClip = g2.getClip();
                g2.setClip(this.dialFrame.getWindow(frame));
                current.draw(g2, this, frame, area);
                g2.setClip(savedClip);
            } else {
                current.draw(g2, this, frame, area);
            }
        }
    }

    // draw the cap if there is one...
    if (this.cap != null && this.cap.isVisible()) {
        if (this.cap.isClippedToWindow()) {
            Shape savedClip = g2.getClip();
            g2.setClip(this.dialFrame.getWindow(frame));
            this.cap.draw(g2, this, frame, area);
            g2.setClip(savedClip);
        } else {
            this.cap.draw(g2, this, frame, area);
        }
    }

    if (this.dialFrame.isVisible()) {
        this.dialFrame.draw(g2, this, frame, area);
    }

}

From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java

private void saveAsPdfBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsPdfBtnActionPerformed
    Document document = new Document(PageSize.A4.rotate());
    String[] headers = new String[] { "Name", "TimeStamp", "Resp Rate", "Heart Rate", "Blood Pressure",
            "Temperature", "Status" };
    String filename = fileNameTxt.getText();
    try {//from   w ww  . j  a  va  2s . co  m
        if (!filename.equals("")) {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename + ".pdf"));

            document.open();
            PdfContentByte cb = writer.getDirectContent();

            cb.saveState();
            PdfPTable table = new PdfPTable(headers.length);
            for (int i = 0; i < headers.length; i++) {
                String header = headers[i];
                PdfPCell cell = new PdfPCell();
                cell.setGrayFill(0.9f);
                cell.setPhrase(new Phrase(header.toUpperCase(), new Font(Font.HELVETICA, 8, Font.BOLD)));
                table.addCell(cell);

            }
            table.completeRow();

            table.spacingBefore();
            table.spacingAfter();
            document.add(table);
            Graphics2D g2 = cb.createGraphicsShapes(500, 500);
            //cb.showTextAligned(PdfContentByte.ALIGN_CENTER, g2, 200, 300, 0);

            Shape oldClip = g2.getClip();
            g2.clipRect(0, 0, 700, 500);

            vitalSignjTable.print(g2);
            g2.setClip(oldClip);

            g2.dispose();
            cb.restoreState();
            JOptionPane.showMessageDialog(null, "file saved", "Saved", JOptionPane.INFORMATION_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(null, "enter the filename", "FileName", JOptionPane.ERROR_MESSAGE);
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

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

/**
 * Draws the plot on a Java 2D graphics device (such as the screen
 * or a printer).// w ww  .  j  a  v  a2  s  . c o  m
 * @param g2 The graphics device.
 * @param plotArea The area within which the plot should be drawn.
 */
@Override
public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor, PlotState state, PlotRenderingInfo info) {
    // adjust for insets...
    RectangleInsets insets = getInsets();
    if (insets != null) {
        plotArea.setRect(plotArea.getX() + insets.getLeft(), plotArea.getY() + insets.getTop(),
                plotArea.getWidth() - insets.getLeft() - insets.getRight(),
                plotArea.getHeight() - insets.getTop() - insets.getBottom());
    }

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

    drawBackground(g2, plotArea);
    drawOutline(g2, plotArea);

    Shape savedClip = g2.getClip();
    g2.clip(plotArea);

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));

    if (this.dataset != null) {
        drawRadar(g2, plotArea, info, 0, this.dataset);
    } else {
        drawNoDataMessage(g2, plotArea);
    }

    g2.clip(savedClip);
    g2.setComposite(originalComposite);

    drawOutline(g2, plotArea);

}

From source file:peakml.util.jfreechart.FastSpectrumPlot.java

@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
        PlotRenderingInfo info) {/*  ww w. j  av a 2s.c  o  m*/
    // add the plot area to the info (used amongst other by the axis for zooming)
    if (info != null)
        info.setPlotArea(area);

    // add the insets (if any)
    RectangleInsets insets = getInsets();
    insets.trim(area);

    // draw the axis and add the dataArea to the info (used amongst other by the axis for zooming)
    AxisSpace space = new AxisSpace();
    space = xaxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space);
    space = yaxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space);

    Rectangle2D dataArea = space.shrink(area, null);
    if (info != null)
        info.setDataArea(dataArea);

    // flood fill the whole area with the background color
    drawBackground(g2, dataArea);

    // draw the axis
    xaxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    yaxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info);

    // sanity check
    if (dataseries.size() == 0)
        return;

    // clip the draw area
    Shape originalclip = g2.getClip();
    g2.clip(dataArea);

    // draw all the values
    for (Data data : dataseries) {
        int xpos = (int) xaxis.valueToJava2D(data.mass, dataArea, RectangleEdge.BOTTOM);
        int ypos = (int) yaxis.valueToJava2D(data.intensity, dataArea, RectangleEdge.LEFT);
        g2.drawLine(xpos, (int) yaxis.valueToJava2D(0, dataArea, RectangleEdge.LEFT), xpos, ypos);

        // draw the label
        if (data.description != null && data.description.length() != 0) {
            g2.setColor(Color.RED);
            g2.drawLine(xpos + 2, ypos - 2, xpos + 15, ypos - 15);
            g2.setColor(Color.BLACK);
            g2.drawString(data.description, xpos + 17, ypos - 17);
        }
    }

    // reset
    g2.setClip(originalclip);
}

From source file:peakml.util.jfreechart.FastTimePlot.java

@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
        PlotRenderingInfo info) {/*w ww .  jav  a 2  s  .c  o m*/
    // add the plot area to the info (used amongst other by the axis for zooming)
    if (info != null)
        info.setPlotArea(area);

    // add the insets (if any)
    RectangleInsets insets = getInsets();
    insets.trim(area);

    // draw the axis and add the dataArea to the info (used amongst other by the axis for zooming)
    AxisSpace space = new AxisSpace();
    space = xaxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space);
    space = yaxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space);

    Rectangle2D dataArea = space.shrink(area, null);
    if (info != null)
        info.setDataArea(dataArea);

    // flood fill the whole area with the background color
    drawBackground(g2, dataArea);

    // draw the axis
    xaxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    yaxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info);

    // sanity check
    if (dataseries.size() == 0)
        return;

    // clip the draw area
    Shape originalclip = g2.getClip();
    g2.clip(dataArea);

    // draw all the values
    int index = 0;
    for (Data data : dataseries.values()) {
        g2.setColor(new Color(data.color == -1 ? colormap.getColor(index++) : data.color));
        for (int i = 0; i < data.size - 1; ++i) {
            g2.drawLine((int) xaxis.valueToJava2D(data.time[i], dataArea, RectangleEdge.BOTTOM),
                    (int) yaxis.valueToJava2D(data.values[i], dataArea, RectangleEdge.LEFT),
                    (int) xaxis.valueToJava2D(data.time[i + 1], dataArea, RectangleEdge.BOTTOM),
                    (int) yaxis.valueToJava2D(data.values[i + 1], dataArea, RectangleEdge.LEFT));
        }
    }

    // reset
    g2.setClip(originalclip);
}

From source file:peakml.util.jfreechart.FastErrorBarPlot.java

@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
        PlotRenderingInfo info) {/*from  w  w w  . ja  v  a2  s.c  o m*/
    // add the plot area to the info (used amongst other by the axis for zooming)
    if (info != null)
        info.setPlotArea(area);

    // add the insets (if any)
    RectangleInsets insets = getInsets();
    insets.trim(area);

    // draw the axis and add the dataArea to the info (used amongst other by the axis for zooming)
    AxisSpace space = new AxisSpace();
    space = xaxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space);
    space = yaxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space);

    Rectangle2D dataArea = space.shrink(area, null);
    if (info != null)
        info.setDataArea(dataArea);

    // flood fill the whole area with the background color
    drawBackground(g2, dataArea);

    // draw the axis
    xaxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    yaxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info);

    // sanity check
    if (dataseries.size() == 0)
        return;

    // clip the draw area
    Shape originalclip = g2.getClip();
    g2.clip(dataArea);

    // create the strokes
    BasicStroke stroke_solid = new BasicStroke(1.f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.f);
    BasicStroke stroke_dashed = new BasicStroke(1.f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.f,
            new float[] { 2, 4 }, 0);

    g2.setStroke(stroke_solid);

    // count the number of labels
    int categoryCount = 0;
    if (showall) {
        for (Data data : dataseries)
            categoryCount += data.yvalues.length;
    } else
        categoryCount = dataseries.size();

    // draw all the values
    int pos = 0;
    boolean dashed = false;
    double prevx = -1, prevy = -1;
    for (Data data : dataseries) {
        if (data.yvalues.length == 0) {
            dashed = true;
            pos++;
            continue;
        }

        double mean[] = showall ? data.yvalues : new double[] { data.getMeanY() };
        double min[] = showall ? data.yvalues : new double[] { data.getMinY() };
        double max[] = showall ? data.yvalues : new double[] { data.getMaxY() };
        for (int i = 0; i < mean.length; ++i) {
            double ypos, xpos = xaxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, pos++, categoryCount,
                    dataArea, RectangleEdge.BOTTOM);

            // draw the mean value
            g2.setColor(Color.RED);
            ypos = yaxis.valueToJava2D(mean[i], dataArea, RectangleEdge.LEFT);
            g2.drawLine((int) xpos - 2, (int) ypos, (int) xpos + 2, (int) ypos);

            // conect the dots
            if (prevx != -1 && prevy != -1) {
                g2.setColor(Color.BLACK);
                if (dashed)
                    g2.setStroke(stroke_dashed);
                g2.drawLine((int) prevx, (int) prevy, (int) xpos, (int) ypos);
                if (dashed) {
                    dashed = false;
                    g2.setStroke(stroke_solid);
                }

            }
            prevy = ypos;
            prevx = xpos;

            // draw the outer values
            g2.setColor(Color.LIGHT_GRAY);
            double ypos_min = yaxis.valueToJava2D(min[i], dataArea, RectangleEdge.LEFT);
            g2.drawLine((int) xpos - 2, (int) ypos_min, (int) xpos + 2, (int) ypos_min);
            double ypos_max = yaxis.valueToJava2D(max[i], dataArea, RectangleEdge.LEFT);
            g2.drawLine((int) xpos - 2, (int) ypos_max, (int) xpos + 2, (int) ypos_max);
            g2.drawLine((int) xpos, (int) ypos_min, (int) xpos, (int) ypos_max);
        }
    }

    // reset
    g2.setClip(originalclip);
}

From source file:com.siteview.ecc.report.xls.JRXlsExporter.java

protected void exportImage(JRPrintImage element, JRExporterGridCell gridCell, int colIndex, int rowIndex,
        int emptyCols) throws JRException {
    try {//from www. j  av a 2  s.c o  m
        int topPadding = Math.max(element.getLineBox().getTopPadding().intValue(),
                getImageBorderCorrection(element.getLineBox().getTopPen()));
        int leftPadding = Math.max(element.getLineBox().getLeftPadding().intValue(),
                getImageBorderCorrection(element.getLineBox().getLeftPen()));
        int bottomPadding = Math.max(element.getLineBox().getBottomPadding().intValue(),
                getImageBorderCorrection(element.getLineBox().getBottomPen()));
        int rightPadding = Math.max(element.getLineBox().getRightPadding().intValue(),
                getImageBorderCorrection(element.getLineBox().getRightPen()));

        //pngEncoder.setImage( null );

        int availableImageWidth = element.getWidth() - leftPadding - rightPadding;
        availableImageWidth = availableImageWidth < 0 ? 0 : availableImageWidth;

        int availableImageHeight = element.getHeight() - topPadding - bottomPadding;
        availableImageHeight = availableImageHeight < 0 ? 0 : availableImageHeight;

        JRRenderable renderer = element.getRenderer();

        if (renderer != null && availableImageWidth > 0 && availableImageHeight > 0) {
            if (renderer.getType() == JRRenderable.TYPE_IMAGE) {
                // Image renderers are all asked for their image data and dimension at some point.
                // Better to test and replace the renderer now, in case of lazy load error.
                renderer = JRImageRenderer.getOnErrorRendererForImageData(renderer, element.getOnErrorType());
                if (renderer != null) {
                    renderer = JRImageRenderer.getOnErrorRendererForDimension(renderer,
                            element.getOnErrorType());
                }
            }
        } else {
            renderer = null;
        }

        if (renderer != null) {
            int normalWidth = availableImageWidth;
            int normalHeight = availableImageHeight;

            Dimension2D dimension = renderer.getDimension();
            if (dimension != null) {
                normalWidth = (int) dimension.getWidth();
                normalHeight = (int) dimension.getHeight();
            }

            float xalignFactor = 0f;
            switch (element.getHorizontalAlignment()) {
            case JRAlignment.HORIZONTAL_ALIGN_RIGHT: {
                xalignFactor = 1f;
                break;
            }
            case JRAlignment.HORIZONTAL_ALIGN_CENTER: {
                xalignFactor = 0.5f;
                break;
            }
            case JRAlignment.HORIZONTAL_ALIGN_LEFT:
            default: {
                xalignFactor = 0f;
                break;
            }
            }

            float yalignFactor = 0f;
            switch (element.getVerticalAlignment()) {
            case JRAlignment.VERTICAL_ALIGN_BOTTOM: {
                yalignFactor = 1f;
                break;
            }
            case JRAlignment.VERTICAL_ALIGN_MIDDLE: {
                yalignFactor = 0.5f;
                break;
            }
            case JRAlignment.VERTICAL_ALIGN_TOP:
            default: {
                yalignFactor = 0f;
                break;
            }
            }

            BufferedImage bi = new BufferedImage(element.getWidth(), element.getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D grx = bi.createGraphics();

            switch (element.getScaleImage()) {
            case JRImage.SCALE_IMAGE_CLIP: {
                int xoffset = (int) (xalignFactor * (availableImageWidth - normalWidth));
                int yoffset = (int) (yalignFactor * (availableImageHeight - normalHeight));

                Shape oldClipShape = grx.getClip();

                grx.clip(new Rectangle(leftPadding, topPadding, availableImageWidth, availableImageHeight));

                try {
                    renderer.render(grx, new Rectangle(xoffset + leftPadding, yoffset + topPadding, normalWidth,
                            normalHeight));
                } finally {
                    grx.setClip(oldClipShape);
                }

                break;
            }
            case JRImage.SCALE_IMAGE_FILL_FRAME: {
                renderer.render(grx,
                        new Rectangle(leftPadding, topPadding, availableImageWidth, availableImageHeight));

                break;
            }
            case JRImage.SCALE_IMAGE_RETAIN_SHAPE:
            default: {
                if (element.getHeight() > 0) {
                    double ratio = (double) normalWidth / (double) normalHeight;

                    if (ratio > (double) availableImageWidth / (double) availableImageHeight) {
                        normalWidth = availableImageWidth;
                        normalHeight = (int) (availableImageWidth / ratio);
                    } else {
                        normalWidth = (int) (availableImageHeight * ratio);
                        normalHeight = availableImageHeight;
                    }

                    int xoffset = leftPadding + (int) (xalignFactor * (availableImageWidth - normalWidth));
                    int yoffset = topPadding + (int) (yalignFactor * (availableImageHeight - normalHeight));

                    renderer.render(grx, new Rectangle(xoffset, yoffset, normalWidth, normalHeight));
                }

                break;
            }
            }

            short mode = backgroundMode;
            short backcolor = whiteIndex;
            if (!isIgnoreCellBackground && gridCell.getCellBackcolor() != null) {
                mode = HSSFCellStyle.SOLID_FOREGROUND;
                backcolor = getNearestColor(gridCell.getCellBackcolor()).getIndex();
            }

            short forecolor = getNearestColor(element.getLineBox().getPen().getLineColor()).getIndex();

            if (element.getMode() == JRElement.MODE_OPAQUE) {
                backcolor = getNearestColor(element.getBackcolor()).getIndex();
            }

            HSSFCellStyle cellStyle = getLoadedCellStyle(mode, backcolor, HSSFCellStyle.ALIGN_LEFT,
                    HSSFCellStyle.VERTICAL_TOP, (short) 0,
                    getLoadedFont(getDefaultFont(), forecolor, null, getLocale()), gridCell);

            createMergeRegion(gridCell, colIndex, rowIndex, cellStyle);

            cell = row.createCell(colIndex);
            //            cell.setCellStyle(cellStyle);

            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) colIndex, rowIndex,
                    (short) (colIndex + gridCell.getColSpan()),
                    rowIndex + (isCollapseRowSpan ? 1 : gridCell.getRowSpan()));
            anchor.setAnchorType(2);
            //pngEncoder.setImage(bi);
            //int imgIndex = workbook.addPicture(pngEncoder.pngEncode(), HSSFWorkbook.PICTURE_TYPE_PNG);
            int imgIndex = workbook.addPicture(
                    JRImageLoader.loadImageDataFromAWTImage(bi, JRRenderable.IMAGE_TYPE_PNG),
                    HSSFWorkbook.PICTURE_TYPE_PNG);
            patriarch.createPicture(anchor, imgIndex);
        }
    } catch (Exception ex) {
        throw new JRException("The cell cannot be added", ex);
    } catch (Error err) {
        throw new JRException("The cell cannot be added", err);
    }
}

From source file:ucar.unidata.idv.control.chart.TimeSeriesChart.java

/**
 * Draw the sunrise/sunset curves/* w w w .j  a  va  2  s. c o m*/
 *
 * @param g2  the graphics area
 * @param plot   the plot
 * @param dataArea  the date range
 */
private void drawSunriseSunset(Graphics2D g2, XYPlot plot, Rectangle2D dataArea) {
    if (sunriseLocation == null) {
        return;
    }
    DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
    Date startDate = ((DateAxis) domainAxis).getMinimumDate();
    Date endDate = ((DateAxis) domainAxis).getMaximumDate();
    if ((sunriseDates == null) || !Misc.equals(startDate, lastStartDate)
            || !Misc.equals(endDate, lastEndDate)) {
        lastStartDate = startDate;
        lastEndDate = endDate;
        sunriseDates = IdvTimeline.makeSunriseDates(sunriseLocation, startDate, endDate);
    }
    int top = (int) (dataArea.getY());
    int bottom = (int) (dataArea.getY() + dataArea.getHeight());
    int height = bottom - top;
    g2.setColor(Color.yellow);
    Shape originalClip = g2.getClip();
    g2.clip(dataArea);
    for (int i = 0; i < sunriseDates.size(); i += 2) {
        Date d1 = (Date) sunriseDates.get(i + 1);
        Date d2 = (Date) sunriseDates.get(i);
        int x1 = (int) domainAxis.valueToJava2D(d1.getTime(), dataArea, RectangleEdge.BOTTOM);
        int x2 = (int) domainAxis.valueToJava2D(d2.getTime(), dataArea, RectangleEdge.BOTTOM);
        g2.fillRect(x1, top, (x2 - x1), height);
    }
    g2.setClip(originalClip);
}

From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).//w  w  w .j a  v a 2 s  .c o m
 *
 * @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 > 2 ? catCount : 3));

            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 > 2 ? catCount : 3));
        }

        // 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);
}