All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class att.grappa.DrawPane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.ScrollPane
                           |
                           +----att.grappa.DrawPane

public class DrawPane
extends ScrollPane
implements ComponentListener
This class is used for displaying the graph. The actual drawing is done on a DrawCanvas object, which is contained within the Drawpane and managed by it.

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

Variable Index

 o tipperTime
Default time in milliseconds before element tip pops up.

Constructor Index

 o DrawPane(Graph, boolean, int)
Creates a DrawPane instance.
 o DrawPane(Graph, boolean, int, Backgrounder)
Creates a DrawPane instance.
 o DrawPane(Graph, boolean, int, Dimension)
Creates a DrawPane instance.
 o DrawPane(Graph, boolean, int, Dimension, Backgrounder)
Creates a DrawPane instance.

Method Index

 o addObserver(Observer)
Add an observer of the LinearMap used by this pane.
 o canonXY(int, int)
Convert a co-ordinate in the pane to the co-ordinates of the graph.
 o clearCanvas()
Clear the canvas.
 o clearGraph(Graph)
Clear the DrawPanes associated with the given graph.
 o clearGraph(Subgraph)
 o clobberCanvas()
Clear the canvas and its linear mapping.
 o componentHidden(ComponentEvent)
Included as required by the ComponentListener interface.
 o componentMoved(ComponentEvent)
Included as required by the ComponentListener interface.
 o componentResized(ComponentEvent)
Calls setupPane() when the pane is resized.
 o componentShown(ComponentEvent)
Included as required by the ComponentListener interface.
 o deleteObserver(Observer)
Delete an observer of the LinearMap used by this pane.
 o deleteObservers()
Deletes all observers of the LinearMap used by this pane.
 o doBackground(Graphics)
Draw the background using the specified Graphics object.
 o doBackground(ImageObserver, Graphics)
Draw the background using the specified Graphics object and ImageObserver.
 o drawGraph(Graph)
Draw the specified graph onto its associated DrawPanes.
 o drawGraph(Subgraph)
 o findContainingElement(Point)
Find the graph element that contains the specified point.
 o getCanvas()
Get the canvas associated with this drawing pane.
 o getCanvasGraphics()
Get the Graphics object of the canvas.
 o getDrawGraph()
Get the current drawing graph as set during setupPane().
 o getFixedSizeFactor()
Get the fixed size factor.
 o getGraph()
Get the graph associated with this pane.
 o getMapCanvasSize()
Get the canvasSize used the last time the pane was adjusted.
 o getMaxCanvasSize()
Get the maximum allowed canvas size.
 o getShowText()
Get the current setting for showing text in this pane.
 o gifImage(OutputStream)
Write image in GIF 87a format to an output stream.
 o gifImage(OutputStream, int)
Write image in GIF 87a format to an output stream
 o paintCanvas()
Repaint the canvas.
 o paintGraph(Graph)
Paint the DrawPanes associated with the given graph.
 o paintGraph(Subgraph)
 o redrawGraph(Graph)
Assume the graph has been setup and drawn and now redraw it
 o redrawGraph(Subgraph)
 o refreshGraph(Graph)
 o refreshGraph(Subgraph)
 o scalePairs(IntPairs)
Map a set of integer co-ordinates in the graph view to a their corresponding co-ordinates in the pane view.
 o scalePairsUntil(IntPairs, int)
Map a sub-set of integer co-ordinates in the graph view to a their corresponding co-ordinates in the pane view.
 o scalePoint(double, double)
Map a double precision co-ordinate in the graph view to the pane view.
 o scalePoint(int, int)
Map an integer co-ordinate in the graph view to the pane view.
 o scalePoint(Point)
Map a point in the graph view to the corresponding point in the pane view.
 o scalePoly(IntPairs)
Map a polygon represented as a set of integer co-ordinates in the graph view to a polygon in the pane view.
 o scalePoly(Polygon)
Map a polygon in the graph view to a polygon in the pane view.
 o scaleRect(int, int, int, int)
