Search this API

y.layout
Class LayoutTool

java.lang.Object
  extended by y.layout.LayoutTool

public class LayoutTool
extends Object

This class is a container for several helper and utility functions for the LayoutGraph class.

See Also:
LayoutGraph

Field Summary
static int CENTER
          Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int).
static byte FLOW_DOWN
          Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider).
static byte FLOW_LEFT
          Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider).
static byte FLOW_NONE
          Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider).
static byte FLOW_RIGHT
          Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider).
static byte FLOW_UP
          Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider).
static int JUSTIFIED
          Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int).
static int LEADING
          Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int).
static int TRAILING
          Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int).
 
Method Summary
static void alignNodeLayouts(LayoutGraph g, NodeList nodes, Node referenceNode, boolean vertical, byte mode)
           
static void applyGraphLayout(LayoutGraph graph, GraphLayout gl)
          Applies a GraphLayout to a LayoutGraph.
static Dimension arrangeRectangleGrid(Rectangle2D[] rects, Rectangle2D finalRect, double viewRatio)
          Reassigns the bounds of the rectangles in rects to fit into a large rectangle, whose bounds will be stored in finalRect.
static int arrangeRectangleRows(Rectangle2D[] rects, Rectangle2D finalRect, double viewRatio)
          Reassigns the bounds of the rectangles in rects to fit in a large rectangle, whose bounds will be stored in finalRect.
static int arrangeRectangleRows(Rectangle2D[] rects, Rectangle2D finalRect, double viewRatio, int alignment)
          Reassigns the bounds of the rectangles in rects to fit into a large rectangle, whose bounds will be stored in finalRect.
static void assignReverseLayout(LayoutGraph graph, Edge e1, Edge e2)
          Set the layout of two parallel edges with different direction identical.
