edu.rit.draw.item
Class ShapeItem
- java.lang.Object
-
- edu.rit.draw.item.DrawingItem
-
- edu.rit.draw.item.OutlinedItem
-
- edu.rit.draw.item.FilledItem
-
- edu.rit.draw.item.ShapeItem
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.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
Constructors Constructor and Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description ShapeItemadd()Add this shape item to the end of the default drawing's sequence of drawing items.ShapeItemadd(Drawing theDrawing)Add this shape item to the end of the given drawing's sequence of drawing items.ShapeItemaddFirst()Add this shape item to the beginning of the default drawing's sequence of drawing items.ShapeItemaddFirst(Drawing theDrawing)Add this shape item to the beginning of the given drawing's sequence of drawing items.voiddraw(java.awt.Graphics2D g2d)Draw this drawing item in the given graphics context.ShapeItemfill(Fill theFill)Set this shape item's fill paint.ShapeItemoutline(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
-
-
-
-
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:
java.lang.NullPointerException- (unchecked exception) Thrown if theItem is null.
-
-
Method Detail
-
outline
public ShapeItem outline(Outline theOutline)
Set this shape item's outline.- Overrides:
outlinein classFilledItem- Parameters:
theOutline- Outline, or Outline.NONE.- Returns:
- This shape item.
-
fill
public ShapeItem fill(Fill theFill)
Set this shape item's fill paint.- Overrides:
fillin classFilledItem- 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:
addin classFilledItem- Returns:
- This shape item.
- Throws:
java.lang.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:
addin classFilledItem- Parameters:
theDrawing- Drawing.- Returns:
- This shape item.
- Throws:
java.lang.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:
addFirstin classFilledItem- Returns:
- This shape item.
- Throws:
java.lang.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:
addFirstin classFilledItem- Parameters:
theDrawing- Drawing.- Returns:
- This shape item.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theDrawing is null.
-
draw
public void draw(java.awt.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:
drawin classDrawingItem- Parameters:
g2d- 2-D graphics context.
-
-
DMelt 3.0 © DataMelt by jWork.ORG