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
-
BBOX_HASH
- Hash code for bounding box attribute (bb)
-
BoundingBox
- The bounding box of the element
-
COLOR_HASH
- Hash code for color attribute (color)
-
DELETION
- Value for indicating a deletion highlight
-
DISTORTION_HASH
- Hash code for distortion attribute (distortion)
-
FONTCOLOR_HASH
- Hash code for fontcolor attribute (fontcolor)
-
FONTNAME_HASH
- Hash code for fontname attribute (fontname)
-
FONTSIZE_HASH
- Hash code for fontsize attribute (fontsize)
-
FONTSTYLE_HASH
- Hash code for fontstyle attribute (fontstyle)
-
GROUPING
- Value for indicating a grouping highlight
-
HEIGHT_HASH
- Hash code for height attribute (height)
-
LABEL_HASH
- Hash code for label attribute (label)
-
LP_HASH
- Hash code for label position attribute (lp)
-
ORIENTATION_HASH
- Hash code for orientation attribute (orientation)
-
PERIPHERIES_HASH
- Hash code for peripheries attribute (peripheries)
-
pointsPerInch
- The number of points per inch.
-
POS_HASH
- Hash code for position attribute (pos)
-
RANKDIR_HASH
- Hash code for rank direction attribute (rankdir)
-
RECTS_HASH
- Hash code for rectangles attribute (rects)
-
SELECTION
- Value for indicating a selection highlight
-
SIDES_HASH
- Hash code for sides attribute (sides)
-
SKEW_HASH
- Hash code for skew attribute (skew)
-
STYLE_HASH
- Hash code for style attribute (style)
-
WIDTH_HASH
- Hash code for width attribute (width)
-
DrawObject()
- Of course, this abstract class cannot be directly instantiated.
-
arrayForTuple(String)
- Converts string of delimited integers to an array of integers.
-
attrNotOfInterest(String)
- Remove the name of an attribute of interest to this object
-
attrOfInterest(String)
- Add the name of an attribute of interest to this class
-
containsPanePoint(DrawPane, Point)
- Checks if the supplied point is inside this object as it is
drawn on the supplied pane.
-
containsPaneXY(DrawPane, int, int)
- Checks if the supplied coordinates are inside this object as it is
drawn on the supplied pane.
-
createPeer(DrawPane)
- Creates the drawing peer specific for this object and the specified pane.
-
deletePeer(DrawPane)
- Delete the peer associated with this object and the specified pane.
-
dimensionForWidthHeight(String, String)
- Converts pair of floating point strings to a Dimension.
-
draw()
- A convenience method that is equivalent to draw(null,null).
-
draw(GraphicContext, DrawPane)
- Draws the graph element using the specified graphic context.
-
emptyMeansRemove(Attribute)
- Remove the local attribute from the element associated with this
DrawObject.
-
erase(DrawPane)
- Erases the graph element from the specified pane.
-
free()
- Reset this object and release its resources for garbage collection.
-
getBounds()
- Get the bounding box of this element
-
getBoundsFlag()
- Get the value of the bounds flag.
-
getColorGC()
- Get the graphic context used for coloring.
-
getElement()
- Get the element associated with this object.
-
getGC()
- Get the graphic context of this object.
-
getHighlightModes()
- Get the current value of the highlight mode settings
-
getParentGC()
- Get the graphic context of this object's parent subgraph.
-
getPeer()
- Get the starting peer for the linked-list of peers associated with this object.
-
getPeerFor(DrawPane)
- Get the peer for this object and the specified pane
-
getRedrawFlag()
- Get the current redraw flag.
-
getTextLabel()
- Get the text label associated with this object
-
hasHighlightMode(long)
- Check if the specified highlight mode is active
-
highlightOff(long)
- Turn the specified highlighting mode off for this object
-
highlightOn(long)
- Turn the specified highlighting mode on for this object
-
initialize(AppObject)
- Initializes the DrawObject.
-
isOfInterest(String)
- Check if the name of an attribute of interest to this object
-
iSpy(Attribute)
- Check if supplied attribute is of interest.
-
iSpy(Attribute, Attribute)
- Check if supplied attribute is of interest.
-
needSetup()
- Mark this object as requiring set-up
-
pointForTuple(String)
- Converts string of comma separated integers to a Point.
-
rectForTuple(String)
- Converts string of comma separated integers to a Rectangle.
-
redraw()
- Redraw the object.
-
setBounds()
- This method to be called when the bounding box needs to be calculated.
-
setBoundsFlag(boolean)
- Setting the bounds flag true indicates that the bounding box needs
to be recomputed.
-
setDrawObject(Element)
- Create the DrawObject for the given Element.
-
setPeer(DrawObjectPeer)
- Set the starting peer for the linked-list of peers associated with this object.
-
setRedrawFlag(boolean)
- Set the redraw flag.
-
setTextLabel(TextLabel)
- Set the text label for this object
-
setupDrawObject(GraphicContext)
- Prepares this object for drawing with respect to the specified context.
-
setupNeeded()
- Check if it appears that this object needs to be set-up
-
setupPeers(GraphicContext)
- Set-up the peers associated with this object.
-
update(Observable, Object)
- This method is called whenever an observed Attribute is changed.
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).
SELECTION
public static final long SELECTION
- Value for indicating a selection highlight
DELETION
public static final long DELETION
- Value for indicating a deletion highlight
GROUPING
public static final long GROUPING
- Value for indicating a grouping highlight
BBOX_HASH
public static final int BBOX_HASH
- Hash code for bounding box attribute (bb)
COLOR_HASH
public static final int COLOR_HASH
- Hash code for color attribute (color)
DISTORTION_HASH
public static final int DISTORTION_HASH
- Hash code for distortion attribute (distortion)
FONTCOLOR_HASH
public static final int FONTCOLOR_HASH
- Hash code for fontcolor attribute (fontcolor)
FONTNAME_HASH
public static final int FONTNAME_HASH
- Hash code for fontname attribute (fontname)
FONTSIZE_HASH
public static final int FONTSIZE_HASH
- Hash code for fontsize attribute (fontsize)
FONTSTYLE_HASH
public static final int FONTSTYLE_HASH
- Hash code for fontstyle attribute (fontstyle)
HEIGHT_HASH
public static final int HEIGHT_HASH
- Hash code for height attribute (height)
LABEL_HASH
public static final int LABEL_HASH
- Hash code for label attribute (label)
LP_HASH
public static final int LP_HASH
- Hash code for label position attribute (lp)
ORIENTATION_HASH
public static final int ORIENTATION_HASH
- Hash code for orientation attribute (orientation)
PERIPHERIES_HASH
public static final int PERIPHERIES_HASH
- Hash code for peripheries attribute (peripheries)
POS_HASH
public static final int POS_HASH
- Hash code for position attribute (pos)
RANKDIR_HASH
public static final int RANKDIR_HASH
- Hash code for rank direction attribute (rankdir)
RECTS_HASH
public static final int RECTS_HASH
- Hash code for rectangles attribute (rects)
SIDES_HASH
public static final int SIDES_HASH
- Hash code for sides attribute (sides)
SKEW_HASH
public static final int SKEW_HASH
- Hash code for skew attribute (skew)
STYLE_HASH
public static final int STYLE_HASH
- Hash code for style attribute (style)
WIDTH_HASH
public static final int WIDTH_HASH
- Hash code for width attribute (width)
BoundingBox
protected Rectangle BoundingBox
- The bounding box of the element
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
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
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
getBoundsFlag
public boolean getBoundsFlag()
- Get the value of the bounds flag.
- Returns:
- the current value of the bounds flag
getBounds
public Rectangle getBounds()
- Get the bounding box of this element
- Returns:
- the bounding box of this element
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
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
setRedrawFlag
public void setRedrawFlag(boolean mode)
- Set the redraw flag.
- Parameters:
- mode - set the redraw flag to this value
getRedrawFlag
public boolean getRedrawFlag()
- Get the current redraw flag.
- Returns:
- true if a redraw is indicated
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
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
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
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
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
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.
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
draw
public void draw()
- A convenience method that is equivalent to draw(null,null).
- See Also:
- draw
getGC
public GraphicContext getGC()
- Get the graphic context of this object.
- Returns:
- this object's graphic context
getParentGC
public GraphicContext getParentGC()
- Get the graphic context of this object's parent subgraph.
- Returns:
- the graphic context of the subgraph containing this object
getElement
public Element getElement()
- Get the element associated with this object.
- Returns:
- the
Element
object underlying this object
free
public void free()
- Reset this object and release its resources for garbage collection.
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
highlightOn
public void highlightOn(long mode)
- Turn the specified highlighting mode on for this object
- Parameters:
- mode - the specific mode of highlighting
highlightOff
public void highlightOff(long mode)
- Turn the specified highlighting mode off for this object
- Parameters:
- mode - the specific mode of highlighting
getHighlightModes
public long getHighlightModes()
- Get the current value of the highlight mode settings
- Returns:
- the highlight mode settings of this object
hasHighlightMode
public boolean hasHighlightMode(long mode)
- Check if the specified highlight mode is active
- Returns:
- true if the mode is active, false otherwise
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
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
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
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
attrOfInterest
protected void attrOfInterest(String name)
- Add the name of an attribute of interest to this class
- Parameters:
- name - the name of the attribute
attrNotOfInterest
protected void attrNotOfInterest(String name)
- Remove the name of an attribute of interest to this object
- Parameters:
- name - the name of the attribute
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
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.
redraw
public void redraw()
- Redraw the object.
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
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
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.
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
getPeer
public DrawObjectPeer getPeer()
- Get the starting peer for the linked-list of peers associated with this object.
- Returns:
- the starting point or null
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
getTextLabel
public TextLabel getTextLabel()
- Get the text label associated with this object
- Returns:
- this object's
TextLabel
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
setupNeeded
public boolean setupNeeded()
- Check if it appears that this object needs to be set-up
- Returns:
- true if setup is required, false otherwise
needSetup
public void needSetup()
- Mark this object as requiring set-up
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