org.eclipse.draw2d.graph
Class Edge

java.lang.Object
  extended byorg.eclipse.draw2d.graph.Edge

public class Edge
extends java.lang.Object

A directed Edge joining a source and target Node. Edges indicate the dependencies between nodes. An Edge provides the information needed to perform a graph layout, and it stores the result of the layout in its various field. Therefore, it functions both as input and output. The input data consists of:

The output of a layout consists of bending longer edges, and potentially inverting edges to remove cycles in the graph. The output consists of:

Since:
2.1

Field Summary
 int cut
          For internal use only.
 java.lang.Object data
          An arbitrary data field for use by clients.
 int delta
          The minimum rank separation between the source and target nodes.
 Point end
           
 boolean flag
          For internal use only.
 boolean isFeedback
          Internal field, used to determine if edge source and target should be swapped.
 int offsetSource
          The edge's attachment point at the source node.
 int offsetTarget
          The edge's attachment point at the target node.
 int padding
          The minimum amount of space to leave on both the left and right sides of the edge.
 Node source
          The source Node.
 Point start
           
 Node target
          The target Node.
 boolean tree
          For internal use only.
 NodeList vNodes
          The virtual nodes used to bend edges which go across one or more ranks.
 int weight
          A hint indicating how straight and short the edge should be relative to other edges in the graph.
 int width
          The width occupied by the edge itself.
 
Constructor Summary
Edge(Node source, Node target)
          Constructs a new edge with the given source and target nodes.
Edge(Node source, Node target, int delta, int weight)
          Constructs a new edge with the given source, target, delta, and weight.
Edge(java.lang.Object data, Node source, Node target)
          Constructs a new edge with the given data object, source, and target node.
 
Method Summary
 int getIndexForRank(int rank)
          For internal use only.
 int getLength()
          For internal use only.
 int getSlack()
          For internal use only.
 int getSourceOffset()
          Returns the effective source offset for this edge.
 int getTargetOffset()
          Returns the effective target offset for this edge.
 void invert()
          Inverts this edge.
 Node opposite(Node end)
          For internal use only.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cut

public int cut
For internal use only. Represents the edge's cut value in the network simplex loop.


data

public java.lang.Object data
An arbitrary data field for use by clients.


delta

public int delta
The minimum rank separation between the source and target nodes.


flag

public boolean flag
For internal use only. Used during layout.


isFeedback

public boolean isFeedback
Internal field, used to determine if edge source and target should be swapped.


offsetSource

public int offsetSource
The edge's attachment point at the source node. The default value is -1, which indicates that the edge should use the node's default outgoing attachment point.


offsetTarget

public int offsetTarget
The edge's attachment point at the target node. The default value is -1, which indicates that the edge should use the node's default incoming attachment point.


source

public Node source
The source Node.


target

public Node target
The target Node.


padding

public int padding
The minimum amount of space to leave on both the left and right sides of the edge.


start

public Point start

end

public Point end

tree

public boolean tree
For internal use only. Field used during layout.


vNodes

public NodeList vNodes
The virtual nodes used to bend edges which go across one or more ranks. Each virtual node is just a regular node which occupies some small amount of space on a row. It's width is equivalent to the edge's width. Clients should use each virtual node's location (x, y, width, and height) as the way to position an edge which spans 1 or more rows.


weight

public int weight
A hint indicating how straight and short the edge should be relative to other edges in the graph. The default value is 1.


width

public int width
The width occupied by the edge itself. The default value is 1.

Constructor Detail

Edge

public Edge(Node source,
            Node target)
Constructs a new edge with the given source and target nodes. All other fields will have their default values.

Parameters:
source - the source Node
target - the target Node

Edge

public Edge(Node source,
            Node target,
            int delta,
            int weight)
Constructs a new edge with the given source, target, delta, and weight.

Parameters:
source - the source Node
target - the target Node
delta - the minimum edge span
weight - the weight hint

Edge

public Edge(java.lang.Object data,
            Node source,
            Node target)
Constructs a new edge with the given data object, source, and target node.

Parameters:
data - an arbitrary data object
source - the source node
target - the target node
Method Detail

getIndexForRank

public int getIndexForRank(int rank)
For internal use only. Returns the index of the Node (or VirtualNode) on this edge at the given rank. If this edge doesn't have a node at the given rank, -1 is returned.

Parameters:
rank - the rank
Returns:
the edges index at the given rank

getLength

public int getLength()
For internal use only. Returns the target node's row minus the source node's row.

Returns:
the distance from the source to target ranks

getSlack

public int getSlack()
For internal use only. Returns the amount of slack in the edge.

Returns:
the edge's slack

getSourceOffset

public int getSourceOffset()
Returns the effective source offset for this edge. The effective source offset is either the offsetSource field, or the source node's default outgoing offset if that field's value is -1.

Returns:
the source offset

getTargetOffset

public int getTargetOffset()
Returns the effective target offset for this edge. The effective target offset is either the offsetTarget field, or the target node's default incoming offset if that field's value is -1.

Returns:
the target offset

opposite

public Node opposite(Node end)
For internal use only. Returns the node opposite the given node on this edge.

Parameters:
end - one end
Returns:
the other end

invert

public void invert()
Inverts this edge. (Source becomes target, target becomes source).


toString

public java.lang.String toString()
See Also:
Object.toString()