com.tensegrity.graph.view
Class VisualOperations

java.lang.Object
  extended bycom.tensegrity.graph.view.VisualOperations

public final class VisualOperations
extends java.lang.Object

Class VisualOperations provides utility methods that draw and transform a graph. There is functionality to fit any group of VisualGraphObject instances into a destination rectangle or to center their bounding rectangle around a given pivot point. The Barycenter computation is included in this class as well. All methods in this class are static.

Version:
$Id: VisualOperations.java,v 1.176 2006/03/21 14:30:41 MichaelKegel Exp $
Author:
Stepan Rutz, BurkhardWick

Method Summary
static void applyScale(VisualGraphView visualgraphview, double sx, double sy)
          Applies a scaling transform to the given VisualGraphView instance.
static void applyTransformToCenterOfComposite(Composite composite, Transform2D xform)
          Applies the given transformation on the center of a Composite object.
static void autospaceAroundVisualNode(VisualGraph visualgraph, VisualNode visualnode)
          Frees space around the given VisualNode by adjusting the positions of all intersecting nodes and all other nodes relatively.
static void autospaceHorizontalAroundVisualNode(VisualGraph visualgraph, VisualNode visualnode)
          Makes space around the given VisualNode by adjusting the positions of all intersecting nodes and all other nodes relatively.
static void autospaceVerticalAroundVisualNode(VisualGraph visualgraph, VisualNode visualnode)
          Makes space around the given VisualNode by adjusting the positions of all intersecting nodes and all other nodes relatively.
static Vector2 barycenter(java.util.List visualobjects)
          Computes the barycenter of the specified VisualObjects.
static Transform2D center(java.util.Iterator visualobjects, double centerX, double centerY)
          Centers the graph around the given point (centerX, centerY).
static void centerGraph(VisualGraphView visualgraphview, java.util.Collection objects)
          Centers the given objects in the VisualGraphView.
static Boundary computeBoundingBox(java.util.Collection visualgraphobjects)
          Computes a bounding of the given list of VisualGraphObjects.
static Boundary computeBoundingBox(CompositeHierarchy hierarchy)
          Computes a bounding of the current selection which is stored in a CompositeHierarchy.
static java.awt.Rectangle computeBounds(java.util.Iterator visualobjects)
          Computes the bounding rectangle of the VisualGraphObject instances accessible via the given Iterator.
static StableHashMap computeDeepestSelection(VisualGraphView visualgraphview)
          Compute the deepest selection by considering the hierarchy of nested subgraphs and not just the toplevel-view.
static java.util.Collection computeInboundCollectionRecursively(VisualGraphView visualgraphview, VisualNode visualnode)
          Iterate over all ports and return the incoming edges.
static int computeIncount(VisualNode visualnode)
          Iterate over all ports and count the incoming edges.
static java.util.ArrayList computeIncountList(VisualNode visualnode)
          Iterate over all ports and list the incoming edges.
static int computeIncountRecursively(VisualGraphView visualgraphview, VisualNode visualnode)
          Iterate over all ports and count the incoming edges.
static int computeIndegree(VisualGraph visualgraph, VisualNode visualnode)
          Iterate over all ports and count the incoming edges that are connected.
static java.util.Collection computeOutboundCollectionRecursively(VisualGraphView visualgraphview, VisualNode visualnode)
          Iterate over all ports and return the outgoing edges.
static int computeOutcount(VisualNode visualnode)
          Iterate over all ports and count the outgoing edges.
static java.util.ArrayList computeOutcountList(VisualNode visualnode)
          Iterate over all ports and list the outgoing edges.
static int computeOutcountRecursively(VisualGraphView visualgraphview, VisualNode visualnode)
          Iterate over all ports and count the outgoing edges.
static int computeOutdegree(VisualGraph visualgraph, VisualNode visualnode)
          Iterate over all ports and count the outgoing edges that are connected.
static Transform2D computeTransformFromVisualSubgraph(VisualGraphView visualgraphview, VisualSubgraph visualsubgraph)
          Computes the Transform2D that transforms coordinates from the given VisualSubgraph to the top-level CompositeView.
static Transform2D computeTransformToVisualSubgraph(VisualGraphView visualgraphview, VisualSubgraph visualsubgraph)
          Computes the Transform2D that transforms coordinates from the top-level CompositeView to the given VisualSubgraph.
static Boundary computeVisibleRegion(CompositeView compositeview)
          Computes the visible region of the given CompositeView.
static java.util.HashMap computeVisualEdge2VisualSubgraphMap(VisualGraphView vsg)
          This method will compute a map with visualedges as keys and the visualsubgraphs they are part of as values.
static java.util.HashMap computeVisualNode2VisualSubgraphMap(VisualGraphView vsg)
          This method will compute a map with VisualNode objects as keys and the VisualSubgraphs they are part of as values.
static void convertCoordinates(Boundary boundary, Transform2D transform)
          Converts the given boundary by the given transformation.