static boolean autoFlipBox(OrientedRectangle rect)
          Flips the orientation of a given rectangle, if its up vector points downward ({OrientedRectangle#getUpY} > 0).
static void clipEdgeOnBB(LayoutGraph gd, Edge e)
          This helper method clips the path of the edge on the bounding box of the start and end points.
static void clipEdgesOnBB(LayoutGraph gd)
          This helper method clips the path of the edge on the bounding box of the start and end points.
static byte determineEdgeFlowDirection(LayoutGraph graph, DataProvider considerEdges)
          Determines the main direction of the edge flow by analyzing the current layout of the graph.
static String edgeLayoutString(LayoutGraph gd, Edge edge)
          Returns the path of the layout of a specific edge as a String.
static Rectangle2D getBoundingBox(LayoutGraph graph, Edge e)
          Returns the bounding box of the given edge.
static Rectangle2D getBoundingBox(LayoutGraph graph, EdgeCursor ec)
          Returns the bounding box of the edges accessible through the given edge cursor.
static Rectangle2D getBoundingBox(LayoutGraph graph, Node n)
          Returns the bounding box of the given node.
static Rectangle2D getBoundingBox(LayoutGraph graph, NodeCursor nc)
          Returns the bounding box of the nodes accessible through the given node cursor.
static Rectangle2D getBoundingBox(LayoutGraph graph, NodeCursor nc, EdgeCursor ec)
          Returns the bounding box of the nodes and edges accessible through the given cursors.
static Rectangle2D getBoundingBox(LayoutGraph graph, NodeCursor nc, EdgeCursor ec, boolean includeLabels)
          Returns the bounding box of the nodes and edges accessible through the given cursors.
static YPointPath getEdgeClippedOnBB(EdgeLayout edge, NodeLayout sourceNode, NodeLayout targetNode)
          This helper method clips the path of an edge on the bounding box of the start and end vertices.
static YPointPath getEdgeClippedOnBB(EdgeLayout edge, NodeLayout sourceNode, NodeLayout targetNode, double inset)
          This helper method clips the path of an edge on the bounding box of the start and end vertices.
static YPointPath getEdgeClippedOnBB(LayoutGraph gd, Edge edge)
          This helper method clips the path of an edge on the bounding box of the start and end vertices.
static YPoint getLabelPlacement(EdgeLabelModel model, YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout, Object param)
          Returns the upper left corner of the given label's paraxial bounding box as encoded by the specified model parameter.
static YPoint getLabelPlacement(NodeLabelModel model, YDimension labelSize, NodeLayout nodeLayout, Object param)
          Returns the upper left corner of the given label's paraxial bounding box as encoded by the specified model parameter.
static double getNodeDistance(LayoutGraph graph, Node s, Node t)
          Returns the distance between the centers of two nodes
static String getNodePositions(LayoutGraph gd)
          Returns the positions of the nodes of a graph's diagram.
static double getPathLength(LayoutGraph graph, Edge e)
          Returns the length of path of a given edge.
static void initDiagram(LayoutGraph gd)
          This method assigns the position (0,0) to all nodes in the graph, and sets the edges to straight lines with ports in the center of the adjacent node.
static boolean isEdgeOutsideNodes(EdgeLayout edge, NodeLayout sourceNode, NodeLayout targetNode, double inset)
          This helper method tests if the path of an edge is outside the bounding box of the start and end vertices.
static boolean isEdgeOutsideNodes(LayoutGraph gd, Edge edge)
          This helper method tests if the path of an edge is outside the bounding box of the start and end vertices.
static boolean isUsingOctilinearEdgeRoutes(LayoutGraph graph, DataProvider considerEdges)
          Returns true if most of the edges of the graph are routed octilinear.
static boolean isUsingOrthogonalEdgeRoutes(LayoutGraph graph, DataProvider considerEdges)
          Returns true if most of the edges of the graph are routed orthogonal.
static void moveEdge(LayoutGraph g, Edge edge, double dx, double dy)
          Moves the edge points of the given edge by the vector (dx,dy).
static void moveEdges(LayoutGraph g, EdgeCursor edges, double dx, double dy)
          Moves all edges accessible through the given edge cursor by the vector (dx,dy).
static void moveNode(LayoutGraph g, Node node, double dx, double dy)
          Moves the given node by the vector (dx,dy).
static void moveNodes(LayoutGraph g, NodeCursor nodes, double dx, double dy)
          Moves all nodes accessible through the given node cursor by the vector (dx,dy).
static void moveSubgraph(LayoutGraph g, EdgeCursor edges, double dx, double dy)
          Moves the subgraph induced by edges accessible through the given edge cursor by the vector (dx,dy).
static void moveSubgraph(LayoutGraph g, NodeCursor nodes, double dx, double dy)
          Moves the subgraph induced by nodes accessible through the given node cursor by the vector (dx,dy).
static boolean pathIntersectsRect(LayoutGraph graph, Edge e, Rectangle2D rect)
          Checks whether or not the path of an edge intersects the interior of a given rectangular area.
static void removeDuplicateBends(LayoutGraph gd)
          This helper method removes duplicate bends from all edges in the graph
static void removeDuplicateBends(LayoutGraph gd, Edge edge)
          This helper method removes duplicate bends from the given edge in the graph
static void resetPath(LayoutGraph gd, Edge edge)
          Assigns a trivial path which has no control points to the specified edge and sets the edge's ports to the center of the corresponding node.
static void resetPath(LayoutGraph gd, Edge edge, boolean resetPorts)
          Assigns a trivial path which has no control points to the specified edge.
static void resetPaths(LayoutGraph gd)
          Assigns a trivial path which has no control points to all edges in the specified graph and sets the edges' ports to the center of the corresponding nodes.
static void resetPaths(LayoutGraph gd, boolean resetPorts)
          Assigns a trivial path which has no control points to all edges in the specified graph.
static void resetPorts(LayoutGraph gd)
          Sets the ports to the center of the nodes.
static void reverseEdgeLayout(EdgeLayout el)
          Reverses the layout of an edge.
static void roundEdgeLayout(LayoutGraph gd, Edge edge)
          Round the values of the control points and ports of an edge.
static void roundLayout(LayoutGraph gd)
          Round the values of the layout of an entire layout.
static void roundNodeLayout(LayoutGraph gd, Node node)
          Round the values of the layout of a node.
static void routeEdgesParallel(LayoutGraph gd, Edge e1, Edge e2, double lineDistance)
          Routes two edges which are incident to the same nodes, in parallel.
static void routeEdgesParallel(LayoutGraph gd, Edge e1, Edge e2, double lineDistance, boolean joinEnds, double absJoinDist, double relJoinDist)
          Routes two edges which are incident to the same nodes, in parallel.
static void routeEdgesParallel(LayoutGraph gd, Edge e1, EdgeList list, double lineDistance)
          Routes a list of edges with are incident to the same nodes, in parallel.
static void routeEdgesParallel(LayoutGraph gd, Edge e1, EdgeList list, double lineDistance, boolean adjustE1, boolean joinEnds, double absJoinDist, double relJoinDist)
          Routes a list of edges which are incident to the same nodes, in parallel.
static void routeSelfLoop(LayoutGraph gd, Edge e)
          Routes a self-loop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEADING

public static final int LEADING
Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int). Rectangles in one row will be aligned with the leading edge.

See Also:
Constant Field Values

TRAILING

public static final int TRAILING
Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int). Rectangles in one row will be aligned to the trailing edge.