Map the supplied parameters describing a rectangle in the graph co-ordinate system into the co-ordinate system of this pane.
 o scaleRect(Rectangle)
Map the supplied rectangle in the graph co-ordinate system into the co-ordinate system of this pane.
 o scaleSize(Dimension)
Map a dimension in the graph view to the corresponding dimension in the pane view.
 o scaleSize(int, int)
Map a width and height in the graph view to the corresponding dimension in the pane view.
 o scaleXLength(double)
Convert a length along the x-axis of the graph co-ordinate system into the corresponding length in the pane co-ordinate system.
 o scaleYLength(double)
Convert a length along the y-axis of the graph co-ordinate system into the corresponding length in the pane co-ordinate system.
 o setBackgrounder(Backgrounder)
Set the background drawing object for this pane.
 o setFixedSizeFactor(double)
Set the fixed size factor.
 o setMaxCanvasSize(int, int)
Set the maximum allowed canvas size.
 o setPercentMargin(int)
Set the percent of canvas size to be reserved for a margin.
 o setShowText(boolean)
Set the current state for showing text in this pane.
 o setTipTime(int)
Set the delay time before tip is searched for and displayed.
 o setupPane()
Setup the pane.
 o setupPane(Subgraph)
 o xlateRect(int, int, int, int)

Variables

 o tipperTime
 public static final int tipperTime
Default time in milliseconds before element tip pops up.

Constructors

 o DrawPane
 public DrawPane(Graph graph,
                 boolean doScaling,
                 int scrollbarPolicy,
                 Dimension prefSize,
                 Backgrounder backgrounder)
Creates a DrawPane instance.

Parameters:
graph - the graph object to be displayed in this pane.
doScaling - when true, canvas will be of fixed size and drawing will be scaled to fit within it, otherwise grow canvas area as needed and do not scale. Note that in this latter case the image may be clipped if there are no scrollbars.
scrollbarPolicy - one of: ScrollPane.SCROLLBARS_ALWAYS, ScrollPane.SCROLLBARS_AS_NEEDED, or ScrollPane.SCROLLBARS_NEVER
prefSize - preferred size of view area onto canvas.
backgrounder - an image drawing interface for painting an arbitrary image in the background
 o DrawPane
 public DrawPane(Graph graph,
                 boolean doScaling,
                 int scrollbarPolicy,
                 Backgrounder backgrounder)
Creates a DrawPane instance. Assumes a default preferred size of 600x400.

Parameters:
graph - the graph object to be displayed in this pane.
doScaling - when true, canvas will be of fixed size and drawing will be scaled to fit within it, otherwise grow canvas area as needed and do not scale. Note that in this latter case the image may be clipped if there are no scrollbars.
scrollbarPolicy - one of: ScrollPane.SCROLLBARS_ALWAYS, ScrollPane.SCROLLBARS_AS_NEEDED, or ScrollPane.SCROLLBARS_NEVER
backgrounder - an image drawing interface for painting an arbitrary image in the background
 o DrawPane
 public DrawPane(Graph graph,
                 boolean doScaling,
                 int scrollbarPolicy)
Creates a DrawPane instance. Assumes a default preferred size of 600x400 and no background image.

Parameters:
graph - the graph object to be displayed in this pane.
doScaling - when true, canvas will be of fixed size and drawing will be scaled to fit within it, otherwise grow canvas area as needed and do not scale. Note that in this latter case the image may be clipped if there are no scrollbars.
scrollbarPolicy - one of: ScrollPane.SCROLLBARS_ALWAYS, ScrollPane.SCROLLBARS_AS_NEEDED, or ScrollPane.SCROLLBARS_NEVER
 o DrawPane
 public DrawPane(Graph graph,
                 boolean doScaling,
                 int scrollbarPolicy,
                 Dimension prefSize)
Creates a DrawPane instance. Assumes there is no background image.

