|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.geom.YDimension y.geom.YRectangle
public class YRectangle
This class defines a rectangle and provides utility methods for it.
Field Summary | |
---|---|
double |
x
The x coordinate of the upper left corner. |
double |
y
The y coordinate of the upper left corner. |
Fields inherited from class y.geom.YDimension |
---|
height, width |
Constructor Summary | |
---|---|
YRectangle()
Creates a new rectangle with upper left corner (0,0) and size (0,0). |
|
YRectangle(double x,
double y,
double width,
double height)
Creates a new rectangle with given upper left corner and size. |
|
YRectangle(YPoint pos,
YDimension size)
Creates a new rectangle with given upper left corner and size. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
|
boolean |
contains(double x,
double y)
Checks whether or not this YRectangle contains the
given point. |
boolean |
contains(double x,
double y,
double width,
double height)
Checks whether or not this YRectangle contains the
rectangle defined by the given frame. |
static boolean |
contains(double rx,
double ry,
double rw,
double rh,
double x,
double y)
Determines whether the specified rectangle contains the specified point. |
static boolean |
contains(double rx,
double ry,
double rw,
double rh,
double x,
double y,
boolean closed)
Determines whether the specified rectangle contains the specified point. |
boolean |
contains(YPoint p)
Checks whether or not this YRectangle contains the
given point. |
boolean |
contains(YRectangle p)
Checks whether or not this YRectangle contains the
given rectangle. |
boolean |
equals(java.lang.Object o)
Tests a dimension to equality to another dimension. |
YRectangle |
getBoundingBox()
Returns this object. |
double |
getEuclideanDistance(YRectangle other)
Returns the Euclidean distance to the passed rectangle. |
YPoint |
getLocation()
Returns coordinates of upper left corner. |
double |
getManhattanDistance(YRectangle other)
Returns the Manhattan distance to the passed rectangle. |
double |
getX()
Returns x-coordinate of upper left corner. |
double |
getY()
Returns y-coordinate of upper left corner. |
int |
hashCode()
|
static boolean |
intersects(YRectangle r1,
YRectangle r2)
Returns whether or not the given rectangles intersect. |
java.lang.String |
toString()
Returns a string representation of this rectangle |
Methods inherited from class y.geom.YDimension |
---|
getHeight, getWidth |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final double x
public final double y
Constructor Detail |
---|
public YRectangle()
public YRectangle(YPoint pos, YDimension size)
pos
- upper left corner of the rectangle.size
- size of the rectangle.public YRectangle(double x, double y, double width, double height)
x
- x-coordinate of upper left corner of the rectangle.y
- y-coordinate of upper left corner of the rectangle.width
- width of the rectangle.height
- height of the rectangle.Method Detail |
---|
public double getManhattanDistance(YRectangle other)
other
- the second rectangle.
public double getEuclideanDistance(YRectangle other)
other
- the second rectangle.
public final double getX()
public final double getY()
public final YPoint getLocation()
public YRectangle getBoundingBox()
getBoundingBox
in interface PlaneObject
public boolean contains(double x, double y)
YRectangle
contains the
given point.
x
- the x-coordinate of the point to check.y
- the x-coordinate of the point to check.
true
if the point lies inside the rectangle;
false
otherwise.public static boolean contains(double rx, double ry, double rw, double rh, double x, double y)
rx
- the x-coordinate of the upper left corner of the rectangle.ry
- the y-coordinate of the upper left corner of the rectangle.rw
- the width of the rectangle.rh
- the height of the rectangle.x
- the x-coordinate of the point to check.y
- the x-coordinate of the point to check.
true
if the point lies inside the rectangle;
false
otherwise.public static boolean contains(double rx, double ry, double rw, double rh, double x, double y, boolean closed)
rx
- the x-coordinate of the upper left corner of the rectangle.ry
- the y-coordinate of the upper left corner of the rectangle.rw
- the width of the rectangle.rh
- the height of the rectangle.x
- the x-coordinate of the point to check.y
- the x-coordinate of the point to check.closed
- if true
, all points on the border of the rectangle are considered to be
contained, otherwise, points on the top and left borders are considered to
be contained while points on the bottom and right borders are not
(this behavior matches Rectangle2D.contains(double, double)
).
true
if the point lies inside the rectangle;
false
otherwise.public boolean contains(YPoint p)
YRectangle
contains the
given point.
public boolean contains(YRectangle p)
YRectangle
contains the
given rectangle.
public boolean contains(double x, double y, double width, double height)
YRectangle
contains the
rectangle defined by the given frame.
public static boolean intersects(YRectangle r1, YRectangle r2)
public java.lang.String toString()
toString
in class YDimension
public int hashCode()
hashCode
in class YDimension
public boolean equals(java.lang.Object o)
YDimension
equals
in class YDimension
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
compareTo
in class YDimension
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |