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

Constructor Index

 o DrawObjectPeer(DrawObject, DrawPane)
Creates a DrawObjectPeer related to the supplied DrawObject and DrawPane.

Method Index

 o contains(int, int)
Checks if the supplied co-ordinates are in the peer.
 o contains(Point)
Checks if the supplied point is in the peer.
 o draw(Graphics, GraphicContext)
Draw this peer.
 o free()
Reset this object and release its resources for garbage collection.
 o getBounds()
Gets the bounds of this peer in terms of the DrawPane coordinates.
 o getDrawObject()
Get the draw object that is the source of this peer
 o getDrawPane()
Get the drawing pane used by this peer
 o getNext()
Get the next peer object sharing the same DrawObject source, but using a different DrawPane.
 o getTextLabelPeer()
Get the text label peer that is drawn in conjunction with this peer.
 o inPeer(int, int)
Checks if the supplied co-ordinates are in the specific shape of this peer.
 o isDrawnOn(DrawPane)
Checks if this peer uses the supplied pane for drawing.
 o polygonContainsPoint(Polygon, int, int)
 o polygonContainsPoint(Polygon, Point)
 o rectangleContainsPoint(Rectangle, int, int)
 o rectangleContainsPoint(Rectangle, Point)
 o remove()
Remove this peer from the linked chain of associated peers.
 o setNext(DrawObjectPeer)
Set the next peer object sharing the same DrawObject source, but using a different DrawPane.
 o setTextLabelPeer(TextLabelPeer)
Set the text label peer that is to be drawn in conjunction with this peer.
 o setupPeer(boolean)
Setup this peer.
 o update(Observable, Object)
This method is called whenever an observed LinearMap is changed.

Constructors

 o 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

Methods

 o getBounds
 public abstract Rectangle getBounds()
Gets the bounds of this peer in terms of the DrawPane coordinates.

 o 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.
 o 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
 o 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
 o 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.
 o 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
 o 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
 o setupPeer
 public abstract void setupPeer(boolean setupTextToo)
Setup this peer.

Parameters:
setupTextToo - indicates if text peer should be setup as well
 o 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
 o remove
 public final void remove()
Remove this peer from the linked chain of associated peers.

 o getDrawObject
 public DrawObject getDrawObject()
Get the draw object that is the source of this peer

Returns:
the associated draw object
 o getDrawPane
 public DrawPane getDrawPane()
Get the drawing pane used by this peer

Returns:
the associated drawing pane
 o 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
 o getTextLabelPeer
 public TextLabelPeer getTextLabelPeer()
Get the text label peer that is drawn in conjunction with this peer.

Returns:
the associated text label peer
 o free
 public void free()
Reset this object and release its resources for garbage collection.

 o rectangleContainsPoint
 public static boolean rectangleContainsPoint(Rectangle rect,
                                              Point pt)
 o rectangleContainsPoint
 public static boolean rectangleContainsPoint(Rectangle rect,
                                              int x,
                                              int y)
 o polygonContainsPoint
 public static boolean polygonContainsPoint(Polygon poly,
                                            Point pt)
 o polygonContainsPoint
 public static boolean polygonContainsPoint(Polygon poly,
                                            int x,
                                            int y)
 o 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