Example usage for java.awt.geom Rectangle2D getMaxY

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

Introduction

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

Prototype

public double getMaxY() 

Source Link

Document

Returns the largest Y coordinate of the framing rectangle of the Shape in double precision.

Usage

From source file:com.zilbo.flamingSailor.TE.model.Component.java

public boolean onSameLine(Rectangle2D otherGeom) {

    Double y1 = this.geom.getMinY();
    Double y3 = this.geom.getMaxY();
    Double y2 = otherGeom.getMinY();
    Double y4 = otherGeom.getMaxY();

    // we have some kind of crossover.
    if (y1 <= y4 && y1 >= y2) {
        // AND the boxes are touching
        if (Math.abs(this.geom.getMinX() - otherGeom.getMaxX()) < 0.5
                || (this.geom.getMaxX() - otherGeom.getMinX()) < 0.5) {
            // assume it's a super/subscript letter and call it the same line.
            return true;
        }//from ww w. j a  v a  2 s .  com

    }
    // we have some kind of crossover.
    if (y2 <= y3 && y2 >= y1) {
        // AND the boxes are touching
        //   logger.info(this.geom.getMinX() - otherGeom.getMaxX());
        if (Math.abs(this.geom.getMinX() - otherGeom.getMaxX()) < 0.5
                || (this.geom.getMaxX() - otherGeom.getMinX()) < 0.5) {
            // assume it's a super/subscript letter and call it the same line.
            return true;
        }

    }
    double yAveT = (y2 + y4) / 2;
    //   double diff = (y4-y2)/4;
    if ((y1 <= (yAveT)) && ((yAveT) < y3)) {
        return true;
    }
    yAveT = (y1 + y3) / 2;
    return (y2 <= yAveT) && (yAveT < y4);

}

From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.ZoomHandlerFX.java

/**
 * Handles a mouse dragged event by updating the zoom rectangle displayed
 * in the ChartViewer./*from w w  w  .  j  a va2 s.c  om*/
 * 
 * @param canvas  the JavaFX canvas (<code>null</code> not permitted).
 * @param e  the mouse event (<code>null</code> not permitted).
 */
@Override
public void handleMouseDragged(ChartCanvas canvas, MouseEvent e) {
    if (this.startPoint == null) {
        //no initial zoom rectangle exists but the handler is set
        //as life handler unregister
        canvas.clearLiveHandler();
        return;
    }

    boolean hZoom, vZoom;
    Plot p = canvas.getChart().getPlot();
    if (!(p instanceof Zoomable)) {
        return;
    }
    Zoomable z = (Zoomable) p;
    if (z.getOrientation().isHorizontal()) {
        hZoom = z.isRangeZoomable();
        vZoom = z.isDomainZoomable();
    } else {
        hZoom = z.isDomainZoomable();
        vZoom = z.isRangeZoomable();
    }
    Rectangle2D dataArea = canvas.findDataArea(this.startPoint);

    double x = this.startPoint.getX();
    double y = this.startPoint.getY();
    double w = 0;
    double h = 0;
    if (hZoom && vZoom) {
        // selected rectangle shouldn't extend outside the data area...
        double xmax = Math.min(e.getX(), dataArea.getMaxX());
        double ymax = Math.min(e.getY(), dataArea.getMaxY());
        w = xmax - this.startPoint.getX();
        h = ymax - this.startPoint.getY();
    } else if (hZoom) {
        double xmax = Math.min(e.getX(), dataArea.getMaxX());
        y = dataArea.getMinY();
        w = xmax - this.startPoint.getX();
        h = dataArea.getHeight();
    } else if (vZoom) {
        double ymax = Math.min(e.getY(), dataArea.getMaxY());
        x = dataArea.getMinX();
        w = dataArea.getWidth();
        h = ymax - this.startPoint.getY();
    }
    viewer.showZoomRectangle(x, y, w, h);
}

From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java

