edu.rit.slides.items
Class Bullet

java.lang.Object
  extended by edu.rit.slides.items.Bullet
All Implemented Interfaces:
Externalizable, Serializable

public class Bullet
extends Object
implements Externalizable

Class Bullet provides various kinds of bullets that can be added to a TextItem. The bullet is always added to the left of the text item, with a specified distance from the left side of the bullet to the left side of the text item.

See Also:
Serialized Form

Field Summary
static int BULLET_KIND_CIRCLE
          A kind of bullet in the shape of a medium sized circle.
static int BULLET_KIND_DOT
          A kind of bullet in the shape of a medium sized dot.
static int BULLET_KIND_NONE
          A kind of bullet with no shape.
static Bullet CIRCLE
          A bullet in the shape of a medium sized circle, offset 36.0 (1/2 inch) from the text item.
static Bullet DOT
          A bullet in the shape of a medium sized dot, offset 36.0 (1/2 inch) from the text item.
static Bullet NONE
          A nonexistent bullet.
static double NORMAL_OFFSET
          The normal bullet offset, 36.0 (1/2 inch).
 
Constructor Summary
Bullet()
          Construct a new empty bullet.
Bullet(int theKind)
          Construct a new bullet of the given kind.
Bullet(int theKind, double theOffset)
          Construct a new bullet of the given kind with the given offset.
 
Method Summary
 void draw(Graphics2D g2d, double ascent, double x, double y)
          Draw this bullet in the given graphics context.
 void readExternal(ObjectInput in)
          Read this bullet from the given object input stream.
 void writeExternal(ObjectOutput out)
          Write this bullet to the given object output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BULLET_KIND_NONE

public static final int BULLET_KIND_NONE
A kind of bullet with no shape.

See Also:
Constant Field Values

BULLET_KIND_DOT

public static final int BULLET_KIND_DOT
A kind of bullet in the shape of a medium sized dot.

See Also:
Constant Field Values

BULLET_KIND_CIRCLE

public static final int BULLET_KIND_CIRCLE
A kind of bullet in the shape of a medium sized circle.

See Also:
Constant Field Values

NORMAL_OFFSET

public static final double NORMAL_OFFSET
The normal bullet offset, 36.0 (1/2 inch).

See Also:
Constant Field Values

NONE

public static final Bullet NONE
A nonexistent bullet.


DOT

public static final Bullet DOT
A bullet in the shape of a medium sized dot, offset 36.0 (1/2 inch) from the text item.


CIRCLE

public static final Bullet CIRCLE
A bullet in the shape of a medium sized circle, offset 36.0 (1/2 inch) from the text item.

Constructor Detail

Bullet

public Bullet()
Construct a new empty bullet.


Bullet

public Bullet(int theKind)
Construct a new bullet of the given kind. The normal offset (Bullet.NORMAL_OFFSET) is used.

Parameters:
theKind - Kind of bullet (one of the BULLET_KIND_XXX values).
Throws:
IllegalArgumentException - (unchecked exception) Thrown if theKind is not one of the legal kinds of bullet.

Bullet

public Bullet(int theKind,
              double theOffset)
Construct a new bullet of the given kind with the given offset.

Parameters:
theKind - Kind of bullet (one of the BULLET_KIND_XXX values).
theOffset - Offset from left side of bullet to left side of text.
Throws:
IllegalArgumentException - (unchecked exception) Thrown if theKind is not one of the legal kinds of bullet.
Method Detail

draw

public void draw(Graphics2D g2d,
                 double ascent,
                 double x,
                 double y)
Draw this bullet in the given graphics context. It assumes the graphics context's paint is already set to the correct value. The bullet is scaled to match the ascent. The bullet's left side is placed relative to the coordinates of the left end of the text baseline (x,y).

Parameters:
g2d - 2-D graphics context.
ascent - Text font ascent.
x - X coordinate of the left end of the text baseline.
y - Y coordinate of the left end of the text baseline.

writeExternal

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

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

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Read this bullet from the given object input stream.

Specified by:
readExternal in interface Externalizable
Parameters:
in - Object input stream.
Throws:
IOException - Thrown if an I/O error occurred.


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