edu.rit.slides.items
Class RectangleItem

java.lang.Object
  extended by edu.rit.slides.items.SlideItem
      extended by edu.rit.slides.items.OutlinedItem
          extended by edu.rit.slides.items.FilledItem
              extended by edu.rit.slides.items.ShapeItem
                  extended by edu.rit.slides.items.RectangleItem
All Implemented Interfaces:
Externalizable, Serializable

public class RectangleItem
extends ShapeItem
implements Externalizable

Class RectangleItem provides a rectangle SlideItem.

Class RectangleItem keeps track of the "last rectangle item." The static RectangleItem.last() method returns a reference to the last created rectangle item.

When a RectangleItem is created, the "last point" (returned by the Point.last() method) is set to the point where the rectangle item was located.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.rit.slides.items.FilledItem
NORMAL_FILL
 
Fields inherited from class edu.rit.slides.items.OutlinedItem
NORMAL_OUTLINE
 
Constructor Summary
RectangleItem()
          Construct a new empty rectangle item.
RectangleItem(Point theLocation, Size theSize)
          Construct a new rectangle item.
RectangleItem(Point theLocation, Size theSize, Fill theFill)
          Construct a new rectangle item.
RectangleItem(Point theLocation, Size theSize, Outline theOutline)
          Construct a new rectangle item.
RectangleItem(Point theLocation, Size theSize, Outline theOutline, Fill theFill)
          Construct a new rectangle item.
 
Method Summary
 Point c()
          Returns the center point of this rectangle item.
 Point e()
          Returns the east middle point of this rectangle item.
static RectangleItem last()
          Returns the last rectangle item created.
 Point location()
          Returns this rectangle item's upper left corner location.
 Point n()
          Returns the north middle point of this rectangle item.
 Point ne()
          Returns the northeast corner point of this rectangle item.
 Point nw()
          Returns the northwest corner point of this rectangle item.
 void readExternal(ObjectInput in)
          Read this rectangle from the given object input stream.
 Point s()
          Returns the south middle point of this rectangle item.
 Point se()
          Returns the southeast corner point of this rectangle item.
 Size size()
          Returns this rectangle item's size.
 Point sw()
          Returns the southwest corner point of this rectangle item.
 Point w()
          Returns the west middle point of this rectangle item.
 void writeExternal(ObjectOutput out)
          Write this rectangle item to the given object output stream.
 
Methods inherited from class edu.rit.slides.items.ShapeItem
draw
 
Methods inherited from class edu.rit.slides.items.FilledItem
setDefaultFill
 
Methods inherited from class edu.rit.slides.items.OutlinedItem
setDefaultOutline
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RectangleItem

public RectangleItem()
Construct a new empty rectangle item.


RectangleItem

public RectangleItem(Point theLocation,
                     Size theSize)
Construct a new rectangle item. The default outline is used. The default fill paint is used.

Parameters:
theLocation - Upper left corner location.
theSize - Size.
Throws:
NullPointerException - (unchecked exception) Thrown if theLocation is null or theSize is null.
IllegalArgumentException - (unchecked exception) Thrown if both the default outline is Outline.NONE (null) and the default fill paint is Fill.NONE (null).

RectangleItem

public RectangleItem(Point theLocation,
                     Size theSize,
                     Fill theFill)
Construct a new rectangle item. The default outline is used. The given fill paint is used.

Parameters:
theLocation - Upper left corner location.
theSize - Size.
theFill - Fill paint, or Fill.NONE.
Throws:
NullPointerException - (unchecked exception) Thrown if theLocation is null or theSize is null.
IllegalArgumentException - (unchecked exception) Thrown if both the default outline is Outline.NONE (null) and theFill is Fill.NONE (null).

RectangleItem

public RectangleItem(Point theLocation,
                     Size theSize,
                     Outline theOutline)
Construct a new rectangle item. The given outline is used. The default fill paint is used.

Parameters:
theLocation - Upper left corner location.
theSize - Size.
theOutline - Outline, or Outline.NONE.
Throws:
NullPointerException - (unchecked exception) Thrown if theLocation is null or theSize is null.
IllegalArgumentException - (unchecked exception) Thrown if both theOutline is Outline.NONE (null) and the default fill paint is Fill.NONE (null).

RectangleItem

public RectangleItem(Point theLocation,
                     Size theSize,
                     Outline theOutline,
                     Fill theFill)
Construct a new rectangle item. The given outline is used. The given fill paint is used.

Parameters:
theLocation - Upper left corner location.
theSize - Size.
theOutline - Outline, or Outline.NONE.
theFill - Fill paint, or Fill.NONE.
Throws:
NullPointerException - (unchecked exception) Thrown if theLocation is null or theSize is null.
IllegalArgumentException - (unchecked exception) Thrown if both theOutline is Outline.NONE (null) and theFill is Fill.NONE (null).
Method Detail

last

public static RectangleItem last()
Returns the last rectangle item created. If no rectangle items have been created yet, null is returned.


location

public Point location()
Returns this rectangle item's upper left corner location.


size

public Size size()
Returns this rectangle item's size.


nw

public Point nw()
Returns the northwest corner point of this rectangle item.


n

public Point n()
Returns the north middle point of this rectangle item.


ne

public Point ne()
Returns the northeast corner point of this rectangle item.


w

public Point w()
Returns the west middle point of this rectangle item.


c

public Point c()
Returns the center point of this rectangle item.


e

public Point e()
Returns the east middle point of this rectangle item.


sw

public Point sw()
Returns the southwest corner point of this rectangle item.


s

public Point s()
Returns the south middle point of this rectangle item.


se

public Point se()
Returns the southeast corner point of this rectangle item.


writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write this rectangle 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 rectangle 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 rectangle cannot be found.


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