private static void drawMaskBoarder(Graphics2D g2, Abstract2DMask mask) {
    g2.setPaint(Color.orange);/*from w w w .j  ava2  s . c  om*/
    g2.setStroke(new BasicStroke(1));
    Rectangle2D frame = mask.getRectangleFrame();
    g2.draw(frame);
    Rectangle2D dragPoint = new Rectangle2D.Double(frame.getMinX() - maskDragPointHalfWidth,
            frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    Color fillColor = new Color(250, 250, 50, 10);
    g2.setPaint(fillColor);
    g2.fill(mask.getShape());
}

From source file:edu.ucla.stat.SOCR.chart.gui.CircleDrawer.java

/**
 * Draws the circle.// ww  w. j a  v  a  2s .c o m
 * 
 * @param g2  the graphics device.
 * @param area  the area in which to draw.
 */
public void draw(Graphics2D g2, Rectangle2D area) {
    Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight());
    if (this.fillPaint != null) {
        g2.setPaint(this.fillPaint);
        g2.fill(ellipse);
    }
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
        g2.draw(ellipse);
    }

    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1.0f));
    Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(), area.getMaxY());
    Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(), area.getCenterY());
    g2.draw(line1);
    g2.draw(line2);
}

From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java

public static void drawMaskBoarder(Graphics2D g2, Rectangle2D frame) {
    g2.setPaint(Color.orange);//from www . j a  va  2  s  .c  o  m
    g2.setStroke(new BasicStroke(1));
    g2.draw(frame);
    Rectangle2D dragPoint = new Rectangle2D.Double(frame.getMinX() - maskDragPointHalfWidth,
            frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth,
            maskDragPointWidth, maskDragPointWidth);
    g2.fill(dragPoint);
    Color fillColor = new Color(250, 250, 50, 30);
    g2.setPaint(fillColor);
    g2.fill(frame);
}

From source file:org.jfree.chart.demo.CircleDrawer.java

/**
 * Draws the circle.// ww w . j  a  v  a2s.  co  m
 * 
 * @param g2  the graphics device.
 * @param area  the area in which to draw.
 */
public void draw(final Graphics2D g2, final Rectangle2D area) {
    final Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight());
    if (this.fillPaint != null) {
        g2.setPaint(this.fillPaint);
        g2.fill(ellipse);
    }
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
        g2.draw(ellipse);
    }

    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1.0f));
    final Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(),
            area.getMaxY());
    final Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(),
            area.getCenterY());
    g2.draw(line1);
    g2.draw(line2);
}

From source file:Clip.java

/**
 * Intersect this clip with another region. As a result, this
 * clip will become the intersecting area of the two regions.
 * @param r the rectangle to intersect with
 *///from w  w w  .j ava2s . com
public void intersection(Rectangle2D r) {
    if (status == INVALID)
        return;
    if (status == EMPTY) {
        setClip(r);
        status = INUSE;
        return;
    }
    clip[0] = Math.max(clip[0], r.getMinX());
    clip[1] = Math.max(clip[1], r.getMinY());
    clip[6] = Math.min(clip[6], r.getMaxX());
    clip[7] = Math.min(clip[7], r.getMaxY());
}

From source file:org.esa.snap.rcp.statistics.ProfilePlotPanel.java

private ChartPanel createChartPanel(JFreeChart chart) {
    profilePlotDisplay = new ChartPanel(chart);

    MaskSelectionToolSupport maskSelectionToolSupport = new MaskSelectionToolSupport(this, profilePlotDisplay,
            "profile_plot_area", "Mask generated from selected profile plot area", Color.RED,
            PlotAreaSelectionTool.AreaType.Y_RANGE) {

        @Override//w w  w .j av a  2  s .  co  m
        protected String createMaskExpression(PlotAreaSelectionTool.AreaType areaType, Shape shape) {
            Rectangle2D bounds = shape.getBounds2D();
            return createMaskExpression(bounds.getMinY(), bounds.getMaxY());
        }

        protected String createMaskExpression(double x1, double x2) {
            String bandName = BandArithmetic.createExternalName(getRaster().getName());
            return String.format("%s >= %s && %s <= %s", bandName, x1, bandName, x2);
        }
    };

    profilePlotDisplay.addChartMouseListener(new XYPlotMarker(profilePlotDisplay, new XYPlotMarker.Listener() {
        @Override
        public void pointSelected(XYDataset xyDataset, int seriesIndex, Point2D dataPoint) {
            if (profileData != null) {
                GeoPos[] geoPositions = profileData.getGeoPositions();
                int index = (int) dataPoint.getX();
                if (index >= 0 && index < geoPositions.length) {
                    if (cursorSynchronizer == null) {
                        cursorSynchronizer = new DefaultCursorSynchronizer();
                    }
                    if (!cursorSynchronizer.isEnabled()) {
                        cursorSynchronizer.setEnabled(true);
                    }
                    cursorSynchronizer.updateCursorOverlays(geoPositions[index]);
                }
            }
        }

        @Override
        public void pointDeselected() {
            cursorSynchronizer.setEnabled(false);
        }
    }));
    profilePlotDisplay.setInitialDelay(200);
    profilePlotDisplay.setDismissDelay(1500);
    profilePlotDisplay.setReshowDelay(200);
    profilePlotDisplay.setZoomTriggerDistance(5);
    profilePlotDisplay.getPopupMenu().addSeparator();
    profilePlotDisplay.getPopupMenu().add(maskSelectionToolSupport.createMaskSelectionModeMenuItem());
    profilePlotDisplay.getPopupMenu().add(maskSelectionToolSupport.createDeleteMaskMenuItem());
    profilePlotDisplay.getPopupMenu().addSeparator();
    profilePlotDisplay.getPopupMenu().add(createCopyDataToClipboardMenuItem());

    return profilePlotDisplay;
}

