Search this API

y.layout
Class LayoutGraph

java.lang.Object
  extended by y.base.Graph
      extended by y.layout.LayoutGraph
All Implemented Interfaces:
GraphInterface, GraphLayout
Direct Known Subclasses:
CopiedLayoutGraph, DefaultLayoutGraph, Graph2D

public abstract class LayoutGraph
extends Graph
implements GraphLayout

A LayoutGraph is a Graph with attached layout information that basically represents a drawing of a graph.

It provides access to the layout information for nodes, edges and labels. This layout information consists of coordinates for the elements.

Layout algorithms work on LayoutGraphs and arrange their nodes and edges.

 

Field Summary
 
Fields inherited from class y.base.Graph
AFTER, BEFORE
 
Constructor Summary
LayoutGraph()
          Creates a new, empty LayoutGraph with default settings.
LayoutGraph(LayoutGraph subgraph)
          Creates a new LayoutGraph which is a copy of the given subgraph.
LayoutGraph(LayoutGraph graph, YCursor nodeSubset)
          Creates a new LayoutGraph which is a copy of the given subgraph.
 
Method Summary
protected abstract  GraphCopier.CopyFactory createGraphCopyFactory()
          Creates a GraphCopier.CopyFactory that can be used by GraphCopier to create a copy of a LayoutGraph instance.
protected abstract  LabelLayoutFactory createLabelFactory()
          Creates a new LabelLayoutFactory for this LayoutGraph that can be used for copying layout information of labels.
 Rectangle getBoundingBox()
          Returns the bounding box of the diagram represented by this LayoutGraph.
 YPoint getCenter(Node node)
          Returns the center coordinates of the given node.
 double getCenterX(Node node)
          Returns the x-coordinate of the given node's center.
 double getCenterY(Node node)
          Returns the y-coordinate of the given node's center.
 EdgeLabelLayout[] getEdgeLabelLayout(Object edge)
          Returns the layout information for all labels associated with the given edge.
 EdgeLayout getEdgeLayout(Object edge)
          Returns the layout information for the given edge.
 EdgeList getEdgeList()
          Returns a list of all edges in the graph.
abstract  Edge getFeature(EdgeLabelLayout labelLayout)
          Returns the edge to which the given EdgeLabelLayout belongs.
abstract  Node getFeature(NodeLabelLayout labelLayout)
          Returns the node to which the given NodeLabelLayout belongs.
 double getHeight(Node node)
          Returns the height of the given node.
abstract  EdgeLabelLayout[] getLabelLayout(Edge edge)
          Returns the layout information for all labels associated with the given edge.
abstract  NodeLabelLayout[] getLabelLayout(Node node)
          Returns the layout information for all labels associated with the given node.
abstract  EdgeLayout getLayout(Edge edge)
          Returns the layout information for the given edge.
