All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ncsa.awt.draw.DrawingPrimitive

java.lang.Object
   |
   +----ncsa.awt.draw.DrawingPrimitive

public abstract class DrawingPrimitive
extends Object
implements Marshallable, Describable
An abstract class from which all other drawing primtives are derived.


Variable Index

 o bounding_box
 o canvas
 o color
 o enteringText
 o grabbed
 o grabbedAt
 o myKey
 o points

Constructor Index

 o DrawingPrimitive()
 o DrawingPrimitive(Rectangle)
Constructs an empty drawing primitive with a given bounding_box
 o DrawingPrimitive(Vector)
Constructs a DrawingPrimitive with a given set of points

Method Index

 o commonAction(int, int)
An action that can be used by both a mouseDrag and mouseUp In this case, it updates the bounding box of the primitive with the new (x, y) coordinate.
 o describe()
 o drawPlot(Graphics)
Draw the primitive in the given graphics context
 o drawPoints(Graphics)
Abstract method that must be implemented by the subclassed primitive.
 o enteringText()
Returns a boolean value to see if we're in a text input mode
 o getCanvas()
Returns the component we're drawing into
 o getColor()
Retrieves the color we're drawing with
 o getKey()
Retrieves a Habanero Key for this Primitive.
 o getPoints()
Retrieves the Vector containing point data
 o grab(int, int)
Grabs this primitive
 o grabbed()
Returns whether or not this primitive has been grabbed
 o inside(int, int)
Returns whether or not the given x,y coordinates are inside this primitive's region.
 o isDeleted()
Called when a primitive is removed, does any cleanup.
 o isValid()
 o keyDownAction(int)
Performed when a key is pressed.
 o mouseDown(int, int)
Sets up the vector of points we're going to do in this drawing operation, and calls the mouseDownAction with point coordinates.
 o mouseDownAction(int, int)
Initializes the data structures for this primitive on mouse down
 o mouseDrag(int, int)
Preforms the mouse dragging operation for this primitive.
 o mouseDragAction(int, int)
Updates the data structures for this primitive during a mouse drag
 o mouseUp(int, int)
Preforms the mouse up operation for this primitive.
 o mouseUpAction(int, int)
Updates the data structures for this primitive during a mouse up
 o move(Point, int, int)
Move this primitive from the current location to a new (x,y)
 o newInstance()
Creates a new instance of this primitive.
 o recalibrate(int, int, int, int)
Given the specified bounding box, return a Rectangle that has been recalculated for the given points.
 o redraw(int, int, int, int)
Redraws the region specified by bounding box
 o release()
Releases the grab on this primitive
 o setBoundingBox(Vector)
Initialize a bounding_box which contains this set of points
 o setCanvas(Component)
Sets the component we're drawing into
 o setColor(Color)
Sets the color we're drawing with
 o setKey(Key)
Sets a Habanero Key (used by a Habanero Lock) for this DrawingPrimitive
 o setPoints(Vector)
Sets the Vector containing point data

Variables

 o color
 protected Color color
 o points
 protected Vector points
 o canvas
 protected transient Component canvas
 o grabbed
 protected transient boolean grabbed
 o grabbedAt
 protected transient Point grabbedAt
 o bounding_box
 protected transient Rectangle bounding_box
 o enteringText
 protected transient boolean enteringText
 o myKey
 protected transient Key myKey

Constructors

 o DrawingPrimitive
 public DrawingPrimitive()
 o DrawingPrimitive
 public DrawingPrimitive(Rectangle rect)
Constructs an empty drawing primitive with a given bounding_box

Parameters:
rect - the Rectangle representing a bounding box
 o DrawingPrimitive
 public DrawingPrimitive(Vector pnts)
Constructs a DrawingPrimitive with a given set of points

Parameters:
pnts - the Vector containing the list of points for this drawing primitive

Methods

 o setBoundingBox
 public void setBoundingBox(Vector pnts)
Initialize a bounding_box which contains this set of points

Parameters:
pnts - the Vector containing the DrawingPrimitive which are used to construct the bounding box.
 o setCanvas
 public void setCanvas(Component canvas)
Sets the component we're drawing into

Parameters:
component - the component
 o getCanvas
 public Component getCanvas()
Returns the component we're drawing into

Returns:
the component
 o getPoints
 public final Vector getPoints()
Retrieves the Vector containing point data

 o setPoints
 public void setPoints(Vector pnts)
Sets the Vector containing point data

Parameters:
pnts - the Point Vector
 o setColor
 public void setColor(Color color)
Sets the color we're drawing with

Parameters:
the - Color
 o getColor
 public Color getColor()
Retrieves the color we're drawing with

Returns:
the color
 o mouseDown
 public void mouseDown(int x,
                       int y)
Sets up the vector of points we're going to do in this drawing operation, and calls the mouseDownAction with point coordinates.

