Class JtvRect
public class JtvRect
A rectangle defined by two JtvPoint corner coordinates.
Field a holds the upper-left corner and b holds the lower-right corner.
Every JT Vision view is rectangular: their constructors accept a JtvRect parameter
(conventionally named Bounds) that determines the region the view covers.
TRect objects are not views themselves and cannot draw.
The rectangle [a=(2,2), b=(5,4)] covers 3 columns × 2 rows and contains 6 cells.
A rectangle with a == b has no area (isEmpty() returns true).
org.viktor44.jtvision.core.JtvRect
Summary
Constructors
| Visibility | Signature |
|---|---|
| public | JtvRect() |
| public | JtvRect(int ax, int ay, int bx, int by) |
| public | JtvRect(JtvPoint p1, JtvPoint p2) |
| public | JtvRect(JtvRect other) |
Fields
| Modifiers | Field name | Type |
|---|---|---|
| private | a | org.viktor44.jtvision.core.JtvPoint |
| private | b | org.viktor44.jtvision.core.JtvPoint |
Methods
| Modifiers | Method signature | Return type |
|---|---|---|
| public | getCopy() | org.viktor44.jtvision.core.JtvRect |
| public | move(int dx, int dy) | org.viktor44.jtvision.core.JtvRect |
| public | grow(int dx, int dy) | org.viktor44.jtvision.core.JtvRect |
| public | intersect(JtvRect r) | org.viktor44.jtvision.core.JtvRect |
| public | union(JtvRect r) | org.viktor44.jtvision.core.JtvRect |
| public | contains(JtvPoint p) | boolean |
| public | isEmpty() | boolean |
| public | assign(JtvRect other) | void |
| public | toString() | String |
| public | getAx() | int |
| public | getAy() | int |
| public | getBx() | int |
| public | getBy() | int |
| public | equals(Object o) | boolean |
| protected | canEqual(Object other) | boolean |
| public | hashCode() | int |
| public | getA() | org.viktor44.jtvision.core.JtvPoint |
| public | setA(JtvPoint a) | void |
| public | getB() | org.viktor44.jtvision.core.JtvPoint |
| public | setB(JtvPoint b) | void |
Constructors
JtvRect()
Constructs a zero-sized rectangle at the origin.
JtvRect(int ax, int ay, int bx, int by)
Constructs a rectangle from raw coordinates.
Parameters
ax- upper-left Xay- upper-left Ybx- lower-right Xby- lower-right Y
JtvRect(JtvPoint p1, JtvPoint p2)
Constructs a rectangle from two points.
Parameters
p1- upper-left cornerp2- lower-right corner
JtvRect(JtvRect other)
Copy constructor.
Parameters
other- rectangle to copy
Fields
org.viktor44.jtvision.core.JtvPoint a
Upper-left corner of the rectangle.
org.viktor44.jtvision.core.JtvPoint b
Lower-right corner of the rectangle (exclusive boundary).
Methods
getCopy()
Returns a deep copy of this rectangle.
move(int dx, int dy)
Translates this rectangle by the given delta, modifying it in place.
Parameters
dx- horizontal offsetdy- vertical offset
Returns
this, for chaining
grow(int dx, int dy)
Expands (or shrinks) this rectangle symmetrically by the given amounts.
Corner a is moved by (-dx, -dy) and b by (+dx, +dy).
Parameters
dx- horizontal expansion (negative to shrink)dy- vertical expansion (negative to shrink)
Returns
this, for chaining
intersect(JtvRect r)
Clips this rectangle to the overlap with r, modifying it in place.
If the rectangles do not overlap the result will satisfy isEmpty().
Parameters
r- the clipping rectangle
Returns
this, for chaining
union(JtvRect r)
Expands this rectangle to the smallest bounding box that contains both this rectangle
and r, modifying it in place.
Parameters
r- the rectangle to include
Returns
this, for chaining
contains(JtvPoint p)
Returns true if point p lies strictly inside this rectangle
(i.e. a.x <= p.x < b.x and a.y <= p.y < b.y).
Parameters
p- the point to test
Returns
true if the point is contained
isEmpty()
Returns true if the rectangle has zero or negative area
(a.x >= b.x or a.y >= b.y).
Returns
true if empty
assign(JtvRect other)
Copies the corners of other into this rectangle.
Parameters
other- source rectangle
toString()
Overrides:
toString() in java.lang.Object
No method description provided
getAx()
No method description provided
getAy()
No method description provided
getBx()
No method description provided
getBy()
No method description provided
equals(Object o)
No method description provided
Parameters
o
canEqual(Object other)
No method description provided
Parameters
other
hashCode()
Overrides:
hashCode() in java.lang.Object
No method description provided
getA()
Upper-left corner of the rectangle.
setA(JtvPoint a)
Upper-left corner of the rectangle.
Parameters
a
getB()
Lower-right corner of the rectangle (exclusive boundary).
setB(JtvPoint b)
Lower-right corner of the rectangle (exclusive boundary).
Parameters
b