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
-
tipperTime
- Default time in milliseconds before element tip pops up.
-
DrawPane(Graph, boolean, int)
- Creates a
DrawPane
instance.
-
DrawPane(Graph, boolean, int, Backgrounder)
- Creates a
DrawPane
instance.
-
DrawPane(Graph, boolean, int, Dimension)
- Creates a
DrawPane
instance.
-
DrawPane(Graph, boolean, int, Dimension, Backgrounder)
- Creates a
DrawPane
instance.
-
addObserver(Observer)
- Add an observer of the
LinearMap
used by this pane.
-
canonXY(int, int)
- Convert a co-ordinate in the pane to the co-ordinates of the graph.
-
clearCanvas()
- Clear the canvas.
-
clearGraph(Graph)
- Clear the DrawPanes associated with the given graph.
-
clearGraph(Subgraph)
-
-
clobberCanvas()
- Clear the canvas and its linear mapping.
-
componentHidden(ComponentEvent)
- Included as required by the
ComponentListener
interface.
-
componentMoved(ComponentEvent)
- Included as required by the
ComponentListener
interface.
-
componentResized(ComponentEvent)
- Calls
setupPane()
when the pane is resized.
-
componentShown(ComponentEvent)
- Included as required by the
ComponentListener
interface.
-
deleteObserver(Observer)
- Delete an observer of the
LinearMap
used by this pane.
-
deleteObservers()
- Deletes all observers of the
LinearMap
used by this pane.
-
doBackground(Graphics)
- Draw the background using the specified
Graphics
object.
-
doBackground(ImageObserver, Graphics)
- Draw the background using the specified
Graphics
object
and ImageObserver
.
-
drawGraph(Graph)
- Draw the specified graph onto its associated DrawPanes.
-
drawGraph(Subgraph)
-
-
findContainingElement(Point)
- Find the graph element that contains the specified point.
-
getCanvas()
- Get the canvas associated with this drawing pane.
-
getCanvasGraphics()
- Get the
Graphics
object of the canvas.
-
getDrawGraph()
- Get the current drawing graph as set during setupPane().
-
getFixedSizeFactor()
- Get the fixed size factor.
-
getGraph()
- Get the graph associated with this pane.
-
getMapCanvasSize()
- Get the canvasSize used the last time the pane was adjusted.
-
getMaxCanvasSize()
- Get the maximum allowed canvas size.
-
getShowText()
- Get the current setting for showing text in this pane.
-
gifImage(OutputStream)
- Write image in GIF 87a format to an output stream.
-
gifImage(OutputStream, int)
- Write image in GIF 87a format to an output stream
-
paintCanvas()
- Repaint the canvas.
-
paintGraph(Graph)
- Paint the DrawPanes associated with the given graph.
-
paintGraph(Subgraph)
-
-
redrawGraph(Graph)
- Assume the graph has been setup and drawn and now redraw it
-
redrawGraph(Subgraph)
-
-
refreshGraph(Graph)
-
-
refreshGraph(Subgraph)
-
-
scalePairs(IntPairs)
- Map a set of integer co-ordinates in the graph view to a
their corresponding co-ordinates in the pane view.
-
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.
-
scalePoint(double, double)
- Map a double precision co-ordinate in the graph view to the pane view.
-
scalePoint(int, int)
- Map an integer co-ordinate in the graph view to the pane view.
-
scalePoint(Point)
- Map a point in the graph view to the corresponding point in the pane view.
-
scalePoly(IntPairs)
- Map a polygon represented as a set of integer co-ordinates in the graph
view to a polygon in the pane view.
-
scalePoly(Polygon)
- Map a polygon in the graph view to a polygon in the pane view.
-
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.
-
scaleRect(Rectangle)
- Map the supplied rectangle in the graph
co-ordinate system into the co-ordinate system of this pane.
-
scaleSize(Dimension)
- Map a dimension in the graph view to the corresponding dimension in the pane view.
-
scaleSize(int, int)
- Map a width and height in the graph view to the corresponding dimension in the pane view.
-
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.
-
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.
-
setBackgrounder(Backgrounder)
- Set the background drawing object for this pane.
-
setFixedSizeFactor(double)
- Set the fixed size factor.
-
setMaxCanvasSize(int, int)
- Set the maximum allowed canvas size.
-
setPercentMargin(int)
- Set the percent of canvas size to be reserved for a margin.
-
setShowText(boolean)
- Set the current state for showing text in this pane.
-
setTipTime(int)
- Set the delay time before tip is searched for and displayed.
-
setupPane()
- Setup the pane.
-
setupPane(Subgraph)
-
-
xlateRect(int, int, int, int)
-
tipperTime
public static final int tipperTime
- Default time in milliseconds before element tip pops up.
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
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
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
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.
getDrawGraph
public Subgraph getDrawGraph()
- Get the current drawing graph as set during setupPane().
- Returns:
- the drawing graph
getCanvas
public DrawCanvas getCanvas()
- Get the canvas associated with this drawing pane.
- Returns:
- the drawing canvas
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
setupPane
public void setupPane(Subgraph sgraph)
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
getMaxCanvasSize
public Dimension getMaxCanvasSize()
- Get the maximum allowed canvas size.
- Returns:
- maximum canvas size or null, if not set
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
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.
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
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
xlateRect
public Rectangle xlateRect(int x,
int y,
int w,
int h)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
deleteObservers
public void deleteObservers()
- Deletes all observers of the
LinearMap
used by this pane.
- See Also:
- deleteObservers
doBackground
public void doBackground(Graphics gr)
- Draw the background using the specified
Graphics
object.
- Parameters:
- gr - the drawing
Graphics
- See Also:
- doBackground
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
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
.
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
getCanvasGraphics
public Graphics getCanvasGraphics()
- Get the
Graphics
object of the canvas.
- Returns:
- the canvas
Graphics
object
paintCanvas
public void paintCanvas()
- Repaint the canvas.
clearCanvas
public void clearCanvas()
- Clear the canvas.
clobberCanvas
public void clobberCanvas()
- Clear the canvas and its linear mapping.
getGraph
public Graph getGraph()
- Get the graph associated with this pane.
- Returns:
- the graph associated with this pane
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
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).
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
drawGraph
public static void drawGraph(Subgraph subgraph)
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
redrawGraph
public static void redrawGraph(Subgraph subgraph)
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
paintGraph
public static void paintGraph(Subgraph subgraph)
refreshGraph
public static void refreshGraph(Graph graph)
refreshGraph
public static void refreshGraph(Subgraph subgraph)
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
clearGraph
public static void clearGraph(Subgraph subgraph)
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
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
componentResized
public void componentResized(ComponentEvent evt)
- Calls
setupPane()
when the pane is resized.
- Parameters:
- evt - the trigger event
- See Also:
- setupPane
componentShown
public void componentShown(ComponentEvent evt)
- Included as required by the
ComponentListener
interface.
- Parameters:
- evt - the trigger event
- See Also:
- componentResized
componentHidden
public void componentHidden(ComponentEvent evt)
- Included as required by the
ComponentListener
interface.
- Parameters:
- evt - the trigger event
- See Also:
- componentResized
componentMoved
public void componentMoved(ComponentEvent evt)
- Included as required by the
ComponentListener
interface.
- Parameters:
- evt - the trigger event
- See Also:
- componentResized
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
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.
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