public class Rectangle
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private double |
bottom
Rectangle bottom row.
|
private double |
left
Rectangle left column.
|
private double |
right
Rectangle right column.
|
private double |
top
Rectangle top row.
|
Constructor and Description |
---|
Rectangle(double top,
double left,
double bottom,
double right)
Constructor.
|
Rectangle(Point topleft,
Dimension size,
Point baseUnits)
Constructor.
|
Rectangle(Rectangle rect)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
bottom()
Get bottom coordinate of this rectangle.
|
boolean |
contains(double x,
double y)
Returns
true if the specified point is inside this
rectangle. |
boolean |
contains(Point p)
Returns
true if the specified point is inside this
rectangle. |
boolean |
contains(Rectangle r)
Returns
true is specified rectangle is completely inside
this rectangle. |
boolean |
empty()
Check if rectangle is empty.
|
boolean |
equals(java.lang.Object obj) |
boolean |
equals(Rectangle rect)
Check if this rectangle is equal to specified one.
|
int |
hashCode()
Compute the hashcode of this rectangle.
|
double |
height(Point baseUnits)
Returns the rectangle's height.
|
Rectangle |
intersection(Rectangle rect)
Calculate rectangle which is intersection between this and specified
rectangle.
|
boolean |
intersects(Rectangle rect)
Check if this and specified rectangle have intersection.
|
double |
left()
Get left coordinate of this rectangle.
|
double |
right()
Get right coordinate of this rectangle.
|
double |
top()
Get top coordinate of this rectangle.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
Rectangle |
translate(double dx,
double dy)
Create new rectangle which is translated by specified offset.
|
Rectangle |
translate(Point p)
Create new rectangle which is translated by specified offset.
|
Rectangle |
union(Rectangle rect)
Create new rectangle which is a union of this and specified rectangle.
|
double |
width(Point baseUnits)
Returns the rectangle's width.
|
private final double bottom
private final double left
private final double right
private final double top
public Rectangle(double top, double left, double bottom, double right)
top
- Top row.left
- Left column.bottom
- Bottom row.right
- Right column.public Rectangle(Point topleft, Dimension size, Point baseUnits)
topleft
- Top-left corner.size
- Rectangle dimension.baseUnits
- The base units for this rectangle.public Rectangle(Rectangle rect)
rect
- Source rectangle.public double bottom()
public boolean contains(double x, double y)
true
if the specified point is inside this
rectangle.x
- X coordinate.y
- Y coordinate.true
if coordinates are inside rectangle.public boolean contains(Point p)
true
if the specified point is inside this
rectangle.p
- Point to check.true
if specified point is inside rectangle.public boolean contains(Rectangle r)
true
is specified rectangle is completely inside
this rectangle.r
- Rectangle to check.true
if specified rectangle is inside this
rectangle.public boolean empty()
true
if rectangle is empty.public boolean equals(Rectangle rect)
rect
- Rectangle to check.true
if rectangles are equal.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public Rectangle intersection(Rectangle rect)
rect
- Source rectangle.null
if there is no intersection.public boolean intersects(Rectangle rect)
rect
- Source rectangle.true
if rectangles have intersection.public double left()
public double right()
public double top()
public Rectangle translate(double dx, double dy)
dx
- Delta X.dy
- Delta Y.public Rectangle translate(Point p)
p
- Offset represented as a point.public Rectangle union(Rectangle rect)
rect
- Source rectangle.public double width(Point baseUnits)
Because the rectangle's coordinates are inclusive and base units differ in ChUI and GUI, they must be provided in the only parameter.
baseUnits
- Reference to Point
instance representing the
base units.public double height(Point baseUnits)
Because the rectangle's coordinates are inclusive and base units differ in ChUI and GUI, they must be provided in the only parameter.
baseUnits
- Reference to Point
instance representing the
base units.public java.lang.String toString()
toString
in class java.lang.Object