Java Rectangle rectFromArray(Rectangle2D aRectangle, double[] pts)

Here you can find the source of rectFromArray(Rectangle2D aRectangle, double[] pts)

Description

rect From Array

License

BSD License

Declaration

private static void rectFromArray(Rectangle2D aRectangle, double[] pts) 

Method Source Code

//package com.java2s;
/*   TouchStone run platform is a software to run lab experiments. It is         *
 *   published under the terms of a BSD license (see details below)              *
 *   Author: Caroline Appert (appert@lri.fr)                                     *
 *   Copyright (c) 2010 Caroline Appert and INRIA, France.                       *
 *   TouchStone run platform reuses parts of an early version which were         *
 *   programmed by Jean-Daniel Fekete under the terms of a MIT (X11) Software    *
 *   License (Copyright (C) 2006 Jean-Daniel Fekete and INRIA, France)           *
 *********************************************************************************/

import java.awt.geom.Rectangle2D;

public class Main {
    private static void rectFromArray(Rectangle2D aRectangle, double[] pts) {
        double minX = pts[0];
        double minY = pts[1];
        double maxX = pts[0];
        double maxY = pts[1];

        double x;
        double y;

        for (int i = 1; i < 4; i++) {
            x = pts[2 * i];//from w  w w. j  ava  2 s  .co  m
            y = pts[(2 * i) + 1];

            if (x < minX) {
                minX = x;
            }
            if (y < minY) {
                minY = y;
            }
            if (x > maxX) {
                maxX = x;
            }
            if (y > maxY) {
                maxY = y;
            }
        }
        aRectangle.setRect(minX, minY, maxX - minX, maxY - minY);
    }
}

Related

  1. randomRectangle(int minW, int maxW, int minH, int maxH)
  2. randomSquare(int minW, int maxW)
  3. rectangleResize(Rectangle rect, int width, int height)
  4. rectCollide(final Rectangle a, final Rectangle b)
  5. rectDistance(final Rectangle r, final Rectangle q)
  6. rectFromRect2D(Rectangle2D rect)
  7. resetPosition(Window window1, Window window2)
  8. right(Rectangle r)
  9. size(final Component component)