2 // Getdown - application installer, patcher and launcher
3 // Copyright (C) 2004-2018 Getdown authors
4 // https://github.com/threerings/getdown/blob/master/LICENSE
6 package com.threerings.getdown.util;
9 * An immutable rectangle.
11 public class Rectangle
15 public final int width;
16 public final int height;
18 public Rectangle (int x, int y, int width, int height)
26 public Rectangle union (Rectangle other) {
27 int x1 = Math.min(x, other.x);
28 int x2 = Math.max(x + width, other.x + other.width);
29 int y1 = Math.min(y, other.y);
30 int y2 = Math.max(y + height, other.y + other.height);
31 return new Rectangle(x1, y1, x2 - x1, y2 - y1);
35 public String toString ()
37 return getClass().getName() + "[x=" + x + ", y=" + y +
38 ", width=" + width + ", height=" + height + "]";