All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class att.grappa.DrawObject

java.lang.Object
   |
   +----att.grappa.DrawObject

public abstract class DrawObject
extends Object
implements Observer, Shape
This class provides the basis for the drawing of graph elements. Extensions of this class and its subclasses allow the drawing methods to be customized. A large set of polygonal shapes are supplied with Grappa. The size and position of the object are as they are specified by the element attributes.

Version:
1.1, 30 Sep 1999; Copyright 1996 - 1999 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs

Variable Index

 o BBOX_HASH
Hash code for bounding box attribute (bb)
 o BoundingBox
The bounding box of the element
 o COLOR_HASH
Hash code for color attribute (color)
 o DELETION
Value for indicating a deletion highlight
 o DISTORTION_HASH
Hash code for distortion attribute (distortion)
 o FONTCOLOR_HASH
Hash code for fontcolor attribute (fontcolor)
 o FONTNAME_HASH
Hash code for fontname attribute (fontname)
 o FONTSIZE_HASH
Hash code for fontsize attribute (fontsize)
 o FONTSTYLE_HASH
Hash code for fontstyle attribute (fontstyle)
 o GROUPING
Value for indicating a grouping highlight
 o HEIGHT_HASH
Hash code for height attribute (height)
 o LABEL_HASH
Hash code for label attribute (label)
 o LP_HASH
Hash code for label position attribute (lp)
 o ORIENTATION_HASH
Hash code for orientation attribute (orientation)
 o PERIPHERIES_HASH
Hash code for peripheries attribute (peripheries)
 o pointsPerInch
The number of points per inch.
 o POS_HASH
Hash code for position attribute (pos)
 o RANKDIR_HASH
Hash code for rank direction attribute (rankdir)
 o RECTS_HASH
Hash code for rectangles attribute (rects)
 o SELECTION
Value for indicating a selection highlight
 o SIDES_HASH
Hash code for sides attribute (sides)
 o SKEW_HASH
Hash code for skew attribute (skew)
 o STYLE_HASH
Hash code for style attribute (style)
 o WIDTH_HASH
Hash code for width attribute (width)

Constructor Index

 o DrawObject()
Of course, this abstract class cannot be directly instantiated.

Method Index

 o arrayForTuple(String)
Converts string of delimited integers to an array of integers.
 o attrNotOfInterest(String)
Remove the name of an attribute of interest to this object
 o attrOfInterest(String)
Add the name of an attribute of interest to this class
 o containsPanePoint(DrawPane, Point)
Checks if the supplied point is inside this object as it is drawn on the supplied pane.
 o containsPaneXY(DrawPane, int, int)
Checks if the supplied coordinates are inside this object as it is drawn on the supplied pane.
 o createPeer(DrawPane)
Creates the drawing peer specific for this object and the specified pane.
 o deletePeer(DrawPane)
Delete the peer associated with this object and the specified pane.
 o dimensionForWidthHeight(String, String)
Converts pair of floating point strings to a Dimension.
 o draw()
A convenience method that is equivalent to draw(null,null).
 o draw(GraphicContext, DrawPane)
Draws the graph element using the specified graphic context.
 o emptyMeansRemove(Attribute)
Remove the local attribute from the element associated with this DrawObject.
 o erase(DrawPane)
Erases the graph element from the specified pane.
 o free()
Reset this object and release its resources for garbage collection.
 o getBounds()
Get the bounding box of this element
 o getBoundsFlag()
Get the value of the bounds flag.
 o getColorGC()
Get the graphic context used for coloring.
 o getElement()
Get the element associated with this object.
 o getGC()
Get the graphic context of this object.
 o getHighlightModes()
Get the current value of the highlight mode settings
 o getParentGC()
Get the graphic context of this object's parent subgraph.
 o getPeer()
Get the starting peer for the linked-list of peers associated with this object.
 o getPeerFor(DrawPane)
Get the peer for this object and the specified pane
 o getRedrawFlag()
Get the current redraw flag.
 o getTextLabel()
Get the text label associated with this object
 o hasHighlightMode(long)
Check if the specified highlight mode is active
 o highlightOff(long)
Turn the specified highlighting mode off for this object
 o highlightOn(long)
Turn the specified highlighting mode on for this object
 o initialize(AppObject)
Initializes the DrawObject.
 o isOfInterest(String)
Check if the name of an attribute of interest to this object
 o iSpy(Attribute)
