View Javadoc
1   package au.gov.amsa.gt;
2   
3   public class Rect {
4   
5       private final double minX;
6       private final double minY;
7       private final double maxX;
8       private final double maxY;
9   
10      public Rect(double minX, double minY, double maxX, double maxY) {
11          this.minX = minX;
12          this.minY = minY;
13          this.maxX = maxX;
14          this.maxY = maxY;
15      }
16  
17      public double minX() {
18          return minX;
19      }
20  
21      public double minY() {
22          return minY;
23      }
24  
25      public double maxX() {
26          return maxX;
27      }
28  
29      public double maxY() {
30          return maxY;
31      }
32  
33      public Rect add(Rect r) {
34          return new Rect(Math.min(minX, r.minX), //
35                  Math.min(minY, r.minY), //
36                  Math.max(maxX, r.maxX), //
37                  Math.max(maxY, r.maxY) //
38          );
39      }
40  
41      @Override
42      public String toString() {
43          return "Rect [minX=" + minX + ", minY=" + minY + ", maxX=" + maxX + ", maxY=" + maxY + "]";
44      }
45  
46  }