Example usage for java.awt.geom Rectangle2D getWidth

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

Introduction

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

Prototype

public abstract double getWidth();

Source Link

Document

Returns the width of the framing rectangle in double precision.

Usage

From source file:KIDLYRenderer.java

/**
 * Calculates the bar width and stores it in the renderer state.
 *
 * @param plot  the plot./* w  w  w.  jav  a 2  s .c  o m*/
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex,
        CategoryItemRendererState state) {

    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        } else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaximumBarWidth();
        double categoryMargin = 0.0;
        double currentItemMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        if (rows > 1) {
            currentItemMargin = getItemMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin
                - currentItemMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
        } else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }
}

From source file:com.munch.exchange.ExchangeChartComposite.java

/**
 * Returns the data area for the chart (the area inside the axes) with the
 * current scaling applied (that is, the area as it appears on screen).
 *
 * @return The scaled data area.//from   w  w  w  .j a v a 2  s  .c om
 */
public Rectangle getScreenDataArea() {
    Rectangle2D dataArea = this.info.getPlotInfo().getDataArea();
    Rectangle clientArea = this.getClientArea();
    int x = (int) (dataArea.getX() * this.scaleX + clientArea.x);
    int y = (int) (dataArea.getY() * this.scaleY + clientArea.y);
    int w = (int) (dataArea.getWidth() * this.scaleX);
    int h = (int) (dataArea.getHeight() * this.scaleY);
    return new Rectangle(x, y, w, h);
}

From source file:gda.plots.TurboXYItemRenderer.java

