All Packages Class Hierarchy This Package Previous Next Index
Class att.grappa.DrawNodePeer
java.lang.Object
|
+----att.grappa.DrawObjectPeer
|
+----att.grappa.DrawNodePeer
- public class DrawNodePeer
- extends DrawObjectPeer
This class provides the basis for actually drawing node elements on a pane.
Extensions of this class and its subclasses allow for the specific drawing
requirements of a particular node element. For each DrawNode
instance and target DrawPane
instance, there is one
DrawNodePeer
instance.
The size and position of the object are possibly scaled and translated from
the values originally supplied through the element attributes as
a consequence of the characteristics of the DrawPane
.
Certainly the y-axis is flipped to account for the origin at the upper-left
as used by the AWT versus the origin to the lower-left as used by the graph.
- Version:
- 1.1, 30 Sep 1999; Copyright 1996 - 1999 by AT&T Corp.
- Author:
- John Mocenigo, Research @ AT&T Labs
-
DrawNodePeer(DrawNode, DrawPane)
- Create an instance of a
DrawNodePeer
related to the supplied DrawNode
and DrawPane
.
-
draw(Graphics, GraphicContext)
- Draws the node using the specified graphics information.
-
getBounds()
- Gets the bounds of this peer in terms of the
DrawPane
coordinates.
-
getCenter()
- Get the center point of the node.
-
getDrawNode()
- Get the
DrawNode
object associated with this peer
-
inOval(int, int, Rectangle, int)
- Check if the supplied co-ordinates are in the oval specified by the
given bounding box and line width.
-
inPeer(int, int)
- Checks if the supplied co-ordinates are in the specific shape of
this peer.
-
setupPeer(boolean)
- Setup this peer.
DrawNodePeer
public DrawNodePeer(DrawNode drawNode,
DrawPane pane)
- Create an instance of a
DrawNodePeer
related to the supplied DrawNode
and DrawPane
.
- Parameters:
- drawNode - the source object for this peer object
- pane - the pane to use when drawing this peer
getBounds
public Rectangle getBounds()
- Gets the bounds of this peer in terms of the
DrawPane
coordinates.
- Returns:
- the bounding box of the peer
- Overrides:
- getBounds in class DrawObjectPeer
draw
public void draw(Graphics gr,
GraphicContext context)
- Draws the node using the specified graphics information.
- Parameters:
- gr - the AWT graphics context to use for drawing, if the value
is null, then the off-screen canvas
Graphics
is used.
- context - the graphic context to use when drawing.
If the context is null, the object's context is used.
- Overrides:
- draw in class DrawObjectPeer
getCenter
public Point getCenter()
- Get the center point of the node.
This value is the pos attribute value translated into the
DrawPane
co-ordinates.
- Returns:
- the center point of the node
setupPeer
public void setupPeer(boolean setupTextToo)
- Setup this peer.
The setup does the actual co-ordinate mappings from what is available
in the
DrawNode
object to the DrawPane
co-ordinates.
- Parameters:
- setupTextToo - indicates if text peer should be setup as well
- Overrides:
- setupPeer in class DrawObjectPeer
inPeer
public boolean inPeer(int x,
int y)
- Checks if the supplied co-ordinates are in the specific shape of
this peer.
- Parameters:
- x - the x co-ordinate to check
- y - the y co-ordinate to check
- Returns:
- true if the co-ordinates lie inside the peer or on its boundary,
false otherwise.
- Overrides:
- inPeer in class DrawObjectPeer
inOval
public static boolean inOval(int x,
int y,
Rectangle bbox,
int lineWidth)
- Check if the supplied co-ordinates are in the oval specified by the
given bounding box and line width.
- Parameters:
- x - the x co-ordinate
- y - the y co-ordinate
- bbox - the bounding box of the oval
- lineWidth - the width of the oval outline
- Returns:
- true if the co-ordinates are in the oval, false otherwise
getDrawNode
public DrawNode getDrawNode()
- Get the
DrawNode
object associated with this peer
- Returns:
- the associated
DrawNode
object
All Packages Class Hierarchy This Package Previous Next Index