abstract  NodeLayout getLayout(Node node)
          Returns the layout information for the given node.
 YPoint getLocation(Node node)
          Returns the coordinates of the given node's upper-left corner.
 NodeLabelLayout[] getNodeLabelLayout(Object node)
          Returns the layout information for all labels associated with the given node.
 NodeLayout getNodeLayout(Object node)
          Returns the layout information for the given node.
 YPointPath getPath(Edge edge)
          Returns the path of an edge, including the ports.
 YList getPathList(Edge edge)
          Returns the path of an edge, including the ports.
 YList getPointList(Edge edge)
          Returns the control points of an edge.
 YPointPath getPoints(Edge edge)
          Returns the control points of an edge.
 YRectangle getRectangle(Node node)
          Returns the rectangle describing the bounding box of the given node.
 YDimension getSize(Node node)
          Returns the size of the given node.
 YPoint getSourcePointAbs(Edge edge)
          Returns the absolute coordinates of the source point of the given edge.
 YPoint getSourcePointRel(Edge edge)
          Returns the relative coordinates of the source point of the given edge.
 YPoint getTargetPointAbs(Edge edge)
          Returns the absolute coordinates of the target point of the given edge.
 YPoint getTargetPointRel(Edge edge)
          Returns the relative coordinates of the target point of the given edge.
 double getWidth(Node node)
          Returns the width of the given node.
 double getX(Node node)
          Returns the x-coordinate of the given node's upper-left corner.
 double getY(Node node)
          Returns the y-coordinate of the given node's upper-left corner.
 void moveBy(Node node, double dx, double dy)
          Moves the upper-left corner of a node by a given vector.
 void setCenter(Node node, double x, double y)
          Specifies the center coordinates of the given node.
 void setCenter(Node node, YPoint position)
          Specifies the center coordinates of the given node.
 void setEndPointsAbs(Edge edge, YPoint source, YPoint target)
          Specifies the two end points of the given edge in absolute coordinates.
 void setLocation(Node node, double x, double y)
          Specifies the coordinates of the upper-left corner of the given node.
 void setLocation(Node node, YPoint position)
          Specifies the coordinates of the upper-left corner of the given node.
 void setPath(Edge edge, YList path)
          Sets the path of the given edge.
 void setPath(Edge edge, YPointPath path)
          Sets the path of the given edge.
 void setPoints(Edge edge, YList points)
          Sets the control points of the given edge.
 void setPoints(Edge edge, YPointPath points)
          Sets the control points of the given edge.
 void setSize(Node node, double width, double height)
          Specifies the width and height of the given node.
 void setSize(Node node, YDimension size)
          Specifies the size of the given node.
 void setSourcePointAbs(Edge edge, YPoint point)
          Specifies the absolute coordinates of the source point of the given edge.
 void setSourcePointRel(Edge edge, YPoint point)
          Specifies the relative coordinates of the source point of the given edge.
 void setTargetPointAbs(Edge edge, YPoint point)
          Specifies the absolute coordinates of the target point of the given edge.
 void setTargetPointRel(Edge edge, YPoint point)
          Specifies the relative coordinates of the target point of the given edge.
 
Methods inherited from class y.base.Graph
addDataProvider, addGraphListener, changeEdge, changeEdge, changeEdge, clear, contains, contains, containsEdge, createCopy, createEdge, createEdge, createEdgeMap, createGraph, createNode, createNodeMap, disposeEdgeMap, disposeNodeMap, E, edgeCount, edgeObjects, edges, fireGraphEvent, firePostEvent, firePostEvent, firePreEvent, firePreEvent, firstEdge, firstNode, firstOutEdge, getDataProvider, getDataProviderKeys, getEdgeArray, getGraphCopyFactory, getGraphListeners, getNodeArray, getRegisteredEdgeMaps, getRegisteredNodeMaps, getSource, getTarget, hasListeners, hide, hide, isEmpty, lastEdge, lastNode, moveSubGraph, moveToFirst, moveToFirst, moveToLast, moveToLast, N, nodeCount, nodeObjects, nodes, printNodeSlotSize, reInsertEdge, reInsertNode, removeDataProvider, removeEdge, removeGraphListener, removeNode, reverseEdge, setGraphCopyFactory, sortEdges, sortEdges, sortNodes, toString, unhide, unhide
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayoutGraph

public LayoutGraph()
Creates a new, empty LayoutGraph with default settings.


LayoutGraph

public LayoutGraph(LayoutGraph subgraph)
Creates a new LayoutGraph which is a copy of the given subgraph.

Parameters:
subgraph - the original subgraph

LayoutGraph

public LayoutGraph(LayoutGraph graph,
                   YCursor nodeSubset)
Creates a new LayoutGraph which is a copy of the given subgraph.

Parameters:
graph - the original graph
nodeSubset - the nodes that induce the subgraph
Method Detail

createGraphCopyFactory

protected abstract GraphCopier.CopyFactory createGraphCopyFactory()
Creates a GraphCopier.CopyFactory that can be used by GraphCopier to create a copy of a LayoutGraph instance.

Overrides:
createGraphCopyFactory in class Graph
Returns:
the factory that copies all elements of the graph

createLabelFactory

protected abstract LabelLayoutFactory createLabelFactory()
Creates a new LabelLayoutFactory for this LayoutGraph that can be used for copying layout information of labels.

Returns:
the new LabelLayoutFactory

getLayout

public abstract NodeLayout getLayout(Node node)
Returns the layout information for the given node.

The layout information consists of the location and size of the node.

Parameters:
node - the node
Returns:
the layout information for the node

getLayout

public abstract EdgeLayout getLayout(Edge edge)
Returns the layout information for the given edge.

The layout information consists of the locations of the control points and end points of the edge.

Parameters:
edge - the edge
Returns:
the layout information for the edge

getLabelLayout

public abstract NodeLabelLayout[] getLabelLayout(Node node)
Returns the layout information for all labels associated with the given node.

The layout information consists of the location, size and orientation of the label.

Parameters:
node - the node
Returns:
the layout information for the node's labels

getLabelLayout

public abstract EdgeLabelLayout[] getLabelLayout(Edge edge)
Returns the layout information for all labels associated with the given edge.

The layout information consists of the location, size and orientation of the label.

Parameters:
edge - the edge
Returns:
the layout information for the edge's labels

getFeature

public abstract Node getFeature(NodeLabelLayout labelLayout)
Returns the node to which the given NodeLabelLayout belongs.

Parameters:
labelLayout - the label's layout information
Returns:
the node that owns the label

getFeature

public abstract Edge getFeature(EdgeLabelLayout labelLayout)
Returns the edge to which the given EdgeLabelLayout belongs.

Parameters:
labelLayout - the label's layout information
Returns:
the edge that owns the label

getNodeLayout

public NodeLayout getNodeLayout(Object node)
Returns the layout information for the given node.

The layout information consists of location and size of the node.

Specified by:
getNodeLayout in interface GraphLayout
Parameters:
node - the node
Returns:
the layout information for the node

getEdgeLayout

public EdgeLayout getEdgeLayout(Object edge)
Returns the layout information for the given edge.

The layout information consists of the control points as well as the port locations of the edge.

Specified by:
getEdgeLayout in interface GraphLayout
Parameters:
edge - the edge
Returns:
the layout information for the edge

getNodeLabelLayout

public NodeLabelLayout[] getNodeLabelLayout(Object node)
Returns the layout information for all labels associated with the given node.

The layout information consists of location, size and orientation of the label.

Specified by:
getNodeLabelLayout in interface GraphLayout
Parameters:
node - the node
Returns:
the layout information for the node's labels

getEdgeLabelLayout

public EdgeLabelLayout[] getEdgeLabelLayout(Object edge)
Returns the layout information for all labels associated with the given edge.

The layout information consists of location, size and orientation of the label.

Specified by:
getEdgeLabelLayout in interface GraphLayout
Parameters:
edge - the edge
Returns:
the layout information for the edge's labels

getCenterX

public double getCenterX(Node node)
Returns the x-coordinate of the given node's center.

Parameters:
node - the node
Returns:
the x-value of the node's center coordinate
See Also:
NodeLayout

getCenterY

public double getCenterY(Node node)
Returns the y-coordinate of the given node's center.

Parameters:
node - the node
Returns:
the y-value of the node's center coordinate
See Also:
NodeLayout

getCenter

public YPoint getCenter(Node node)
Returns the center coordinates of the given node.

Parameters:
node - the node
Returns:
the location of the node's center
See Also:
NodeLayout, setCenter(Node, double, double)

getX

public double getX(Node node)
Returns the x-coordinate of the given node's upper-left corner.

Parameters:
node - the node
Returns:
the x-value of the node's upper-left corner
See Also:
NodeLayout.getX()

getY

public double getY(Node node)
Returns the y-coordinate of the given node's upper-left corner.

Parameters:
node - the node
Returns:
the y-value of the node's upper-left corner
See Also:
NodeLayout.getY()

getLocation

public YPoint getLocation(Node node)
Returns the coordinates of the given node's upper-left corner.

Parameters:
node - the node
Returns:
the location of the node's upper-left corner
See Also:
NodeLayout.getX(), NodeLayout.getY()

getWidth

public double getWidth(Node node)
Returns the width of the given node.

Parameters:
node - the node
Returns:
the width of the node
See Also:
NodeLayout.getWidth()

getHeight

public double getHeight(Node node)
Returns the height of the given node.

Parameters:
node - the node
Returns:
the height of the node
See Also:
NodeLayout.getHeight()

getSize

public YDimension getSize(Node node)
Returns the size of the given node.

Parameters:
node - the node
Returns:
the size of the node
See Also:
NodeLayout.getWidth(), NodeLayout.getHeight()

getRectangle

public YRectangle getRectangle(Node node)
Returns the rectangle describing the bounding box of the given node.

Parameters:
node - the node
Returns:
the bounds of the node
See Also:
getLocation(Node), getSize(Node)

setCenter

public void setCenter(Node node,
                      YPoint position)
Specifies the center coordinates of the given node.

Parameters:
node - the node
position - the new location of the node's center
See Also:
NodeLayout, setCenter(Node, double, double)

setCenter

public void setCenter(Node node,
                      double x,
                      double y)
Specifies the center coordinates of the given node.

Parameters:
node - the node
x - the new x-coordinate of the node's center
y - the new y-coordinate of the node's center
See Also:
NodeLayout

setSize

public void setSize(Node node,
                    double width,
                    double height)
Specifies the width and height of the given node.

Parameters:
node - the node
width - the new width of the node
height - the new height of the node
See Also:
NodeLayout.setSize(double, double)

setSize

public void setSize(Node node,
                    YDimension size)
Specifies the size of the given node.

Parameters:
node - the node
size - the new size of the node
See Also:
setSize(Node, double, double), NodeLayout.setSize(double, double)

setLocation

public void setLocation(Node node,
                        double x,
                        double y)
Specifies the coordinates of the upper-left corner of the given node.

Parameters:
node - the node
x - the new x-coordinate of the upper-left corner
y - the new y-coordinate of the upper-left corner
See Also:
NodeLayout.setLocation(double, double)

setLocation

public void setLocation(Node node,
                        YPoint position)
Specifies the coordinates of the upper-left corner of the given node.

Parameters:
node - the node
position - the new location of the upper-left corner
See Also:
NodeLayout.setLocation(double, double), setLocation(Node, double, double)

moveBy

public void moveBy(Node node,
                   double dx,
                   double dy)
Moves the upper-left corner of a node by a given vector.

Parameters:
node - the node
dx - the x-component of the vector
dy - the y-component of the vector

getPoints

public YPointPath getPoints(Edge edge)
Returns the control points of an edge.

 
The source and target port are not included in this path.
Parameters:
edge - the edge
Returns:
a YPointPath representing the sequence of control points of the edge
See Also:
EdgeLayout

getPointList

public YList getPointList(Edge edge)
Returns the control points of an edge.

 
The source and target port are not included in this path.
Parameters:
edge - the edge
Returns:
a list of YPoints representing the sequence of control points of the edge
See Also:
EdgeLayout

getPath

public YPointPath getPath(Edge edge)
Returns the path of an edge, including the ports. The path of an edge is the position of the source port, followed by the positions of the bends, followed by the position of the target port.

Parameters:
edge - the edge
Returns:
the path of the given edge

getPathList

public YList getPathList(Edge edge)
Returns the path of an edge, including the ports. The path of an edge is the position of the source port, followed by the positions of the bends, followed by the position of the target port.

Parameters:
edge - the edge
Returns:
a list of YPoints representing the path of the given edge

setPath

public void setPath(Edge edge,
                    YPointPath path)
Sets the path of the given edge. The path of an edge is the position of the source port, followed by the positions of the bends, followed by the position of the target port.

Both source and target port are expected to be given in absolute coordinates.

 
Previously specified coordinates will be cleared.
Precondition:
The length of the path must be at least 2.
Parameters:
edge - an edge in the graph
path - the new path sequence of the edge

setPath