/**
 * Draws the visual representation of a single data item. This mostly reproduces the code of StandardXYItemRenderer
 * but using the line by line information stored in the SimpleXYSeries instead of the series indexed information
 * stored in the Renderer itself.//www  .ja  v  a  2 s . co m
 * 
 * @param g2
 *            the graphics device.
 * @param state
 *            the renderer state.
 * @param dataArea
 *            the area within which the data is being drawn.
 * @param info
 *            collects information about the drawing.
 * @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 crosshairState
 *            crosshair information for the plot ( <code>null</code> permitted).
 * @param pass
 *            the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int _item,
        CrosshairState crosshairState, int pass) {

    if (_item > 0)
        return;
    SimpleXYSeries sxys = (SimpleXYSeries) ((SimpleXYSeriesCollection) dataset).getSeries(series);
    if (!sxys.isVisible()) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    g2.setPaint(sxys.getPaint());
    g2.setStroke(sxys.getStroke());

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();

    try {
        int x0 = -1; // the x position in pixels of the previous point
        int y0 = -1; // the y position in pixels of the previous point
        int x1 = -1; // the x position in pixels of the current point
        int y1 = -1; // the y position in pixels of the current point
        int xmin = (int) dataArea.getMinX();
        int xmax = (int) dataArea.getMaxX();
        int ymin = (int) dataArea.getMinY();
        int ymax = (int) dataArea.getMaxY();
        GeneralPath path = null;

        /*
         * To remove the time spent repeatedly calling domainAxis.valueToJava2D for linear axes use simple linear
         * maths
         */
        double xl = 0., mx = Double.NaN, cx = 0.;
        if (domainAxis instanceof SimpleNumberAxis) {
            xl = domainAxis.getRange().getLowerBound();
            mx = dataArea.getWidth() / (domainAxis.getRange().getUpperBound() - xl);
            cx = xmin;
        }
        double yl = 0., my = Double.NaN, cy = 0.;
        if (rangeAxis instanceof SimpleNumberAxis) {
            yl = rangeAxis.getRange().getLowerBound();
            my = -dataArea.getHeight() / (rangeAxis.getRange().getUpperBound() - yl);
            cy = ymax;
        }
        List<XYDataItem> list = sxys.getData();

        boolean MX_MY_NaN = Double.isNaN(mx) || Double.isNaN(my);
        Paint paint = sxys.getPaint();
        Stroke stroke = sxys.getStroke();
        Paint paint_symbol = sxys.getSymbolPaint();
        Stroke stroke_symbol = new BasicStroke();
        drawLines = sxys.isDrawLines();
        boolean filled = sxys.getFilled();
        Shape shape = sxys.getSymbol();
        boolean drawMarkers = sxys.isDrawMarkers() & shape != null;
        int tooltipThresholdCounts = -1; /* number of points to be shown below which markers are also to be drawn */
        if (drawLines && drawMarkers && shape != null && tooltipThreshold != 0) {
            Rectangle shapeBoundingBox = shape.getBounds();
            tooltipThresholdCounts = (int) dataArea.getWidth()
                    / (Math.max(1, shapeBoundingBox.width) * tooltipThreshold);
        }

        java.util.Vector<ddouble> markerPositions = null;
        Shape entityArea = null;
        EntityCollection entities = null;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
        }
        boolean prevLineAdded = false;
        // In case the iterator does not work then use the TODO comment iterator use and why not always
        // comment variables
        synchronized (list) {
            Iterator<XYDataItem> iter = list.iterator();
            /*
             * loop over all points calculating X1 and Y1. Store previous points positions into X0 and Y0 The
             * variable addThis determines if the current point is to be added to the path If previous line was
             * added that the current must be even if off the screen - but in this case the flag prevLineAdded is
             * set false so that the next does not have to be added.
             */
            for (int item = 0; iter.hasNext(); item++, x0 = x1, y0 = y1, x1 = -1, y1 = -1) {
                XYDataItem dataitem = iter.next();
                double x = dataitem.getX().doubleValue();
                double y = dataitem.getY().doubleValue();
                x = xValueTransformer.transformValue(x);

                x1 = MX_MY_NaN ? (int) domainAxis.valueToJava2D(x, dataArea, xAxisLocation)
                        : (int) ((x - xl) * mx + cx);
                y1 = MX_MY_NaN ? (int) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation)
                        : (int) ((y - yl) * my + cy);

                boolean addThis = true;
                if (item == 0) {
                    x0 = x1;
                    y0 = y1;
                    if ((x1 < xmin) || (x1 > xmax) || (y1 < ymin) || (y1 > ymax)) {
                        addThis = false;
                    }
                } else {
                    if (x1 == x0 && y1 == y0) {
                        addThis = false;
                    }
                    if ((x1 < xmin && x0 < xmin) || (x1 > xmax && x0 > xmax) || (y1 < ymin && y0 < ymin)
                            || (y1 > ymax && y0 > ymax)) {
                        if (prevLineAdded) {
                            path = addPointToLine(path, orientation, x1, y1);
                        }
                        addThis = false;
                    }
                }
                if (addThis) {
                    /*
                     * If the current point is to be added then ensure previous one is as well to prevent lines
                     * not crossing the edge of the screen
                     */
                    if (!prevLineAdded) {
                        path = addPointToLine(path, orientation, x0, y0);
                    }
                    path = addPointToLine(path, orientation, x1, y1);
                    prevLineAdded = true;
                }
                prevLineAdded = addThis;
                if (addThis && drawMarkers) {
                    if (markerPositions == null) {
                        markerPositions = new java.util.Vector<ddouble>();
                    }
                    markerPositions.add(new ddouble(item, x1, y1));
                    if (tooltipThresholdCounts != -1 && markerPositions.size() > tooltipThresholdCounts) {
                        drawMarkers = false;
                        markerPositions = null;
                    }
                }
            }
            if (path != null) {
                g2.setStroke(stroke);
                g2.setPaint(paint);
                g2.draw(path);
            }
            if (markerPositions != null) {
                if (drawMarkers) {
                    g2.setPaint(paint_symbol);
                    g2.setStroke(stroke_symbol);
                    for (ddouble dd : markerPositions) {
                        Shape shape_item = ShapeUtilities.createTranslatedShape(shape, dd.x, dd.y);
                        if (filled) {
                            g2.fill(shape_item);
                        } else {
                            g2.draw(shape_item);
                        }
                        entityArea = shape_item;
                        // add an entity for the item...
                        if (entities != null) {
                            addEntity(entities, entityArea, dataset, series, dd.item, dd.x, dd.y);
                        }
                    }
                    g2.setPaint(paint);
                    g2.setStroke(stroke);
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:spinworld.gui.RadarPlot.java

private void drawTickLabel(Graphics2D g2, Rectangle2D radarArea, Point2D middlePoint, double _axisAngle,
        int cat, double tick) {
    double axisAngle = normalize(_axisAngle);
    double _origin = getOrigin(cat).doubleValue();
    double max = getMaxValue(cat).doubleValue();
    double tickValue = ((max - _origin) * tick) + _origin;
    String label = "" + Math.round(tickValue * 1000) / 1000d;
    FontRenderContext frc = g2.getFontRenderContext();
    Rectangle2D labelBounds = getLabelFont().getStringBounds(label, frc);
    int labelW = (int) labelBounds.getWidth();
    int labelH = (int) labelBounds.getHeight();

    double centerX = radarArea.getCenterX();
    double centerY = radarArea.getCenterY();

    double adj = middlePoint.distance(centerX, centerY);
    double opp = TICK_MARK_LENGTH / 2 + 4;
    double hyp = Math.sqrt(Math.pow(opp, 2) + Math.pow(adj, 2));
    double angle = Math.toDegrees(Math.atan(opp / adj));
    int charHeight = g2.getFontMetrics().getHeight();
    int charWidth = g2.getFontMetrics().charWidth('M');

    double alphaRad = Math.toRadians(axisAngle - angle);
    double labelX = centerX + (hyp * Math.cos(alphaRad));
    double labelY = centerY - (hyp * Math.sin(alphaRad)) + labelH;

    //        g2.draw(new Line2D.Double(centerX, centerY, labelX, labelY - labelH)); // test line

    double sinGap = Math.pow(Math.sin(Math.toRadians(axisAngle)), 2);
    if (axisAngle > 90 && axisAngle < 270) {
        labelY -= labelH;/*from   w  w  w .  j  a v a 2s  .c  om*/
        labelY += (charHeight * sinGap / 2);
    } else {
        labelY -= (charHeight * sinGap / 2);
    }
    double cosGap = Math.pow(Math.cos(Math.toRadians(axisAngle)), 2);
    if (axisAngle > 180) {
        labelX -= labelW;
        labelX += (charWidth * cosGap / 2);
    } else {
        labelX -= (charWidth * cosGap / 2);
    }
    //        g2.drawRect((int) labelX, (int) labelY - labelH, labelW, labelH); // test rectangle
    g2.setPaint(getLabelPaint());
    g2.setFont(getLabelFont());
    g2.drawString(label, (float) labelX, (float) labelY);
}

From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java

/**
 * Applies any scaling that is in effect for the chart drawing to the given
 * rectangle.//from   w w  w.  ja v a2 s.c om
 * 
 * @param rect
 *          the rectangle.
 * 
 * @return A new scaled rectangle.
 */
public Rectangle scale(final Rectangle2D rect) {
    final Rectangle insets = this.getClientArea();
    final int x = (int) Math.round(rect.getX() * getScaleX()) + insets.x;
    final int y = (int) Math.round(rect.getY() * this.getScaleY()) + insets.y;
    final int w = (int) Math.round(rect.getWidth() * this.getScaleX());
    final int h = (int) Math.round(rect.getHeight() * this.getScaleY());
    return new Rectangle(x, y, w, h);
}

From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java

private void drawDestinationElement(final Graphics2D g, final MindMapPanelConfig cfg) {
    if (this.destinationElement != null && this.draggedElement != null) {
        g.setColor(new Color((cfg.getSelectLineColor().getRGB() & 0xFFFFFF) | 0x80000000, true));
        g.setStroke(new BasicStroke(this.config.safeScaleFloatValue(3.0f, 0.1f)));

        final Rectangle2D rectToDraw = new Rectangle2D.Double();
        rectToDraw.setRect(this.destinationElement.getBounds());
        final double selectLineGap = cfg.getSelectLineGap() * 3.0d * cfg.getScale();
        rectToDraw.setRect(rectToDraw.getX() - selectLineGap, rectToDraw.getY() - selectLineGap,
                rectToDraw.getWidth() + selectLineGap * 2, rectToDraw.getHeight() + selectLineGap * 2);

        final int position = calcDropPosition(this.destinationElement, this.draggedElement.getPosition());

        boolean draw = !this.draggedElement.isPositionInside()
                && !this.destinationElement.getModel().hasAncestor(this.draggedElement.getElement().getModel());

        switch (this.draggedElement.getModifier()) {
        case NONE: {
            switch (position) {
            case DRAG_POSITION_TOP: {
                rectToDraw.setRect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(),
                        rectToDraw.getHeight() / 2);
            }//from   w  ww  . java2 s  .  co  m
                break;
            case DRAG_POSITION_BOTTOM: {
                rectToDraw.setRect(rectToDraw.getX(), rectToDraw.getY() + rectToDraw.getHeight() / 2,
                        rectToDraw.getWidth(), rectToDraw.getHeight() / 2);
            }
                break;
            case DRAG_POSITION_LEFT: {
                rectToDraw.setRect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth() / 2,
                        rectToDraw.getHeight());
            }
                break;
            case DRAG_POSITION_RIGHT: {
                rectToDraw.setRect(rectToDraw.getX() + rectToDraw.getWidth() / 2, rectToDraw.getY(),
                        rectToDraw.getWidth() / 2, rectToDraw.getHeight());
            }
                break;
            default:
                draw = false;
                break;
            }
        }
            break;
        case MAKE_JUMP: {
        }
            break;
        default:
            throw new Error("Unexpected state " + this.draggedElement.getModifier());
        }

        if (draw) {
            g.fill(rectToDraw);
        }
    }
}

