Here you can find the source of rectFromArray(Rectangle2D aRectangle, double[] pts)
private static void rectFromArray(Rectangle2D aRectangle, double[] pts)
//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); } }