Check if supplied attribute is of interest.
 o iSpy(Attribute, Attribute)
Check if supplied attribute is of interest.
 o needSetup()
Mark this object as requiring set-up
 o pointForTuple(String)
Converts string of comma separated integers to a Point.
 o rectForTuple(String)
Converts string of comma separated integers to a Rectangle.
 o redraw()
Redraw the object.
 o setBounds()
This method to be called when the bounding box needs to be calculated.
 o setBoundsFlag(boolean)
Setting the bounds flag true indicates that the bounding box needs to be recomputed.
 o setDrawObject(Element)
Create the DrawObject for the given Element.
 o setPeer(DrawObjectPeer)
Set the starting peer for the linked-list of peers associated with this object.
 o setRedrawFlag(boolean)
Set the redraw flag.
 o setTextLabel(TextLabel)
Set the text label for this object
 o setupDrawObject(GraphicContext)
Prepares this object for drawing with respect to the specified context.
 o setupNeeded()
Check if it appears that this object needs to be set-up
 o setupPeers(GraphicContext)
Set-up the peers associated with this object.
 o update(Observable, Object)
This method is called whenever an observed Attribute is changed.

Variables

 o pointsPerInch
 public static final double pointsPerInch
The number of points per inch. This choice is fairly standard and also it is the one used by the layout programs (e.g., dot).

 o SELECTION
 public static final long SELECTION
Value for indicating a selection highlight

 o DELETION
 public static final long DELETION
Value for indicating a deletion highlight

 o GROUPING
 public static final long GROUPING
Value for indicating a grouping highlight

 o BBOX_HASH
 public static final int BBOX_HASH
Hash code for bounding box attribute (bb)

 o COLOR_HASH
 public static final int COLOR_HASH
Hash code for color attribute (color)

 o DISTORTION_HASH
 public static final int DISTORTION_HASH
Hash code for distortion attribute (distortion)

 o FONTCOLOR_HASH
 public static final int FONTCOLOR_HASH
Hash code for fontcolor attribute (fontcolor)

 o FONTNAME_HASH
 public static final int FONTNAME_HASH
Hash code for fontname attribute (fontname)

 o FONTSIZE_HASH
 public static final int FONTSIZE_HASH
Hash code for fontsize attribute (fontsize)

 o FONTSTYLE_HASH
 public static final int FONTSTYLE_HASH
Hash code for fontstyle attribute (fontstyle)

 o HEIGHT_HASH
 public static final int HEIGHT_HASH
Hash code for height attribute (height)

 o LABEL_HASH
 public static final int LABEL_HASH
Hash code for label attribute (label)

 o LP_HASH
 public static final int LP_HASH
Hash code for label position attribute (lp)

 o ORIENTATION_HASH
 public static final int ORIENTATION_HASH
Hash code for orientation attribute (orientation)

 o PERIPHERIES_HASH
 public static final int PERIPHERIES_HASH
Hash code for peripheries attribute (peripheries)

 o POS_HASH
 public static final int POS_HASH
Hash code for position attribute (pos)

 o RANKDIR_HASH
 public static final int RANKDIR_HASH
Hash code for rank direction attribute (rankdir)

 o RECTS_HASH
 public static final int RECTS_HASH
Hash code for rectangles attribute (rects)

 o SIDES_HASH
 public static final int SIDES_HASH
Hash code for sides attribute (sides)

 o SKEW_HASH
 public static final int SKEW_HASH
Hash code for skew attribute (skew)

 o STYLE_HASH
 public static final int STYLE_HASH
Hash code for style attribute (style)

 o WIDTH_HASH
 public static final int WIDTH_HASH
Hash code for width attribute (width)

 o BoundingBox
 protected Rectangle BoundingBox
The bounding box of the element

Constructors

 o DrawObject
 public DrawObject()
Of course, this abstract class cannot be directly instantiated. This constructor creates an uninitialized DrawObject with a default set of attributes that it will observe (in its role as an Observer)

See Also:
Observer

Methods

 o initialize
 protected void initialize(AppObject obj)
Initializes the DrawObject. Application writers extending the DrawObject class and deciding to override this method should best call super.initialize(obj) in that case.

Parameters:
obj - the AppObject associated with this DrawObject
 o setBoundsFlag
 public void setBoundsFlag(boolean mode)
Setting the bounds flag true indicates that the bounding box needs to be recomputed. Whenever the flag is set to true, the bounds flag for the entire graph is also set to true.

