public class Rectangle extends java.lang.Object implements Shape
| Modifier and Type | Field and Description |
|---|---|
double |
x1 |
double |
x2 |
double |
y1 |
double |
y2 |
| Constructor and Description |
|---|
Rectangle() |
Rectangle(double x1,
double y1,
double x2,
double y2) |
Rectangle(Rectangle r)
Constructs a new
Rectangle, initialized to match
the values of the specified Rectangle. |
| Modifier and Type | Method and Description |
|---|---|
Rectangle |
buffer(double dw,
double dh) |
Rectangle |
clone()
Returns a clone of this shape
|
int |
compareTo(Rectangle r2) |
int |
compareTo(Shape s)
Comparison is done by lexicographic ordering of attributes
< x1, y1, x2, y2>
|
boolean |
contains(double x,
double y) |
boolean |
contains(double rx1,
double ry1,
double rx2,
double ry2) |
boolean |
contains(Point p) |
boolean |
contains(Rectangle r) |
double |
distanceTo(double px,
double py)
Gets the distance of this shape to the given point.
|
void |
draw(java.awt.Graphics g,
double xscale,
double yscale)
Draws the shape to the given graphics and scale.
|
void |
draw(java.awt.Graphics g,
Rectangle fileMBR,
int imageWidth,
int imageHeight,
double scale)
Draws a shape to the given graphics.
|
boolean |
equals(java.lang.Object obj) |
void |
expand(Shape s) |
void |
fromText(Text text)
Retrieve information from the given text.
|
Point |
getCenterPoint() |
double |
getHeight() |
Rectangle |
getIntersection(Shape s) |
double |
getMaxDistance(Rectangle r2) |
double |
getMaxDistanceTo(double px,
double py)
Maximum distance to the perimeter of the Rectangle
|
Rectangle |
getMBR()
Returns minimum bounding rectangle for this shape.
|
double |
getMinDistance(Rectangle r2) |
double |
getMinDistanceTo(double px,
double py) |
double |
getWidth() |
void |
invalidate() |
boolean |
isIntersected(Shape s)
Returns true if this shape is intersected with the given shape
|
boolean |
isValid() |
void |
readFields(java.io.DataInput in) |
void |
set(double x1,
double y1,
double x2,
double y2) |
void |
set(Shape s) |
java.lang.String |
toString() |
Text |
toText(Text text)
Store current object as string in the given text appending text already there.
|
Rectangle |
translate(double dx,
double dy)
Returns a new rectangle after tanslating with the given amount
|
Rectangle |
union(Shape s) |
void |
write(java.io.DataOutput out) |
public Rectangle()
public Rectangle(Rectangle r)
Rectangle, initialized to match
the values of the specified Rectangle.r - the Rectangle from which to copy initial values
to a newly constructed Rectanglepublic Rectangle(double x1,
double y1,
double x2,
double y2)
public void set(Shape s)
public void set(double x1,
double y1,
double x2,
double y2)
public void write(java.io.DataOutput out)
throws java.io.IOException
java.io.IOExceptionpublic void readFields(java.io.DataInput in)
throws java.io.IOException
java.io.IOExceptionpublic int compareTo(Shape s)
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic double distanceTo(double px,
double py)
ShapedistanceTo in interface Shapepublic double getMaxDistanceTo(double px,
double py)
px - py - public double getMinDistanceTo(double px,
double py)
public double getMinDistance(Rectangle r2)
public double getMaxDistance(Rectangle r2)
public Rectangle clone()
Shapepublic Rectangle getMBR()
Shapepublic boolean isIntersected(Shape s)
ShapeisIntersected in interface Shapepublic boolean contains(Point p)
public boolean contains(double x,
double y)
public boolean contains(Rectangle r)
public void expand(Shape s)
public boolean contains(double rx1,
double ry1,
double rx2,
double ry2)
public Point getCenterPoint()
public Text toText(Text text)
TextSerializabletoText in interface TextSerializablepublic void fromText(Text text)
TextSerializablefromText in interface TextSerializablepublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isValid()
public void invalidate()
public double getHeight()
public double getWidth()
public int compareTo(Rectangle r2)
public void draw(java.awt.Graphics g,
Rectangle fileMBR,
int imageWidth,
int imageHeight,
double scale)
Shapedraw in interface Shapeg - - the graphics or canvas to draw tofileMBR - - the MBR of the file in which the shape is containedimageWidth - - width of the image to drawimageHeight - - height of the image to drawscale - - the scale used to convert shape coordinates to image coordinatespublic void draw(java.awt.Graphics g,
double xscale,
double yscale)
Shapepublic Rectangle buffer(double dw, double dh)
public Rectangle translate(double dx, double dy)