public final class LayoutGraphUtilities extends Object
LayoutGraphUtilities
provides several helper and utility functions for LayoutGraph
and the
layout algorithms
.LayoutGraph
Modifier and Type | Method and Description |
---|---|
static void |
alignNodeLayouts(LayoutGraph graph,
NodeList nodes,
Node referenceNode,
boolean vertical,
NodeAlignment mode)
Aligns the specified nodes either vertically or horizontally according to the specified node alignment mode.
|
static YDimension |
arrangeRectangleGrid(Rectangle2D[] rectangles,
Rectangle2D finalRect,
double aspectRatio)
Reassigns the bounds of the rectangles in a grid to fit in a large rectangle with an aspect ratio close to the specified
aspect ratio.
|
static int |
arrangeRectangleMultiRows(Rectangle2D[] rectangles,
Rectangle2D finalRect,
double preferredWidth,
double preferredHeight,
boolean compaction,
MultiRowConstraint constraintMode)
Reassigns the bounds of the rectangles in multiple rows to fit the preferred width and height.
|
static int |
arrangeRectangleMultiRows(Rectangle2D[] rectangles,
Rectangle2D finalRect,
double preferredWidth,
double preferredHeight,
boolean compaction,
MultiRowConstraint constraintMode,
RowAlignment alignment)
Reassigns the bounds of the rectangles in multiple rows to fit the preferred width and height.
|
static int |
arrangeRectangleRows(Rectangle2D[] rectangles,
Rectangle2D finalRect,
double aspectRatio)
Reassigns the bounds of the rectangles to fit in a large rectangle with an aspect ratio close to the specified aspect
ratio.
|
static int |
arrangeRectangleRows(Rectangle2D[] rectangles,
Rectangle2D finalRect,
double aspectRatio,
RowAlignment alignment)
Reassigns the bounds of the rectangles to fit in a large rectangle with an aspect ratio close to the specified aspect
ratio.
|
static void |
assignReverseLayout(LayoutGraph graph,
Edge edge1,
Edge edge2)
Applies the reversed layout of the first edge to the second edge.
|
static boolean |
autoFlipBox(YOrientedRectangle rect)
|
static void |
clipEdgeOnBounds(LayoutGraph graph,
Edge edge)
Clips the path of the given edge on the bounding box of the source and target points.
|
static YPointPath |
clipEdgePathOnBounds(IEdgeLayout edge,
INodeLayout source,
INodeLayout target)
Returns the path of an edge clipped on insets of the bounding box of the source and target node.
|
static YPointPath |
clipEdgePathOnBounds(IEdgeLayout edge,
INodeLayout source,
INodeLayout target,
double inset)
Returns the path of an edge clipped on insets of the bounding box of the source and target node.
|
static YPointPath |
clipEdgePathOnBounds(LayoutGraph graph,
Edge edge)
Returns the path of an edge clipped on the bounding box of the source and target node.
|
static void |
clipEdgesOnBounds(LayoutGraph graph)
Clips the path of all edges in the graph on the bounding box of their source and target points.
|
static YPointPath |
clipPathOnBounds(YPointPath path,
YRectangle sourceBox,
YRectangle targetBox)
Returns the path of a given edge path clipped on the given bounding boxes of the source and target node.
|
static EdgeFlow |
determineEdgeFlowDirection(LayoutGraph graph,
IDataProvider considerEdges)
Determines the main direction of the edge flow by analyzing the current layout of the graph.
|
static String |
edgeLayoutString(LayoutGraph graph,
Edge edge)
Returns a
String representation of the path of the given edge. |
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
Edge edge)
Returns the bounding box of the given edge.
|
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
IEdgeCursor edges)
Returns the bounding box of the edges accessible through the given cursor.
|
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
INodeCursor nodes)
Returns the bounding box of the nodes accessible through the given cursor.
|
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
INodeCursor nodes,
IEdgeCursor edges)
Returns the bounding box of the nodes and edges accessible through the given cursors.
|
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
INodeCursor nodes,
IEdgeCursor edges,
boolean includeLabels)
Returns the bounding box of the nodes and edges accessible through the given cursors, optionally including node labels
and edge labels.
|
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
INodeCursor nodes,
IEdgeCursor edges,
boolean includeNodeLabels,
boolean includeEdgeLabels)
Returns the bounding box of the nodes and edges accessible through the given cursors, optionally including node labels
or edge labels.
|
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
INodeCursor nodes,
IEdgeCursor edges,
boolean includeNodeLabels,
boolean includeEdgeLabels,
boolean includeHalos)
Returns the bounding box of the nodes and edges accessible through the given cursors, optionally including node labels,
edge labels or
NodeHalo s. |
static Rectangle2D |
getBoundingBox(LayoutGraph graph,
Node node)
Returns the bounding box of the given node.
|
static ILabelLayoutFactory |
getLabelFactory(LayoutGraph graph)
Returns the
ILabelLayoutFactory for the given graph. |
static YPoint |
getLabelPlacement(IEdgeLabelLayoutModel model,
YDimension labelSize,
IEdgeLayout edgeLayout,
INodeLayout sourceLayout,
INodeLayout targetLayout,
Object param)
Returns the upper-left corner of the paraxial bounding box of the given edge label as encoded by the specified model
parameter.
|
static YPoint |
getLabelPlacement(INodeLabelLayoutModel model,
YDimension labelSize,
INodeLayout nodeLayout,
Object param)
Returns the upper-left corner of the paraxial bounding box of the given node label as encoded by the specified model
parameter.
|
static double |
getNodeDistance(LayoutGraph graph,
Node node1,
Node node2)
Returns the distance between the centers of the two given nodes.
|
static String |
getNodePositions(LayoutGraph graph)
Returns a
String representation of all node positions in the graph. |
static double |
getPathLength(LayoutGraph graph,
Edge edge)
Returns the length of the path of the given edge.
|
static boolean |
isEdgeOutsideNodes(IEdgeLayout edge,
INodeLayout source,
INodeLayout target,
double halo)
Checks whether or not the path of an edge is outside the bounding box of the source and target node, considering the
given halo.
|
static boolean |
isEdgeOutsideNodes(LayoutGraph graph,
Edge edge)
Checks whether or not the path of an edge is outside the bounding box of the source and target node.
|
static boolean |
isUsingOctilinearEdgeRoutes(LayoutGraph graph,
IDataProvider considerEdges)
Determines whether or not most of the edges of the graph are routed octilinear.
|
static boolean |
isUsingOrthogonalEdgeRoutes(LayoutGraph graph,
IDataProvider considerEdges)
Determines whether or not most of the edges of the graph are routed orthogonally.
|
static void |
moveEdge(LayoutGraph graph,
Edge edge,
double dx,
double dy)
Moves all control points of the given edge by the vector
(dx,dy) . |
static void |
moveEdges(LayoutGraph graph,
IEdgeCursor edges,
double dx,
double dy)
Moves the control points of all edges accessible through the given
IEdgeCursor by the vector (dx,dy) . |
static void |
moveNode(LayoutGraph graph,
Node node,
double dx,
double dy)
Moves the given node by the vector
(dx,dy) . |
static void |
moveNodes(LayoutGraph graph,
INodeCursor nodes,
double dx,
double dy)
Moves all nodes accessible through the given
INodeCursor by the vector (dx,dy) . |
static void |
moveSubgraph(LayoutGraph graph,
IEdgeCursor edges,
double dx,
double dy)
Moves the subgraph induced by the edges accessible through the given
IEdgeCursor by the vector (dx,dy) . |
static void |
moveSubgraph(LayoutGraph graph,
INodeCursor nodes,
double dx,
double dy)
Moves the subgraph induced by the nodes accessible through the given
INodeCursor by the vector (dx,dy) . |
static boolean |
pathIntersectsRect(LayoutGraph graph,
Edge edge,
Rectangle2D rect)
Checks whether or not the path of the given edge intersects the interior of a given rectangular area.
|
static void |
removeDuplicateBends(LayoutGraph graph)
Removes successive bends that have the same coordinates from all edges in the graph.
|
static void |
removeDuplicateBends(LayoutGraph graph,
Edge edge)
Removes successive bends that have the same coordinates from the given edge.
|
static void |
resetPath(LayoutGraph graph,
Edge edge)
Assigns a trivial path which has no control points to the specified edge.
|
static void |
resetPath(LayoutGraph graph,
Edge edge,
boolean resetPorts)
Assigns a trivial path which has no control points to the specified edge.
|
static void |
resetPaths(LayoutGraph graph)
Assigns a trivial path which has no control points to all edges in the specified graph.
|
static void |
resetPaths(LayoutGraph graph,
boolean resetPorts)
Assigns a trivial path which has no control points to all edges in the specified graph.
|
static void |
resetPorts(LayoutGraph graph)
Sets the ports of all edges in the graph to the center of the nodes.
|
static void |
reverseEdgeLayout(IEdgeLayout el)
Reverses the layout of an edge.
|
static void |
roundEdgeLayout(LayoutGraph graph,
Edge edge)
Rounds the locations of the control points and ports of the given edge to integer values.
|
static void |
roundLayout(LayoutGraph graph)
Rounds coordinates and sizes in the layout of an entire graph to integer values.
|
static void |
roundNodeLayout(LayoutGraph graph,
Node node)
Rounds the location and size of the given node to integer values.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge1,
Edge edge2,
double lineDistance)
Routes two edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge1,
Edge edge2,
double lineDistance,
boolean joinEnds)
Routes two edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge1,
Edge edge2,
double lineDistance,
boolean joinEnds,
double absJoinDist)
Routes two edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge1,
Edge edge2,
double lineDistance,
boolean joinEnds,
double absJoinDist,
double relJoinDist)
Routes two edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge,
EdgeList edges,
double lineDistance)
Routes a list of edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge,
EdgeList edges,
double lineDistance,
boolean adjustE1)
Routes a list of edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge,
EdgeList edges,
double lineDistance,
boolean adjustE1,
boolean joinEnds)
Routes a list of edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge,
EdgeList edges,
double lineDistance,
boolean adjustE1,
boolean joinEnds,
double absJoinDist)
Routes a list of edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeEdgesParallel(LayoutGraph graph,
Edge edge,
EdgeList edges,
double lineDistance,
boolean adjustE1,
boolean joinEnds,
double absJoinDist,
double relJoinDist)
Routes a list of edges which are incident to the same nodes in parallel, optionally joining the end points.
|
static void |
routeSelfLoop(LayoutGraph graph,
Edge edge)
Routes a self-loop.
|
public static final void alignNodeLayouts(LayoutGraph graph, NodeList nodes, Node referenceNode, boolean vertical, NodeAlignment mode)
For vertical arrangements, nodes are either top-aligned
,
center-aligned
, bottom-aligned
, or
vertically distributed
.
For horizontal arrangements, nodes are either left-aligned
,
center-aligned
, right-aligned
, or
horizontally distributed
.
In this context, distributed means that the specified nodes are placed in such a way that the projections of
their bounds onto the vertical or horizontal coordinate axis do not overlap. For example, after vertically distributing
nodes, (n1.y + n1.height) <= n2.y
for two consecutively placed nodes n1
and n2
.
graph
- the graph that contains the specified nodesnodes
- the subset of the specified graph's nodes that is arrangedreferenceNode
- if null
, the common coordinate for aligning the specified nodes is calculated as the the vertical minimum
(top-aligned), the vertical center, the vertical maximum (bottom-aligned), the horizontal minimum (left-aligned), the
horizontal center, or the horizontal maximum (right-aligned) of the bounds of the specified nodes; otherwise the
appropriate coordinate of the given reference node's bounds is used as common coordinate for aligning the specified
nodes. The reference node is ignored when distributing
nodes.vertical
- true
if nodes should be aligned (or distributed) according to their y-coordinates; otherwise nodes are aligned
(or distributed) according to their x-coordinates.mode
- one of the valid alignment modespublic static final YDimension arrangeRectangleGrid(Rectangle2D[] rectangles, Rectangle2D finalRect, double aspectRatio)
The aspect ratio must be greater than 0
.
IllegalArgumentException
- if the given aspect ratio is less than or equal to zerorectangles
- the rectangles whose coordinates will be modifiedfinalRect
- the exact dimension will be placed in this rectangleaspectRatio
- the preferred aspect ratio of the gridpublic static final int arrangeRectangleMultiRows(Rectangle2D[] rectangles, Rectangle2D finalRect, double preferredWidth, double preferredHeight, boolean compaction, MultiRowConstraint constraintMode)
The rectangles will be placed within this bound, arranged in rows, where each row may be split into more sub-rows. This
often leads to more compact results than provided by the procedure used in
arrangeRectangleRows(Rectangle2D[], Rectangle2D, double, RowAlignment)
. A row will be subdivided into more
rows, if two successive rectangles to be placed in the row could be placed stacked within this row without making the
row larger in height.
The preferred width and height should be greater than 0
, otherwise the nodes are not arranged.
rectangles
- the rectangles to arrange (coordinates will be assigned)finalRect
- the exact resulting dimension will be stored in this rectanglepreferredWidth
- the preferred width of the result rectanglepreferredHeight
- the preferred height of the result rectanglecompaction
- true
if the algorithm tries to always minimize the resulting dimension, whilst respecting the given constraints,
false
otherwiseconstraintMode
- the width or height constraints to considerarrangeRectangleMultiRows(Rectangle2D[], Rectangle2D, double, double, boolean, MultiRowConstraint, RowAlignment)
public static final int arrangeRectangleMultiRows(Rectangle2D[] rectangles, Rectangle2D finalRect, double preferredWidth, double preferredHeight, boolean compaction, MultiRowConstraint constraintMode, RowAlignment alignment)
The rectangles will be placed within this bound, arranged in rows, where each row may be split into more sub-rows. This
often leads to more compact results than provided by the procedure used in
arrangeRectangleRows(Rectangle2D[], Rectangle2D, double, RowAlignment)
. A row will be subdivided into more
rows, if two successive rectangles to be placed in the row could be placed stacked within this row without making the
row larger in height.
The preferred width and height should be greater than 0
, otherwise the nodes are not arranged.
rectangles
- the rectangles to arrange (coordinates will be assigned)finalRect
- the exact resulting dimension will be stored in this rectanglepreferredWidth
- the preferred width of the result rectanglepreferredHeight
- the preferred height of the result rectanglecompaction
- true
if the algorithm tries to always minimize the resulting dimension, whilst respecting the given constraints,
false
otherwiseconstraintMode
- the width or height constraints to consideralignment
- the alignment inside a rowarrangeRectangleMultiRows(Rectangle2D[], Rectangle2D, double, double, boolean, MultiRowConstraint, RowAlignment)
public static final int arrangeRectangleRows(Rectangle2D[] rectangles, Rectangle2D finalRect, double aspectRatio)
This is achieved by arranging the rectangles in rows.
The aspect ratio must be greater than 0
.
IllegalArgumentException
- if the aspect ratio is 0
or lessrectangles
- the rectangles whose coordinates will be modifiedfinalRect
- the exact dimension of the resulting rectangleaspectRatio
- the preferred aspect ratio of the resulting rectanglepublic static final int arrangeRectangleRows(Rectangle2D[] rectangles, Rectangle2D finalRect, double aspectRatio, RowAlignment alignment)
This is achieved by arranging the rectangles in rows.
The aspect ratio must be greater than 0
.
IllegalArgumentException
- if the aspect ratio is 0
or lessrectangles
- the rectangles whose coordinates will be modifiedfinalRect
- the exact dimension of the resulting rectangleaspectRatio
- the preferred aspect ratio of the resulting rectanglealignment
- one of the valid row alignmentspublic static final void assignReverseLayout(LayoutGraph graph, Edge edge1, Edge edge2)
graph
- the graph to which both edges belongedge1
- the edge which adopts the pointsedge2
- the templatepublic static final boolean autoFlipBox(YOrientedRectangle rect)
(
upY
> 0)
.
That means, it rotates the rectangle by 180
degrees without changing the rectangle's center.
rect
- the given rectangletrue
if the given rectangle was flipped, false
otherwisepublic static final void clipEdgeOnBounds(LayoutGraph graph, Edge edge)
On a clipped edge, the source and target port will be located at the border of the corresponding node.
graph
- the graph to which the edge belongsedge
- the edge to clippublic static final YPointPath clipEdgePathOnBounds(IEdgeLayout edge, INodeLayout source, INodeLayout target)
On the clipped edge, the source and target port will be located inside the node with an inset to the border of the corresponding node.
edge
- the clipped edgesource
- the source of the edgetarget
- the target of the edgepublic static final YPointPath clipEdgePathOnBounds(IEdgeLayout edge, INodeLayout source, INodeLayout target, double inset)
On the clipped edge, the source and target port will be located inside the node with an inset to the border of the corresponding node.
edge
- the clipped edgesource
- the source of the edgetarget
- the target of the edgeinset
- the inset of the nodepublic static final YPointPath clipEdgePathOnBounds(LayoutGraph graph, Edge edge)
On the clipped edge, the source and target port will be located at the border of the corresponding node.
graph
- the graph to which the edge belongsedge
- the clipped edgepublic static final void clipEdgesOnBounds(LayoutGraph graph)
On a clipped edge, the source and target port will be located at the border of the corresponding node.
graph
- the graphclipEdgeOnBounds(LayoutGraph, Edge)
public static final YPointPath clipPathOnBounds(YPointPath path, YRectangle sourceBox, YRectangle targetBox)
clipEdgePathOnBounds(LayoutGraph, Edge)
and
clipEdgePathOnBounds(IEdgeLayout, INodeLayout, INodeLayout, double)
, the path can explicitly be specified
and is not queried from a given graph and edge. Furthermore, this method does not consider any insets on the given
boxespath
- the path that will be clippedsourceBox
- the box of the source node that the given path should be clipped attargetBox
- the box of the target node that the given path should be clipped atpublic static final EdgeFlow determineEdgeFlowDirection(LayoutGraph graph, IDataProvider considerEdges)
The method only considers edges that are marked in the given IDataProvider
.
graph
- the underlying graphconsiderEdges
- the edges to considerpublic static final String edgeLayoutString(LayoutGraph graph, Edge edge)
String
representation of the path of the given edge.graph
- the graph to which the edge belongsedge
- the edgeString
that contains all control points of the edgepublic static final Rectangle2D getBoundingBox(LayoutGraph graph, Edge edge)
In this case, the bounding box is the smallest paraxial rectangle which contains the control points as well as the absolute coordinates of the source and target point of the edge.
graph
- the graph that contains the edgeedge
- the edgeLayoutGraph.getSourcePointAbs(Edge)
,
LayoutGraph.getTargetPointAbs(Edge)
,
LayoutGraph.getLayout(Edge)
public static final Rectangle2D getBoundingBox(LayoutGraph graph, IEdgeCursor edges)
In this case, the bounding box is the smallest paraxial rectangle which contains the control points as well as the absolute coordinates of the source and target points of all given edges.
graph
- the graph that contains the edgesedges
- the edges to include in the bounding boxLayoutGraph.getSourcePointAbs(Edge)
,
LayoutGraph.getTargetPointAbs(Edge)
,
LayoutGraph.getLayout(Edge)
public static final Rectangle2D getBoundingBox(LayoutGraph graph, INodeCursor nodes)
In this case, the bounding box is the smallest paraxial rectangle which contains the given nodes.
graph
- the graph that contains the nodesnodes
- the nodes to include in the bounding boxcom.yworks.yfiles.layout.LayoutGraph.getNodeLayout(java.lang.Object)
public static final Rectangle2D getBoundingBox(LayoutGraph graph, INodeCursor nodes, IEdgeCursor edges)
In this case, the bounding box is the smallest paraxial rectangle which contains the given nodes and the control points as well as the source and target points of all edges.
graph
- the graph that contains the nodes and edgesnodes
- the nodes to include in the bounding boxedges
- the edges to include in the bounding boxgetBoundingBox(LayoutGraph, IEdgeCursor)
,
getBoundingBox(LayoutGraph, INodeCursor)
public static final Rectangle2D getBoundingBox(LayoutGraph graph, INodeCursor nodes, IEdgeCursor edges, boolean includeLabels)
In this case, the bounding box is the smallest paraxial rectangle which contains the given nodes and the control points as well as the source and target points of all edges. If labels should be included, it also contains their boxes.
graph
- the graph that contains the given nodes and edgesnodes
- the nodes to include in the bounding boxedges
- the edges to include in the bounding boxincludeLabels
- true
if labels of nodes and edges should be included, false
otherwisegetBoundingBox(LayoutGraph, INodeCursor, IEdgeCursor, boolean, boolean, boolean)
public static Rectangle2D getBoundingBox(LayoutGraph graph, INodeCursor nodes, IEdgeCursor edges, boolean includeNodeLabels, boolean includeEdgeLabels)
In this case, the bounding box is the smallest paraxial rectangle which contains the given nodes and the control points as well as the source and target points of all edges. If node or edge labels should be included, it also contains their boxes.
graph
- the graph that contains the given nodes and edgesnodes
- the nodes to include in the bounding boxedges
- the edges to include in the bounding boxincludeNodeLabels
- true
if labels of nodes should be included, false
otherwiseincludeEdgeLabels
- true
if labels of edges should be included, false
otherwisepublic static final Rectangle2D getBoundingBox(LayoutGraph graph, INodeCursor nodes, IEdgeCursor edges, boolean includeNodeLabels, boolean includeEdgeLabels, boolean includeHalos)
NodeHalo
s.
In this case, the bounding box is the smallest paraxial rectangle which contains the given nodes and the control points
as well as the source and target points of all edges. If node or edge labels should be included, it also contains their
boxes. NodeHalo
s can also extend the bounding box if desired.
graph
- the graph that contains the given nodes and edgesnodes
- the nodes to include in the bounding boxedges
- the edges to include in the bounding boxincludeNodeLabels
- true
if labels of nodes should be included, false
otherwiseincludeEdgeLabels
- true
if labels of edges should be included, false
otherwiseincludeHalos
- true
if NodeHalo
s should be included, false
otherwisepublic static final Rectangle2D getBoundingBox(LayoutGraph graph, Node node)
In this case, the bounding box is the smallest paraxial rectangle which contains the given node. It is identical to the node's bounds.
graph
- the graph that contains the nodenode
- the nodecom.yworks.yfiles.layout.LayoutGraph.getNodeLayout(java.lang.Object)
public static final ILabelLayoutFactory getLabelFactory(LayoutGraph graph)
ILabelLayoutFactory
for the given graph.graph
- the graphpublic static final YPoint getLabelPlacement(IEdgeLabelLayoutModel model, YDimension labelSize, IEdgeLayout edgeLayout, INodeLayout sourceLayout, INodeLayout targetLayout, Object param)
The parameter describes the abstract position of the label within the specified model. The parameter must have been generated by that model.
model
- the IEdgeLabelLayoutModel
used for placing the labellabelSize
- the size of the label that should be placededgeLayout
- the layout of the edge to which the label belongssourceLayout
- the layout of the edge's source nodetargetLayout
- the layout of the edge's target nodeparam
- the model parameterIEdgeLabelLayoutModel.getLabelPlacement(YDimension, IEdgeLayout, INodeLayout, INodeLayout, Object)
,
YOrientedRectangle.getBoundingBox()
public static final YPoint getLabelPlacement(INodeLabelLayoutModel model, YDimension labelSize, INodeLayout nodeLayout, Object param)
The parameter describes the abstract position of the label within the specified model. The parameter must have been generated by that model.
model
- the INodeLabelLayoutModel
used for placing the labellabelSize
- the size of the labelnodeLayout
- the layout of the node to which the label belongsparam
- the model parameterINodeLabelLayoutModel.getLabelPlacement(YDimension, INodeLayout, Object)
,
YOrientedRectangle.getBoundingBox()
public static final double getNodeDistance(LayoutGraph graph, Node node1, Node node2)
graph
- the graph to which the nodes belongnode1
- the first nodenode2
- the second nodepublic static final String getNodePositions(LayoutGraph graph)
String
representation of all node positions in the graph.graph
- the graphString
containing all node locationsLayoutGraph.getLocation(Node)
public static final double getPathLength(LayoutGraph graph, Edge edge)
The path starts at the source point, traverses through all control points and ends at the target point.
graph
- the graph to which the edge belongsedge
- the edgepublic static final boolean isEdgeOutsideNodes(IEdgeLayout edge, INodeLayout source, INodeLayout target, double halo)
The edge is outside the nodes if its control points as well as the source and target point are not inside the nodes' bounding boxes.
The nodes can be enlarged by a halo to check if the edge keeps some distance to the nodes.
edge
- the edgesource
- the source of the edgetarget
- the target of the edgehalo
- the halo for the nodestrue
if the edge is outside the nodes, false
otherwisepublic static final boolean isEdgeOutsideNodes(LayoutGraph graph, Edge edge)
The edge is outside the nodes if its control points as well as the source and target point are not inside the nodes' bounding boxes.
graph
- the graph to which the edge belongsedge
- the edgetrue
if the edge is outside the nodes, false
otherwisepublic static final boolean isUsingOctilinearEdgeRoutes(LayoutGraph graph, IDataProvider considerEdges)
The method only considers edges marked in the given IDataProvider
.
true
for orthogonal layouts.graph
- the underlying graphconsiderEdges
- the edges to considertrue
if most of the edges in the graph are routed octilinear, false
otherwisepublic static final boolean isUsingOrthogonalEdgeRoutes(LayoutGraph graph, IDataProvider considerEdges)
The method only considers edges marked in the given IDataProvider
.
graph
- the underlying graphconsiderEdges
- the edges to considertrue
if most of the edges in the graph are routed orthogonally, false
otherwisepublic static final void moveEdge(LayoutGraph graph, Edge edge, double dx, double dy)
(dx,dy)
.graph
- the graphedge
- the edgedx
- the horizontal distance to movedy
- the vertical distance to movepublic static final void moveEdges(LayoutGraph graph, IEdgeCursor edges, double dx, double dy)
IEdgeCursor
by the vector (dx,dy)
.graph
- the graphedges
- the edges to be moveddx
- the horizontal distance to movedy
- the vertical distance to movepublic static final void moveNode(LayoutGraph graph, Node node, double dx, double dy)
(dx,dy)
.graph
- the graphnode
- the nodedx
- the horizontal distance to movedy
- the vertical distance to movepublic static final void moveNodes(LayoutGraph graph, INodeCursor nodes, double dx, double dy)
INodeCursor
by the vector (dx,dy)
.graph
- the graphnodes
- the nodes to be moveddx
- the horizontal distance to movedy
- the vertical distance to movepublic static final void moveSubgraph(LayoutGraph graph, IEdgeCursor edges, double dx, double dy)
IEdgeCursor
by the vector (dx,dy)
.graph
- the graph that contains the subgraphedges
- the edges that induce the subgraphdx
- the horizontal distance to movedy
- the vertical distance to movepublic static final void moveSubgraph(LayoutGraph graph, INodeCursor nodes, double dx, double dy)
INodeCursor
by the vector (dx,dy)
.graph
- the graph that contains the subgraphnodes
- the nodes that induce the subgraphdx
- the horizontal distance to movedy
- the vertical distance to movepublic static final boolean pathIntersectsRect(LayoutGraph graph, Edge edge, Rectangle2D rect)
graph
- the graph to which the edge belongsedge
- the edgerect
- the rectangular area to check for intersectiontrue
if the edge path intersects with the given rectangle, false
otherwisepublic static final void removeDuplicateBends(LayoutGraph graph)
graph
- the graphpublic static final void removeDuplicateBends(LayoutGraph graph, Edge edge)
graph
- the graphedge
- the edgepublic static final void resetPath(LayoutGraph graph, Edge edge)
graph
- the graphedge
- the edgepublic static final void resetPath(LayoutGraph graph, Edge edge, boolean resetPorts)
graph
- the graphedge
- the edgeresetPorts
- true
if the ports of the edge should be set to the center of the corresponding nodes, false
otherwisepublic static final void resetPaths(LayoutGraph graph)
graph
- the graphpublic static final void resetPaths(LayoutGraph graph, boolean resetPorts)
graph
- the graphresetPorts
- true
if the ports of the edges should be set to the center of the corresponding nodes, false
otherwisepublic static final void resetPorts(LayoutGraph graph)
graph
- the graphLayoutGraph.setSourcePointRel(Edge, YPoint)
,
LayoutGraph.setTargetPointRel(Edge, YPoint)
public static final void reverseEdgeLayout(IEdgeLayout el)
The order of the control points is reversed and source and target point are swapped.
el
- the layout information of an edgepublic static final void roundEdgeLayout(LayoutGraph graph, Edge edge)
graph
- the graph to which the edge belongsedge
- the edge whose values are roundedpublic static final void roundLayout(LayoutGraph graph)
graph
- the graphroundNodeLayout(LayoutGraph, Node)
,
roundEdgeLayout(LayoutGraph, Edge)
public static final void roundNodeLayout(LayoutGraph graph, Node node)
graph
- the graph to which the node belongsnode
- the node whose values are roundedpublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge1, Edge edge2, double lineDistance)
The second edge gets a path that is parallel to the path of the first (leading) edge.
graph
- the graphedge1
- the leading edgeedge2
- the edge to be adjustedlineDistance
- the distance between the two edgespublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge1, Edge edge2, double lineDistance, boolean joinEnds)
The second edge gets a path that is parallel to the path of the first (leading) edge.
graph
- the graphedge1
- the leading edgeedge2
- the edge to be adjustedlineDistance
- the distance between the two edgesjoinEnds
- true
if the edges should share their end points (the ones of the leading edge), false
otherwisepublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge1, Edge edge2, double lineDistance, boolean joinEnds, double absJoinDist)
The second edge gets a path that is parallel to the path of the first (leading) edge.
graph
- the graphedge1
- the leading edgeedge2
- the edge to be adjustedlineDistance
- the distance between the two edgesjoinEnds
- true
if the edges should share their end points (the ones of the leading edge), false
otherwiseabsJoinDist
- the absolute distance between the end points and the beginning of the parallel segment routing if the ends are joinedpublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge1, Edge edge2, double lineDistance, boolean joinEnds, double absJoinDist, double relJoinDist)
The second edge gets a path that is parallel to the path of the first (leading) edge.
graph
- the graphedge1
- the leading edgeedge2
- the edge to be adjustedlineDistance
- the distance between the two edgesjoinEnds
- true
if the edges should share their end points (the ones of the leading edge), false
otherwiseabsJoinDist
- the absolute distance between the end points and the beginning of the parallel segment routing if the ends are joinedrelJoinDist
- the relative distance, measured relative to the length of the first/last segments if the ends are joinedpublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge, EdgeList edges, double lineDistance)
All edges get a path that is parallel to the path of the first (leading) edge.
The position of the leading edge may be adjusted if there is an odd number of parallel edges. It will be moved from the center to achieve a more symmetric port assignment.
graph
- the graphedge
- the leading edgeedges
- the list of edges that will be aligned with the leading edgelineDistance
- the distance between two edgespublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge, EdgeList edges, double lineDistance, boolean adjustE1)
All edges get a path that is parallel to the path of the first (leading) edge.
The position of the leading edge may be adjusted if there is an odd number of parallel edges. It will be moved from the center to achieve a more symmetric port assignment.
graph
- the graphedge
- the leading edgeedges
- the list of edges that will be aligned with the leading edgelineDistance
- the distance between two edgesadjustE1
- true
if the leading edge should be adjusted if the size of list is odd, false
otherwisepublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge, EdgeList edges, double lineDistance, boolean adjustE1, boolean joinEnds)
All edges get a path that is parallel to the path of the first (leading) edge.
The position of the leading edge may be adjusted if there is an odd number of parallel edges. It will be moved from the center to achieve a more symmetric port assignment.
graph
- the graphedge
- the leading edgeedges
- the list of edges that will be aligned with the leading edgelineDistance
- the distance between two edgesadjustE1
- true
if the leading edge should be adjusted if the size of list is odd, false
otherwisejoinEnds
- true
if the edges should share their end points (the ones of the leading edge), false
otherwisepublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge, EdgeList edges, double lineDistance, boolean adjustE1, boolean joinEnds, double absJoinDist)
All edges get a path that is parallel to the path of the first (leading) edge.
The position of the leading edge may be adjusted if there is an odd number of parallel edges. It will be moved from the center to achieve a more symmetric port assignment.
graph
- the graphedge
- the leading edgeedges
- the list of edges that will be aligned with the leading edgelineDistance
- the distance between two edgesadjustE1
- true
if the leading edge should be adjusted if the size of list is odd, false
otherwisejoinEnds
- true
if the edges should share their end points (the ones of the leading edge), false
otherwiseabsJoinDist
- the absolute distance between the end points and the beginning of the parallel segment routing if the ends are joinedpublic static final void routeEdgesParallel(LayoutGraph graph, Edge edge, EdgeList edges, double lineDistance, boolean adjustE1, boolean joinEnds, double absJoinDist, double relJoinDist)
All edges get a path that is parallel to the path of the first (leading) edge.
The position of the leading edge may be adjusted if there is an odd number of parallel edges. It will be moved from the center to achieve a more symmetric port assignment.
graph
- the graphedge
- the leading edgeedges
- the list of edges that will be aligned with the leading edgelineDistance
- the distance between two edgesadjustE1
- true
if the leading edge should be adjusted if the size of list is odd, false
otherwisejoinEnds
- true
if the edges should share their end points (the ones of the leading edge), false
otherwiseabsJoinDist
- the absolute distance between the end points and the beginning of the parallel segment routing if the ends are joinedrelJoinDist
- the relative distance, measured relative to the length of the first/last segments if the ends are joinedpublic static final void routeSelfLoop(LayoutGraph graph, Edge edge)
For a self-loop edge, source and target are identical. The path of the self-loop will start at the top of the node, go around the upper-left corner and end at the left side of the node.
graph
- the graph to which the edge belongsedge
- the self-loop