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.
-
bounding_box
-
-
canvas
-
-
color
-
-
enteringText
-
-
grabbed
-
-
grabbedAt
-
-
myKey
-
-
points
-
-
DrawingPrimitive()
-
-
DrawingPrimitive(Rectangle)
- Constructs an empty drawing primitive with a given bounding_box
-
DrawingPrimitive(Vector)
- Constructs a DrawingPrimitive with a given set of points
-
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.
-
describe()
-
-
drawPlot(Graphics)
- Draw the primitive in the given graphics context
-
drawPoints(Graphics)
-
Abstract method that must be implemented by the subclassed
primitive.
-
enteringText()
- Returns a boolean value to see if we're in a text input mode
-
getCanvas()
- Returns the component we're drawing into
-
getColor()
- Retrieves the color we're drawing with
-
getKey()
- Retrieves a Habanero Key for this Primitive.
-
getPoints()
- Retrieves the Vector containing point data
-
grab(int, int)
- Grabs this primitive
-
grabbed()
- Returns whether or not this primitive has been grabbed
-
inside(int, int)
- Returns whether or not the given x,y coordinates are inside this
primitive's region.
-
isDeleted()
- Called when a primitive is removed, does any cleanup.
-
isValid()
-
-
keyDownAction(int)
- Performed when a key is pressed.
-
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.
-
mouseDownAction(int, int)
-
Initializes the data structures for this primitive on mouse down
-
mouseDrag(int, int)
- Preforms the mouse dragging operation for this primitive.
-
mouseDragAction(int, int)
-
Updates the data structures for this primitive during a mouse drag
-
mouseUp(int, int)
- Preforms the mouse up operation for this primitive.
-
mouseUpAction(int, int)
-
Updates the data structures for this primitive during a mouse up
-
move(Point, int, int)
- Move this primitive from the current location to a new (x,y)
-
newInstance()
- Creates a new instance of this primitive.
-
recalibrate(int, int, int, int)
- Given the specified bounding box, return a Rectangle that has
been recalculated for the given points.
-
redraw(int, int, int, int)
- Redraws the region specified by bounding box
-
release()
- Releases the grab on this primitive
-
setBoundingBox(Vector)
- Initialize a bounding_box which contains this set of points
-
setCanvas(Component)
- Sets the component we're drawing into
-
setColor(Color)
- Sets the color we're drawing with
-
setKey(Key)
- Sets a Habanero Key (used by a Habanero Lock) for this
DrawingPrimitive
-
setPoints(Vector)
- Sets the Vector containing point data
color
protected Color color
points
protected Vector points
canvas
protected transient Component canvas
grabbed
protected transient boolean grabbed
grabbedAt
protected transient Point grabbedAt
bounding_box
protected transient Rectangle bounding_box
enteringText
protected transient boolean enteringText
myKey
protected transient Key myKey
DrawingPrimitive
public DrawingPrimitive()
DrawingPrimitive
public DrawingPrimitive(Rectangle rect)
- Constructs an empty drawing primitive with a given bounding_box
- Parameters:
- rect - the Rectangle representing a bounding box
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
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.
setCanvas
public void setCanvas(Component canvas)
- Sets the component we're drawing into
- Parameters:
- component - the component
getCanvas
public Component getCanvas()
- Returns the component we're drawing into
- Returns:
- the component
getPoints
public final Vector getPoints()
- Retrieves the Vector containing point data
setPoints
public void setPoints(Vector pnts)
- Sets the Vector containing point data
- Parameters:
- pnts - the Point Vector
setColor
public void setColor(Color color)
- Sets the color we're drawing with
- Parameters:
- the - Color
getColor
public Color getColor()
- Retrieves the color we're drawing with
- Returns:
- the color
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.
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.
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.
grabbed
public final boolean grabbed()
- Returns whether or not this primitive has been grabbed
- Returns:
- a boolean value
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
release
public void release()
- Releases the grab on this primitive
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
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
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
isDeleted
public void isDeleted()
- Called when a primitive is removed, does any cleanup.
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
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.
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
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
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
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
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.
enteringText
public final boolean enteringText()
- Returns a boolean value to see if we're in a text input mode
- Returns:
- a boolean value
drawPlot
public void drawPlot(Graphics g)
- Draw the primitive in the given graphics context
- Parameters:
- g - the graphics context
drawPoints
public abstract void drawPoints(Graphics g)
- Abstract method that must be implemented by the subclassed
primitive.
setKey
public final void setKey(Key key)
- Sets a Habanero Key (used by a Habanero Lock) for this
DrawingPrimitive
- Parameters:
- key - A Habanero Key
getKey
public final Key getKey()
- Retrieves a Habanero Key for this Primitive.
isValid
public boolean isValid()
All Packages Class Hierarchy This Package Previous Next Index