edu.rit.draw.item
Class ShapeItem

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
All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
Polygon, RectangularItem

public abstract class ShapeItem
extends FilledItem

Class ShapeItem is the abstract base class for a DrawingItem that consists of a single 2-D graphics shape with an outline and an interior.

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
ShapeItem()
          Construct a new shape item.
ShapeItem(ShapeItem theItem)
          Construct a new shape item with the same outline and fill paint as the given shape item.
 
Method Summary
 ShapeItem add()
          Add this shape item to the end of the default drawing's sequence of drawing items.
 ShapeItem add(Drawing theDrawing)
          Add this shape item to the end of the given drawing's sequence of drawing items.
 ShapeItem addFirst()
          Add this shape item to the beginning of the default drawing's sequence of drawing items.
 ShapeItem addFirst(Drawing theDrawing)
          Add this shape item to the beginning of the given drawing's sequence of drawing items.
 void draw(Graphics2D g2d)
          Draw this drawing item in the given graphics context.
 ShapeItem fill(Fill theFill)
          Set this shape item's fill paint.
 ShapeItem outline(Outline theOutline)
          Set this shape item's outline.
 
Methods inherited from class edu.rit.draw.item.FilledItem
defaultFill, defaultFill, fill, readExternal, writeExternal
 
Methods inherited from class edu.rit.draw.item.OutlinedItem
defaultOutline, defaultOutline, outline
 
Methods inherited from class edu.rit.draw.item.DrawingItem
boundingBox, c, e, height, n, ne, nw, s, se, size, sw, w, width
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeItem

public ShapeItem()
Construct a new shape item.


ShapeItem

public ShapeItem(ShapeItem theItem)
Construct a new shape item with the same outline and fill paint as the given shape item.

Parameters:
theItem - Shape item.
Throws:
NullPointerException - (unchecked exception) Thrown if theItem is null.
Method Detail

outline

public ShapeItem outline(Outline theOutline)
Set this shape item's outline.

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

fill

public ShapeItem fill(Fill theFill)
Set this shape item's fill paint.

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

add

public ShapeItem add()
Add this shape item to the end of the default drawing's sequence of drawing items.

Overrides:
add in class FilledItem
Returns:
This shape item.
Throws:
NullPointerException - (unchecked exception) Thrown if there is no default drawing.
See Also:
Drawing.defaultDrawing()

add

public ShapeItem add(Drawing theDrawing)
Add this shape item to the end of the given drawing's sequence of drawing items.

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

addFirst

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

Overrides:
addFirst in class FilledItem
Returns:
This shape item.
Throws:
NullPointerException - (unchecked exception) Thrown if there is no default drawing.
See Also:
Drawing.defaultDrawing()

addFirst

public ShapeItem addFirst(Drawing theDrawing)
Add this shape item to the beginning of the given drawing's sequence of drawing items.

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

draw

public void draw(Graphics2D g2d)
Draw this drawing item in the given graphics context. This method is allowed to change the graphics context's paint, stroke, and transform, and it doesn't have to change them back.

Overrides:
draw in class DrawingItem
Parameters:
g2d - 2-D graphics context.


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