Example usage for java.awt.geom Rectangle2D contains

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

Introduction

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

Prototype

public boolean contains(Point2D p) 

Source Link

Usage

From source file:org.gumtree.vis.hist2d.Hist2DPanel.java

private void changeSelectedMask(MouseEvent e, EntityCollection entities) {
    // Do masking service
    // if no initial masking point was set, ignore dragging...
    Rectangle2D screenArea = getScreenDataArea();
    Point2D screenPoint = translateScreenToJava2D(e.getPoint());
    //       System.out.println("screen point is [" + screenPoint.getX() + ", " +
    //             screenPoint.getY() + "]");
    if (screenArea.contains(screenPoint)) {
        Point2D chartPoint = translateScreenToChart(screenPoint);
        if (chartPoint != null) {
            //             System.out.println("chart point is [" + chartPoint.getX() + ", " +
            //                   chartPoint.getY() + "]");
            changeSelectedMask(chartPoint);
            repaint();//from ww  w .j  a  v  a 2s. c  o m
        }
    }
}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

/**
 * Receives notification of mouse clicks on the panel. These are
 * translated and passed on to any registered {@link ChartMouseListener}s.
 *
 * @param event  Information about the mouse event.
 *///ww  w  .  jav  a  2 s  .  c  om
@Override
public void mouseClicked(MouseEvent event) {

    Insets insets = getInsets();
    int x = (int) ((event.getX() - insets.left) / getScaleX());
    int y = (int) ((event.getY() - insets.top) / getScaleY());

    setAnchor(new Point2D.Double(x, y));
    if (getChart() == null) {
        return;
    }
    //        getChart().setNotify(true);  // force a redraw
    // new entity code...
    //        if (listeners.length == 0) {
    //            return;
    //        }

    //        if ((event.getModifiers() & maskingSelectionMask) != 0) {
    if (isInternalLegendEnabled) {
        Rectangle2D screenArea = getScreenDataArea();
        Rectangle2D legendArea = new Rectangle2D.Double(screenArea.getMaxX() - internalLegendSetup.getMinX(),
                screenArea.getMinY() + internalLegendSetup.getMinY(), internalLegendSetup.getWidth(),
                internalLegendSetup.getHeight());
        if (legendArea.contains(event.getPoint())) {
            selectInternalLegend(true);
            selectMask(Double.NaN, Double.NaN);
            repaint();
            return;
        } else {
            selectInternalLegend(false);
        }
    }
    if (!isTextInputEnabled() && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
        selectMask(ChartMaskingUtilities.translateScreenX(x, getScreenDataArea(), getChart()), Double.NaN);
        repaint();
    }
    if ((event.getModifiers() & seriesSelectionEventMask) == 0) {
        if (getSelectedMask() != null && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0
                && !getSelectedMask().getRange()
                        .contains(ChartMaskingUtilities.translateScreenX(x, getScreenDataArea(), getChart()))) {
            selectMask(Double.NaN, Double.NaN);
        }
        repaint();
    } else if (!isTextInputEnabled()) {
        selectMask(ChartMaskingUtilities.translateScreenX(x, getScreenDataArea(), getChart()), Double.NaN);
        repaint();
    }

    ChartEntity entity = null;
    if (getChartRenderingInfo() != null) {
        EntityCollection entities = getChartRenderingInfo().getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
            if (entity instanceof XYItemEntity) {
                XYItemEntity xyEntity = (XYItemEntity) entity;
                //                   XYDataset dataset = xyEntity.getDataset();
                //                   int item = ((XYItemEntity) entity).getItem();
                //                   chartX = dataset.getXValue(xyEntity.getSeriesIndex(), item);
                //                   chartY = dataset.getYValue(xyEntity.getSeriesIndex(), item);
                //                   Point2D screenPoint = ChartMaskingUtilities.translateChartPoint(
                //                         new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart());
                //                   if (getHorizontalAxisTrace()) {
                //                      horizontalTraceLocation = (int) screenPoint.getX();
                //                   }
                //                   if (getVerticalAxisTrace()) {
                //                      verticalTraceLocation = (int) screenPoint.getY();
                //                   }
                if ((event.getModifiers() & seriesSelectionEventMask) != 0
                        && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
                    selectSeries(xyEntity.getSeriesIndex());
                    return;
                } else if ((event.getModifiers() & maskingSelectionMask) == 0
                        && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
                    if (selectedSeriesIndex != xyEntity.getSeriesIndex()) {
                        selectSeries(-1);
                        return;
                    }
                }
            } else {
                if (selectedSeriesIndex >= 0) {
                    if ((event.getModifiers() & seriesSelectionEventMask) != 0
                            && (event.getModifiers() & maskingSelectionMask) == 0
                            && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
                        selectSeries(-1);
                        return;
                    }
                }
            }
        }
    }
    XYChartMouseEvent chartEvent = new XYChartMouseEvent(getChart(), event, entity);
    chartEvent.setXY(getChartX(), getChartY());
    Object[] listeners = getListeners(ChartMouseListener.class);
    for (int i = listeners.length - 1; i >= 0; i -= 1) {
        ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent);
    }
    super.mouseClicked(event);
}

