Java tutorial
//package com.java2s; //License from project: Apache License import java.awt.*; public class Main { public static Rectangle getRectangle(Point p1, Point p2) { return new Rectangle(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y), Math.abs(p1.x - p2.x), Math.abs(p1.y - p2.y)); } }