Example usage for java.awt.geom Rectangle2D getMinX

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

Introduction

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

Prototype

public double getMinX() 

Source Link

Document

Returns the smallest X coordinate of the framing rectangle of the Shape in double precision.

Usage

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

public static Abstract2DMask translateChartRectangle(Abstract2DMask mask, Rectangle2D imageArea,
        JFreeChart chart) {//from w  w w  .  j a  v  a 2 s  .  c  o m
    Rectangle2D bound = mask.getRectangleFrame();
    Point2D start = new Point2D.Double(bound.getMinX(), bound.getMinY());
    Point2D end = new Point2D.Double(bound.getMaxX(), bound.getMaxY());
    Point2D screenStart = translateChartPoint(start, imageArea, chart);
    Point2D screenEnd = translateChartPoint(end, imageArea, chart);
    Abstract2DMask imageMask = mask.clone();
    imageMask.setRectangleFrame(new Rectangle2D.Double(Math.min(screenStart.getX(), screenEnd.getX()),
            Math.min(screenStart.getY(), screenEnd.getY()), Math.abs(screenStart.getX() - screenEnd.getX()),
            Math.abs(screenStart.getY() - screenEnd.getY())));
    return imageMask;
}

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

private static void drawMaskBoarder(Graphics2D g2, Abstract2DMask mask) {
    g2.setPaint(Color.orange);//from   ww w .  j  av  a  2 s  .  com
    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:org.gumtree.vis.mask.ChartMaskingUtilities.java

public static void drawMaskBoarder(Graphics2D g2, Rectangle2D frame) {
    g2.setPaint(Color.orange);//from   ww w. j a v a2 s .  co 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:ec.util.chart.swing.JTimeSeriesRendererSupport.java

private static Shape createShape(double x, double y, Rectangle2D hotspot) {
    Area result = new Area(new RoundRectangle2D.Double(hotspot.getX(), hotspot.getY(), hotspot.getWidth(),
            hotspot.getHeight(), 8, 8));

    boolean right = hotspot.getMinX() > x;

    Polygon po = new Polygon();
    po.addPoint(0, 0);// w  ww .jav  a2  s.  c  o  m
    po.addPoint(0, 10);
    po.addPoint(10, 0);
    AffineTransform af = new AffineTransform();
    if (right) {
        af.translate(hotspot.getX() - 7, hotspot.getY() + hotspot.getHeight() / 2);
        af.rotate(-Math.PI / 4);
    } else {
        af.translate(hotspot.getMaxX() + 7, hotspot.getY() + hotspot.getHeight() / 2);
        af.rotate(Math.PI * 3 / 4);
    }

    Shape shape = af.createTransformedShape(po);
    result.add(new Area(shape));
    return result;
}

From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartMouseAndMotionListener.java

/**
 * Returns a point based on (x, y) but constrained to be within the bounds
 * of the given rectangle.  This method could be moved to JCommon.
 *
 * @param x  the x-coordinate.// w w  w.j  av  a 2 s . c o m
 * @param y  the y-coordinate.
 * @param area  the rectangle (<code>null</code> not permitted).
 *
 * @return A point within the rectangle.
 */
protected Point getPointInRectangle(int x, int y, Rectangle2D area) {
    x = (int) Math.max(Math.ceil(area.getMinX()), Math.min(x, Math.floor(area.getMaxX())));
    y = (int) Math.max(Math.ceil(area.getMinY()), Math.min(y, Math.floor(area.getMaxY())));
    return new Point(x, y);
}

From source file:Bounce.java

/**
 * Moves the ball to the next position, reversing direction if it hits one of
 * the edges//from w  ww.ja v a  2 s.c  om
 */
public void move(Rectangle2D bounds) {
    x += dx;
    y += dy;
    if (x < bounds.getMinX()) {
        x = bounds.getMinX();
        dx = -dx;
    }
    if (x + XSIZE >= bounds.getMaxX()) {
        x = bounds.getMaxX() - XSIZE;
        dx = -dx;
    }
    if (y < bounds.getMinY()) {
        y = bounds.getMinY();
        dy = -dy;
    }
    if (y + YSIZE >= bounds.getMaxY()) {
        y = bounds.getMaxY() - YSIZE;
        dy = -dy;
    }
}

From source file:it.unibo.alchemist.model.implementations.linkingrules.ConnectionBeam.java

@Override
public Neighborhood<T> computeNeighborhood(final Node<T> center, final Environment<T> env) {
    final Neighborhood<T> normal = super.computeNeighborhood(center, env);
    if (oenv == null) {
        if (!(env instanceof Environment2DWithObstacles<?, ?>)) {
            return normal;
        }/*from w  w w.jav a2s  . c  om*/
        oenv = (Environment2DWithObstacles<?, ?>) env;
        obstacles.reset();
        oenv.getObstacles().forEach((obs) -> {
            /*
             * Doubles are prone to approximation errors. Use nextAfter to get rid of them
             */
            final Rectangle2D bounds = obs.getBounds2D();
            final double mx = nextAfter(bounds.getMinX(), java.lang.Double.NEGATIVE_INFINITY);
            final double my = nextAfter(bounds.getMinY(), java.lang.Double.NEGATIVE_INFINITY);
            final double ex = nextUp(bounds.getMaxX());
            final double ey = nextUp(bounds.getMaxY());
            obstacles.add(new Area(new Rectangle2D.Double(mx, my, ex - mx, ey - my)));
        });
    }
    if (!normal.isEmpty()) {
        final Position cp = env.getPosition(center);
        final List<Node<T>> neighs = normal.getNeighbors().stream().filter((neigh) -> {
            final Position np = env.getPosition(neigh);
            return !oenv.intersectsObstacle(cp, np) || projectedBeamOvercomesObstacle(cp, np);
        }).collect(ArrayList::new, (l, el) -> l.add(el), (l1, l2) -> l1.addAll(l2));
        return Neighborhoods.make(env, center, neighs);
    }
    return normal;
}

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

private double percentW(double x, Rectangle2D r) {
    return (x - r.getMinX()) / r.getWidth();
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.CustomLegendGraphic.java

@Override
public void draw(Graphics2D g2, Rectangle2D area) {

    area = trimMargin(area);//from   w  ww.  j a  v a  2  s. c  o  m
    drawBorder(g2, area);
    area = trimBorder(area);
    area = trimPadding(area);

    if (isLineVisible()) {
        Point2D location = RectangleAnchor.coordinates(area, getShapeLocation());
        Shape aLine = ShapeUtilities.createTranslatedShape(getLine(), getShapeAnchor(), location.getX(),
                location.getY());
        g2.setPaint(getLinePaint());
        g2.setStroke(getLineStroke());
        g2.draw(aLine);
    }

    if (isShapeVisible()) {
        Point2D location = RectangleAnchor.coordinates(area, getShapeLocation());

        Shape s = ShapeUtilities.createTranslatedShape(getShape(), getShapeAnchor(), location.getX(),
                location.getY());
        if (isShapeFilled()) {
            Paint p = getFillPaint();
            if (p instanceof GradientPaint) {
                GradientPaint gp = (GradientPaint) getFillPaint();
                p = getFillPaintTransformer().transform(gp, s);
            } else if (p instanceof LinearGradientPaint) {
                LinearGradientPaint gradient = (LinearGradientPaint) p;
                Rectangle2D bounds = s.getBounds2D();
                p = getTranslatedLinearGradientPaint(gradient,
                        new Point2D.Double(bounds.getMinX(), bounds.getMinY()),
                        new Point2D.Double(bounds.getMaxX(), bounds.getMaxY()), false);
            }
            g2.setPaint(p);
            g2.fill(s);
        }
        if (isShapeOutlineVisible()) {
            g2.setPaint(getOutlinePaint());
            g2.setStroke(getOutlineStroke());
            g2.draw(s);
        }
    }

}

From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartMouseAndMotionListener.java

/**
 * Draw a box to the left of the selected region, and one to the right, that together
 * encompass everything but the selection
 *
 *
 * @param selectedRegion//from   ww  w. j  ava 2s . co  m
 * @param stroke
 * @param color
 */
protected void drawAllButSelectedRegionHoriz(Rectangle2D selectedRegion, Stroke stroke, Color color,
        boolean xorMode, Graphics2D g2) {
    Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea();
    Rectangle2D firstBox = new Rectangle((int) scaledDataArea.getMinX(), (int) scaledDataArea.getMinY(),
            (int) (selectedRegion.getMinX() - scaledDataArea.getMinX()), (int) scaledDataArea.getMaxY());
    Rectangle2D secondBox = new Rectangle((int) selectedRegion.getMaxX(), (int) scaledDataArea.getMinY(),
            (int) (scaledDataArea.getMaxX() - selectedRegion.getMaxX()), (int) scaledDataArea.getMaxY());
    drawSelectedRegion(firstBox, stroke, color, xorMode, g2);
    drawSelectedRegion(secondBox, stroke, color, xorMode, g2);
}