static void convertCoordinates(CompositeLine compositeline, Transform2D transform)
          Converts all the coordinates of the given CompositeLine by the given transformation.
static void convertCoordinates(Composite composite, Transform2D transform)
          Converts the boundary of the given Composite by the given transformation.
static void convertCoordinates(Coordinate[] coordinates, Transform2D transform)
          Converts all the coordinates of the given array by the given transformation.
static void convertCoordinates(VisualEdge visualedge, Transform2D transform)
          Converts all the coordinates of the given VisualEdge by the given transformation.
static void fancyVisualTree(VisualGraph visualgraph, java.lang.String geometry, java.lang.String style)
          Makes a fancy visualgraph if its a tree.
static double[] findBoundsVisualGraphOrSelection(VisualGraphView visualgraphview)
          Helper to find the bounds of either the entire VisualGraphView or of the selection.
static java.util.Iterator findIntersections(VisualGraphObject subject, java.util.Iterator visualobjects)
          Finds all those VisualGraphObject objects that intersect the given VisualGraphObject.
static Transform2D fit(java.util.Collection visualobjects, java.awt.Rectangle region)
          Computes a transform that fits the VisualObjects into the given region.
static void flip(BaseCompositeIterator iterator, double sx, double sy, double x0, double y0, double x1, double y1)
          Flips the given visualobjects with the given sx and sy scaling factors.
static void flip(java.util.Iterator iterator, double sx, double sy, double x0, double y0, double x1, double y1)
          Flips the given VisualObjects with the given sx and sy scaling factors.
static java.util.Collection getDeepSelection(VisualGraphView visualgraphview)
          Compute the deepest selection by considering the hierarchy of nested subgraphs and not just the toplevel-view.
static Transform2D goodfit(java.util.Collection visualobjects, java.awt.Rectangle region)
          Computes a transform that fits the visualobjects into the given region.
static boolean intersectionTest(Coordinate[] coords, Boundary boundary)
          Returns true if there is an intersection between the bounds and the multi segment line.
static boolean intersectionTest(Coordinate[] coords, BoundingBox bbox)
           
static void makeOrthogonalHorizontalLine(VisualGraphView visualgraphview, VisualEdge visualedge)
          Turns the given VisualEdge objects into an horizontal orthogonal line.
static void makeOrthogonalHorizontalLines(VisualGraphView visualgraphview, java.util.Iterator visualedges)
          Makes all the given VisualEdge objects to horizontal orthogonal lines.
static void makeOrthogonalVerticalLine(VisualGraphView visualgraphview, VisualEdge visualedge)
          Turns the given VisualEdges into an vertical orthogonal line.
static void makeOrthogonalVerticalLines(VisualGraphView visualgraphview, java.util.Iterator visualedges)
          Turns all given VisualEdges to vertical orthogonal lines.
static void makeStraightLine(VisualEdge visualedge)
          Turns the given VisualEdge into a straight line by deleting additional points.
static void makeStraightLines(java.util.Iterator visualedges)
          Transforms all given VisualEdge to straight lines by deleting additional points.
static double maximumDistance(java.util.List visualobjects)
          Computes the maximum distance that occurs between any two of the given VisualObjects.
static double minimumDistance(java.util.List visualobjects)
          Computes the minimum distance that occurs between any two of the given VisualObjects.
static void recursiveSelection(VisualGraphView visualgraphview, boolean selected)
          Deprecated. make use of CompositeViewOperations.recursiveSelection(CompositeView, boolean) instead.
static void rotate(BaseCompositeIterator iterator, double angle, double x0, double y0, double x1, double y1)
          Rotates the given visualobjects with the given angle.
static void rotate(java.util.Iterator iterator, double angle, double x0, double y0, double x1, double y1)
          Rotates the given visualobjects with the given angle.
static void translate(java.util.Iterator visualobjects, Transform2D transform)
          Translate the specified visualobjects.
static void translateViewportAccordingToBoundary(CompositeView compositeview, Boundary boundary)
          This method will set the viewport of the given CompositeView, so that the given boundary is visible.
static void translateViewportAccordingToBoundary(CompositeView compositeview, Boundary boundary, boolean validatePosition)
          This method will set the viewport of the given CompositeView, so that the given boundary is visible.
static void translateViewportAccordingToBoundary(CompositeView compositeview, Boundary boundary, boolean validatePosition, boolean updateView)
          This method will set the viewport of the given CompositeView, so that the given boundary is visible.
static void translateViewportAccordingToComposite(CompositeView compositeview, Composite composite)
          This method does the same as method translateViewportAccordingToBoundary(com.tensegrity.composite.CompositeView, com.tensegrity.graphics.Boundary), but is a convenience wrapper that operates on composites directly.
static void translateViewportAccordingToGraph(VisualGraphView visualgraphview)
          This method set the viewport of the VisualGraphView given by visualgraphview so that the graph is centered within the viewport.
static void translateViewportAroundCenter(CompositeView compositeview, double cx, double cy)
          This method will set the viewport so that it is centered around the given coordinates.
