|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--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 | |
private double |
angle
angle as described by getAngle() This is always between -PI and PI |
java.awt.Graphics |
graphics
Graphics context for this Geometric object. |
private double |
height
height |
private double |
height_x
x component of the height vector. |
private double |
height_y
y component of the height vector. |
private Polygon |
points
The original data points |
long |
time_stamp
Time stamp of this object. |
private double |
width
width |
private double |
width_x
x component of the width vector. |
private double |
width_y
y component of the width vector. |
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 GeometricObject |
CIRCLE,
ELLIPSE,
LINE,
POINT,
POLYGON,
RECTANGLE,
SQUARE |
| Constructor Summary | |
(package private) |
Rectangle(double x,
double y,
double width_x,
double width_y,
double height)
The constructor. |
(package private) |
Rectangle(double x,
double y,
Point width_vector,
double height)
The constructor. |
(package private) |
Rectangle(int x,
int y,
int width,
int height)
The constructor. |
(package private) |
Rectangle(Point upper_left_point,
java.awt.Dimension dimension)
The constructor. |
(package private) |
Rectangle(Point upper_left_point,
java.awt.Dimension dimension,
double angle)
The constructor. |
(package private) |
Rectangle(java.awt.Rectangle rectangle)
The constructor. |
(package private) |
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 |
java.lang.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(java.awt.Graphics g)
Draw the object |
void |
paint(java.awt.Graphics g,
int thickness)
Draw the object |
void |
paintOriginal(java.awt.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(java.awt.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(java.awt.Graphics g,
int number_of_shades)
Shade the object |
void |
shade(java.awt.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. |
java.lang.String |
toString()
Override toString |
boolean |
touches(GeometricObject object)
This method should return true if the input objects touch. |
Rectangle |
union(Rectangle rectangle)
Return the rectangularBounds of the union of this rectangle and the argument. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private Polygon points
private double angle
private double width_x
private double width_y
private double height_x
private double height_y
private double width
private double height
public double x
public double y
public long time_stamp
public java.awt.Graphics graphics
| Constructor Detail |
Rectangle(java.awt.Rectangle rectangle)
Rectangle(Point upper_left_point,
java.awt.Dimension dimension)
Rectangle(Point upper_left_point,
java.awt.Dimension dimension,
double angle)
Rectangle(double x,
double y,
Point width_vector,
double height)
Rectangle(double x,
double y,
double width_x,
double width_y,
double height)
Rectangle(Rectangle r)
Rectangle(int x,
int y,
int width,
int height)
| Method Detail |
public void setRectangle(Rectangle r)
public void scaleAboutCenter(double scale)
public java.lang.String getType()
public java.lang.String toString()
public void paint()
public void paintOriginal(java.awt.Graphics g)
public void paint(java.awt.Graphics g,
int thickness)
public void shade(java.awt.Graphics g,
int shades,
int thickness,
int offset)
public void paint(java.awt.Graphics g)
public void shade(java.awt.Graphics g,
int number_of_shades)
public boolean pointIsOn(Point point,
int radius)
public boolean pointIsOnOriginal(Point p,
int radius)
public void setGraphicsContext(java.awt.Graphics g)
public boolean touches(GeometricObject object)
public Rectangle getRectangularBounds()
public boolean containsGeometricObject(GeometricObject object)
public Polygon getPolygonalBounds()
public int spatialRelation(GeometricObject object,
double scale)
public int spatialRelation(GeometricObject object)
public boolean hasOnMajorAxisDirection(GeometricObject object)
public int spatialRelationCartesian(GeometricObject object)
public double getWidth()
public double getHeight()
public double getAngle()
public 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)
public long getTimeStamp()
public double getMinorAxisAngle()
public double getMajorAxisAngle()
public int getMajorAxisDirection()
public void setDataPoints(Polygon points)
public Polygon getDataPoints()
public double area()
public Rectangle union(Rectangle rectangle)
public boolean containsGeometricObjects(GeometricObject[] objects)
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||