edu.rit.draw.item
Class RectangularItem

java.lang.Object
  extended by edu.rit.draw.item.DrawingItem
      extended by edu.rit.draw.item.OutlinedItem
          extended by edu.rit.draw.item.FilledItem
              extended by edu.rit.draw.item.ShapeItem
                  extended by edu.rit.draw.item.RectangularItem
All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
Ellipse, Oval, Rectangle

public abstract class RectangularItem
extends ShapeItem
implements 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
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
 RectangularItem add()
          Add this rectangular item to the end of the default drawing's sequence of drawing items.
 RectangularItem add(Drawing theDrawing)
          Add this rectangular item to the end of the given drawing's sequence of drawing items.
 RectangularItem addFirst()
          Add this rectangular item to the beginning of the default drawing's sequence of drawing items.
 RectangularItem addFirst(Drawing theDrawing)
          Add this rectangular item to the beginning of the given drawing's sequence of drawing items.
 RectangularItem c(double x, double y)
          Set the center point of this rectangular item's bounding box.
 RectangularItem c(Point thePoint)
          Set the center point of this rectangular item's bounding box.
 RectangularItem e(double x, double y)
          Set the east middle point of this rectangular item's bounding box.
 RectangularItem e(Point thePoint)
          Set the east middle point of this rectangular item's bounding box.
 RectangularItem fill(Fill theFill)
          Set this rectangular item's fill paint.
 double height()
          Returns the height of this rectangular item's bounding box.
 RectangularItem height(double theHeight)
          Set the height of this rectangular item's bounding box.
 RectangularItem n(double x, double y)
          Set the north middle point of this rectangular item's bounding box.
 RectangularItem n(Point thePoint)
          Set the north middle point of this rectangular item's bounding box.
 RectangularItem ne(double x, double y)
          Set the northeast corner point of this rectangular item's bounding box.
 RectangularItem ne(Point thePoint)
          Set the northeast corner point of this rectangular item's bounding box.
 Point nw()
          Returns the northwest corner point of this rectangular item's bounding box.
 RectangularItem nw(double x, double y)
          Set the northwest corner point of this rectangular item's bounding box.
 RectangularItem nw(Point thePoint)
          Set the northwest corner point of this rectangular item's bounding box.
 RectangularItem outline(Outline theOutline)
          Set this rectangular item's outline.
 void readExternal(ObjectInput in)
          Read this rectangular item from the given object input stream.
 RectangularItem s(double x, double y)
          Set the south middle point of this rectangular item's bounding box.
 RectangularItem s(Point thePoint)
          Set the south middle point of this rectangular item's bounding box.
 RectangularItem se(double x, double y)
          Set the southeast corner point of this rectangular item's bounding box.
 RectangularItem se(Point thePoint)
          Set the southeast corner point of this rectangular item's bounding box.
 RectangularItem size(Size theSize)
          Set the size of this rectangular item's bounding box.
 RectangularItem sw(double x, double y)
          Set the southwest corner point of this rectangular item's bounding box.
 RectangularItem sw(Point thePoint)
          Set the southwest corner point of this rectangular item's bounding box.
 RectangularItem w(double x, double y)
          Set the west middle point of this rectangular item's bounding box.
 RectangularItem w(Point thePoint)
          Set the west middle point of this rectangular item's bounding box.
 double width()
          Returns the width of this rectangular item's bounding box.
 RectangularItem width(double theWidth)
          Set the width of this rectangular item's bounding box.
 void writeExternal(ObjectOutput out)
          Write this rectangular item to the given object output stream.
 
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
 

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:
NullPointerException - (unchecked exception) Thrown if theItem is null.
Method Detail

outline

public RectangularItem outline(Outline theOutline)
Set this rectangular item's outline.

Overrides:
outline in class ShapeItem
Parameters:
theOutline - Outline, or Outline.NONE.
Returns:
This rectangular item.

fill

public RectangularItem fill(Fill theFill)
Set this rectangular item's fill paint.

Overrides:
fill in class ShapeItem
Parameters:
theFill - Fill paint, or Fill.NONE.
Returns:
This rectangular item.

size

public RectangularItem size(Size theSize)
Set the size of this rectangular item's bounding box.

Parameters:
theSize - Size.
Returns:
This rectangular item.
Throws:
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:
width in class DrawingItem
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:
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:
height in class DrawingItem
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:
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:
nw in class DrawingItem
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
add in class ShapeItem
Returns:
This rectangular item.
Throws:
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.

Overrides:
add in class ShapeItem
Parameters:
theDrawing - Drawing.
Returns:
This rectangular item.
Throws:
NullPointerException - (unchecked exception) Thrown if theDrawing is null.

addFirst

public RectangularItem addFirst()
Add this rectangular item to the beginning of the default drawing's sequence of drawing items.

Overrides:
addFirst in class ShapeItem
Returns:
This rectangular item.
Throws:
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.

Overrides:
addFirst in class ShapeItem
Parameters:
theDrawing - Drawing.
Returns:
This rectangular item.
Throws:
NullPointerException - (unchecked exception) Thrown if theDrawing is null.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write this rectangular item to the given object output stream.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class FilledItem
Parameters:
out - Object output stream.
Throws:
IOException - Thrown if an I/O error occurred.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Read this rectangular item from the given object input stream.

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class FilledItem
Parameters:
in - Object input stream.
Throws:
IOException - Thrown if an I/O error occurred.
ClassNotFoundException - Thrown if any class needed to deserialize this rectangular item cannot be found.


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.