From source file:org.gumtree.vis.awt.JChartPanel.java

private void moveSelectedText(MouseEvent e) {
    Point2D screenPoint = translateScreenToJava2D(e.getPoint());
    Rectangle2D screenArea = getScreenDataArea();
    if (screenArea.contains(screenPoint)) {

        if (textMovePoint != null) {
            //               Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint()));
            double screenX = ChartMaskingUtilities.translateScreenX(e.getX() / getScaleX(), getScreenDataArea(),
                    getChart());/*from w w w  .  j  av a2s  .c  o  m*/
            double screenY = ChartMaskingUtilities.translateScreenY(e.getY(), getScreenDataArea(), getChart(),
                    0);
            //               Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint()));
            Point2D point = new Point2D.Double(screenX, screenY);
            selectedTextWrapper.setRect(selectedTextWrapper.getMinX() + point.getX() - textMovePoint.getX(),
                    selectedTextWrapper.getMinY() + point.getY() - textMovePoint.getY(),
                    selectedTextWrapper.getWidth(), selectedTextWrapper.getHeight());
            if (point != null) {
                this.textMovePoint = point;
            }
            repaint();
        }
    }
}

From source file:edu.dlnu.liuwenpeng.render.XYBarRenderer.java

/**
 * Draws an item label.  This method is provided as an alternative to
 * {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int, 
 * double, double, boolean)} so that the bar can be used to calculate the 
 * label anchor point. /*  ww w  . java2s  .co  m*/
 * 
 * @param g2  the graphics device.
 * @param dataset  the dataset.
 * @param series  the series index.
 * @param item  the item index.
 * @param plot  the plot.
 * @param generator  the label generator (<code>null</code> permitted, in 
 *         which case the method does nothing, just returns).
 * @param bar  the bar.
 * @param negative  a flag indicating a negative value.
 */
protected void drawItemLabel(Graphics2D g2, XYDataset dataset, int series, int item, XYPlot plot,
        XYItemLabelGenerator generator, Rectangle2D bar, boolean negative) {

    if (generator == null) {
        return; // nothing to do
    }
    String label = generator.generateLabel(dataset, series, item);
    if (label == null) {
        return; // nothing to do   
    }

    Font labelFont = getItemLabelFont(series, item);
    g2.setFont(labelFont);
    Paint paint = getItemLabelPaint(series, item);
    g2.setPaint(paint);

    // find out where to place the label...
    ItemLabelPosition position = null;
    if (!negative) {
        position = getPositiveItemLabelPosition(series, item);
    } else {
        position = getNegativeItemLabelPosition(series, item);
    }

    // work out the label anchor point...
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());

    if (isInternalAnchor(position.getItemLabelAnchor())) {
        Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(),
                (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());

        if (bounds != null) {
            if (!bar.contains(bounds.getBounds2D())) {
                if (!negative) {
                    position = getPositiveItemLabelPositionFallback();
                } else {
                    position = getNegativeItemLabelPositionFallback();
                }
                if (position != null) {
                    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar,
                            plot.getOrientation());
                }
            }
        }

    }

    if (position != null) {
        TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    }
}

From source file:edu.dlnu.liuwenpeng.render.BarRenderer.java

/**    
* Draws an item label.  This method is overridden so that the bar can be    
* used to calculate the label anchor point.    
*    /* w  ww.  j  av  a 2  s. c o m*/
* @param g2  the graphics device.    
* @param data  the dataset.    
* @param row  the row.    
* @param column  the column.    
* @param plot  the plot.    
* @param generator  the label generator.    
* @param bar  the bar.    
* @param negative  a flag indicating a negative value.    
*/
protected void drawItemLabel(Graphics2D g2, CategoryDataset data, int row, int column, CategoryPlot plot,
        CategoryItemLabelGenerator generator, Rectangle2D bar, boolean negative) {

    String label = generator.generateLabel(data, row, column);
    if (label == null) {
        return; // nothing to do    
    }

    Font labelFont = getItemLabelFont(row, column);
    g2.setFont(labelFont);
    Paint paint = getItemLabelPaint(row, column);
    g2.setPaint(paint);

    // find out where to place the label...    
    ItemLabelPosition position = null;
    if (!negative) {
        position = getPositiveItemLabelPosition(row, column);
    } else {
        position = getNegativeItemLabelPosition(row, column);
    }

    // work out the label anchor point...    
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());

    if (isInternalAnchor(position.getItemLabelAnchor())) {
        Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(),
                (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());

        if (bounds != null) {
            if (!bar.contains(bounds.getBounds2D())) {
                if (!negative) {
                    position = getPositiveItemLabelPositionFallback();
                } else {
                    position = getNegativeItemLabelPositionFallback();
                }
                if (position != null) {
                    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar,
                            plot.getOrientation());
                }
            }
        }

    }

    if (position != null) {
        TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    }
}

From source file:edu.dlnu.liuwenpeng.render.NewXYBarRenderer.java

/**    
* Draws an item label.  This method is provided as an alternative to    
* {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int,     
* double, double, boolean)} so that the bar can be used to calculate the     
* label anchor point.     //  ww w .  j a va 2s  .com
*     
* @param g2  the graphics device.    
* @param dataset  the dataset.    
* @param series  the series index.    
* @param item  the item index.    
* @param plot  the plot.    
* @param generator  the label generator (<code>null</code> permitted, in     
*         which case the method does nothing, just returns).    
* @param bar  the bar.    
* @param negative  a flag indicating a negative value.    
*/
protected void drawItemLabel(Graphics2D g2, XYDataset dataset, int series, int item, XYPlot plot,
        XYItemLabelGenerator generator, Rectangle2D bar, boolean negative) {

    if (generator == null) {
        return; // nothing to do    
    }
    String label = generator.generateLabel(dataset, series, item);
    if (label == null) {
        return; // nothing to do       
    }

    Font labelFont = getItemLabelFont(series, item);
    g2.setFont(labelFont);
    Paint paint = getItemLabelPaint(series, item);
    g2.setPaint(paint);

    // find out where to place the label...    
    ItemLabelPosition position = null;
    if (!negative) {
        position = getPositiveItemLabelPosition(series, item);
    } else {
        position = getNegativeItemLabelPosition(series, item);
    }

    // work out the label anchor point...    
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());

    if (isInternalAnchor(position.getItemLabelAnchor())) {
        Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(),
                (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());

        if (bounds != null) {
            if (!bar.contains(bounds.getBounds2D())) {
                if (!negative) {
                    position = getPositiveItemLabelPositionFallback();
                } else {
                    position = getNegativeItemLabelPositionFallback();
                }
                if (position != null) {
                    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar,
                            plot.getOrientation());
                }
            }
        }

    }

    if (position != null) {
        TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    }
}

From source file:org.gumtree.vis.hist2d.Hist2DPanel.java

protected int findCursorOnSelectedItem(int x, int y) {
    if (getSelectedMask() != null && !getSelectedMask().getRectangleFrame().isEmpty()) {
        Rectangle2D screenArea = getScreenDataArea();
        Rectangle2D maskArea = ChartMaskingUtilities
                .translateChartRectangle(getSelectedMask(), getScreenDataArea(), getChart())
                .getRectangleFrame();//from ww w.j a  va2  s. c  o m
        Rectangle2D intersect = screenArea.createIntersection(maskArea);
        Point2D point = new Point2D.Double(x, y);
        double minX = maskArea.getMinX();
        double maxX = maskArea.getMaxX();
        double minY = maskArea.getMinY();
        double maxY = maskArea.getMaxY();
        double width = maskArea.getWidth();
        double height = maskArea.getHeight();
        if (!intersect.isEmpty() && screenArea.contains(point)) {
            //              if (y > minY && y < maxY) {
            //                 if (minX > screenArea.getMinX() + 1 
            //                       && minX < screenArea.getMaxX() - 1) {
            //                       if (x > minX - 4 && x < minX + (width < 8 ? width / 2 : 4)) {
            //                          return Cursor.W_RESIZE_CURSOR;
            //                       } 
            //                 }
            //                 if (maxX > screenArea.getMinX() + 1 
            //                       && maxX < screenArea.getMaxX() - 1) {
            //                       if (x > maxX - (width < 8 ? width / 2 : 4) && x < maxX + 4) {
            //                          return Cursor.E_RESIZE_CURSOR;
            //                       } 
            //                 }
            //              }
            if (height > 8 && width > 8) {
                Rectangle2D center = new Rectangle2D.Double(minX + 4, minY + 4, width - 8, height - 8);
                if (screenArea.createIntersection(center).contains(point)) {
                    return Cursor.MOVE_CURSOR;
                }
            }
            if (height > 8) {
                Rectangle2D west = new Rectangle2D.Double(minX - 4, minY + 4, width < 8 ? width / 2 + 4 : 8,
                        height - 8);
                if (screenArea.createIntersection(west).contains(point)) {
                    return Cursor.W_RESIZE_CURSOR;
                }
                Rectangle2D east = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY + 4,
                        width < 8 ? width / 2 + 4 : 8, height - 8);
                if (screenArea.createIntersection(east).contains(point)) {
                    return Cursor.E_RESIZE_CURSOR;
                }
            }
            if (width > 8) {
                Rectangle2D north = new Rectangle2D.Double(minX + 4, minY - 4, width - 8,
                        height < 8 ? height / 2 + 4 : 8);
                if (screenArea.createIntersection(north).contains(point)) {
                    return Cursor.N_RESIZE_CURSOR;
                }
                Rectangle2D south = new Rectangle2D.Double(minX + 4, maxY - (height < 8 ? height / 2 : 4),
                        width - 8, height < 8 ? height / 2 + 4 : 8);
                if (screenArea.createIntersection(south).contains(point)) {
                    return Cursor.S_RESIZE_CURSOR;
                }
            }
            Rectangle2D northwest = new Rectangle2D.Double(minX - 4, minY - 4, width < 8 ? width / 2 + 4 : 8,
                    height < 8 ? height / 2 + 4 : 8);
            if (screenArea.createIntersection(northwest).contains(point)) {
                return Cursor.NW_RESIZE_CURSOR;
            }
            Rectangle2D northeast = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY - 4,
                    width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8);
            if (screenArea.createIntersection(northeast).contains(point)) {
                return Cursor.NE_RESIZE_CURSOR;
            }
            Rectangle2D southwest = new Rectangle2D.Double(minX - 4, maxY - (height < 8 ? height / 2 : 4),
                    width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8);
            if (screenArea.createIntersection(southwest).contains(point)) {
                return Cursor.SW_RESIZE_CURSOR;
            }
            Rectangle2D southeast = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4),
                    maxY - (height < 8 ? height / 2 : 4), width < 8 ? width / 2 + 4 : 8,
                    height < 8 ? height / 2 + 4 : 8);
            if (screenArea.createIntersection(southeast).contains(point)) {
                return Cursor.SE_RESIZE_CURSOR;
            }
        }
        //           System.out.println("intersect X:[" + intersect.getMinX() + ", " + 
        //                 (intersect.getMinX() + intersect.getWidth()) + 
        //                 "], Y:[" + intersect.getMinY() + ", " + 
        //                 (intersect.getMinY() + intersect.getHeight()) +
        //                 "], x=" + point.getX() + ", y=" + point.getY() + 
        //                 " " + intersect.contains(point));
    }
    return Cursor.DEFAULT_CURSOR;
}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

protected int findCursorOnSelectedItem(int x, int y) {
    if (isInternalLegendEnabled && isInternalLegendSelected) {
        Rectangle2D screenArea = getScreenDataArea();
        Rectangle2D legendArea = new Rectangle2D.Double(screenArea.getMaxX() - internalLegendSetup.getMinX(),
                screenArea.getMinY() + internalLegendSetup.getMinY(), internalLegendSetup.getWidth(),
                internalLegendSetup.getHeight());
        Rectangle2D intersect = screenArea.createIntersection(legendArea);
        Point2D point = new Point2D.Double(x, y);
        double minX = legendArea.getMinX();
        double maxX = legendArea.getMaxX();
        double minY = legendArea.getMinY();
        double width = legendArea.getWidth();
        double height = legendArea.getHeight();
        if (!intersect.isEmpty() && screenArea.contains(point)) {
            if (width > 8) {
                Rectangle2D center = new Rectangle2D.Double(minX + 4, minY, width - 8, height);
                if (screenArea.createIntersection(center).contains(point)) {
                    return Cursor.MOVE_CURSOR;
                }//from   w w  w.  ja  v a 2  s . c om
            }
            Rectangle2D west = new Rectangle2D.Double(minX - 4, minY, width < 8 ? width / 2 + 4 : 8, height);
            if (screenArea.createIntersection(west).contains(point)) {
                return Cursor.W_RESIZE_CURSOR;
            }
            Rectangle2D east = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY,
                    width < 8 ? width / 2 + 4 : 8, height);
            if (screenArea.createIntersection(east).contains(point)) {
                return Cursor.E_RESIZE_CURSOR;
            }
        }
    } else if (getSelectedMask() != null && !getSelectedMask().isEmpty()) {
        Rectangle2D screenArea = getScreenDataArea();
        Rectangle2D maskArea = ChartMaskingUtilities.getDomainMaskFrame(getSelectedMask(), getScreenDataArea(),
                getChart());
        Rectangle2D intersect = screenArea.createIntersection(maskArea);
        Point2D point = new Point2D.Double(x, y);
        double minX = maskArea.getMinX();
        double maxX = maskArea.getMaxX();
        double minY = maskArea.getMinY();
        double width = maskArea.getWidth();
        double height = maskArea.getHeight();
        if (!intersect.isEmpty() && screenArea.contains(point)) {
            if (width > 8) {
                Rectangle2D center = new Rectangle2D.Double(minX + 4, minY, width - 8, height);
                if (screenArea.createIntersection(center).contains(point)) {
                    return Cursor.MOVE_CURSOR;
                }
            }
            Rectangle2D west = new Rectangle2D.Double(minX - 4, minY, width < 8 ? width / 2 + 4 : 8, height);
            if (screenArea.createIntersection(west).contains(point)) {
                return Cursor.W_RESIZE_CURSOR;
            }
            Rectangle2D east = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY,
                    width < 8 ? width / 2 + 4 : 8, height);
            if (screenArea.createIntersection(east).contains(point)) {
                return Cursor.E_RESIZE_CURSOR;
            }
        }
    }
    return Cursor.DEFAULT_CURSOR;
}

From source file:KIDLYRenderer.java

/**
 * Draws an item label.  This method is overridden so that the bar can be
 * used to calculate the label anchor point.
 *
 * @param g2  the graphics device.//from   w  w w. j  a  va 2 s .  c  o  m
 * @param data  the dataset.
 * @param row  the row.
 * @param column  the column.
 * @param plot  the plot.
 * @param generator  the label generator.
 * @param bar  the bar.
 * @param negative  a flag indicating a negative value.
 */
protected void drawItemLabel(Graphics2D g2, CategoryDataset data, int row, int column, CategoryPlot plot,
        CategoryItemLabelGenerator generator, Rectangle2D bar, boolean negative) {

    String label = generator.generateLabel(data, row, column);
    if (label == null) {
        return; // nothing to do
    }

    Font labelFont = getItemLabelFont(row, column);
    g2.setFont(labelFont);
    Paint paint = getItemLabelPaint(row, column);
    g2.setPaint(paint);

    // find out where to place the label...
    ItemLabelPosition position = null;
    if (!negative) {
        position = getPositiveItemLabelPosition(row, column);
    } else {
        position = getNegativeItemLabelPosition(row, column);
    }

    // work out the label anchor point...
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());

    if (isInternalAnchor(position.getItemLabelAnchor())) {
        Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(),
                (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());

        if (bounds != null) {
            if (!bar.contains(bounds.getBounds2D())) {
                if (!negative) {
                    position = getPositiveItemLabelPositionFallback();
                } else {
                    position = getNegativeItemLabelPositionFallback();
                }
                if (position != null) {
                    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar,
                            plot.getOrientation());
                }
            }
        }

    }

    if (position != null) {
        TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Handles a 'mouse pressed' event./* ww  w  .j  a v a  2s .  c om*/
 * <P>
 * This event is the popup trigger on Unix/Linux. For Windows, the popup trigger is the 'mouse
 * released' event.
 * 
 * @param e
 *            The mouse event.
 */

@Override
public void mousePressed(MouseEvent e) {
    if (this.chart == null) {
        return;
    }
    Plot plot = this.chart.getPlot();
    int mods = e.getModifiers();
    if ((mods & this.panMask) == this.panMask) {
        // can we pan this plot?
        if (plot instanceof Pannable) {
            Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());
            if (screenDataArea != null && screenDataArea.contains(e.getPoint())) {
                this.panW = screenDataArea.getWidth();
                this.panH = screenDataArea.getHeight();
                this.panLast = e.getPoint();
                setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
            }
        }
    } else if (this.selectionRectangle == null) {
        Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());
        if (screenDataArea != null) {
            this.zoomPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea);
        } else {
            this.zoomPoint = null;
        }
        if (e.isPopupTrigger()) {
            if (this.popup != null) {
                displayPopupMenu(e.getX(), e.getY());
            }
        }
    }
}