|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrcssjava.geom.Rectangle
public class Rectangle
Implementation of 2d axis-parallel rectangle
Constructor Summary | |
---|---|
Rectangle()
Constructs a rectangle with all point at the origin |
|
Rectangle(double width,
double length)
Constructs a rectangle with the given width and length, and with center at the origin |
|
Rectangle(double width,
double length,
VecPosition center)
Constructs a rectangle with the given width and length, and center position |
|
Rectangle(VecPosition p1,
VecPosition p2)
Constructs a rectangle from two corners diagonal from each other |
Method Summary | |
---|---|
Rectangle |
add(double d)
Create a new rectangle shifted in x and y by the given value |
Rectangle |
add(VecPosition v)
Create a new rectangle shifted by the given vector |
java.util.Iterator<VecPosition> |
cornerIterator()
Get iterator over corners starting with the top-left and moving clockwise |
VecPosition |
getBottomLeft()
Get position of bottom-left corner |
VecPosition |
getBottomRight()
Get position of bottom-right corner |
LineSegment |
getBottomSide()
Get bottom edge |
double |
getBottomX()
Get x coordinate of bottom edge |
VecPosition |
getCenter()
Get center |
LineSegment |
getLeftSide()
Get left edge |
double |
getLeftY()
Get y coordinate of left edge |
double |
getLength()
Get length |
LineSegment |
getRightSide()
Get right edge |
double |
getRightY()
Get y coordinate of right edge |
VecPosition |
getTopLeft()
Get position of top-left corner |
VecPosition |
getTopRight()
Get position of top-right corner |
LineSegment |
getTopSide()
Get top edge |
double |
getTopX()
Get x coordinate of top edge |
double |
getWidth()
Get width |
boolean |
isInside(VecPosition p)
Is the given point inside the rectangle? |
void |
setPoints(VecPosition p1,
VecPosition p2)
Set rectangle from the two diagonal corners given |
java.util.Iterator<LineSegment> |
sideIterator()
Get iterator over sides starting with the top and moving clockwise |
Rectangle |
subtract(double d)
Create a new rectangle shifted in x and y by the given value in the opposite direction |
Rectangle |
subtract(VecPosition v)
Create a new rectangle shifted by the given vector in the opposite direction |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Rectangle()
public Rectangle(double width, double length)
width
- size in y directionlength
- size in x directionpublic Rectangle(double width, double length, VecPosition center)
width
- size in y directionlength
- size in x directioncenter
- center of rectanglepublic Rectangle(VecPosition p1, VecPosition p2)
p1
- first cornerp2
- second cornerMethod Detail |
---|
public void setPoints(VecPosition p1, VecPosition p2)
p1
- first cornerp2
- second cornerpublic VecPosition getTopLeft()
public VecPosition getBottomRight()
public VecPosition getTopRight()
public VecPosition getBottomLeft()
public double getTopX()
public double getBottomX()
public double getLeftY()
public double getRightY()
public LineSegment getTopSide()
public LineSegment getBottomSide()
public LineSegment getLeftSide()
public LineSegment getRightSide()
public java.util.Iterator<VecPosition> cornerIterator()
public java.util.Iterator<LineSegment> sideIterator()
public boolean isInside(VecPosition p)
isInside
in interface Region
p
- test point
true
if point lies insidepublic VecPosition getCenter()
public double getWidth()
public double getLength()
public Rectangle add(double d)
d
- distance to shift rectangle
public Rectangle add(VecPosition v)
v
- vector to shift rectangle
public Rectangle subtract(double d)
d
- distance to shift rectangle
public Rectangle subtract(VecPosition v)
v
- vector to shift rectangle in opposite direction
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |