|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.LayoutTool
public class LayoutTool
This class is a container for several helper and utility functions for the LayoutGraph class.
LayoutGraph
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 |
---|
public static final int LEADING
arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int)
.
Rectangles in one row will be aligned with the leading edge.
public static final int TRAILING
arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int)
.
Rectangles in one row will be aligned to the trailing edge.
public static final int JUSTIFIED
arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int)
.
Rectangles in one row will be justified in the row.
public static final int CENTER
arrangeRectangleRows(java.awt.geom.Rectangle2D[], java.awt.geom.Rectangle2D, double, int)
.
Rectangles in one row will be centered on the row.
public static final byte FLOW_UP
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
.
This value specifies that the flow direction of most edges is up.
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
,
Constant Field Valuespublic static final byte FLOW_DOWN
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
.
This value specifies that the flow direction of most edges is down.
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
,
Constant Field Valuespublic static final byte FLOW_LEFT
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
.
This value specifies that the flow direction of most edges is left.
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
,
Constant Field Valuespublic static final byte FLOW_RIGHT
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
.
This value specifies that the flow direction of most edges is right.
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
,
Constant Field Valuespublic static final byte FLOW_NONE
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
.
This value specifies that there is no main flow direction.
determineEdgeFlowDirection(LayoutGraph, y.base.DataProvider)
,
Constant Field ValuesMethod Detail |
---|
public static byte determineEdgeFlowDirection(LayoutGraph graph, DataProvider considerEdges)
graph
- the underlying graph.considerEdges
- the edges to consider.
FLOW_DOWN
, FLOW_LEFT
, FLOW_NONE
, FLOW_RIGHT
or FLOW_UP
.public static boolean isUsingOrthogonalEdgeRoutes(LayoutGraph graph, DataProvider considerEdges)
graph
- the underlying graph.considerEdges
- the edges to consider.
public static boolean isUsingOctilinearEdgeRoutes(LayoutGraph graph, DataProvider considerEdges)
Note: for orthogonal layouts this method returns true.
graph
- the underlying graph.considerEdges
- the edges to consider.
public static double getNodeDistance(LayoutGraph graph, Node s, Node t)
public static double getPathLength(LayoutGraph graph, Edge e)
public static void reverseEdgeLayout(EdgeLayout el)
public static void resetPaths(LayoutGraph gd)
resetPaths(gd, true)
gd
- a graph diagram.resetPaths(LayoutGraph, boolean)
public static void resetPaths(LayoutGraph gd, boolean resetPorts)
gd
- a graph diagram.resetPorts
- if true
, the ports of the edges are set
to the center of the corresponding nodes.public static void resetPath(LayoutGraph gd, Edge edge)
resetPath(gd, edge, true)
gd
- a graph diagram.edge
- an edge in graph.resetPath(LayoutGraph, y.base.Edge, boolean)
public static void resetPath(LayoutGraph gd, Edge edge, boolean resetPorts)
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.public static void removeDuplicateBends(LayoutGraph gd)
gd
- a graph diagram.public static void removeDuplicateBends(LayoutGraph gd, Edge edge)
gd
- a graph diagram.edge
- the edge.public static void moveEdge(LayoutGraph g, Edge edge, double dx, double dy)
(dx,dy)
.
public static void moveEdges(LayoutGraph g, EdgeCursor edges, double dx, double dy)
(dx,dy)
.
public static void moveNode(LayoutGraph g, Node node, double dx, double dy)
(dx,dy)
.
public static void moveNodes(LayoutGraph g, NodeCursor nodes, double dx, double dy)
(dx,dy)
.
public static void moveSubgraph(LayoutGraph g, EdgeCursor edges, double dx, double dy)
(dx,dy)
.
public static void moveSubgraph(LayoutGraph g, NodeCursor nodes, double dx, double dy)
(dx,dy)
.
public static Rectangle2D getBoundingBox(LayoutGraph graph, NodeCursor nc, EdgeCursor ec)
public static Rectangle2D getBoundingBox(LayoutGraph graph, Node n)
public static Rectangle2D getBoundingBox(LayoutGraph graph, NodeCursor nc)
public static Rectangle2D getBoundingBox(LayoutGraph graph, Edge e)
public static Rectangle2D getBoundingBox(LayoutGraph graph, EdgeCursor ec)
public static Rectangle2D getBoundingBox(LayoutGraph graph, NodeCursor nc, EdgeCursor ec, boolean includeLabels)
public static YPoint getLabelPlacement(NodeLabelModel model, YDimension labelSize, NodeLayout nodeLayout, Object param)
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.
NodeLabelModel.getLabelPlacement(y.geom.YDimension, NodeLayout, Object)
public static YPoint getLabelPlacement(EdgeLabelModel model, YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout, Object param)
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.
EdgeLabelModel.getLabelPlacement(y.geom.YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
public static void resetPorts(LayoutGraph gd)
gd
- a graph diagram.public static YPointPath getEdgeClippedOnBB(EdgeLayout edge, NodeLayout sourceNode, NodeLayout targetNode)
public static YPointPath getEdgeClippedOnBB(LayoutGraph gd, Edge edge)
public static YPointPath getEdgeClippedOnBB(EdgeLayout edge, NodeLayout sourceNode, NodeLayout targetNode, double inset)
public static boolean isEdgeOutsideNodes(LayoutGraph gd, Edge edge)
public static boolean isEdgeOutsideNodes(EdgeLayout edge, NodeLayout sourceNode, NodeLayout targetNode, double inset)
public static void clipEdgesOnBB(LayoutGraph gd)
public static void clipEdgeOnBB(LayoutGraph gd, Edge e)
public static String edgeLayoutString(LayoutGraph gd, Edge edge)
public static void roundNodeLayout(LayoutGraph gd, Node node)
public static void roundEdgeLayout(LayoutGraph gd, Edge edge)
public static void roundLayout(LayoutGraph gd)
public static void routeEdgesParallel(LayoutGraph gd, Edge e1, Edge e2, double lineDistance)
routeEdgesParallel(LayoutGraph, Edge, Edge, double, boolean, double, double)
public static void routeEdgesParallel(LayoutGraph gd, Edge e1, Edge e2, double lineDistance, boolean joinEnds, double absJoinDist, double relJoinDist)
gd
- the graphe1
- the leading edgee2
- the edge to be adjusted (may be e1)lineDistance
- the distance between the two edgesjoinEnds
- whether the end points should all be set to the end points of e1absJoinDist
- the absolute distance between the end points and the beginning to
the parallel segment routingrelJoinDist
- the relative distance, measured relative to the length of the
first/last segmentspublic static void routeEdgesParallel(LayoutGraph gd, Edge e1, EdgeList list, double lineDistance)
.routeEdgesParallel(gd, e1, list, lineDistance, false, false, 0.0d, 0.0d)
gd
- the graphe1
- the leading edgelist
- the list of edges that will be aligned to e1lineDistance
- the distance between two edgesrouteEdgesParallel(LayoutGraph, Edge, EdgeList, double, boolean, boolean, double, double)
public static void routeEdgesParallel(LayoutGraph gd, Edge e1, EdgeList list, double lineDistance, boolean adjustE1, boolean joinEnds, double absJoinDist, double relJoinDist)
gd
- the graphe1
- the leading edgelist
- the list of edges that will be aligned to e1lineDistance
- the distance between two edgesadjustE1
- whether e1 should be adjusted if the size of list is oddjoinEnds
- whether the end points should all be set to the end points of e1absJoinDist
- the absolute distance between the end points and the beginning to
the parallel segment routingrelJoinDist
- the relative distance, measured relative to the length of the
first/last segmentspublic static void routeSelfLoop(LayoutGraph gd, Edge e)
e
- An edge with e.source.equals(e.target)
.public static void assignReverseLayout(LayoutGraph graph, Edge e1, Edge e2)
e1
- the edge for which the points are set.e2
- the template.public static String getNodePositions(LayoutGraph gd)
public static void initDiagram(LayoutGraph gd)
public static int arrangeRectangleRows(Rectangle2D[] rects, Rectangle2D finalRect, double viewRatio)
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.
rects
- the rectangles whose coordinates will be modifiedfinalRect
- the exact dimension will be placed in this rectangleviewRatio
- the preferred ratio of the resulting bounds
public static Dimension arrangeRectangleGrid(Rectangle2D[] rects, Rectangle2D finalRect, double viewRatio)
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.
rects
- the rectangles whose, coordinates will be modifiedfinalRect
- the exact dimension will be placed in this rectangleviewRatio
- the preferred ratio of the grid
public static int arrangeRectangleRows(Rectangle2D[] rects, Rectangle2D finalRect, double viewRatio, int alignment)
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.
alignment
- determines the alignment policy for rows, that are not
completely filledrects
- the rectangles whose coordinates will be modifiedfinalRect
- the exact dimension will be placed in this rectangleviewRatio
- the preferred ratio of the resulting bounds
public static boolean pathIntersectsRect(LayoutGraph graph, Edge e, Rectangle2D rect)
public static void applyGraphLayout(LayoutGraph graph, GraphLayout gl)
public static void alignNodeLayouts(LayoutGraph g, NodeList nodes, Node referenceNode, boolean vertical, byte mode)
public static boolean autoFlipBox(OrientedRectangle rect)
rect
- the given rectangle.
true
if the given rectangle was flipped and false
otherwise.
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |