|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.jfimagine.jfgraph.geom.Rect
Rect class. A class used to represent a rectangle in the plane with double coordinates.
Attention: Here we used a clockwise quadrant system. And the first quadrant is under right bottom corner.
| Field Summary | |
protected JFPoint |
m_leftBottom
Left-bottom vertex of rectangle. |
protected JFPoint |
m_leftTop
Left-top vertex of rectangle. |
protected JFPoint |
m_rightBottom
Right-bottom vertex of rectangle. |
protected JFPoint |
m_rightTop
Right-top vertex of rectangle. |
static int |
SIDETYPE_BOTTOM
A const side type represents the bottom side of a rectangle |
static int |
SIDETYPE_LEFT
A const side type represents the left side of a rectangle |
static int |
SIDETYPE_RIGHT
A const side type represents the right side of a rectangle |
static int |
SIDETYPE_TOP
A const side type represents the top side of a rectangle |
static int |
VERTEXMOVETYPE_ISOSCELESTRAPEZOID
A isosceles trapezoid vertex moving type of rectangle. |
static int |
VERTEXMOVETYPE_PARALLEL
A parallelogram vertex moving type of rectangle. |
static int |
VERTEXMOVETYPE_RECTANGLE
A rectangular vertex moving type of rectangle. |
static int |
VERTEXMOVETYPE_SCALE
A rectangular scale vertex moving type of rectangle. |
static int |
VERTEXMOVETYPE_TRAPEZOID
A trapezoid vertex moving type of rectangle. |
static int |
VERTEXTYPE_LEFTBOTTOM
A const vertext type represents the left-bottom vertex of a rectangle |
static int |
VERTEXTYPE_LEFTTOP
A const vertext type represents the left-top vertex of a rectangle |
static int |
VERTEXTYPE_RIGHTBOTTOM
A const vertext type represents the right-bottom vertex of a rectangle |
static int |
VERTEXTYPE_RIGHTTOP
A const vertext type represents the right-top vertex of a rectangle |
| Constructor Summary | |
Rect()
Constructor for Rect. |
|
Rect(double x,
double y,
double w,
double h)
Constructor for Rect. |
|
Rect(JFPoint startPoint,
JFPoint endPoint)
Constructor for Rect. |
|
Rect(Rect rect)
Constructor for Rect. |
|
| Method Summary | |
boolean |
canAddPort(double x,
double y,
JFPoint startPoint,
JFPoint endPoint,
JFPoint portPoint)
Test if current rectangle can add a port according to the position x,y. |
java.lang.Object |
clone()
Creates a new object of the same class and with the same contents as this object. |
boolean |
contains(double x,
double y)
Test if a point(x, y coordinates for instead) is within this rectangle. |
boolean |
contains(JFPoint pnt)
Test if a point is within this rectangle. |
boolean |
equals(java.lang.Object obj)
Determines whether or not two objects are equal. |
void |
flipBy()
Reverse this rectangle by a central y coordinate of this rectangle. |
void |
flipBy(double baseY)
Reverse this rectangle by a y coordinate. |
Rect |
getBounds()
Get the bounds of this rectangle. |
JFPoint |
getCenter()
Get a center point of this rectangle. |
double |
getHeight()
Get height of this rectangle. |
LineSeg |
getSide(int sideType)
Get a side line of this rectangle. |
JFPoint |
getVertex(int vertexType)
Get a vertex point of this rectangle. |
double |
getWidth()
Get width of this rectangle. |
double |
getX()
Get x coordiate of this rectangle. |
double |
getY()
Get y coordiate of this rectangle. |
int |
hashCode()
Returns the hashcode for this Object. |
boolean |
intersects(double x1,
double y1,
double x2,
double y2)
Tests if the specified line segment intersects the interior of this Rect. |
boolean |
intersects(double x1,
double y1,
int pickOffset)
Tests if the specified point intersects any side of this rectangle. |
boolean |
intersects(JFPoint pnt,
int pickOffset)
Tests if the specified point intersects any side of this rectangle. |
boolean |
intersects(LineSeg line)
Tests if the specified line segment intersects the interior of this Rect. |
boolean |
intersects(Rect rect)
Tests if the specified rectangle intersects the interior of this Rect. |
void |
mirrorBy()
Mirror this rectangle by a central x coordinate of this rectangle. |
void |
mirrorBy(double baseX)
Mirror this rectangle by a x coordinate. |
void |
moveBy(double x,
double y)
Move this rectangle by specific x and y coordinates. |
void |
moveVertex(int vertexType,
double x,
double y,
int moveType)
Move a vertex of a rectangle. |
static JFPoint |
newScaleCenter(JFPoint center,
JFPoint basePoint,
JFPoint refPoint1,
JFPoint refPoint2,
double scale)
When a shape is scaled, its location center will be changed probably. |
LineSeg |
pickLine(double x,
double y,
double pickOffset)
Pick a line segment of this rectangle by a point with a pickoffset. |
void |
rotateBy(double theta)
Rotate this rectangle by an angle theta. |
void |
rotateBy(double baseX,
double baseY,
double theta)
Rotate this line by a specified point and an angle theta. |
void |
rotateBy(JFPoint pnt,
double theta)
Rotate this rectangle by a specified point and an angle theta. |
void |
scaleBy(JFPoint basePoint,
double xScale,
double yScale)
Scale current object by a specified x and y scale. |
void |
scaleBy(JFPoint basePoint,
JFPoint refPoint1,
JFPoint refPoint2,
double scale)
Scale current rectangle by specified points and scale percent. |
void |
setValue(double x,
double y,
double w,
double h)
Set the bounds of current rectangle. |
void |
setValue(Rect rect)
Set the value of current rectangle. |
void |
setVertex(int vertexType,
double x,
double y)
Set a vertex point of this rectangle. |
void |
setVertex(int vertexType,
JFPoint pnt)
Set a vertex point of this rectangle. |
java.lang.String |
toString()
Convert this object to String |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int VERTEXTYPE_LEFTTOP
public static final int VERTEXTYPE_RIGHTTOP
public static final int VERTEXTYPE_LEFTBOTTOM
public static final int VERTEXTYPE_RIGHTBOTTOM
public static final int SIDETYPE_LEFT
public static final int SIDETYPE_TOP
public static final int SIDETYPE_RIGHT
public static final int SIDETYPE_BOTTOM
public static final int VERTEXMOVETYPE_SCALE
public static final int VERTEXMOVETYPE_RECTANGLE
public static final int VERTEXMOVETYPE_PARALLEL
public static final int VERTEXMOVETYPE_TRAPEZOID
public static final int VERTEXMOVETYPE_ISOSCELESTRAPEZOID
protected JFPoint m_leftTop
protected JFPoint m_rightTop
protected JFPoint m_leftBottom
protected JFPoint m_rightBottom
| Constructor Detail |
public Rect()
public Rect(Rect rect)
rect - A rectangle object.
public Rect(double x,
double y,
double w,
double h)
x - X coordiate.y - Y coordiate.w - Width of this rectangle.h - Height of this rectangle.
public Rect(JFPoint startPoint,
JFPoint endPoint)
startPoint - A startPoint for one endpoint of this rectangle.endPoint - An endPoint for another endpoint of this rectangle.| Method Detail |
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public void setValue(double x,
double y,
double w,
double h)
x - X coordiate.y - Y coordiate.w - Width of this rectangle.h - Height of this rectangle.public void setValue(Rect rect)
rect - A new rectangle.public Rect getBounds()
public JFPoint getVertex(int vertexType)
public void setVertex(int vertexType,
JFPoint pnt)
vertexType - An vertex type of a rectangle.pnt - A new vertex point.
public void setVertex(int vertexType,
double x,
double y)
vertexType - An vertex type of a rectangle.
public void moveVertex(int vertexType,
double x,
double y,
int moveType)
vertexType - An vertex type of a rectangle.moveType - scale, rectangular, parallel or trapezoid vertex moving type.public LineSeg getSide(int sideType)
public JFPoint getCenter()
public void scaleBy(JFPoint basePoint,
JFPoint refPoint1,
JFPoint refPoint2,
double scale)
basePoint - A base point that is unmovable.refPoint1 - A 'width' reference point.refPoint2 - A 'height' reference point.scale - A reference scale percent.
public void scaleBy(JFPoint basePoint,
double xScale,
double yScale)
basePoint - A base scale point for scaling reference.xScale - A scale percentage in x coordinate, default to 1.0yScale - A scale percentage in y coordinate, default to 1.0
public static JFPoint newScaleCenter(JFPoint center,
JFPoint basePoint,
JFPoint refPoint1,
JFPoint refPoint2,
double scale)
center - An old center of the scaled object.basePoint - A base point that is unmovable.refPoint1 - A 'width' reference point.refPoint2 - A 'height' reference point.scale - A reference scale percent.
public void moveBy(double x,
double y)
x - X coordiate to moveby.y - Y coordiate to moveby.public void rotateBy(double theta)
theta - A rotate angle.
public void rotateBy(JFPoint pnt,
double theta)
pnt - A rotate center point.theta - A rotate angle.
public void rotateBy(double baseX,
double baseY,
double theta)
theta - A rotate angle.public void mirrorBy()
public void mirrorBy(double baseX)
baseX - A mirror base x coordinate.public void flipBy()
public void flipBy(double baseY)
baseY - A flip base y coordinate.public boolean contains(JFPoint pnt)
pnt - A point.
public boolean contains(double x,
double y)
The algorithm for testing if a point is within this rectangle is at below.
count = 0; [start at endpoint P, make an radial line L from right to left] for [each side S of this rectangle] do if [P is on one side S] then return true; if [side S is not a horizontal line] then if [one endpoint of S is on L] if [this endpoint is the max y coordinate of the two endpoints of S] then count = count+1 else if [S interacts L] then count=count+1; if count mod 2 = 1 then return true; else return false;
x - X coordinate of this point.y - Y coordinate of this point.
public LineSeg pickLine(double x,
double y,
double pickOffset)
x - X coordinate of this point.y - Y coordinate of this point.pickOffset - An analog pick offset that great equal than 0.
public boolean canAddPort(double x,
double y,
JFPoint startPoint,
JFPoint endPoint,
JFPoint portPoint)
x - X coordinate of the port.y - Y coordinate of the port.
public boolean intersects(JFPoint pnt,
int pickOffset)
pnt - the specified point.pickOffset - An analog offset for 'pick' this line.
true if the specified point intersects one side of this rectangle.
false otherwise.
public boolean intersects(double x1,
double y1,
int pickOffset)
pickOffset - An analog offset for 'pick' this line.
true if the specified point intersects one side of this rectangle.
false otherwise.
public boolean intersects(double x1,
double y1,
double x2,
double y2)
Rect.
true if the specified line segment intersects
the interior of this Rect; false
otherwise.public boolean intersects(LineSeg line)
Rect.
line - the specified LineSeg to test for intersection
with the interior of this Rect
true if the specified LineSeg
intersects the interior of this Rect;
false otherwise.public boolean intersects(Rect rect)
Rect.
rect - the specified Rect to test for intersection
with the interior of this Rect
true if the specified Rect
intersects the interior of this Rect;
false otherwise.public java.lang.String toString()
toString in class java.lang.Object
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - an object to be compared with this object
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||