static void translateViewportAroundCenter(VisualGraphView vgv, double cx, double cy)
          This method will set the viewport so that it is centered around the given coordinates.
static double validateZoom(double scale)
          Validates a scale value for a CompositeView and returns a scale value that lies withing the valid range.
static void xSortedVGOs(java.util.List list)
          Sorts the given list containing VisualGraphObjects inplace based on their x-center.
static void ySortedVGOs(java.util.List list)
          Sorts the given list containing VisualGraphObjects inplace based on their y-center.
static void zoomToFit(VisualGraphView visualgraphview)
          Zooms the VisualGraphView so that it fits the view.
static void zoomToFit(VisualGraphView visualgraphview, Boundary insets)
          Zooms the VisualGraphView so that it fits the view.
static void zoomToFit(VisualGraphView visualgraphview, Boundary insets, double maxZoom)
          Zooms the VisualGraphView so that it fits the view.
static void zoomToFit(VisualGraphView visualgraphview, java.util.Collection visualobjects)
          Zooms the VisualGraphView so that the given object fit into the view.
static void zoomToFit(VisualGraphView visualgraphview, java.util.Collection visualobjects, Boundary insets)
          Zooms the VisualGraphView so that the given object fit into the view.
static void zoomToFit(VisualGraphView visualgraphview, java.util.Collection visualobjects, Boundary insets, double maxZoom)
          Zooms the VisualGraphView so that the given object fit into the view.
static void zoomToFit(VisualGraphView visualgraphview, java.util.Collection visualobjects, Boundary insets, double maxZoom, boolean noZoomIn)
          Zooms the VisualGraphView so that the given object fit into the view.
static void zoomToFit(VisualGraphView visualgraphview, java.awt.Rectangle bounds, Boundary insets)
          Zooms the VisualGraphView so that the given object fit into the view.
static void zoomToFit(VisualGraphView visualgraphview, java.awt.Rectangle bounds, Boundary insets, double maxZoom, boolean noZoomIn)
          Zooms the VisualGraphView so that the given object fit into the view.
static void zoomToFitNoMagnification(VisualGraphView visualgraphview)
          Zooms the VisualGraphView so that it fits the view.
static void zoomToFitProportional(VisualGraphView visualgraphview, Boundary destBoundary)
          Zooms the VisualGraphView so that it fits the view.
static void zoomToFitProportional(VisualGraphView visualgraphview, java.util.Collection visualobjects, Boundary destBoundary)
          Zooms the VisualGraphView so that the given object fit into the view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

computeIncount

public static final int computeIncount(VisualNode visualnode)
Iterate over all ports and count the incoming edges. Note that this is not the in-degree.

Parameters:
visualnode - the VisualNode to investigate.
Returns:
the in-count of the VisualNode.

computeIndegree

public static final int computeIndegree(VisualGraph visualgraph,
                                        VisualNode visualnode)
Iterate over all ports and count the incoming edges that are connected. Note that this is the in-degree.

Parameters:
visualgraph - the VisualGraph the VisualNode is in.
visualnode - the VisualNode to investigate.
Returns:
the in-count of the VisualNode.

computeIncountList

public static final java.util.ArrayList computeIncountList(VisualNode visualnode)
Iterate over all ports and list the incoming edges. Note that this is not the in-degree.

Parameters:
visualnode - the VisualNode to investigate.
Returns:
a list of the VisualEdge objects that are incoming.

computeOutcount

public static final int computeOutcount(VisualNode visualnode)
Iterate over all ports and count the outgoing edges. Note that this is not the out-degree.

Parameters:
visualnode - the VisualNode to investigate.
Returns:
the out-count of the VisualNode.

computeOutdegree

public static final int computeOutdegree(VisualGraph visualgraph,
                                         VisualNode visualnode)
Iterate over all ports and count the outgoing edges that are connected. Note that this is the out-degree.

Parameters:
visualgraph - the VisualGraph the VisualNode is in.
visualnode - the VisualNode to investigate.
Returns:
the out-count of the VisualNode.

computeOutcountList

public static final java.util.ArrayList computeOutcountList(VisualNode visualnode)
Iterate over all ports and list the outgoing edges. Note that this is not the out-degree.

Parameters:
visualnode - the VisualNode to investigate.
Returns:
a list of the VisualEdge objects that are outgoing.

computeIncountRecursively

public static final int computeIncountRecursively(VisualGraphView visualgraphview,
                                                  VisualNode visualnode)
Iterate over all ports and count the incoming edges. Note that this is not the indegree.

Parameters:
visualgraphview - the toplevel view.
visualnode - the visualnode to investigate.
Returns:
the incount of the visualnode.

computeOutcountRecursively

public static final int computeOutcountRecursively(VisualGraphView visualgraphview,
                                                   VisualNode visualnode)
Iterate over all ports and count the outgoing edges. Note that this is not the outdegree.