Parameters:
x - the x coordinate when the mouseDown event occurred.
y - the y coordinate when the mouseDown event occurred.
 o mouseDrag
 public void mouseDrag(int x,
                       int y)
Preforms the mouse dragging operation for this primitive. If the primitive has been selected for a dragging operation, the move method is called. Otherwise, it's a straight drawing operation, so the mouseDragAction method is called.

Parameters:
x - the x coordinate when the mouseDrag event occurred.
y - the y coordinate when the mouseDrag event occurred.
 o mouseUp
 public void mouseUp(int x,
                     int y)
Preforms the mouse up operation for this primitive. If the primitive has been selected for a dragging operation, nothing is done. Otherwise, it's a straight drawing operation, so the mouseUpAction method is called.

Parameters:
x - the x coordinate when the mouseUp event occurred.
y - the y coordinate when the mouseUp event occurred.
 o grabbed
 public final boolean grabbed()
Returns whether or not this primitive has been grabbed

Returns:
a boolean value
 o grab
 public void grab(int x,
                  int y)
Grabs this primitive

Parameters:
x - the x coordinate where the primitive was grabbed
y - the y coordinate where the primitive was grabbed
 o release
 public void release()
Releases the grab on this primitive

 o redraw
 public Rectangle redraw(int x0,
                         int y0,
                         int x1,
                         int y1)
Redraws the region specified by bounding box

Parameters:
x0 - upper left hand x coordinate of bounding box
y0 - upper left hand y coordinate of bounding box
x1 - lower right hand x coordinate of bounding box
y1 - lower right hand y coordinate of bounding box
 o recalibrate
 public Rectangle recalibrate(int x0,
                              int y0,
                              int x1,
                              int y1)
Given the specified bounding box, return a Rectangle that has been recalculated for the given points. Java currently (JDK 1.0) doesn't allow negative height and width, so this routine is necessary recalibrate rectangular region specified.

Parameters:
x0 - upper left hand x coordinate of bounding box
y0 - upper left hand y coordinate of bounding box
x1 - lower right hand x coordinate of bounding box
y1 - lower right hand y coordinate of bounding box
 o inside
 public boolean inside(int x,
                       int y)
Returns whether or not the given x,y coordinates are inside this primitive's region.

Parameters:
x - the x coordinate
y - the y coordinate
 o isDeleted
 public void isDeleted()
Called when a primitive is removed, does any cleanup.

 o move
 public void move(Point start,
                  int x,
                  int y)
Move this primitive from the current location to a new (x,y)

Parameters:
start - the reference Point at which this move started
x - the x coordinate
y - the y coordinate
 o newInstance
 public DrawingPrimitive newInstance()
Creates a new instance of this primitive. In order for a newInstance() method to be called directly (without this routine), the user would have to specify the actual name of the object. Ideally, this would just be by doing something like: dp = (DrawingPrimitive)Class.forName("Oval").newInstance(); However, since these routines exist within a package, the user would have to specify a fully qualified package name and object name to create the object. It could end up looking like: dp = (DrawingPrimitive)Class.forName("ncsa.drawing.Oval").newInstance(); And, if the package ever changed locations, the code in the user application would need to be modified. In order to spare the user this, I created this routine which handles everything internally.

 o mouseDownAction
 public void mouseDownAction(int x,
                             int y)
Initializes the data structures for this primitive on mouse down

Parameters:
x - the x coordinate
y - the y coordinate
 o commonAction
 public void commonAction(int x,
                          int y)
An action that can be used by both a mouseDrag and mouseUp In this case, it updates the bounding box of the primitive with the new (x, y) coordinate. This is used for drawing and DrawingPrimitive selection.

Parameters:
x - the x coordinate
y - the y coordinate
 o mouseDragAction
 public void mouseDragAction(int x,
                             int y)
Updates the data structures for this primitive during a mouse drag

Parameters:
x - the x coordinate
y - the y coordinate
 o mouseUpAction
 public void mouseUpAction(int x,
                           int y)
Updates the data structures for this primitive during a mouse up

Parameters:
x - the x coordinate
y - the y coordinate
 o keyDownAction
 public void keyDownAction(int key)
Performed when a key is pressed. For most primitives, this is empty. It can be used to implement text input, or multi-action drawing primitives.

 o enteringText
 public final boolean enteringText()
Returns a boolean value to see if we're in a text input mode

Returns:
a boolean value
 o drawPlot
 public void drawPlot(Graphics g)
Draw the primitive in the given graphics context

Parameters:
g - the graphics context
 o drawPoints
 public abstract void drawPoints(Graphics g)
Abstract method that must be implemented by the subclassed primitive.

 o setKey
 public final void setKey(Key key)
Sets a Habanero Key (used by a Habanero Lock) for this DrawingPrimitive

Parameters:
key - A Habanero Key
 o getKey
 public final Key getKey()
Retrieves a Habanero Key for this Primitive.

 o isValid
 public boolean isValid()

All Packages  Class Hierarchy  This Package  Previous  Next  Index