edu.rit.draw.item
Class RectangularItem
- java.lang.Object
-
- edu.rit.draw.item.DrawingItem
-
- edu.rit.draw.item.OutlinedItem
-
- edu.rit.draw.item.FilledItem
-
- edu.rit.draw.item.ShapeItem
-
- edu.rit.draw.item.RectangularItem
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable
public abstract class RectangularItem extends ShapeItem implements java.io.Externalizable
Class RectangularItem is the abstract base class for a DrawingItem that has an outline, is filled with a paint, and occupies a rectangular area of a certain size at a certain location.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class edu.rit.draw.item.FilledItem
NORMAL_FILL
-
Fields inherited from class edu.rit.draw.item.OutlinedItem
NORMAL_OUTLINE
-
-
Constructor Summary
Constructors Constructor and Description RectangularItem()Construct a new rectangular item.RectangularItem(RectangularItem theItem)Construct a new rectangular item with the same outline, fill paint, location, and size as the given rectangular item.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description RectangularItemadd()Add this rectangular item to the end of the default drawing's sequence of drawing items.RectangularItemadd(Drawing theDrawing)Add this rectangular item to the end of the given drawing's sequence of drawing items.RectangularItemaddFirst()Add this rectangular item to the beginning of the default drawing's sequence of drawing items.RectangularItemaddFirst(Drawing theDrawing)Add this rectangular item to the beginning of the given drawing's sequence of drawing items.RectangularItemc(double x, double y)Set the center point of this rectangular item's bounding box.RectangularItemc(Point thePoint)Set the center point of this rectangular item's bounding box.RectangularIteme(double x, double y)Set the east middle point of this rectangular item's bounding box.RectangularIteme(Point thePoint)Set the east middle point of this rectangular item's bounding box.RectangularItemfill(Fill theFill)Set this rectangular item's fill paint.doubleheight()Returns the height of this rectangular item's bounding box.RectangularItemheight(double theHeight)Set the height of this rectangular item's bounding box.RectangularItemn(double x, double y)Set the north middle point of this rectangular item's bounding box.RectangularItemn(Point thePoint)Set the north middle point of this rectangular item's bounding box.RectangularItemne(double x, double y)Set the northeast corner point of this rectangular item's bounding box.RectangularItemne(Point thePoint)Set the northeast corner point of this rectangular item's bounding box.Pointnw()Returns the northwest corner point of this rectangular item's bounding box.RectangularItemnw(double x, double y)Set the northwest corner point of this rectangular item's bounding box.RectangularItemnw(Point thePoint)Set the northwest corner point of this rectangular item's bounding box.RectangularItemoutline(Outline theOutline)Set this rectangular item's outline.voidreadExternal(java.io.ObjectInput in)Read this rectangular item from the given object input stream.RectangularItems(double x, double y)Set the south middle point of this rectangular item's bounding box.RectangularItems(Point thePoint)Set the south middle point of this rectangular item's bounding box.RectangularItemse(double x, double y)Set the southeast corner point of this rectangular item's bounding box.RectangularItemse(Point thePoint)Set the southeast corner point of this rectangular item's bounding box.RectangularItemsize(Size theSize)Set the size of this rectangular item's bounding box.RectangularItemsw(double x, double y)Set the southwest corner point of this rectangular item's bounding box.RectangularItemsw(Point thePoint)Set the southwest corner point of this rectangular item's bounding box.RectangularItemw(double x, double y)Set the west middle point of this rectangular item's bounding box.RectangularItemw(Point thePoint)Set the west middle point of this rectangular item's bounding box.doublewidth()Returns the width of this rectangular item's bounding box.RectangularItemwidth(double theWidth)Set the width of this rectangular item's bounding box.voidwriteExternal(java.io.ObjectOutput out)Write this rectangular item to the given object output stream.-
Methods inherited from class edu.rit.draw.item.FilledItem
defaultFill, defaultFill, fill
-
Methods inherited from class edu.rit.draw.item.OutlinedItem
defaultOutline, defaultOutline, outline
-
-
-
-
Constructor Detail
-
RectangularItem
public RectangularItem()
Construct a new rectangular item. The rectangular item's northwest corner is located at (0,0). The rectangular item's size is the default size (determined by the subclass).
-
RectangularItem
public RectangularItem(RectangularItem theItem)
Construct a new rectangular item with the same outline, fill paint, location, and size as the given rectangular item.- Parameters:
theItem- Rectangular item.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theItem is null.
-
-
Method Detail
-
outline
public RectangularItem outline(Outline theOutline)
Set this rectangular item's outline.
-
fill
public RectangularItem fill(Fill theFill)
Set this rectangular item's fill paint.
-
size
public RectangularItem size(Size theSize)
Set the size of this rectangular item's bounding box.- Parameters:
theSize- Size.- Returns:
- This rectangular item.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if the width or the height of theSize is less than 0.
-
width
public double width()
Returns the width of this rectangular item's bounding box.- Specified by:
widthin classDrawingItem- Returns:
- Width.
-
width
public RectangularItem width(double theWidth)
Set the width of this rectangular item's bounding box.- Parameters:
theWidth- Width.- Returns:
- This rectangular item.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theWidth is less than 0.
-
height
public double height()
Returns the height of this rectangular item's bounding box.- Specified by:
heightin classDrawingItem- Returns:
- Height.
-
height
public RectangularItem height(double theHeight)
Set the height of this rectangular item's bounding box.- Parameters:
theHeight- Height.- Returns:
- This rectangular item.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theHeight is less than 0.
-
nw
public Point nw()
Returns the northwest corner point of this rectangular item's bounding box.- Specified by:
nwin classDrawingItem- Returns:
- Northwest corner point.
-
nw
public RectangularItem nw(double x, double y)
Set the northwest corner point of this rectangular item's bounding box.- Parameters:
x- X coordinate of northwest corner point.y- Y coordinate of northwest corner point.- Returns:
- This rectangular item.
-
nw
public RectangularItem nw(Point thePoint)
Set the northwest corner point of this rectangular item's bounding box.- Parameters:
thePoint- Northwest corner point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
n
public RectangularItem n(double x, double y)
Set the north middle point of this rectangular item's bounding box.- Parameters:
x- X coordinate of north middle point.y- Y coordinate of north middle point.- Returns:
- This rectangular item.
-
n
public RectangularItem n(Point thePoint)
Set the north middle point of this rectangular item's bounding box.- Parameters:
thePoint- North middle point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
ne
public RectangularItem ne(double x, double y)
Set the northeast corner point of this rectangular item's bounding box.- Parameters:
x- X coordinate of northeast corner point.y- Y coordinate of northeast corner point.- Returns:
- This rectangular item.
-
ne
public RectangularItem ne(Point thePoint)
Set the northeast corner point of this rectangular item's bounding box.- Parameters:
thePoint- Northeast corner point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
w
public RectangularItem w(double x, double y)
Set the west middle point of this rectangular item's bounding box.- Parameters:
x- X coordinate of west middle point.y- Y coordinate of west middle point.- Returns:
- This rectangular item.
-
w
public RectangularItem w(Point thePoint)
Set the west middle point of this rectangular item's bounding box.- Parameters:
thePoint- West middle point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
c
public RectangularItem c(double x, double y)
Set the center point of this rectangular item's bounding box.- Parameters:
x- X coordinate of center point.y- Y coordinate of center point.- Returns:
- This rectangular item.
-
c
public RectangularItem c(Point thePoint)
Set the center point of this rectangular item's bounding box.- Parameters:
thePoint- Center point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
e
public RectangularItem e(double x, double y)
Set the east middle point of this rectangular item's bounding box.- Parameters:
x- X coordinate of east middle point.y- Y coordinate of east middle point.- Returns:
- This rectangular item.
-
e
public RectangularItem e(Point thePoint)
Set the east middle point of this rectangular item's bounding box.- Parameters:
thePoint- East middle point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
sw
public RectangularItem sw(double x, double y)
Set the southwest corner point of this rectangular item's bounding box.- Parameters:
x- X coordinate of southwest corner point.y- Y coordinate of southwest corner point.- Returns:
- This rectangular item.
-
sw
public RectangularItem sw(Point thePoint)
Set the southwest corner point of this rectangular item's bounding box.- Parameters:
thePoint- Southwest corner point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
s
public RectangularItem s(double x, double y)
Set the south middle point of this rectangular item's bounding box.- Parameters:
x- X coordinate of south middle point.y- Y coordinate of south middle point.- Returns:
- This rectangular item.
-
s
public RectangularItem s(Point thePoint)
Set the south middle point of this rectangular item's bounding box.- Parameters:
thePoint- South middle point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
se
public RectangularItem se(double x, double y)
Set the southeast corner point of this rectangular item's bounding box.- Parameters:
x- X coordinate of southeast corner point.y- Y coordinate of southeast corner point.- Returns:
- This rectangular item.
-
se
public RectangularItem se(Point thePoint)
Set the southeast corner point of this rectangular item's bounding box.- Parameters:
thePoint- Southeast corner point.- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
add
public RectangularItem add()
Add this rectangular item to the end of the default drawing's sequence of drawing items.- Overrides:
addin classShapeItem- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if there is no default drawing.- See Also:
Drawing.defaultDrawing()
-
add
public RectangularItem add(Drawing theDrawing)
Add this rectangular item to the end of the given drawing's sequence of drawing items.
-
addFirst
public RectangularItem addFirst()
Add this rectangular item to the beginning of the default drawing's sequence of drawing items.- Overrides:
addFirstin classShapeItem- Returns:
- This rectangular item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if there is no default drawing.- See Also:
Drawing.defaultDrawing()
-
addFirst
public RectangularItem addFirst(Drawing theDrawing)
Add this rectangular item to the beginning of the given drawing's sequence of drawing items.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite this rectangular item to the given object output stream.- Specified by:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classFilledItem- Parameters:
out- Object output stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundExceptionRead this rectangular item from the given object input stream.- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classFilledItem- Parameters:
in- Object input stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.java.lang.ClassNotFoundException- Thrown if any class needed to deserialize this rectangular item cannot be found.
-
-
DMelt 3.0 © DataMelt by jWork.ORG