JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
RectangleImmutable.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.nativewindow.util;
30
31import java.util.List;
32
33import com.jogamp.common.type.WriteCloneable;
34
35/** Immutable Rectangle interface, with its position on the top-left. */
36public interface RectangleImmutable extends WriteCloneable, Comparable<RectangleImmutable> {
37
38 int getHeight();
39
40 int getWidth();
41
42 /** x-position, left of rectangle. */
43 int getX();
44
45 /** y-position, top of rectangle. */
46 int getY();
47
48 /** Returns a new {@link Rectangle} instance containing the union of this rectangle and the given rectangle. */
50 /** Returns a new {@link Rectangle} instance containing the union of this rectangle and the given coordinates. */
51 Rectangle union(final int rx1, final int ry1, final int rx2, final int ry2);
52 /**
53 * Calculates the union of the given rectangles, stores it in this instance and returns this instance.
54 * @param rectangles given list of rectangles
55 * @return this instance holding the union of given rectangles.
56 */
57 Rectangle union(final List<RectangleImmutable> rectangles);
58
59 /** Returns a new {@link Rectangle} instance containing the intersection of this rectangle and the given rectangle. */
61 /** Returns a new {@link Rectangle} instance containing the intersection of this rectangle and the given coordinates. */
62 Rectangle intersection(final int rx1, final int ry1, final int rx2, final int ry2);
63 /**
64 * Returns the coverage of given rectangle w/ this this one, i.e. between <code>0.0</code> and <code>1.0</code>.
65 * <p>
66 * Coverage is computed by:
67 * <pre>
68 * isect = this.intersection(r);
69 * coverage = area( isect ) / area( this ) ;
70 * </pre>
71 * </p>
72 */
74
76
77 /**
78 * <p>
79 * Compares square of size 1st, if equal the square of position.
80 * </p>
81 * {@inheritDoc}
82 */
83 @Override
84 public int compareTo(final RectangleImmutable d);
85
86 /**
87 * Checks whether two rect objects are equal. Two instances
88 * of <code>Rectangle</code> are equal if the four integer values
89 * of the fields <code>y</code>, <code>x</code>,
90 * <code>height</code>, and <code>width</code> are all equal.
91 * @return <code>true</code> if the two rectangles are equal;
92 * otherwise <code>false</code>.
93 */
94 @Override
95 boolean equals(Object obj);
96
97 @Override
98 int hashCode();
99
100}
Immutable Rectangle interface, with its position on the top-left.
Rectangle union(final int rx1, final int ry1, final int rx2, final int ry2)
Returns a new Rectangle instance containing the union of this rectangle and the given coordinates.
Rectangle intersection(final int rx1, final int ry1, final int rx2, final int ry2)
Returns a new Rectangle instance containing the intersection of this rectangle and the given coordina...
Rectangle union(final List< RectangleImmutable > rectangles)
Calculates the union of the given rectangles, stores it in this instance and returns this instance.
Rectangle intersection(RectangleImmutable r)
Returns a new Rectangle instance containing the intersection of this rectangle and the given rectangl...
int getX()
x-position, left of rectangle.
boolean equals(Object obj)
Checks whether two rect objects are equal.
int getY()
y-position, top of rectangle.
float coverage(RectangleImmutable r)
Returns the coverage of given rectangle w/ this this one, i.e.
int compareTo(final RectangleImmutable d)
boolean contains(RectangleImmutable r)
Rectangle union(final RectangleImmutable r)
Returns a new Rectangle instance containing the union of this rectangle and the given rectangle.