Parameters:
visualgraphview - the top level view.
visualnode - the VisualNode to investigate.
Returns:
the outcount of the VisualNode.

computeInboundCollectionRecursively

public static final java.util.Collection computeInboundCollectionRecursively(VisualGraphView visualgraphview,
                                                                             VisualNode visualnode)
Iterate over all ports and return the incoming edges. Note that this is not the indegree.

Parameters:
visualgraphview - the toplevel view.
visualnode - the visualnode to investigate.
Returns:
the outbound visualedges of the visualnode.

computeOutboundCollectionRecursively

public static final java.util.Collection computeOutboundCollectionRecursively(VisualGraphView visualgraphview,
                                                                              VisualNode visualnode)
Iterate over all ports and return the outgoing edges. Note that this is not the outdegree.

Parameters:
visualgraphview - the toplevel view.
visualnode - the visualnode to investigate.
Returns:
the outbound visualedges of the visualnode.

flip

public static final void flip(java.util.Iterator iterator,
                              double sx,
                              double sy,
                              double x0,
                              double y0,
                              double x1,
                              double y1)
Flips the given VisualObjects with the given sx and sy scaling factors.

Parameters:
iterator - the iterator of the VisualObjects to flip.
sx - the x scaling factor for the flip.
sy - the x scaling factor for the flip.
x0 - the left coordinate of the flip bounding box.
y0 - the top coordinate of the flip bounding box.
x1 - the right coordinate of the flip bounding box.
y1 - the bottom coordinate of the flip bounding box.

flip

public static final void flip(BaseCompositeIterator iterator,
                              double sx,
                              double sy,
                              double x0,
                              double y0,
                              double x1,
                              double y1)
Flips the given visualobjects with the given sx and sy scaling factors.

Parameters:
iterator - the iterator of the visualobjects to flip.
sx - the x scaling factor for the flip.
sy - the x scaling factor for the flip.
x0 - the left coordinate of the flip bounding box.
y0 - the top coordinate of the flip bounding box.
x1 - the right coordinate of the flip bounding box.
y1 - the bottom coordinate of the flip bounding box.

rotate

public static final void rotate(java.util.Iterator iterator,
                                double angle,
                                double x0,
                                double y0,
                                double x1,
                                double y1)
Rotates the given visualobjects with the given angle.

Parameters:
iterator - the iterator of the visualobjects to flip.
angle - the angle to rotate around in degrees.
x0 - the left coordinate of the flip bounding box.
y0 - the top coordinate of the flip bounding box.
x1 - the right coordinate of the flip bounding box.
y1 - the bottom coordinate of the flip bounding box.

rotate

public static final void rotate(BaseCompositeIterator iterator,
                                double angle,
                                double x0,
                                double y0,
                                double x1,
                                double y1)
Rotates the given visualobjects with the given angle.

Parameters:
iterator - the iterator of the visualobjects to flip.
angle - the angle to rotate around in degrees.
x0 - the left coordinate of the flip bounding box.
y0 - the top coordinate of the flip bounding box.
x1 - the right coordinate of the flip bounding box.
y1 - the bottom coordinate of the flip bounding box.

goodfit

public static final Transform2D goodfit(java.util.Collection visualobjects,
                                        java.awt.Rectangle region)
Computes a transform that fits the visualobjects into the given region.

Parameters:
visualobjects - list of visualgraphobjects to modify.
region - rectangular region to fit the visualobjects into.
Returns:
transformation that modifies the visualobjects in the desired way.

translate

public static final void translate(java.util.Iterator visualobjects,
                                   Transform2D transform)
Translate the specified visualobjects.

Parameters:
visualobjects - list of visualgraphobjects to modify.
transform - the transform to apply to the visualgraphobjects.

center

public static final Transform2D center(java.util.Iterator visualobjects,
                                       double centerX,
                                       double centerY)
Centers the graph around the given point (centerX, centerY).

Parameters:
visualobjects - iterator of visualgraphobjects to modify.
centerX - the x coordinate of the center point.
centerY - the y coordinate of the center point.
Returns:
transformation that modifies the visualobjects in the desired way.

fit

public static final Transform2D fit(java.util.Collection visualobjects,
                                    java.awt.Rectangle region)
Computes a transform that fits the VisualObjects into the given region.

Parameters:
visualobjects - list of VisualObjects to modify.
region - rectangular region to fit the VisualObjects into.
Returns:
transformation that modifies the VisualObjects in the desired way.

computeBounds

public static final java.awt.Rectangle computeBounds(java.util.Iterator visualobjects)
Computes the bounding rectangle of the VisualGraphObject instances accessible via the given Iterator.

Parameters:
visualobjects - an Iterator linking to VisualObjects.
Returns:
a rectangular region that closely fits the specified list of VisualObjects.

Find more information in the class documentation


barycenter

public static final Vector2 barycenter(java.util.List visualobjects)
Computes the barycenter of the specified VisualObjects.

Parameters:
visualobjects - list of VisualObjects to scan.
Returns:
the barycenter of the specified VisualObjects.

minimumDistance

public static final double minimumDistance(java.util.List visualobjects)
Computes the minimum distance that occurs between any two of the given VisualObjects.

Parameters:
visualobjects - list of VisualObjects to scan.
Returns:
the minimum distance between any two of the scanned objects.

maximumDistance

public static final double maximumDistance(java.util.List visualobjects)
Computes the maximum distance that occurs between any two of the given VisualObjects.

Parameters:
visualobjects - list of VisualObjects to scan.
Returns:
the maximum distance between any two of the scanned objects.

fancyVisualTree

public static final void fancyVisualTree(VisualGraph visualgraph,
                                         java.lang.String geometry,
                                         java.lang.String style)
Makes a fancy visualgraph if its a tree.

Parameters:
visualgraph - the VisualGraph to make fancy.
geometry - the geometry to use.
style - the geometry to use.

computeVisibleRegion

public static final Boundary computeVisibleRegion(CompositeView compositeview)
Computes the visible region of the given CompositeView.

Parameters:
compositeview - the CompositeView to investigate.
Returns:
the visible region of the given CompositeView.

translateViewportAccordingToComposite

public static final void translateViewportAccordingToComposite(CompositeView compositeview,
                                                               Composite composite)
This method does the same as method translateViewportAccordingToBoundary(com.tensegrity.composite.CompositeView, com.tensegrity.graphics.Boundary), but is a convenience wrapper that operates on composites directly.

Parameters:
compositeview - the CompositeView to operate in.
composite - the composite to make visible.
See Also:
translateViewportAccordingToBoundary(CompositeView, Boundary)

translateViewportAccordingToGraph

public static final void translateViewportAccordingToGraph(VisualGraphView visualgraphview)
This method set the viewport of the VisualGraphView given by visualgraphview so that the graph is centered within the viewport. Doing so the current scale of the VisualGraphView is also taken into account.
If the graph is to large for the current viewport the graph is aligned to the left and top border.

Parameters:
visualgraphview - the VisualGraphView whos viewport should be translated

translateViewportAccordingToBoundary

public static final void translateViewportAccordingToBoundary(CompositeView compositeview,
                                                              Boundary boundary)
This method will set the viewport of the given CompositeView, so that the given boundary is visible. The viewport is translated so that the boundary is centered in the viewport. This is not always possible. For example, if the boundary is placed too close to one of the borders of the CompositeView, then the view is centered as much as possible. If the boundary of the composite is located directly in a corner of the CompositeView, then no centering is possible at all. If the given boundary is visible already, then no viewport translation is applied either.

Parameters:
compositeview - the CompositeView to adjust.
boundary - the boundary to make visible.

Find more information in the class documentation


translateViewportAccordingToBoundary

public static final void translateViewportAccordingToBoundary(CompositeView compositeview,
                                                              Boundary boundary,
                                                              boolean validatePosition)
This method will set the viewport of the given CompositeView, so that the given boundary is visible. The viewport is translated so that the boundary is centered in the viewport. This is not always possible. For example, if the boundary is placed too close to one of the borders of the composite view, then the view is centered as much as possible. If the boundary of the composite is located directly in a corner of the CompositeView, then no centering is possible at all. If the given boundary is visible already, then no viewport translation is applied either.

Parameters:
compositeview - the CompositeView to adjust.
boundary - the boundary to make visible.
validatePosition - If true, the viewport will be validated, so it will not be positioned in an empty area of the graph.

translateViewportAccordingToBoundary

public static final void translateViewportAccordingToBoundary(CompositeView compositeview,
                                                              Boundary boundary,
                                                              boolean validatePosition,
                                                              boolean updateView)
This method will set the viewport of the given CompositeView, so that the given boundary is visible. The viewport is translated so that the boundary is centered in the viewport. This is not always possible. For example, if the boundary is placed too close to one of the borders of the composite view, then the view is centered as much as possible. If the boundary of the composite is located directly in a corner of the CompositeView, then no centering is possible at all. If the given boundary is visible already, then no viewport translation is applied either.

Parameters:
compositeview - the CompositeView to adjust.
boundary - the boundary to make visible.
validatePosition - If true, the viewport will be validated, so it will not be positioned in an empty area of the graph.
updateView - If true, the view will updated.

translateViewportAroundCenter

public static final void translateViewportAroundCenter(CompositeView compositeview,
                                                       double cx,
                                                       double cy)
This method will set the viewport so that it is centered around the given coordinates.

Parameters:
compositeview - the composite view to act in.
cx - the x coordinate of the center of the viewport.
cy - the y coordinate of the center of the viewport.

translateViewportAroundCenter

public static final void translateViewportAroundCenter(VisualGraphView vgv,
                                                       double cx,
                                                       double cy)
This method will set the viewport so that it is centered around the given coordinates.

Parameters:
vgv - the VisualGraphView to act in.
cx - the x coordinate of the center of the viewport.
cy - the y coordinate of the center of the viewport.

