All Packages Class Hierarchy This Package Previous Next Index
Class att.grappa.DrawObjectPeer
java.lang.Object
|
+----att.grappa.DrawObjectPeer
- public abstract class DrawObjectPeer
- extends Object
- implements Observer
This class provides the basis for actually drawing graph elements on a pane.
Extensions of this class and its subclasses allow for the specific drawing
requirements of a particular graph element. For each DrawObject
instance and target DrawPane
instance, there is one
DrawObjectPeer
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
-
DrawObjectPeer(DrawObject, DrawPane)
- Creates a
DrawObjectPeer
related to the supplied DrawObject
and DrawPane
.
-
contains(int, int)
- Checks if the supplied co-ordinates are in the peer.
-
contains(Point)
- Checks if the supplied point is in the peer.
-
draw(Graphics, GraphicContext)
- Draw this peer.
-
free()
- Reset this object and release its resources for garbage collection.
-
getBounds()
- Gets the bounds of this peer in terms of the
DrawPane
coordinates.
-
getDrawObject()
- Get the draw object that is the source of this peer
-
getDrawPane()
- Get the drawing pane used by this peer
-
getNext()
- Get the next peer object sharing the same
DrawObject
source,
but using a different DrawPane
.
-
getTextLabelPeer()
- Get the text label peer that is drawn in conjunction with this peer.
-
inPeer(int, int)
- Checks if the supplied co-ordinates are in the specific shape of
this peer.
-
isDrawnOn(DrawPane)
- Checks if this peer uses the supplied pane for drawing.
-
polygonContainsPoint(Polygon, int, int)
-
-
polygonContainsPoint(Polygon, Point)
-
-
rectangleContainsPoint(Rectangle, int, int)
-
-
rectangleContainsPoint(Rectangle, Point)
-
-
remove()
- Remove this peer from the linked chain of associated peers.
-
setNext(DrawObjectPeer)
- Set the next peer object sharing the same
DrawObject
source,
but using a different DrawPane
.
-
setTextLabelPeer(TextLabelPeer)
- Set the text label peer that is to be drawn in conjunction with this peer.
-
setupPeer(boolean)
- Setup this peer.
-
update(Observable, Object)
- This method is called whenever an observed LinearMap is changed.
DrawObjectPeer
public DrawObjectPeer(DrawObject drawObject,
DrawPane pane)
- Creates a
DrawObjectPeer
related to the supplied DrawObject
and DrawPane
.
- Parameters:
- drawObject - the source object for this peer object
- pane - the pane to use when drawing this peer
getBounds
public abstract Rectangle getBounds()
- Gets the bounds of this peer in terms of the
DrawPane
coordinates.
inPeer
protected abstract 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.
contains
public boolean contains(Point pt)
- Checks if the supplied point is in the peer.
Initially, containment by the bounding box is checked and then,
if contained by the bounding box,
inPeer
is called.
- Parameters:
- pt - the point to be checked
- Returns:
- true if the peer contains the point, false otherwise
- See Also:
- inPeer
contains
public boolean contains(int x,
int y)
- Checks if the supplied co-ordinates are in the peer.
Initially, containment by the bounding box is checked and the,
if contained by the bounding box,
inPeer
is called.
- Parameters:
- x - the x co-ordinate to be checked
- y - the y co-ordinate to be checked
- Returns:
- true if the peer contains the point, false otherwise
- See Also:
- inPeer
isDrawnOn
public boolean isDrawnOn(DrawPane candidate)
- Checks if this peer uses the supplied pane for drawing.
- Parameters:
- candidate - the
DrawPane
to check
- Returns:
- true, if the supplied pane is used for drawing, false otherwise.
getNext
public DrawObjectPeer getNext()
- Get the next peer object sharing the same
DrawObject
source,
but using a different DrawPane
. Peers are stored as a linked
chain.
- Returns:
- the next peer in the linked chain of peers of the source
DrawObject
- See Also:
- getDrawObject, getPeer, getDrawPane
setNext
public DrawObjectPeer setNext(DrawObjectPeer next)
- Set the next peer object sharing the same
DrawObject
source,
but using a different DrawPane
. Peers are stored as a linked
list with the initial link being available from the DrawObject
.
If the supplied peer is already in the linked list, it is not added and it
is set as the return value.
- Returns:
- the value of the peer previously stored in the next slot (which may be null) or the supplied peer if that peer is already somewhere in the linked list
- See Also:
- getDrawObject, getPeer, getDrawPane
setupPeer
public abstract void setupPeer(boolean setupTextToo)
- Setup this peer.
- Parameters:
- setupTextToo - indicates if text peer should be setup as well
draw
public abstract void draw(Graphics gr,
GraphicContext context)
- Draw this peer.
- Parameters:
- gr - the AWT graphic context to use for drawing
- context - the Grappa context to use for drawing
remove
public final void remove()
- Remove this peer from the linked chain of associated peers.
getDrawObject
public DrawObject getDrawObject()
- Get the draw object that is the source of this peer
- Returns:
- the associated draw object
getDrawPane
public DrawPane getDrawPane()
- Get the drawing pane used by this peer
- Returns:
- the associated drawing pane
setTextLabelPeer
public TextLabelPeer setTextLabelPeer(TextLabelPeer peer)
- Set the text label peer that is to be drawn in conjunction with this peer.
- Returns:
- the previously associated text label peer
getTextLabelPeer
public TextLabelPeer getTextLabelPeer()
- Get the text label peer that is drawn in conjunction with this peer.
- Returns:
- the associated text label peer
free
public void free()
- Reset this object and release its resources for garbage collection.
rectangleContainsPoint
public static boolean rectangleContainsPoint(Rectangle rect,
Point pt)
rectangleContainsPoint
public static boolean rectangleContainsPoint(Rectangle rect,
int x,
int y)
polygonContainsPoint
public static boolean polygonContainsPoint(Polygon poly,
Point pt)
polygonContainsPoint
public static boolean polygonContainsPoint(Polygon poly,
int x,
int y)
update
public void update(Observable obs,
Object arg)
- This method is called whenever an observed LinearMap is changed.
It is required by the
Observer
interface.
- Parameters:
- obs - the observable object that has been updated
- arg - when not null, it indicates that
obs
need no longer be
observed and in its place arg
should be observed.
All Packages Class Hierarchy This Package Previous Next Index