|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rit.draw.item.DrawingItem
edu.rit.draw.item.OutlinedItem
edu.rit.draw.item.FilledItem
edu.rit.draw.item.ShapeItem
edu.rit.draw.item.RectangularItem
edu.rit.draw.item.Rectangle
public class Rectangle
Class Rectangle provides a rectangle DrawingItem. The rectangle may have sharp corners or round corners.
| If the rectangle has round corners, the round corner distance gives the distance from where the (sharp) corner would normally be to the starting and ending points of the round corner arc, as shown in the adjoining diagram. (The round corner distance is d.) A round corner distance of 0 results in a sharp corner. In a particular rectangle, the same round corner distance is used for every corner; that is, either all the corners are sharp or all the corners are rounded the same amount. Different rectangles can have different round corner distances. | ![]() |
The static defaultSize(), defaultWidth(), defaultHeight(), and defaultRound() methods are provided to set the default size, width, height, and round corner distance. If a rectangle's size, width, height, or round corner distance is not specified, the current default size, width, height, or round corner distance is used.
| Field Summary | |
|---|---|
static double |
NORMAL_HEIGHT
The normal height for rectangles (72). |
static double |
NORMAL_ROUND
The normal round corner distance (0), signifying sharp corners. |
static double |
NORMAL_WIDTH
The normal width for rectangles (72). |
| Fields inherited from class edu.rit.draw.item.FilledItem |
|---|
NORMAL_FILL |
| Fields inherited from class edu.rit.draw.item.OutlinedItem |
|---|
NORMAL_OUTLINE |
| Constructor Summary | |
|---|---|
Rectangle()
Construct a new rectangle. |
|
Rectangle(Rectangle theItem)
Construct a new rectangle with the same outline, fill paint, location, and size as the given rectangle. |
|
| Method Summary | |
|---|---|
Rectangle |
add()
Add this rectangle to the end of the default drawing's sequence of drawing items. |
Rectangle |
add(Drawing theDrawing)
Add this rectangle to the end of the given drawing's sequence of drawing items. |
Rectangle |
addFirst()
Add this rectangle to the beginning of the default drawing's sequence of drawing items. |
Rectangle |
addFirst(Drawing theDrawing)
Add this rectangle to the beginning of the given drawing's sequence of drawing items. |
Rectangle |
c(double x,
double y)
Set the center point of this rectangle's bounding box. |
Rectangle |
c(Point thePoint)
Set the center point of this rectangle's bounding box. |
static double |
defaultHeight()
Returns the default height for rectangles. |
static void |
defaultHeight(double theHeight)
Set the default height for rectangles. |
static double |
defaultRound()
Returns the default round corner distance. |
static void |
defaultRound(double theRound)
Set the default round corner distance. |
static Size |
defaultSize()
Returns the default size for rectangles. |
static void |
defaultSize(Size theSize)
Set the default size for rectangles. |
static double |
defaultWidth()
Returns the default width for rectangles. |
static void |
defaultWidth(double theWidth)
Set the default width for rectangles. |
Rectangle |
e(double x,
double y)
Set the east middle point of this rectangle's bounding box. |
Rectangle |
e(Point thePoint)
Set the east middle point of this rectangle's bounding box. |
Rectangle |
fill(Fill theFill)
Set this rectangle's fill paint. |
Rectangle |
height(double theHeight)
Set the height of this rectangle's bounding box. |
Rectangle |
n(double x,
double y)
Set the north middle point of this rectangle's bounding box. |
Rectangle |
n(Point thePoint)
Set the north middle point of this rectangle's bounding box. |
Rectangle |
ne(double x,
double y)
Set the northeast corner point of this rectangle's bounding box. |
Rectangle |
ne(Point thePoint)
Set the northeast corner point of this rectangle's bounding box. |
Rectangle |
nw(double x,
double y)
Set the northwest corner point of this rectangle's bounding box. |
Rectangle |
nw(Point thePoint)
Set the northwest corner point of this rectangle's bounding box. |
Rectangle |
outline(Outline theOutline)
Set this rectangle's outline. |
void |
readExternal(ObjectInput in)
Read this rectangle from the given object input stream. |
double |
round()
Returns this rectangle's round corner distance. |
Rectangle |
round(double theRound)
Set this rectangle's round corner distance. |
Rectangle |
s(double x,
double y)
Set the south middle point of this rectangle's bounding box. |
Rectangle |
s(Point thePoint)
Set the south middle point of this rectangle's bounding box. |
Rectangle |
se(double x,
double y)
Set the southeast corner point of this rectangle's bounding box. |
Rectangle |
se(Point thePoint)
Set the southeast corner point of this rectangle's bounding box. |
Rectangle |
size(Size theSize)
Set the size of this rectangle's bounding box. |
Rectangle |
sw(double x,
double y)
Set the southwest corner point of this rectangle's bounding box. |
Rectangle |
sw(Point thePoint)
Set the southwest corner point of this rectangle's bounding box. |
Rectangle |
w(double x,
double y)
Set the west middle point of this rectangle's bounding box. |
Rectangle |
w(Point thePoint)
Set the west middle point of this rectangle's bounding box. |
Rectangle |
width(double theWidth)
Set the width of this rectangle's bounding box. |
void |
writeExternal(ObjectOutput out)
Write this rectangle to the given object output stream. |
| Methods inherited from class edu.rit.draw.item.RectangularItem |
|---|
height, nw, width |
| Methods inherited from class edu.rit.draw.item.ShapeItem |
|---|
draw |
| Methods inherited from class edu.rit.draw.item.FilledItem |
|---|
defaultFill, defaultFill, fill |
| Methods inherited from class edu.rit.draw.item.OutlinedItem |
|---|
defaultOutline, defaultOutline, outline |
| Methods inherited from class edu.rit.draw.item.DrawingItem |
|---|
boundingBox, c, e, n, ne, s, se, size, sw, w |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double NORMAL_WIDTH
public static final double NORMAL_HEIGHT
public static final double NORMAL_ROUND
| Constructor Detail |
|---|
public Rectangle()
public Rectangle(Rectangle theItem)
theItem - Rectangle.
NullPointerException - (unchecked exception) Thrown if theItem is null.| Method Detail |
|---|
public static Size defaultSize()
public static void defaultSize(Size theSize)
theSize - Default size.
IllegalArgumentException - (unchecked exception) Thrown if the width or the height of
theSize is less than 0.public static double defaultWidth()
public static void defaultWidth(double theWidth)
theWidth - Default width.
IllegalArgumentException - (unchecked exception) Thrown if theWidth is less than 0.public static double defaultHeight()
public static void defaultHeight(double theHeight)
theHeight - Default height.
IllegalArgumentException - (unchecked exception) Thrown if theHeight is less than 0.public static double defaultRound()
public static void defaultRound(double theRound)
theRound - Default round corner distance.
IllegalArgumentException - (unchecked exception) Thrown if theRound is less than 0.public Rectangle outline(Outline theOutline)
outline in class RectangularItemtheOutline - Outline, or Outline.NONE.
public Rectangle fill(Fill theFill)
fill in class RectangularItemtheFill - Fill paint, or Fill.NONE.
public Rectangle size(Size theSize)
size in class RectangularItemtheSize - Size.
IllegalArgumentException - (unchecked exception) Thrown if the width or the height of
theSize is less than 0.public Rectangle width(double theWidth)
width in class RectangularItemtheWidth - Width.
IllegalArgumentException - (unchecked exception) Thrown if theWidth is less than 0.public Rectangle height(double theHeight)
height in class RectangularItemtheHeight - Height.
IllegalArgumentException - (unchecked exception) Thrown if theHeight is less than 0.
public Rectangle nw(double x,
double y)
nw in class RectangularItemx - X coordinate of northwest corner point.y - Y coordinate of northwest corner point.
public Rectangle nw(Point thePoint)
nw in class RectangularItemthePoint - Northwest corner point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle n(double x,
double y)
n in class RectangularItemx - X coordinate of north middle point.y - Y coordinate of north middle point.
public Rectangle n(Point thePoint)
n in class RectangularItemthePoint - North middle point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle ne(double x,
double y)
ne in class RectangularItemx - X coordinate of northeast corner point.y - Y coordinate of northeast corner point.
public Rectangle ne(Point thePoint)
ne in class RectangularItemthePoint - Northeast corner point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle w(double x,
double y)
w in class RectangularItemx - X coordinate of west middle point.y - Y coordinate of west middle point.
public Rectangle w(Point thePoint)
w in class RectangularItemthePoint - West middle point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle c(double x,
double y)
c in class RectangularItemx - X coordinate of center point.y - Y coordinate of center point.
public Rectangle c(Point thePoint)
c in class RectangularItemthePoint - Center point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle e(double x,
double y)
e in class RectangularItemx - X coordinate of east middle point.y - Y coordinate of east middle point.
public Rectangle e(Point thePoint)
e in class RectangularItemthePoint - East middle point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle sw(double x,
double y)
sw in class RectangularItemx - X coordinate of southwest corner point.y - Y coordinate of southwest corner point.
public Rectangle sw(Point thePoint)
sw in class RectangularItemthePoint - Southwest corner point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle s(double x,
double y)
s in class RectangularItemx - X coordinate of south middle point.y - Y coordinate of south middle point.
public Rectangle s(Point thePoint)
s in class RectangularItemthePoint - South middle point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.
public Rectangle se(double x,
double y)
se in class RectangularItemx - X coordinate of southeast corner point.y - Y coordinate of southeast corner point.
public Rectangle se(Point thePoint)
se in class RectangularItemthePoint - Southeast corner point.
NullPointerException - (unchecked exception) Thrown if thePoint is null.public double round()
public Rectangle round(double theRound)
theRound - Round corner distance.
IllegalArgumentException - (unchecked exception) Thrown if theRound is less than 0.public Rectangle add()
add in class RectangularItemNullPointerException - (unchecked exception) Thrown if there is no default drawing.Drawing.defaultDrawing()public Rectangle add(Drawing theDrawing)
add in class RectangularItemtheDrawing - Drawing.
NullPointerException - (unchecked exception) Thrown if theDrawing is null.public Rectangle addFirst()
addFirst in class RectangularItemNullPointerException - (unchecked exception) Thrown if there is no default drawing.Drawing.defaultDrawing()public Rectangle addFirst(Drawing theDrawing)
addFirst in class RectangularItemtheDrawing - Drawing.
NullPointerException - (unchecked exception) Thrown if theDrawing is null.
public void writeExternal(ObjectOutput out)
throws IOException
writeExternal in interface ExternalizablewriteExternal in class RectangularItemout - Object output stream.
IOException - Thrown if an I/O error occurred.
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
readExternal in interface ExternalizablereadExternal in class RectangularItemin - Object input stream.
IOException - Thrown if an I/O error occurred.
ClassNotFoundException - Thrown if any class needed to deserialize this rectangle cannot be
found.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||