Parameters:
mode - value to which the bounds flag should be set
 o getBoundsFlag
 public boolean getBoundsFlag()
Get the value of the bounds flag.

Returns:
the current value of the bounds flag
 o getBounds
 public Rectangle getBounds()
Get the bounding box of this element

Returns:
the bounding box of this element
 o setBounds
 public abstract Rectangle setBounds()
This method to be called when the bounding box needs to be calculated.

Returns:
the bounding box of this object in graph co-ordinates
 o emptyMeansRemove
 public boolean emptyMeansRemove(Attribute attr) throws IllegalAttributeException
Remove the local attribute from the element associated with this DrawObject. Which element to remove is determined by the name of the supplied attribute, and the go-ahead for removal is that the value of the supplied attribute be null or the empty string. When the attribute is removed, the associated default attribute, if any, takes effect.

Parameters:
attr - the name of this attribute determines what local attribute is to be removed and the value determines whether the attribute should be removed (a null or empty value indicates removal is desired).
Returns:
true if the attribute is removed, false otherwise
Throws: IllegalAttributeException
whenever the attribute to be removed is one that must be present for drawing purposes
 o setRedrawFlag
 public void setRedrawFlag(boolean mode)
Set the redraw flag.

Parameters:
mode - set the redraw flag to this value
 o getRedrawFlag
 public boolean getRedrawFlag()
Get the current redraw flag.

Returns:
true if a redraw is indicated
 o arrayForTuple
 public static int[] arrayForTuple(String tuple) throws NumberFormatException
Converts string of delimited integers to an array of integers. The delimiters are any of comma, space or tab. Note that multiple consecutive delimiters are treated as a single delimiter. If string is null or contains no tokens, an array of length two is returned, both of whose elements equal zero.

Parameters:
tuple - a string of delimited integers.
Returns:
the supplied string as an array of ints
Throws: NumberFormatException
whenever a token in the tuple string is neither a delimiter nor an integer
 o pointForTuple
 public static Point pointForTuple(String tuple) throws IllegalArgumentException, NumberFormatException
Converts string of comma separated integers to a Point.

Parameters:
tuple - a string of two comma separated integers.
Returns:
the supplied string as a Point.
Throws: IllegalArgumentException
whenever the tuple string is not of the correct format
Throws: NumberFormatException
if arrayForTuple does
 o rectForTuple
 public static Rectangle rectForTuple(String tuple) throws IllegalArgumentException, NumberFormatException
Converts string of comma separated integers to a Rectangle.

Parameters:
tuple - a string of four comma separated integers.
Returns:
the supplied string as a Rectangle.
Throws: IllegalArgumentException
whenever the tuple string is not of the correct format
Throws: NumberFormatException
if arrayForTuple does
 o dimensionForWidthHeight
 protected Dimension dimensionForWidthHeight(String w,
                                             String h)
Converts pair of floating point strings to a Dimension. In addition, the units are converted from inches to points.

Parameters:
width - the width string.
height - the height string.
Returns:
the supplied width and height strings as a Dimension.
See Also:
pointsPerInch
 o setupDrawObject
 public void setupDrawObject(GraphicContext context)
Prepares this object for drawing with respect to the specified context.

Parameters:
context - the context to be used when drawing the object
 o draw
 public void draw(GraphicContext context,
                  DrawPane pane)
Draws the graph element using the specified graphic context.

Parameters:
context - the graphic context to use when drawing. If the context is null, the object's context is used.
pane - restrict drawing to the supplied pane, if supplied.
 o erase
 public void erase(DrawPane pane)
Erases the graph element from the specified pane.

Parameters:
pane - the pane from which the drawn object is to be erased
 o draw
 public void draw()
A convenience method that is equivalent to draw(null,null).

See Also:
draw
 o getGC
 public GraphicContext getGC()
Get the graphic context of this object.

Returns:
this object's graphic context
 o getParentGC
 public GraphicContext getParentGC()
Get the graphic context of this object's parent subgraph.

Returns:
the graphic context of the subgraph containing this object
 o getElement
 public Element getElement()
Get the element associated with this object.

Returns:
the Element object underlying this object
 o free
 public void free()
Reset this object and release its resources for garbage collection.

 o deletePeer
 public void deletePeer(DrawPane pane)
Delete the peer associated with this object and the specified pane.

Parameters:
pane - the pane related to the peer to be deleted
 o highlightOn
 public void highlightOn(long mode)
Turn the specified highlighting mode on for this object

