public class Rectangular extends 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(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(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 |
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) |
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(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 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 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)
Copyright © 2015. All rights reserved.