Parameters:
graph - the graph object to be displayed in this pane.
doScaling - when true, canvas will be of fixed size and drawing will be scaled to fit within it, otherwise grow canvas area as needed and do not scale. Note that in this latter case the image may be clipped if there are no scrollbars.
scrollbarPolicy - one of: ScrollPane.SCROLLBARS_ALWAYS, ScrollPane.SCROLLBARS_AS_NEEDED, or ScrollPane.SCROLLBARS_NEVER
prefSize - preferred size of view area onto canvas.

Methods

 o getDrawGraph
 public Subgraph getDrawGraph()
Get the current drawing graph as set during setupPane().

Returns:
the drawing graph
 o getCanvas
 public DrawCanvas getCanvas()
Get the canvas associated with this drawing pane.

Returns:
the drawing canvas
 o setupPane
 public void setupPane()
Setup the pane. Based on the characteristics of this pane and the current size of the graph, the canvas size and / or linear mapping are adjusted as needed. If the mapping is recalculated, observers of the mapping are notified and this DrawPane is passed as an argument to the notifyObservers method.

See Also:
java.util.notifyObservers
 o setupPane
 public void setupPane(Subgraph sgraph)
 o setMaxCanvasSize
 public Dimension setMaxCanvasSize(int width,
                                   int height)
Set the maximum allowed canvas size.

Parameters:
width - maximum canvas width
height - maximum canvas height
Returns:
previous maximum size or null, if not set
 o getMaxCanvasSize
 public Dimension getMaxCanvasSize()
Get the maximum allowed canvas size.

Returns:
maximum canvas size or null, if not set
 o canonXY
 public Point canonXY(int x,
                      int y)
Convert a co-ordinate in the pane to the co-ordinates of the graph.

Parameters:
x - the x co-ordinate
y - the y co-ordinate
Returns:
the resulting re-mapped point
See Also:
revMap
 o getShowText
 public boolean getShowText()
Get the current setting for showing text in this pane.

Returns:
true if the graph is drawn with text information visible, false if the text information has been suppressed.
 o setShowText
 public boolean setShowText(boolean newValue)
Set the current state for showing text in this pane.

Parameters:
newValue - the new value for the text visibility status
Returns:
the previous value of the text visibility setting
 o scaleRect
 public Rectangle scaleRect(int x,
                            int y,
                            int w,
                            int h)
Map the supplied parameters describing a rectangle in the graph co-ordinate system into the co-ordinate system of this pane.

Parameters:
x - x co-ordinate of upper-left corner of rectangle
y - y co-ordinate of upper-left corner of rectangle
w - width of rectangle
h - height of rectangle
Returns:
the corresponding rectangle in the pane co-ordinate system
See Also:
map, getApproximation
 o xlateRect
 public Rectangle xlateRect(int x,
                            int y,
                            int w,
                            int h)
 o scaleRect
 public Rectangle scaleRect(Rectangle rect)
Map the supplied rectangle in the graph co-ordinate system into the co-ordinate system of this pane.

Parameters:
rect - a rectangle in the graph co-ordindate system
Returns:
the corresponding rectangle in the pane co-ordinate system
See Also:
scaleRect
 o scaleXLength
 public double scaleXLength(double len)
Convert a length along the x-axis of the graph co-ordinate system into the corresponding length in the pane co-ordinate system.

Parameters:
len - the length in the graph view
Returns:
the length in the pane view
See Also:
scaleYLength, scaleX, abs
 o scaleYLength
 public double scaleYLength(double len)
Convert a length along the y-axis of the graph co-ordinate system into the corresponding length in the pane co-ordinate system.

Parameters:
len - the length in the graph view
Returns:
the length in the pane view
See Also:
scaleXLength, scaleY, abs
 o scalePoint
 public DoublePoint scalePoint(double ptx,
                               double pty)
Map a double precision co-ordinate in the graph view to the pane view.

Parameters:
ptx - the x co-ordinate in the graph view
pty - the y co-ordinate in the graph view
Returns:
the corresponding double-precision point in the pane view
See Also:
map
 o scalePoint
 public Point scalePoint(int ptx,
                         int pty)
Map an integer co-ordinate in the graph view to the pane view.

Parameters:
ptx - the x co-ordinate in the graph view
pty - the y co-ordinate in the graph view
Returns:
the corresponding double-precision point in the pane view
See Also:
map, getApproximation
 o scalePoly
 public Polygon scalePoly(Polygon inPoly)
Map a polygon in the graph view to a polygon in the pane view.

Parameters:
inPoly - the polygon in the graph view
Returns:
the corresponding polygon in the pane view
 o scalePairs
 public IntPairs scalePairs(IntPairs inPairs)
Map a set of integer co-ordinates in the graph view to a their corresponding co-ordinates in the pane view. The co-ordinates are passed using an IntPairs object.

Parameters:
inPairs - the co-ordinate set in the graph view
Returns:
the corresponding co-ordinate set in the pane view
 o scalePairsUntil
 public IntPairs scalePairsUntil(IntPairs inPairs,
                                 int end)
Map a sub-set of integer co-ordinates in the graph view to a their corresponding co-ordinates in the pane view. The co-ordinates are passed using an IntPairs object.

Parameters:
inPairs - the co-ordinate set in the graph view
end - the ending point within the supplied set (where 1<=end<=inPairs.size())
Returns:
the corresponding co-ordinate set in the pane view
 o scalePoly
 public Polygon scalePoly(IntPairs inPairs)
Map a polygon represented as a set of integer co-ordinates in the graph view to a polygon in the pane view.

Parameters:
inPairs - the co-ordinates representing the polygon in the graph view
Returns:
the corresponding polygon in the pane view
 o scalePoint
 public Point scalePoint(Point pt)
Map a point in the graph view to the corresponding point in the pane view.

Parameters:
pt - the point in the graph view
Returns:
the corresponding point in the pane view
See Also:
scalePoint
 o scaleSize
 public Dimension scaleSize(Dimension sz)
Map a dimension in the graph view to the corresponding dimension in the pane view.

Parameters:
sz - the dimension in the graph view
Returns:
the corresponding dimension in the pane view
See Also:
scaleSize
 o scaleSize
 public Dimension scaleSize(int wd,
                            int ht)
Map a width and height in the graph view to the corresponding dimension in the pane view.

Parameters:
wd - the width in the graph view
ht - the height in the graph view
Returns:
the corresponding dimension in the pane view
See Also:
scale, getApproximation
 o addObserver
 public void addObserver(Observer obs)
Add an observer of the LinearMap used by this pane.

Parameters:
obs - the observer of the mapping to be added
See Also:
addObserver
 o deleteObserver
 public void deleteObserver(Observer obs)
Delete an observer of the LinearMap used by this pane.

Parameters:
obs - the observer of the mapping to be deleted
See Also:
deleteObserver
 o deleteObservers
 public void deleteObservers()
Deletes all observers of the LinearMap used by this pane.

See Also:
deleteObservers
 o doBackground
 public void doBackground(Graphics gr)
Draw the background using the specified Graphics object.

Parameters:
gr - the drawing Graphics
See Also:
doBackground
 o doBackground
 public void doBackground(ImageObserver obs,
                          Graphics gr)
Draw the background using the specified Graphics object and ImageObserver.

Parameters:
obs - the image observer, if any
gr - the drawing Graphics
 o getMapCanvasSize
 public Dimension getMapCanvasSize()
Get the canvasSize used the last time the pane was adjusted. The canvas size in set in setupPane() and is used for adjusting the LinearMap.

Returns:
the last canvas size used in setting the LinearMap.
 o setBackgrounder
 public void setBackgrounder(Backgrounder backgrounder)
Set the background drawing object for this pane.

Parameters:
backgrounder - the object for drawing the background of this pane
See Also:
Backgrounder
 o getCanvasGraphics
 public Graphics getCanvasGraphics()
Get the Graphics object of the canvas.

Returns:
the canvas Graphics object
 o paintCanvas
 public void paintCanvas()
Repaint the canvas.

 o clearCanvas
 public void clearCanvas()
Clear the canvas.

 o clobberCanvas
 public void clobberCanvas()
Clear the canvas and its linear mapping.

 o getGraph
 public Graph getGraph()
Get the graph associated with this pane.

Returns:
the graph associated with this pane
 o gifImage
 public void gifImage(OutputStream output) throws IOException
Write image in GIF 87a format to an output stream. The GIF can contain up to 256 colors.

Parameters:
output - the OutputStream to use for writing
 o gifImage
 public void gifImage(OutputStream output,
                      int colors) throws IOException
Write image in GIF 87a format to an output stream

Parameters:
output - the OutputStream to use for writing
colors - the maximum number of colors (up to 256) to be allowed in the GIF (the size of the GIF file can be reduced a bit by specifying a number smaller than 256 when that is appropriate to do).
 o drawGraph
 public static void drawGraph(Graph graph)
Draw the specified graph onto its associated DrawPanes.

Parameters:
graph - the graph to be drawn
all - if true, draw all elements even if redraw flag is not set
 o drawGraph
 public static void drawGraph(Subgraph subgraph)
 o redrawGraph
 public static void redrawGraph(Graph graph)
Assume the graph has been setup and drawn and now redraw it

Parameters:
graph - the graph to redraw
 o redrawGraph
 public static void redrawGraph(Subgraph subgraph)
 o paintGraph
 public static void paintGraph(Graph graph)
Paint the DrawPanes associated with the given graph.

Parameters:
graph - the graph whose DrawPanes are to be cleared
 o paintGraph
 public static void paintGraph(Subgraph subgraph)
 o refreshGraph
 public static void refreshGraph(Graph graph)
 o refreshGraph
 public static void refreshGraph(Subgraph subgraph)
 o clearGraph
 public static void clearGraph(Graph graph)
Clear the DrawPanes associated with the given graph.

Parameters:
graph - the graph whose DrawPanes are to be cleared
 o clearGraph
 public static void clearGraph(Subgraph subgraph)
 o findContainingElement
 public Element findContainingElement(Point pt)
Find the graph element that contains the specified point. The point is in the co-ordinate system of the pane.

Parameters:
pt - the point to check
Returns:
the first element found that contains the point
See Also:
setAccessibility
 o setPercentMargin
 public int setPercentMargin(int pct)
Set the percent of canvas size to be reserved for a margin. The margin is the area between the bounding box of the graph and the edge of the canvas.

Parameters:
pct - the percent of the canvas size to reserve as a margin
 o componentResized
 public void componentResized(ComponentEvent evt)
Calls setupPane() when the pane is resized.

Parameters:
evt - the trigger event
See Also:
setupPane
 o componentShown
 public void componentShown(ComponentEvent evt)
Included as required by the ComponentListener interface.

Parameters:
evt - the trigger event
See Also:
componentResized
 o componentHidden
 public void componentHidden(ComponentEvent evt)
Included as required by the ComponentListener interface.

Parameters:
evt - the trigger event
See Also:
componentResized
 o componentMoved
 public void componentMoved(ComponentEvent evt)
Included as required by the ComponentListener interface.

Parameters:
evt - the trigger event
See Also:
componentResized
 o setTipTime
 public int setTipTime(int time)
Set the delay time before tip is searched for and displayed.

Parameters:
time - the minimum time in milliseconds that the cursor needs to remain motionless for the tip to appear
Returns:
the previous delay time
 o setFixedSizeFactor
 public double setFixedSizeFactor(double factor)
Set the fixed size factor. The fixed size factor, when non-zero, is used to scale the width and height by a fixed amount so that node size is not changed when zooming.

Parameters:
factor - the new fixed size factor.
Returns:
the previous fixed size factor.
 o getFixedSizeFactor
 public double getFixedSizeFactor()
Get the fixed size factor.

Returns:
the current fixed size factor
See Also:
setFixedSizeFactor

All Packages  Class Hierarchy  This Package  Previous  Next  Index