From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java

/**
 * Returns the data area for the chart (the area inside the axes) with the
 * current scaling applied (that is, the area as it appears on screen).
 * /*from ww  w. j a  v  a 2 s .co m*/
 * @return The scaled data area.
 */
public Rectangle getScreenDataArea() {
    final Rectangle2D dataArea = this.info.getPlotInfo().getDataArea();
    final Rectangle clientArea = this.getClientArea();
    final int x = (int) (dataArea.getX() * this.scaleX + clientArea.x);
    final int y = (int) (dataArea.getY() * this.scaleY + clientArea.y);
    final int w = (int) (dataArea.getWidth() * this.scaleX);
    final int h = (int) (dataArea.getHeight() * this.scaleY);
    return new Rectangle(x, y, w, h);
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

private void setPaint(final boolean invert, final double xoffset, final double yoffset, final boolean fill) {
    if (paint instanceof Color) {
        final Color color = (Color) paint;
        final int alpha = color.getAlpha();
        if (fill) {
            if (alpha != currentFillGState) {
                currentFillGState = alpha;
                PdfGState gs = fillGState[alpha];
                if (gs == null) {
                    gs = new PdfGState();
                    gs.setFillOpacity(alpha / 255.00f);
                    fillGState[alpha] = gs;
                }//from  ww  w.  j  a v a2s  .com
                cb.setGState(gs);
            }
            cb.setColorFill(color);
        } else {
            if (alpha != currentStrokeGState) {
                currentStrokeGState = alpha;
                PdfGState gs = strokeGState[alpha];
                if (gs == null) {
                    gs = new PdfGState();
                    gs.setStrokeOpacity(alpha / 255.0f);
                    strokeGState[alpha] = gs;
                }
                cb.setGState(gs);
            }
            cb.setColorStroke(color);
        }
    } else if (paint instanceof GradientPaint) {
        final GradientPaint gp = (GradientPaint) paint;
        final Point2D p1 = gp.getPoint1();
        transform.transform(p1, p1);
        final Point2D p2 = gp.getPoint2();
        transform.transform(p2, p2);
        final Color c1 = gp.getColor1();
        final Color c2 = gp.getColor2();
        final PdfShading shading = PdfShading.simpleAxial(cb.getPdfWriter(), (float) p1.getX(),
                normalizeY((float) p1.getY()), (float) p2.getX(), normalizeY((float) p2.getY()), c1, c2);
        final PdfShadingPattern pat = new PdfShadingPattern(shading);
        if (fill) {
            cb.setShadingFill(pat);
        } else {
            cb.setShadingStroke(pat);
        }
    } else if (paint instanceof TexturePaint) {
        try {
            final TexturePaint tp = (TexturePaint) paint;
            final BufferedImage img = tp.getImage();
            final Rectangle2D rect = tp.getAnchorRect();
            final com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null);
            final PdfPatternPainter pattern = cb.createPattern(image.getWidth(), image.getHeight());
            final AffineTransform inverse = this.normalizeMatrix();
            inverse.translate(rect.getX(), rect.getY());
            inverse.scale(rect.getWidth() / image.getWidth(), -rect.getHeight() / image.getHeight());
            final double[] mx = new double[6];
            inverse.getMatrix(mx);
            pattern.setPatternMatrix((float) mx[0], (float) mx[1], (float) mx[2], (float) mx[3], (float) mx[4],
                    (float) mx[5]);
            image.setAbsolutePosition(0, 0);
            pattern.addImage(image);
            if (fill) {
                cb.setPatternFill(pattern);
            } else {
                cb.setPatternStroke(pattern);
            }

        } catch (Exception ex) {
            if (fill) {
                cb.setColorFill(Color.gray);
            } else {
                cb.setColorStroke(Color.gray);
            }
        }
    } else {
        try {
            int type = BufferedImage.TYPE_4BYTE_ABGR;
            if (paint.getTransparency() == Transparency.OPAQUE) {
                type = BufferedImage.TYPE_3BYTE_BGR;
            }
            final BufferedImage img = new BufferedImage((int) width, (int) height, type);
            final Graphics2D g = (Graphics2D) img.getGraphics();
            g.transform(transform);
            final AffineTransform inv = transform.createInverse();
            Shape fillRect = new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight());
            fillRect = inv.createTransformedShape(fillRect);
            g.setPaint(paint);
            g.fill(fillRect);
            if (invert) {
                final AffineTransform tx = new AffineTransform();
                tx.scale(1, -1);
                tx.translate(-xoffset, -yoffset);
                g.drawImage(img, tx, null);
            }
            g.dispose();
            // g = null;
            final com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null);
            final PdfPatternPainter pattern = cb.createPattern(width, height);
            image.setAbsolutePosition(0, 0);
            pattern.addImage(image);
            if (fill) {
                cb.setPatternFill(pattern);
            } else {
                cb.setPatternStroke(pattern);
            }
        } catch (Exception ex) {
            if (fill) {
                cb.setColorFill(Color.gray);
            } else {
                cb.setColorStroke(Color.gray);
            }
        }
    }
}