Parameters:
mode - the specific mode of highlighting
 o highlightOff
 public void highlightOff(long mode)
Turn the specified highlighting mode off for this object

Parameters:
mode - the specific mode of highlighting
 o getHighlightModes
 public long getHighlightModes()
Get the current value of the highlight mode settings

Returns:
the highlight mode settings of this object
 o hasHighlightMode
 public boolean hasHighlightMode(long mode)
Check if the specified highlight mode is active

Returns:
true if the mode is active, false otherwise
 o getColorGC
 public GraphicContext getColorGC()
Get the graphic context used for coloring. A specific context for coloring is used since the highlighting modes can change the color settings, but the original values need to be retained as well.

Returns:
the coloring context
 o setDrawObject
 public static void setDrawObject(Element elem) throws InstantiationException
Create the DrawObject for the given Element.

Parameters:
elem - the Element whose DrawOpbject is to be created
Throws: InstantiationException
whenever the DrawObject cannot be created
 o iSpy
 public boolean iSpy(Attribute candidate)
Check if supplied attribute is of interest.

Parameters:
candidate - the attribute to look for
Returns:
true if the attribute is worth watching
 o iSpy
 public boolean iSpy(Attribute candidate,
                     Attribute incumbent)
Check if supplied attribute is of interest. The incumbent, if not null or equal to the candidate, is no longer observed.

Parameters:
candidate - the attribute to look for
incumbent - the attribute that possibly was observed earlier
Returns:
true if the attribute is worth watching
 o attrOfInterest
 protected void attrOfInterest(String name)
Add the name of an attribute of interest to this class

Parameters:
name - the name of the attribute
 o attrNotOfInterest
 protected void attrNotOfInterest(String name)
Remove the name of an attribute of interest to this object

Parameters:
name - the name of the attribute
 o isOfInterest
 public boolean isOfInterest(String name)
Check if the name of an attribute of interest to this object

Parameters:
name - the name of the attribute
Returns:
true when the name is of interest
 o update
 public void update(Observable obs,
                    Object arg)
This method is called whenever an observed Attribute 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.
 o redraw
 public void redraw()
Redraw the object.

 o containsPanePoint
 public boolean containsPanePoint(DrawPane pane,
                                  Point pt)
Checks if the supplied point is inside this object as it is drawn on the supplied pane.

Parameters:
pane - the pane that supplied the frame of reference for the coordinates
pt - the point to check
Returns:
true if the point is contained in this object with respect to the specified pane
 o containsPaneXY
 public boolean containsPaneXY(DrawPane pane,
                               int x,
                               int y)
Checks if the supplied coordinates are inside this object as it is drawn on the supplied pane.

Parameters:
pane - the pane that supplied the frame of reference for the coordinates
x - the x-coordinate to check
y - the y-coordinate to check
Returns:
true if the coordinates are contained in this object with respect to the specified pane
 o createPeer
 public abstract void createPeer(DrawPane pane)
Creates the drawing peer specific for this object and the specified pane.

Parameters:
pane - the DrawPane upon which the object will be drawn.
 o setPeer
 public DrawObjectPeer setPeer(DrawObjectPeer peer)
Set the starting peer for the linked-list of peers associated with this object.

Parameters:
peer - the peer to set as the starting point
Returns:
the previous starting point or null
 o getPeer
 public DrawObjectPeer getPeer()
Get the starting peer for the linked-list of peers associated with this object.

Returns:
the starting point or null
 o getPeerFor
 public DrawObjectPeer getPeerFor(DrawPane pane)
Get the peer for this object and the specified pane

Parameters:
pane - the pane whose peer is requested
Returns:
the peer associated with the supplied pane or null
 o getTextLabel
 public TextLabel getTextLabel()
Get the text label associated with this object

Returns:
this object's TextLabel
 o setTextLabel
 public TextLabel setTextLabel(TextLabel newTextLabel)
Set the text label for this object

Parameters:
newTextLabel - the new text label value
Returns:
the old text label value
 o setupNeeded
 public boolean setupNeeded()
Check if it appears that this object needs to be set-up

Returns:
true if setup is required, false otherwise
 o needSetup
 public void needSetup()
Mark this object as requiring set-up

 o setupPeers
 public void setupPeers(GraphicContext context)
Set-up the peers associated with this object.

Parameters:
context - the context in which to perform the set-up

All Packages  Class Hierarchy  This Package  Previous  Next  Index