From source file:org.esa.beam.visat.toolviews.stat.ProfilePlotPanel.java

private ChartPanel createChartPanel(JFreeChart chart) {
    profilePlotDisplay = new ChartPanel(chart);

    MaskSelectionToolSupport maskSelectionToolSupport = new MaskSelectionToolSupport(this, profilePlotDisplay,
            "profile_plot_area", "Mask generated from selected profile plot area", Color.RED,
            PlotAreaSelectionTool.AreaType.Y_RANGE) {

        @Override//from  w ww.  j av  a2  s .c om
        protected String createMaskExpression(PlotAreaSelectionTool.AreaType areaType, Shape shape) {
            Rectangle2D bounds = shape.getBounds2D();
            return createMaskExpression(bounds.getMinY(), bounds.getMaxY());
        }

        protected String createMaskExpression(double x1, double x2) {
            String bandName = BandArithmetic.createExternalName(getRaster().getName());
            return String.format("%s >= %s && %s <= %s", bandName, x1, bandName, x2);
        }
    };

    profilePlotDisplay.addChartMouseListener(new XYPlotMarker(profilePlotDisplay, new XYPlotMarker.Listener() {
        @Override
        public void pointSelected(XYDataset xyDataset, int seriesIndex, Point2D dataPoint) {
            if (profileData != null) {
                GeoPos[] geoPositions = profileData.getGeoPositions();
                int index = (int) dataPoint.getX();
                if (index >= 0 && index < geoPositions.length) {
                    if (cursorSynchronizer == null) {
                        cursorSynchronizer = new CursorSynchronizer(VisatApp.getApp());
                    }
                    if (!cursorSynchronizer.isEnabled()) {
                        cursorSynchronizer.setEnabled(true);
                    }
                    cursorSynchronizer.updateCursorOverlays(geoPositions[index]);
                }
            }
        }

        @Override
        public void pointDeselected() {
            cursorSynchronizer.setEnabled(false);
        }
    }));
    profilePlotDisplay.setInitialDelay(200);
    profilePlotDisplay.setDismissDelay(1500);
    profilePlotDisplay.setReshowDelay(200);
    profilePlotDisplay.setZoomTriggerDistance(5);
    profilePlotDisplay.getPopupMenu().addSeparator();
    profilePlotDisplay.getPopupMenu().add(maskSelectionToolSupport.createMaskSelectionModeMenuItem());
    profilePlotDisplay.getPopupMenu().add(maskSelectionToolSupport.createDeleteMaskMenuItem());
    profilePlotDisplay.getPopupMenu().addSeparator();
    profilePlotDisplay.getPopupMenu().add(createCopyDataToClipboardMenuItem());

    return profilePlotDisplay;
}

From source file:com.projity.pm.graphic.xbs.XbsLayout.java

protected int updateBounds(Point2D origin, Rectangle2D ref) {//cache in current version isn't a tree
    double x = origin.getX() + ref.getWidth() / 2;
    double y = origin.getY() + ref.getHeight() / 2;
    GraphicNode node, previous = null;/*from  www.  jav  a 2 s .  c  o  m*/
    int maxLevel = 0;
    for (ListIterator i = cache.getIterator(); i.hasNext();) {
        node = (GraphicNode) i.next();
        if (node.getLevel() > maxLevel)
            maxLevel = node.getLevel();
        if (previous != null && node.getLevel() <= previous.getLevel()) {
            setShape(previous, ref, x, y + (previous.getLevel() - 1) * (ref.getMaxY()));
            x += ref.getMaxX();
        }
        previous = node;
    }
    if (previous != null) {
        setShape(previous, ref, x, y + (previous.getLevel() - 1) * (ref.getMaxY()));
    }
    return maxLevel;
}