From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java

/**
 * Handles a 'mouse released' event.  On Windows, we need to check if this 
 * is a popup trigger, but only if we haven't already been tracking a zoom
 * rectangle./*from   ww w. jav a  2  s . c o m*/
 *
 * @param e  information about the event.
 */
public void mouseReleased(MouseEvent e) {

    if (this.zoomRectangle != null) {
        boolean hZoom = false;
        boolean vZoom = false;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            hZoom = this.rangeZoomable;
            vZoom = this.domainZoomable;
        } else {
            hZoom = this.domainZoomable;
            vZoom = this.rangeZoomable;
        }

        boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance;
        boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance;
        if (zoomTrigger1 || zoomTrigger2) {
            if ((hZoom && (e.getX() < this.zoomPoint.getX()))
                    || (vZoom && (e.getY() < this.zoomPoint.getY()))) {
                // restoreAutoBounds();
            } else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(),
                        (int) this.zoomPoint.getY());
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    x = this.zoomPoint.getX();
                    y = screenDataArea.getMinY();
                    w = Math.min(this.zoomRectangle.getWidth(),
                            screenDataArea.getMaxX() - this.zoomPoint.getX());
                    h = screenDataArea.getHeight();
                } else if (!hZoom) {
                    x = screenDataArea.getMinX();
                    y = this.zoomPoint.getY();
                    w = screenDataArea.getWidth();
                    h = Math.min(this.zoomRectangle.getHeight(),
                            screenDataArea.getMaxY() - this.zoomPoint.getY());
                } else {
                    x = this.zoomPoint.getX();
                    y = this.zoomPoint.getY();
                    w = Math.min(this.zoomRectangle.getWidth(),
                            screenDataArea.getMaxX() - this.zoomPoint.getX());
                    h = Math.min(this.zoomRectangle.getHeight(),
                            screenDataArea.getMaxY() - this.zoomPoint.getY());
                }
                if (activeROI != null) {
                    Rectangle2D rectangleArea = new Rectangle2D.Double(x, y, w, h);
                    g2 = (Graphics2D) getGraphics();
                    g2.setPaint(activeROI.getColor());
                    g2.draw(rectangleArea);
                    activeROI.add(rectangleArea, getRange(rectangleArea));
                    RoiFromChartProcess process = new RoiFromChartProcess();
                    process.addParam("roi", activeROI);
                    process.addParam("raster", (FLyrRasterSE) rasterSE);
                    process.setActions(this);
                    process.start();
                    if (gestorRois != null) {
                        // Cargar la nueva ROI en el destor
                        gestorRois.clearRoiGraphics();
                    }
                }

            }
            this.zoomPoint = null;
            this.zoomRectangle = null;
            updateUI();
        } else {
            // Erase the zoom rectangle
            Graphics2D g2 = (Graphics2D) getGraphics();
            drawRectangle(g2);
            g2.dispose();
            this.zoomPoint = null;
            this.zoomRectangle = null;
        }

    }

    else if (e.isPopupTrigger()) {
        if (this.popup != null) {
            displayPopupMenu(e.getX(), e.getY());
        }
    }
}

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

/**
 * Returns the location for a label//from  w  w  w . j a  v  a2s. c  om
 *
 * @param labelBounds the label bounds.
 * @param ascent the ascent (height of font).
 * @param plotArea the plot area
 * @param startAngle the start angle for the pie series.
 *
 * @return The location for a label.
 */
protected Point2D calculateLabelLocation(Rectangle2D labelBounds, double ascent, Rectangle2D plotArea,
        double startAngle) {
    Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN);
    Point2D point1 = arc1.getEndPoint();

    double deltaX = -(point1.getX() - plotArea.getCenterX()) * this.axisLabelGap;
    double deltaY = -(point1.getY() - plotArea.getCenterY()) * this.axisLabelGap;

    double labelX = point1.getX() - deltaX;
    double labelY = point1.getY() - deltaY;

    if (labelX < plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth();
    }

    if (labelX == plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth() / 2;
    }

    if (labelY > plotArea.getCenterY()) {
        labelY += ascent;
    }

    return new Point2D.Double(labelX, labelY);
}