X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fcom%2Fthreerings%2Fgetdown%2Futil%2FRectangle.java;fp=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fcom%2Fthreerings%2Fgetdown%2Futil%2FRectangle.java;h=3671d7d4ea2f1e8ea7e4c0c4c29bdb463ab68739;hb=ca8504cf9d10874dce9f07cf7a9d933853fe0dd0;hp=0000000000000000000000000000000000000000;hpb=775e7bc104584e88dddcea73fbf02c66f5200c16;p=jalview.git diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/Rectangle.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/Rectangle.java new file mode 100644 index 0000000..3671d7d --- /dev/null +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/Rectangle.java @@ -0,0 +1,40 @@ +// +// Getdown - application installer, patcher and launcher +// Copyright (C) 2004-2018 Getdown authors +// https://github.com/threerings/getdown/blob/master/LICENSE + +package com.threerings.getdown.util; + +/** + * An immutable rectangle. + */ +public class Rectangle +{ + public final int x; + public final int y; + public final int width; + public final int height; + + public Rectangle (int x, int y, int width, int height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public Rectangle union (Rectangle other) { + int x1 = Math.min(x, other.x); + int x2 = Math.max(x + width, other.x + other.width); + int y1 = Math.min(y, other.y); + int y2 = Math.max(y + height, other.y + other.height); + return new Rectangle(x1, y1, x2 - x1, y2 - y1); + } + + /** {@inheritDoc} */ + public String toString () + { + return getClass().getName() + "[x=" + x + ", y=" + y + + ", width=" + width + ", height=" + height + "]"; + } +}