Package diva.graph.basic
Class BasicLayoutTarget
- java.lang.Object
-
- diva.graph.basic.BasicLayoutTarget
-
- All Implemented Interfaces:
LayoutTarget
public class BasicLayoutTarget extends java.lang.Object implements LayoutTarget
The basic set of information necessary to layout a graph: a mapping the graph data structure to aspects of its visual representation, a viewport to layout in, and some manipulation routines including pick, place, and route. This is an implementation for the Diva canvas, other layout target implementations can "port" the layout algorithms to other display implementations.- Version:
- $Id$
- Author:
- Michael Shilman
- Pt.AcceptedRating:
- Red
-
-
Constructor Summary
Constructors Constructor Description BasicLayoutTarget(GraphController controller)Construct a new layout target that operates in the given pane.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.geom.Rectangle2DgetBounds(java.lang.Object node)Return the bounds of the figure associated with the given node in the target's view.GraphControllergetController()Return the graph controller.protected GraphicsPanegetGraphicsPane()Return the pane of this display.GraphModelgetGraphModel()Return the graph model that we are operating on.doublegetLayoutPercentage()Return the percentage of the pane that is used for layout.protected java.lang.ObjectgetRootGraph()Return the root graph of this display.java.awt.geom.Rectangle2DgetViewport(java.lang.Object composite)Return the viewport of the given graph as a rectangle in logical coordinates.java.lang.ObjectgetVisualObject(java.lang.Object object)Return the visual object of the given graph object.java.util.IteratorintersectingEdges(java.awt.geom.Rectangle2D r)Return an iterator over the node or edge figures which intersect the given rectangle.java.util.IteratorintersectingNodes(java.awt.geom.Rectangle2D r)Return an iterator over the nodes which intersect the given rectangle in the top-level graph.booleanisEdgeVisible(java.lang.Object edge)Return whether or not the given edge is actually visible in the view.booleanisNodeVisible(java.lang.Object node)Return whether or not the given node is actually visible in the view.voidroute(java.lang.Object edge)Route absolutely the figure associated with the given edge in the target's view.voidsetLayoutPercentage(double d)Set the percentage of the pane that should be used for layout.voidtranslate(java.lang.Object node, double dx, double dy)Translate the figure associated with the given node in the target's view by the given delta.
-
-
-
Constructor Detail
-
BasicLayoutTarget
public BasicLayoutTarget(GraphController controller)
Construct a new layout target that operates in the given pane.
-
-
Method Detail
-
getBounds
public java.awt.geom.Rectangle2D getBounds(java.lang.Object node)
Return the bounds of the figure associated with the given node in the target's view.- Specified by:
getBoundsin interfaceLayoutTarget
-
getController
public GraphController getController()
Return the graph controller.
-
getGraphModel
public GraphModel getGraphModel()
Return the graph model that we are operating on.- Specified by:
getGraphModelin interfaceLayoutTarget
-
getLayoutPercentage
public double getLayoutPercentage()
Return the percentage of the pane that is used for layout.- See Also:
setLayoutPercentage(double)
-
getGraphicsPane
protected GraphicsPane getGraphicsPane()
Return the pane of this display. This is a template method for lazy subclassers.
-
getRootGraph
protected java.lang.Object getRootGraph()
Return the root graph of this display. This is a template method for lazy subclassers.
-
getViewport
public java.awt.geom.Rectangle2D getViewport(java.lang.Object composite)
Return the viewport of the given graph as a rectangle in logical coordinates.- Specified by:
getViewportin interfaceLayoutTarget
-
getVisualObject
public java.lang.Object getVisualObject(java.lang.Object object)
Return the visual object of the given graph object. Note that the purpose of a layout target is to abstract away the visual object and using this method breaks that abstraction.- Specified by:
getVisualObjectin interfaceLayoutTarget
-
isNodeVisible
public boolean isNodeVisible(java.lang.Object node)
Return whether or not the given node is actually visible in the view.- Specified by:
isNodeVisiblein interfaceLayoutTarget
-
isEdgeVisible
public boolean isEdgeVisible(java.lang.Object edge)
Return whether or not the given edge is actually visible in the view.- Specified by:
isEdgeVisiblein interfaceLayoutTarget
-
intersectingNodes
public java.util.Iterator intersectingNodes(java.awt.geom.Rectangle2D r)
Return an iterator over the nodes which intersect the given rectangle in the top-level graph.- Specified by:
intersectingNodesin interfaceLayoutTarget
-
intersectingEdges
public java.util.Iterator intersectingEdges(java.awt.geom.Rectangle2D r)
Return an iterator over the node or edge figures which intersect the given rectangle.- Specified by:
intersectingEdgesin interfaceLayoutTarget
-
route
public void route(java.lang.Object edge)
Route absolutely the figure associated with the given edge in the target's view.- Specified by:
routein interfaceLayoutTarget
-
setLayoutPercentage
public void setLayoutPercentage(double d)
Set the percentage of the pane that should be used for layout. This method defines a frame in which layout is executed that is sized layoutPercentage*bounds, where "bounds" is the rectangular bounding box of the visual representation of a particular graph.- See Also:
getViewport(Object)
-
translate
public void translate(java.lang.Object node, double dx, double dy)Translate the figure associated with the given node in the target's view by the given delta.- Specified by:
translatein interfaceLayoutTarget
-
-