edu.rit.draw.item
Class Arrow
- java.lang.Object
-
- edu.rit.draw.item.Arrow
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable
public class Arrow extends java.lang.Object implements java.io.ExternalizableClass Arrow provides various kinds of arrowheads that can be added to the ends of a Line.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static ArrowNONEA nonexistent arrow.static ArrowOPENAn open arrow in the shape of a narrow triangle.static ArrowSOLIDA solid arrow in the shape of a narrow triangle.
-
Constructor Summary
Constructors Constructor and Description Arrow()Construct a new nonexistent arrow.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voiddraw(java.awt.Graphics2D g2d, float width, double x, double y, double phi)Draw this arrow in the given graphics context.voidreadExternal(java.io.ObjectInput in)Read this arrow from the given object input stream.voidwriteExternal(java.io.ObjectOutput out)Write this arrow to the given object output stream.
-
-
-
Field Detail
-
NONE
public static final Arrow NONE
A nonexistent arrow.
-
SOLID
public static final Arrow SOLID
A solid arrow in the shape of a narrow triangle.
-
OPEN
public static final Arrow OPEN
An open arrow in the shape of a narrow triangle.
-
-
Method Detail
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite this arrow to the given object output stream.- Specified by:
writeExternalin interfacejava.io.Externalizable- 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.IOExceptionRead this arrow from the given object input stream.- Specified by:
readExternalin interfacejava.io.Externalizable- Parameters:
in- Object input stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
draw
public void draw(java.awt.Graphics2D g2d, float width, double x, double y, double phi)Draw this arrow in the given graphics context. It assumes the graphics context's stroke and paint are already set to the correct values. The arrow is scaled to match the width. The arrow's tip is placed at the coordinates (x,y). The arrow is rotated so it points in the direction given by phi.- Parameters:
g2d- 2-D graphics context.width- Stroke width.x- X coordinate of the arrow's tip.y- Y coordinate of the arrow's tip.phi- Angle in which the arrow points (radians).
-
-
DMelt 3.0 © DataMelt by jWork.ORG