public class Rectangular
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
x1 |
protected int |
x2 |
protected int |
y1 |
protected int |
y2 |
Constructor and Description |
---|
Rectangular() |
Rectangular(int x1,
int y1,
int x2,
int y2) |
Rectangular(java.awt.Rectangle src) |
Rectangular(Rectangular src) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(int x,
int y)
Checks if this rectangle contains a point.
|
void |
copy(Rectangular src) |
boolean |
encloses(Rectangular other)
Checks if this rectangle entirely contains another rectangle.
|
boolean |
enclosesX(Rectangular other)
Checks if this rectangle entirely contains the X coordinates of another rectangle.
|
boolean |
enclosesY(Rectangular other)
Checks if this rectangle entirely contains the Y coordinates of another rectangle.
|
boolean |
equals(java.lang.Object obj) |
void |
expandToEnclose(Rectangular other) |
int |
getArea() |
int |
getHeight() |
int |
getWidth() |
int |
getX1() |
int |
getX2() |
int |
getY1() |
int |
getY2() |
Rectangular |
hsplit(Rectangular other)
If this rectangle intersets with the other one, splits this rectangle horizontally so that it does not intersect with the other one anymore.
|
Rectangular |
intersection(Rectangular other) |
boolean |
intersects(Rectangular other) |
boolean |
intersectsX(Rectangular other) |
boolean |
intersectsY(Rectangular other) |
boolean |
isEmpty() |
int |
midX() |
int |
midY() |
Rectangular |
replaceX(Rectangular other)
Replaces the X coordinates of the rectangle with the X coordinates of another one.
|
Rectangular |
replaceY(Rectangular other)
Replaces the Y coordinates of the rectangle with the Y coordinates of another one.
|
void |
setX1(int x1) |
void |
setX2(int x2) |
void |
setY1(int y1) |
void |
setY2(int y2) |
java.lang.String |
toString() |
Rectangular |
vsplit(Rectangular other)
If this rectangle intersets with the other one, splits this rectangle horizontally so that it does not intersect with the other one anymore.
|
public Rectangular()
public Rectangular(int x1, int y1, int x2, int y2)
public Rectangular(Rectangular src)
public Rectangular(java.awt.Rectangle src)
public void copy(Rectangular src)
public int getX1()
public void setX1(int x1)
x1
- the x1 to setpublic int getX2()
public void setX2(int x2)
x2
- the x2 to setpublic int getY1()
public void setY1(int y1)
y1
- the y1 to setpublic int getY2()
public void setY2(int y2)
y2
- the y2 to setpublic int getWidth()
public int getHeight()
public int midX()
public int midY()
public int getArea()
public boolean isEmpty()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public boolean encloses(Rectangular other)
other
- the other rectanglepublic boolean enclosesX(Rectangular other)
other
- the other rectanglepublic boolean enclosesY(Rectangular other)
other
- the other rectanglepublic boolean contains(int x, int y)
x
- the point X coordinatey
- the point Y coordinatepublic boolean intersects(Rectangular other)
public boolean intersectsX(Rectangular other)
public boolean intersectsY(Rectangular other)
public Rectangular intersection(Rectangular other)
public Rectangular replaceX(Rectangular other)
other
- the rectangle whose X coordinates will be usedpublic Rectangular replaceY(Rectangular other)
other
- the rectangle whose Y coordinates will be usedpublic Rectangular hsplit(Rectangular other)
other
- the rectangle used to split this onepublic Rectangular vsplit(Rectangular other)
other
- the rectangle used to split this onepublic void expandToEnclose(Rectangular other)
public java.lang.String toString()
toString
in class java.lang.Object