applyTransformToCenterOfComposite

public static final void applyTransformToCenterOfComposite(Composite composite,
                                                           Transform2D xform)
Applies the given transformation on the center of a Composite object. Typically the transformation is a scaling or rotation operation. The bounding box of the composite is adjusted as well.

Parameters:
composite - the Composite to transform.
xform - the transform to apply.

Find more information in the class documentation


findIntersections

public static final java.util.Iterator findIntersections(VisualGraphObject subject,
                                                         java.util.Iterator visualobjects)
Finds all those VisualGraphObject objects that intersect the given VisualGraphObject.

Parameters:
subject - the VisualGraphObject to make scan against all others.
visualobjects - the list of VisualGraphObject that are compared with the subject object.
Returns:
iterator for all intersecting object.

autospaceAroundVisualNode

public static final void autospaceAroundVisualNode(VisualGraph visualgraph,
                                                   VisualNode visualnode)
Frees space around the given VisualNode by adjusting the positions of all intersecting nodes and all other nodes relatively. If no other nodes are intersected by the given VisualNode this method will not make any changes to the given VisualGraph.

Parameters:
visualgraph - the VisualGraph to operate in.
visualnode - the VisualNode that is subject of the operation.
See Also:
autospaceHorizontalAroundVisualNode(VisualGraph, VisualNode), autospaceVerticalAroundVisualNode(VisualGraph, VisualNode)

Find more information in the class documentation


autospaceHorizontalAroundVisualNode

public static final void autospaceHorizontalAroundVisualNode(VisualGraph visualgraph,
                                                             VisualNode visualnode)
Makes space around the given VisualNode by adjusting the positions of all intersecting nodes and all other nodes relatively. If no other nodes are intersected by the given VisualNode this method will not make any changes to the VisualGraph. This method makes horizontal space only.

Parameters:
visualgraph - the VisualGraph to operate in.
visualnode - the VisualNode that is subject of the operation.

autospaceVerticalAroundVisualNode

public static final void autospaceVerticalAroundVisualNode(VisualGraph visualgraph,
                                                           VisualNode visualnode)
Makes space around the given VisualNode by adjusting the positions of all intersecting nodes and all other nodes relatively. If no other nodes are intersected by the given VisualNode this method will not make any changes to the VisualGraph. This method makes vertical space only.

Parameters:
visualgraph - the VisualGraph to operate in.
visualnode - the VisualNode that is subject of the operation.

centerGraph

public static final void centerGraph(VisualGraphView visualgraphview,
                                     java.util.Collection objects)
Centers the given objects in the VisualGraphView.

Parameters:
visualgraphview - the VisualGraphView to act in.
objects - a collection of the object to center.

makeStraightLines

public static final void makeStraightLines(java.util.Iterator visualedges)
Transforms all given VisualEdge to straight lines by deleting additional points. If a VisualEdge is a straight line already, nothing will happen to the VisualEdge.

Parameters:
visualedges - an iterator over all the VisualEdges that should be made to straight lines.

makeStraightLine

public static final void makeStraightLine(VisualEdge visualedge)
Turns the given VisualEdge into a straight line by deleting additional points. If a VisualEdge is a straight line already, nothing will happen to the VisualEdge.

Parameters:
visualedge - the VisualEdge to be turned to a straight line.

makeOrthogonalVerticalLines

public static final void makeOrthogonalVerticalLines(VisualGraphView visualgraphview,
                                                     java.util.Iterator visualedges)
Turns all given VisualEdges to vertical orthogonal lines.

Parameters:
visualgraphview - the top level container.
visualedges - an iterator over all the VisualEdges that should be converted.

makeOrthogonalVerticalLine

public static final void makeOrthogonalVerticalLine(VisualGraphView visualgraphview,
                                                    VisualEdge visualedge)
Turns the given VisualEdges into an vertical orthogonal line.

Parameters:
visualgraphview - the top level container.
visualedge - the VisualEdge that should be converted.

makeOrthogonalHorizontalLines

public static final void makeOrthogonalHorizontalLines(VisualGraphView visualgraphview,
                                                       java.util.Iterator visualedges)
Makes all the given VisualEdge objects to horizontal orthogonal lines.

Parameters:
visualgraphview - the top level container.
visualedges - an iterator over all the VisualEdges to be converted.

makeOrthogonalHorizontalLine

public static final void makeOrthogonalHorizontalLine(VisualGraphView visualgraphview,
                                                      VisualEdge visualedge)
Turns the given VisualEdge objects into an horizontal orthogonal line.

Parameters:
visualgraphview - the top level container.
visualedge - the VisualEdge that should be converted.

zoomToFitNoMagnification

public static final void zoomToFitNoMagnification(VisualGraphView visualgraphview)
Zooms the VisualGraphView so that it fits the view.

Parameters:
visualgraphview - the VisualGraphView to fit.

zoomToFitProportional

public static final void zoomToFitProportional(VisualGraphView visualgraphview,
                                               Boundary destBoundary)
Zooms the VisualGraphView so that it fits the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
destBoundary - the bounds to fit into the view.

zoomToFitProportional

public static final void zoomToFitProportional(VisualGraphView visualgraphview,
                                               java.util.Collection visualobjects,
                                               Boundary destBoundary)
Zooms the VisualGraphView so that the given object fit into the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
visualobjects - the VisualObjects to fit into the view.
destBoundary - the destination boundary.

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview)
Zooms the VisualGraphView so that it fits the view.

Parameters:
visualgraphview - the VisualGraphView to fit.

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview,
                                   Boundary insets)
Zooms the VisualGraphView so that it fits the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
insets - Insets to create a border around the elements. Can be null.

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview,
                                   Boundary insets,
                                   double maxZoom)
Zooms the VisualGraphView so that it fits the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
insets - Insets to create a border around the elements. Can be null.
maxZoom - Do not zoom larger than this value

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview,
                                   java.util.Collection visualobjects)
Zooms the VisualGraphView so that the given object fit into the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
visualobjects - the VisualObjects to fit into the view.

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview,
                                   java.util.Collection visualobjects,
                                   Boundary insets)
Zooms the VisualGraphView so that the given object fit into the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
visualobjects - the VisualObjects to fit into the view.
insets - Insets to create a border around the elements. Can be null.

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview,
                                   java.util.Collection visualobjects,
                                   Boundary insets,
                                   double maxZoom)
Zooms the VisualGraphView so that the given object fit into the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
visualobjects - the VisualObjects to fit into the view.
insets - Insets to create a border around the elements. Can be null.
maxZoom - Do not zoom larger than this value

zoomToFit

public static void zoomToFit(VisualGraphView visualgraphview,
                             java.util.Collection visualobjects,
                             Boundary insets,
                             double maxZoom,
                             boolean noZoomIn)
Zooms the VisualGraphView so that the given object fit into the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
visualobjects - the VisualObjects to fit into the view.
insets - Insets to create a border around the elements. Can be null.
maxZoom - Do not zoom larger than this value
noZoomIn - true, to avoid zooming in

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview,
                                   java.awt.Rectangle bounds,
                                   Boundary insets)
Zooms the VisualGraphView so that the given object fit into the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
bounds - the rectangle to fit into the view.
insets - Insets to create a border around the elements. Can be null.

zoomToFit

public static final void zoomToFit(VisualGraphView visualgraphview,
                                   java.awt.Rectangle bounds,
                                   Boundary insets,
                                   double maxZoom,
                                   boolean noZoomIn)
Zooms the VisualGraphView so that the given object fit into the view.

Parameters:
visualgraphview - the VisualGraphView to fit.
bounds - the rectangle to fit into the view.
insets - Insets to create a border around the elements. Can be null.
maxZoom - Do not zoom larger than this value
noZoomIn - true, to avoid zooming in

computeTransformToVisualSubgraph

public static final Transform2D computeTransformToVisualSubgraph(VisualGraphView visualgraphview,
                                                                 VisualSubgraph visualsubgraph)
Computes the Transform2D that transforms coordinates from the top-level CompositeView to the given VisualSubgraph.

Please note that the CompositeHierarchy and CompositeHierarchyUtilities are a more generic and most often better way of computing such transforms.

Parameters:
visualgraphview - the top level VisualGraphView.
visualsubgraph - the VisualSubgraph to look for.
Returns:
the Transform2D that converts coordinates to the specified VisualSubgraph.

computeTransformFromVisualSubgraph

public static final Transform2D computeTransformFromVisualSubgraph(VisualGraphView visualgraphview,
                                                                   VisualSubgraph visualsubgraph)
Computes the Transform2D that transforms coordinates from the given VisualSubgraph to the top-level CompositeView.

Please note that the CompositeHierarchy and CompositeHierarchyUtilities are a more generic and most often better way of computing such transforms.

Parameters:
visualgraphview - the top level VisualGraphView.
visualsubgraph - the VisualSubgraph to look for.
Returns:
the Transform2D that converts coordinates from the specified VisualSubgraph.

computeVisualNode2VisualSubgraphMap

public static final java.util.HashMap computeVisualNode2VisualSubgraphMap(VisualGraphView vsg)
This method will compute a map with VisualNode objects as keys and the VisualSubgraphs they are part of as values. Some entries in the map have null values, in this case the corresponding VisualNode objects are part of the VisualGraphView itself.

Parameters:
vsg - the VisualGraphView to perform the search in.
Returns:
a map of VisualNodes to VisualSubgraph.

computeVisualEdge2VisualSubgraphMap

public static final java.util.HashMap computeVisualEdge2VisualSubgraphMap(VisualGraphView vsg)
This method will compute a map with visualedges as keys and the visualsubgraphs they are part of as values. Some entries in the map have null values, in this case the corresponding visualedges are part of the visualgraphview itself.

Parameters:
vsg - the visualgraphview to perform the search in.
Returns:
a map of visualnodes to visualsubgraph.