See Also:
Constant Field Values

JUSTIFIED

public static final int JUSTIFIED
Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int). Rectangles in one row will be justified in the row.

See Also:
Constant Field Values

CENTER

public static final int CENTER
Constant which can be used for arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int). Rectangles in one row will be centered on the row.

See Also:
Constant Field Values

FLOW_UP

public static final byte FLOW_UP
Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider). This value specifies that the flow direction of most edges is up.

See Also:
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider), Constant Field Values

FLOW_DOWN

public static final byte FLOW_DOWN
Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider). This value specifies that the flow direction of most edges is down.

See Also:
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider), Constant Field Values

FLOW_LEFT

public static final byte FLOW_LEFT
Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider). This value specifies that the flow direction of most edges is left.

See Also:
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider), Constant Field Values

FLOW_RIGHT

public static final byte FLOW_RIGHT
Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider). This value specifies that the flow direction of most edges is right.

See Also:
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider), Constant Field Values

FLOW_NONE

public static final byte FLOW_NONE
Edge flow specifier used by method determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider). This value specifies that there is no main flow direction.

See Also:
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider), Constant Field Values
Method Detail

determineEdgeFlowDirection

public static byte determineEdgeFlowDirection(LayoutGraph graph,
                                              DataProvider considerEdges)
Determines the main direction of the edge flow by analyzing the current layout of the graph. The method only considers edges for which the given DataProvider returns true.

Parameters:
graph - the underlying graph.
considerEdges - the edges to consider.
Returns:
the flow direction, i.e., FLOW_DOWN, FLOW_LEFT, FLOW_NONE, FLOW_RIGHT or FLOW_UP.

isUsingOrthogonalEdgeRoutes

public static boolean isUsingOrthogonalEdgeRoutes(LayoutGraph graph,
                                                  DataProvider considerEdges)
Returns true if most of the edges of the graph are routed orthogonal. The method only considers edges for which the given DataProvider returns true.

Parameters:
graph - the underlying graph.
considerEdges - the edges to consider.
Returns:
true if most of the edges of the graph are routed orthogonal.

isUsingOctilinearEdgeRoutes

public static boolean isUsingOctilinearEdgeRoutes(LayoutGraph graph,
                                                  DataProvider considerEdges)
Returns true if most of the edges of the graph are routed octilinear. The method only considers edges for which the given DataProvider returns true.

Note: for orthogonal layouts this method returns true.

Parameters:
graph - the underlying graph.
considerEdges - the edges to consider.
Returns:
true if most of the edges of the graph are routed octilinear.

getNodeDistance

public static double getNodeDistance(LayoutGraph graph,
                                     Node s,
                                     Node t)
Returns the distance between the centers of two nodes


getPathLength

public static double getPathLength(LayoutGraph graph,
                                   Edge e)
Returns the length of path of a given edge. The path starts at the source point traverses through all control points and ends at the target point.


reverseEdgeLayout

public static void reverseEdgeLayout(EdgeLayout el)
Reverses the layout of an edge. This method reverses the order of points and swaps source with target point.


resetPaths

public static void resetPaths(LayoutGraph gd)
Assigns a trivial path which has no control points to all edges in the specified graph and sets the edges' ports to the center of the corresponding nodes. Calling this method is equivalent to
resetPaths(gd, true)

Parameters:
gd - a graph diagram.
See Also:
resetPaths(LayoutGraph, boolean)

resetPaths

public static void resetPaths(LayoutGraph gd,
                              boolean resetPorts)
Assigns a trivial path which has no control points to all edges in the specified graph.

Parameters:
gd - a graph diagram.
resetPorts - if true, the ports of the edges are set to the center of the corresponding nodes.

resetPath

public static void resetPath(LayoutGraph gd,
                             Edge edge)
Assigns a trivial path which has no control points to the specified edge and sets the edge's ports to the center of the corresponding node. Calling this method is equivalent to
resetPath(gd, edge, true)

Parameters:
gd - a graph diagram.
edge - an edge in graph.
See Also:
resetPath(LayoutGraph, y.base.Edge, boolean)

resetPath

public static void resetPath(LayoutGraph gd,
                             Edge edge,
                             boolean resetPorts)
Assigns a trivial path which has no control points to the specified edge.

Parameters:
gd - a graph diagram.
edge - an edge in graph.
resetPorts - if true, the ports of the edge are set to the center of the corresponding node.

removeDuplicateBends

public static void removeDuplicateBends(LayoutGraph gd)
This helper method removes duplicate bends from all edges in the graph

Parameters:
gd - a graph diagram.

removeDuplicateBends

public static void removeDuplicateBends(LayoutGraph gd,
                                        Edge edge)
This helper method removes duplicate bends from the given edge in the graph

Parameters:
gd - a graph diagram.
edge - the edge.

moveEdge

public static void moveEdge(LayoutGraph g,
                            Edge edge,
                            double dx,
                            double dy)
Moves the edge points of the given edge by the vector (dx,dy).


moveEdges

public static void moveEdges(LayoutGraph g,
                             EdgeCursor edges,
                             double dx,
                             double dy)
Moves all edges accessible through the given edge cursor by the vector (dx,dy).


moveNode

public static void moveNode(LayoutGraph g,
                            Node node,
                            double dx,
                            double dy)
Moves the given node by the vector (dx,dy).


moveNodes

public static void moveNodes(LayoutGraph g,
                             NodeCursor nodes,
                             double dx,
                             double dy)
Moves all nodes accessible through the given node cursor by the vector (dx,dy).


moveSubgraph

public static void moveSubgraph(LayoutGraph g,
                                EdgeCursor edges,
                                double dx,
                                double dy)
Moves the subgraph induced by edges accessible through the given edge cursor by the vector (dx,dy).


moveSubgraph

public static void moveSubgraph(LayoutGraph g,
                                NodeCursor nodes,
                                double dx,
                                double dy)
Moves the subgraph induced by nodes accessible through the given node cursor by the vector (dx,dy).


getBoundingBox

public static Rectangle2D getBoundingBox(LayoutGraph graph,
                                         NodeCursor nc,
                                         EdgeCursor ec)
Returns the bounding box of the nodes and edges accessible through the given cursors.


getBoundingBox

public static Rectangle2D getBoundingBox(LayoutGraph graph,
                                         Node n)
Returns the bounding box of the given node.


getBoundingBox

public static Rectangle2D getBoundingBox(LayoutGraph graph,
                                         NodeCursor nc)
Returns the bounding box of the nodes accessible through the given node cursor.


getBoundingBox

public static Rectangle2D getBoundingBox(LayoutGraph graph,
                                         Edge e)
Returns the bounding box of the given edge.


getBoundingBox

public static Rectangle2D getBoundingBox(LayoutGraph graph,
                                         EdgeCursor ec)
Returns the bounding box of the edges accessible through the given edge cursor.


getBoundingBox

public static Rectangle2D getBoundingBox(LayoutGraph graph,
                                         NodeCursor nc,
                                         EdgeCursor ec,
                                         boolean includeLabels)
Returns the bounding box of the nodes and edges accessible through the given cursors. Optionally, the resulting bounding box will also include the bounds of all node and edge labels attached to the accessible node sand edges.


getLabelPlacement

public static YPoint getLabelPlacement(NodeLabelModel model,
                                       YDimension labelSize,
                                       NodeLayout nodeLayout,
                                       Object param)
Returns the upper left corner of the given label's paraxial bounding box as encoded by the specified model parameter.

Parameters:
model - the label model used to place the label.
labelSize - the size of the label that should be placed.
nodeLayout - the layout of the node to which the label belongs.
param - the model parameter that describes the abstract position of the label within the specified model. The parameter must have been generated by said model.
Returns:
the upper left corner of the label's bounding box.
See Also:
NodeLabelModel.getLabelPlacement(y.geom.YDimension, NodeLayout, Object)

getLabelPlacement

public static YPoint getLabelPlacement(EdgeLabelModel model,
                                       YDimension labelSize,
                                       EdgeLayout edgeLayout,
                                       NodeLayout sourceLayout,
                                       NodeLayout targetLayout,
                                       Object param)
Returns the upper left corner of the given label's paraxial bounding box as encoded by the specified model parameter.

Parameters:
model - the label model used to place the label.
labelSize - the size of the label that should be placed.
edgeLayout - the layout of the edge to which the label belongs.
sourceLayout - the layout of the source node of the label owning edge.
targetLayout - the layout of the target node of the label owning edge.
param - the model parameter that describes the abstract position of the label within the specified model. The parameter must have been generated by said model.
Returns:
the upper left corner of the label's bounding box.
See Also:
EdgeLabelModel.getLabelPlacement(y.geom.YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)

resetPorts

public static void resetPorts(LayoutGraph gd)
Sets the ports to the center of the nodes.

Parameters:
gd - a graph diagram.

getEdgeClippedOnBB

public static YPointPath getEdgeClippedOnBB(EdgeLayout edge,
                                            NodeLayout sourceNode,
                                            NodeLayout targetNode)
This helper method clips the path of an edge on the bounding box of the start and end vertices.


getEdgeClippedOnBB

public static YPointPath getEdgeClippedOnBB(LayoutGraph gd,
                                            Edge edge)
This helper method clips the path of an edge on the bounding box of the start and end vertices.


getEdgeClippedOnBB

public static YPointPath getEdgeClippedOnBB(EdgeLayout edge,
                                            NodeLayout sourceNode,
                                            NodeLayout targetNode,
                                            double inset)
This helper method clips the path of an edge on the bounding box of the start and end vertices.


isEdgeOutsideNodes

public static boolean isEdgeOutsideNodes(LayoutGraph gd,
                                         Edge edge)
This helper method tests if the path of an edge is outside the bounding box of the start and end vertices.


isEdgeOutsideNodes

public static boolean isEdgeOutsideNodes(EdgeLayout edge,
                                         NodeLayout sourceNode,
                                         NodeLayout targetNode,
                                         double inset)
This helper method tests if the path of an edge is outside the bounding box of the start and end vertices.


clipEdgesOnBB

public static void clipEdgesOnBB(LayoutGraph gd)
This helper method clips the path of the edge on the bounding box of the start and end points.


clipEdgeOnBB

public static void clipEdgeOnBB(LayoutGraph gd,
                                Edge e)
This helper method clips the path of the edge on the bounding box of the start and end points.


edgeLayoutString

public static String edgeLayoutString(LayoutGraph gd,
                                      Edge edge)
Returns the path of the layout of a specific edge as a String.


roundNodeLayout

public static void roundNodeLayout(LayoutGraph gd,
                                   Node node)
Round the values of the layout of a node.


roundEdgeLayout

public static void roundEdgeLayout(LayoutGraph gd,
                                   Edge edge)
Round the values of the control points and ports of an edge.


roundLayout

public static void roundLayout(LayoutGraph gd)
Round the values of the layout of an entire layout.


routeEdgesParallel

public static void routeEdgesParallel(LayoutGraph gd,
                                      Edge e1,
                                      Edge e2,
                                      double lineDistance)
Routes two edges which are incident to the same nodes, in parallel.

See Also:
routeEdgesParallel(LayoutGraph, Edge, Edge, double, boolean, double, double)

routeEdgesParallel

public static void routeEdgesParallel(LayoutGraph gd,
                                      Edge e1,
                                      Edge e2,
                                      double lineDistance,
                                      boolean joinEnds,
                                      double absJoinDist,
                                      double relJoinDist)
Routes two edges which are incident to the same nodes, in parallel.

Parameters:
gd - the graph
e1 - the leading edge
e2 - the edge to be adjusted (may be e1)
lineDistance - the distance between the two edges
joinEnds - whether the end points should all be set to the end points of e1
absJoinDist - the absolute distance between the end points and the beginning to the parallel segment routing
relJoinDist - the relative distance, measured relative to the length of the first/last segments

routeEdgesParallel

public static void routeEdgesParallel(LayoutGraph gd,
                                      Edge e1,
                                      EdgeList list,
                                      double lineDistance)
Routes a list of edges with are incident to the same nodes, in parallel. Invoking this method is equivalent to:
 routeEdgesParallel(gd, e1, list, lineDistance, false, false, 0.0d, 0.0d)
 
.

Parameters:
gd - the graph
e1 - the leading edge
list - the list of edges that will be aligned to e1
lineDistance - the distance between two edges
See Also:
routeEdgesParallel(LayoutGraph, Edge, EdgeList, double, boolean, boolean, double, double)

routeEdgesParallel

public static void routeEdgesParallel(LayoutGraph gd,
                                      Edge e1,
                                      EdgeList list,
                                      double lineDistance,
                                      boolean adjustE1,
                                      boolean joinEnds,
                                      double absJoinDist,
                                      double relJoinDist)
Routes a list of edges which are incident to the same nodes, in parallel.

Parameters:
gd - the graph
e1 - the leading edge
list - the list of edges that will be aligned to e1
lineDistance - the distance between two edges
adjustE1 - whether e1 should be adjusted if the size of list is odd
joinEnds - whether the end points should all be set to the end points of e1
absJoinDist - the absolute distance between the end points and the beginning to the parallel segment routing
relJoinDist - the relative distance, measured relative to the length of the first/last segments

routeSelfLoop

public static void routeSelfLoop(LayoutGraph gd,
                                 Edge e)
Routes a self-loop.

Parameters:
e - An edge with e.source.equals(e.target).

assignReverseLayout

public static void assignReverseLayout(LayoutGraph graph,
                                       Edge e1,
                                       Edge e2)
Set the layout of two parallel edges with different direction identical.

Parameters:
e1 - the edge for which the points are set.
e2 - the template.

getNodePositions

public static String getNodePositions(LayoutGraph gd)
Returns the positions of the nodes of a graph's diagram.


initDiagram

public static void initDiagram(LayoutGraph gd)
This method assigns the position (0,0) to all nodes in the graph, and sets the edges to straight lines with ports in the center of the adjacent node.


arrangeRectangleRows

public static int arrangeRectangleRows(Rectangle2D[] rects,
                                       Rectangle2D finalRect,
                                       double viewRatio)
Reassigns the bounds of the rectangles in rects to fit in a large rectangle, whose bounds will be stored in finalRect. This procedure tries to generate a final rectangle, whose aspect ratio is as close as possible to viewRatio. This is achieved by arranging the rectangles in a rows. The number of used rows will be returned. This method invokes arrangeRectangleRows with LEADING as the last argument.

Parameters:
rects - the rectangles whose coordinates will be modified
finalRect - the exact dimension will be placed in this rectangle
viewRatio - the preferred ratio of the resulting bounds
Returns:
the number of used rows

arrangeRectangleGrid

public static Dimension arrangeRectangleGrid(Rectangle2D[] rects,
                                             Rectangle2D finalRect,
                                             double viewRatio)
Reassigns the bounds of the rectangles in rects to fit into a large rectangle, whose bounds will be stored in finalRect. This procedure tries to generate a final rectangle, whose aspect ratio is as close as possible to viewRatio. This is achieved by arranging the rectangles in a grid-like fashion. The dimension of this grid is returned.

Parameters:
rects - the rectangles whose, coordinates will be modified
finalRect - the exact dimension will be placed in this rectangle
viewRatio - the preferred ratio of the grid
Returns:
the dimension of the grid

arrangeRectangleRows

public static int arrangeRectangleRows(Rectangle2D[] rects,
                                       Rectangle2D finalRect,
                                       double viewRatio,
                                       int alignment)
Reassigns the bounds of the rectangles in rects to fit into a large rectangle, whose bounds will be stored in finalRect. This procedure tries to generate a final rectangle, whose aspect ratio is as close as possible to viewRatio. This is achieved by arranging the rectangles in rows. The number of generated rows is returned.

Parameters:
alignment - determines the alignment policy for rows, that are not completely filled
rects - the rectangles whose coordinates will be modified
finalRect - the exact dimension will be placed in this rectangle
viewRatio - the preferred ratio of the resulting bounds
Returns:
the number of generated rows

pathIntersectsRect

public static boolean pathIntersectsRect(LayoutGraph graph,
                                         Edge e,
                                         Rectangle2D rect)
Checks whether or not the path of an edge intersects the interior of a given rectangular area.


applyGraphLayout

public static void applyGraphLayout(LayoutGraph graph,
                                    GraphLayout gl)
Applies a GraphLayout to a LayoutGraph.

Precondition:
the GraphLayout data must be defined for elements in the given LayoutGraph.

alignNodeLayouts

public static void alignNodeLayouts(LayoutGraph g,
                                    NodeList nodes,
                                    Node referenceNode,
                                    boolean vertical,
                                    byte mode)

autoFlipBox

public static boolean autoFlipBox(OrientedRectangle rect)
Flips the orientation of a given rectangle, if its up vector points downward ({OrientedRectangle#getUpY} > 0). That means, it rotates the rectangle by 180 degree without changing the rectangle's center.

Parameters:
rect - the given rectangle.
Returns:
true if the given rectangle was flipped and false otherwise.

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.