|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--edu.mit.sketch.geom.Rectangle
This class represents a Rectangle described by its width and height vectors. This class also implements Rotatable. This means it has a getAngle() method. The angle that is returned is the angle between the width vector and the x axis. This angle is always equal to or greater than 0 and strictly less than Math.PI/2.
| Field Summary | |
Graphics |
graphics
Graphics context for this Geometric object. |
long |
time_stamp
Time stamp of this object. |
double |
x
The x coordinate of the position of width vector. |
double |
y
The y coordinate of the position of width vector |
| Fields inherited from interface edu.mit.sketch.geom.GeometricObject |
CIRCLE, ELLIPSE, LINE, POINT, POLYGON, RECTANGLE, SQUARE |
| Constructor Summary | |
Rectangle(double x,
double y,
double width_x,
double width_y,
double height)
The constructor. |
|
Rectangle(double x,
double y,
Point width_vector,
double height)
The constructor. |
|
Rectangle(int x,
int y,
int width,
int height)
The constructor. |
|
Rectangle(Point upper_left_point,
Dimension dimension)
The constructor. |
|
Rectangle(Point upper_left_point,
Dimension dimension,
double angle)
The constructor. |
|
Rectangle(Rectangle rectangle)
The constructor. |
|
Rectangle(Rectangle r)
The constructor. |
|
| Method Summary | |
double |
area()
Return area. |
boolean |
containsGeometricObject(GeometricObject object)
Returns false if the argument is not completely inside this object. |
boolean |
containsGeometricObjects(GeometricObject[] objects)
Returns false if the objects in the input array are completely inside this object. |
double |
getAngle()
Returns the angle of the object WRT the x axis in radians. |
Point |
getCenter()
Returns the center of this rectangle. |
Polygon |
getDataPoints()
This method is used to get the original data points that forms this GeometricObject |
double |
getHeight()
Returns the height |
double |
getMajorAxisAngle()
Returns the angle between the longer of width or height vectors and the x axis. |
int |
getMajorAxisDirection()
Returns the direction of the major axis of this Rectangle Known eksik: Should be tested. |
double |
getMajorAxisLength()
Returns the larger of width and height. |
double |
getMinorAxisAngle()
Returns the angle between the shorter of width or height vectors and the x axis. |
double |
getMinorAxisLength()
Returns the smaller of width and height. |
Polygon |
getPolygonalBounds()
This method should return a polygon that corresponds to this object. |
Rectangle |
getRectangularBounds()
Supplied for completeness. |
long |
getTimeStamp()
Returns the time stamp of the current Terminal |
String |
getType()
Implement GeometricObject |
double |
getWidth()
Returns the width |
boolean |
hasOnMajorAxisDirection(GeometricObject object)
This method should return true if the input object lies in the major axis direction of this Rectangle. |
static boolean |
isRectangle(Polygon p)
Returns true if the input polygon looks like a Rectangle Can be optimized by eliminating Polygon conversions. |
void |
paint()
Draw the object |
void |
paint(Graphics g)
Draw the object |
void |
paint(Graphics g,
int thickness)
Draw the object |
void |
paintOriginal(Graphics g)
This method is used to paint the original data points that forms this GeometricObject |
boolean |
pointIsOn(Point point,
int radius)
Returns true if the point is within +-radius distance from the curve defining the object. |
boolean |
pointIsOnOriginal(Point p,
int radius)
Returns true if the point is within +-radius distance from the original curve defining the object. |
void |
rotateAbout(Point p,
double theta)
Rotates the rectangle about the point p theta radians CCW. |
void |
scaleAboutCenter(double scale)
scaleAboutCenter |
void |
setDataPoints(Polygon points)
This method is used to set the original data points that forms this GeometricObject |
void |
setGraphicsContext(Graphics g)
Set graphics context for this Geometric object. |
void |
setRectangle(Rectangle r)
setRectangle |
void |
setTimeStamp(long time_stamp)
Sets the time stamp of the current Terminal |
void |
shade(Graphics g,
int number_of_shades)
Shade the object |
void |
shade(Graphics g,
int shades,
int thickness,
int offset)
Shade the object |
int |
spatialRelation(GeometricObject object)
This method should return the spatial relation of the input parameter with respect to this object. |
int |
spatialRelation(GeometricObject object,
double scale)
This method should return the spatial relation of the input parameter with respect to this object. |
int |
spatialRelationCartesian(GeometricObject object)
This method should return the spatial relation of the input parameter with respect to this object. |
String |
toString()
Override toString |
boolean |
touches(GeometricObject object)
This method should return true if the input objects touch. |
void |
translate(double x,
double y)
Add the arguments to the (x, y) position of the object. |
Rectangle |
union(Rectangle rectangle)
Return the rectangularBounds of the union of this rectangle and the argument. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public double x
public double y
public long time_stamp
public transient Graphics graphics
| Constructor Detail |
public Rectangle(Rectangle rectangle)
public Rectangle(Point upper_left_point,
Dimension dimension)
public Rectangle(Point upper_left_point,
Dimension dimension,
double angle)
public Rectangle(double x,
double y,
Point width_vector,
double height)
public Rectangle(double x,
double y,
double width_x,
double width_y,
double height)
public Rectangle(Rectangle r)
public Rectangle(int x,
int y,
int width,
int height)
| Method Detail |
public void setRectangle(Rectangle r)
public void scaleAboutCenter(double scale)
public String getType()
getType in interface Paintablepublic String toString()
toString in class Objectpublic void paint()
paint in interface Paintablepublic void paintOriginal(Graphics g)
paintOriginal in interface Paintable
public void paint(Graphics g,
int thickness)
public void shade(Graphics g,
int shades,
int thickness,
int offset)
public void paint(Graphics g)
paint in interface Paintable
public void shade(Graphics g,
int number_of_shades)
public boolean pointIsOn(Point point,
int radius)
pointIsOn in interface Translatable
public boolean pointIsOnOriginal(Point p,
int radius)
pointIsOnOriginal in interface Translatablepublic void setGraphicsContext(Graphics g)
setGraphicsContext in interface Paintablepublic boolean touches(GeometricObject object)
touches in interface GeometricObjectpublic Rectangle getRectangularBounds()
getRectangularBounds in interface GeometricObjectpublic boolean containsGeometricObject(GeometricObject object)
containsGeometricObject in interface GeometricObjectpublic Polygon getPolygonalBounds()
getPolygonalBounds in interface GeometricObject
public int spatialRelation(GeometricObject object,
double scale)
Example for scale:
Scale = 1 => 100%
Scale = 1.5 => 150%
(0,0)
|--------------------------> X
|
|
| | |
| | |
| ___|___|___\ horizontal_up
| | | /
| | |
| ___|___|___\ horizontal_down
| | | /
| | |
| | |
| V V
| left right
|
|
|
|
Y V
public int spatialRelation(GeometricObject object)
(0,0)
|--------------------------> X
|
|
| | |
| | |
| ___|___|___\ horizontal_up
| | | /
| | |
| ___|___|___\ horizontal_down
| | | /
| | |
| | |
| V V
| left right
|
|
|
|
Y V
spatialRelation in interface GeometricObjectpublic boolean hasOnMajorAxisDirection(GeometricObject object)
(0,0)
|------------------------> X
|
|
| /\ /\
| | |
| | |
| ___|__________|___\
| | | /
| *****| |*****
| ___|__________|___\
| | | /
| | |
| | |
|
|
|
|
Y V
public int spatialRelationCartesian(GeometricObject object)
Y /\
|
|
| /\ /\
| | |
| | |
| ___|___|___\
| | | /
| | |
| ___|___|___\
| | | /
| | |
| | |
|
|
|
|
|--------------------------> X
(0,0)
public double getWidth()
public double getHeight()
public double getAngle()
getAngle in interface Rotatablepublic double getMajorAxisLength()
public double getMinorAxisLength()
public void rotateAbout(Point p,
double theta)
public Point getCenter()
public static boolean isRectangle(Polygon p)
public void setTimeStamp(long time_stamp)
setTimeStamp in interface Terminalpublic long getTimeStamp()
getTimeStamp in interface Terminalpublic double getMinorAxisAngle()
public double getMajorAxisAngle()
public int getMajorAxisDirection()
public void setDataPoints(Polygon points)
setDataPoints in interface GeometricObjectpublic Polygon getDataPoints()
getDataPoints in interface GeometricObjectpublic double area()
public Rectangle union(Rectangle rectangle)
public void translate(double x,
double y)
translate in interface Translatablepublic boolean containsGeometricObjects(GeometricObject[] objects)
containsGeometricObjects in interface GeometricObject
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||