computeDeepestSelection

public static final StableHashMap computeDeepestSelection(VisualGraphView visualgraphview)
Compute the deepest selection by considering the hierarchy of nested subgraphs and not just the toplevel-view.

Parameters:
visualgraphview - the VisualGraphView to start the search in.
Returns:
HashMap the HashMap with the hierarchy

getDeepSelection

public static final java.util.Collection getDeepSelection(VisualGraphView visualgraphview)
Compute the deepest selection by considering the hierarchy of nested subgraphs and not just the toplevel-view.

Parameters:
visualgraphview - the VisualGraphView to start the search in.
Returns:
a collection holding the deep selected elements.

convertCoordinates

public static final void convertCoordinates(Composite composite,
                                            Transform2D transform)
Converts the boundary of the given Composite by the given transformation.

Parameters:
composite - the Composite whose boundary should be transformed.
transform - the Transform2D that describes the boundary change.

convertCoordinates

public static final void convertCoordinates(VisualEdge visualedge,
                                            Transform2D transform)
Converts all the coordinates of the given VisualEdge by the given transformation.

Parameters:
visualedge - the VisualEdge whose coordinates should be transformed.
transform - the Transform2D that describes the coordinate change.

convertCoordinates

public static final void convertCoordinates(Coordinate[] coordinates,
                                            Transform2D transform)
Converts all the coordinates of the given array by the given transformation.

Parameters:
coordinates - the array of coordinates to convert.
transform - the Transform2D that describes the coordinate change.

convertCoordinates

public static final void convertCoordinates(CompositeLine compositeline,
                                            Transform2D transform)
Converts all the coordinates of the given CompositeLine by the given transformation.

Parameters:
compositeline - the CompositeLine whose coordinates should be transformed.
transform - the Transform2D that describes the coordinate change.

convertCoordinates

public static final void convertCoordinates(Boundary boundary,
                                            Transform2D transform)
Converts the given boundary by the given transformation.

Parameters:
boundary - the Boundary to be transformed.
transform - the Transform2D to apply.

intersectionTest

public static final boolean intersectionTest(Coordinate[] coords,
                                             Boundary boundary)
Returns true if there is an intersection between the bounds and the multi segment line.

Parameters:
coords - line segments coordinates.
boundary - the boundary to test for intersection.
Returns:
true if there is an intersection.

intersectionTest

public static final boolean intersectionTest(Coordinate[] coords,
                                             BoundingBox bbox)

computeBoundingBox

public static final Boundary computeBoundingBox(CompositeHierarchy hierarchy)
Computes a bounding of the current selection which is stored in a CompositeHierarchy. The coordinates of the returned bounding box are given in units of the coordinate system of the CompositeView the selection is within.

Parameters:
hierarchy - the selection
Returns:
the bounding box in the top-level coordinate system.

computeBoundingBox

public static final Boundary computeBoundingBox(java.util.Collection visualgraphobjects)
Computes a bounding of the given list of VisualGraphObjects.

Parameters:
visualgraphobjects - a collection of VisualGraphObjects.
Returns:
the bounding box of the the VisualGraphObject objects.

recursiveSelection

public static final void recursiveSelection(VisualGraphView visualgraphview,
                                            boolean selected)
Deprecated. make use of CompositeViewOperations.recursiveSelection(CompositeView, boolean) instead.

Recursively sets all the VisualGraphObjects that are contained in the specified VisualGraphView to the desired selection-state.

VisualGraphObjects that are nested in embedded VisualSubgraphs are processed as well.

Parameters:
visualgraphview - the VisualGraphView to process.
selected - the selection state to apply to all contained VisualGraphObjects.

xSortedVGOs

public static final void xSortedVGOs(java.util.List list)
Sorts the given list containing VisualGraphObjects inplace based on their x-center.

Parameters:
list - the list of VisualGraphObjects to sort inplace.

ySortedVGOs

public static final void ySortedVGOs(java.util.List list)
Sorts the given list containing VisualGraphObjects inplace based on their y-center.

Parameters:
list - the list of VisualGraphObjects to sort inplace.

applyScale

public static void applyScale(VisualGraphView visualgraphview,
                              double sx,
                              double sy)
Applies a scaling transform to the given VisualGraphView instance.

Parameters:
visualgraphview - the VisualGraphView to scale.
sx - scale in x direction.
sy - scale in y direction.

findBoundsVisualGraphOrSelection

public static double[] findBoundsVisualGraphOrSelection(VisualGraphView visualgraphview)
Helper to find the bounds of either the entire VisualGraphView or of the selection.

Parameters:
visualgraphview - the VisualGraphView to investigate.
Returns:
boundary as 4-tuple of doubles containing x0, y0, x1, y1

validateZoom

public static double validateZoom(double scale)
Validates a scale value for a CompositeView and returns a scale value that lies withing the valid range.

Parameters:
scale - The scale that should be validated
Returns:
A valid scale value that can be set to the view


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.