public void setPath(Edge edge,
                    YList path)
Sets the path of the given edge. The path of an edge is the position of the source port, followed by the positions of the bends, followed by the position of the target port.

Both source and target port are expected to be given in absolute coordinates.

 
Previously specified coordinates will be cleared.
Precondition:
The length of the path must be at least 2.
Parameters:
edge - an edge in the graph
path - the list of YPoints representing the new path sequence of the edge

setPoints

public void setPoints(Edge edge,
                      YPointPath points)
Sets the control points of the given edge.

The source and target points of the edge will not be modified.

 
Previously specified points will be cleared.
Parameters:
edge - an edge in the graph
points - the new sequence of control points

setPoints

public void setPoints(Edge edge,
                      YList points)
Sets the control points of the given edge.

The source and target points of the edge will not be modified.

 
Previously specified points will be cleared.
Parameters:
edge - an edge in the graph
points - the list of YPoints representing the new sequence of control points

setEndPointsAbs

public void setEndPointsAbs(Edge edge,
                            YPoint source,
                            YPoint target)
Specifies the two end points of the given edge in absolute coordinates.

Parameters:
edge - the edge
source - the port on the source side of the edge
target - the port on the target side of the edge
See Also:
setSourcePointAbs(Edge, YPoint), setTargetPointAbs(Edge, YPoint)

getSourcePointRel

public YPoint getSourcePointRel(Edge edge)
Returns the relative coordinates of the source point of the given edge.

The coordinates are interpreted relative to the center of the source node.

Parameters:
edge - the edge
Returns:
the relative source point coordinates of the edge
See Also:
EdgeLayout.getSourcePoint()

getTargetPointRel

public YPoint getTargetPointRel(Edge edge)
Returns the relative coordinates of the target point of the given edge.

The coordinates are interpreted relative to the center of the target node.

Parameters:
edge - the edge
Returns:
the relative target point coordinates of the edge
See Also:
EdgeLayout.getTargetPoint()

setSourcePointRel

public void setSourcePointRel(Edge edge,
                              YPoint point)
Specifies the relative coordinates of the source point of the given edge.

The coordinates are interpreted relative to the center of the source node.

Parameters:
edge - the edge
point - the new relative source point coordinates of the edge
See Also:
EdgeLayout.setSourcePoint(YPoint)

setTargetPointRel

public void setTargetPointRel(Edge edge,
                              YPoint point)
Specifies the relative coordinates of the target point of the given edge.

The coordinates are interpreted relative to the center of the target node.

Parameters:
edge - the edge
point - the new relative target point coordinates of the edge
See Also:
EdgeLayout.setTargetPoint(YPoint)

getSourcePointAbs

public YPoint getSourcePointAbs(Edge edge)
Returns the absolute coordinates of the source point of the given edge.

Parameters:
edge - the edge
Returns:
the absolute source point coordinates of the edge

getTargetPointAbs

public YPoint getTargetPointAbs(Edge edge)
Returns the absolute coordinates of the target point of the given edge.

Parameters:
edge - the edge
Returns:
the absolute target point coordinates of the edge

setSourcePointAbs

public void setSourcePointAbs(Edge edge,
                              YPoint point)
Specifies the absolute coordinates of the source point of the given edge.

Parameters:
edge - the edge
point - the new absolute source point coordinates of the edge

setTargetPointAbs

public void setTargetPointAbs(Edge edge,
                              YPoint point)
Specifies the absolute coordinates of the target point of the given edge.

Parameters:
edge - the edge
point - the new absolute target point coordinates of the edge

getEdgeList

public EdgeList getEdgeList()
Returns a list of all edges in the graph.

Returns:
the edges contained in the graph

getBoundingBox

public Rectangle getBoundingBox()
Returns the bounding box of the diagram represented by this LayoutGraph. This is the smallest rectangle containing the entire graph. If the graph does not contain any nodes (and therefore no edges either), the bounding box will have negative width and/or height.

Specified by:
getBoundingBox in interface GraphLayout
Returns:
the bounds of the graph

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