Package org.eclipse.draw2d.graph

# Class Edge

java.lang.Object
org.eclipse.draw2d.graph.Edge

public class Edge extends 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:

- `source` - the source Node
- `target` - the target Node
- `delta` - the minimum number of rows the edge should span
- `weight` - a hint indicating this edge's importance
- `width` - the edge's width
- `padding` - the amount of space to leave on either side of the edge
- [`offsetSource`] - the edge's attachment point at the source node
- [`offsetTarget`] - the edge's attachment point at the target node

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

- `vNodes` - the virtual nodes (if any) which make up the bendpoints
- `isFeedback` - `true` if the edge points backwards

Since:
  2.1.2

## Field Summary

Fields
Modifier and Type
Field
Description
`Object`
`data`
An arbitrary data field for use by clients.
`int`
`delta`
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead.
`Point`
`end`
Deprecated, for removal: This API element is subject to removal in a future version.
use `getPoints()`.
`boolean`
`isFeedback`
Deprecated, for removal: This API element is subject to removal in a future version.
INTERNAL field, use accessor method Indicates an edge was inverted during the layout.
`int`
`offsetSource`
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead.
`int`
`offsetTarget`
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead.
`int`
`padding`
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead.
`Node`
`source`
The source Node.
`Point`
`start`
Deprecated, for removal: This API element is subject to removal in a future version.
use `getPoints()`.
`Node`
`target`
The target Node.
`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`
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead.

## Constructor Summary

Constructors
Constructor
Description
`Edge(Object data, Node source, Node target)`
Constructs a new edge with the given data object, source, and target node.
`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.

## Method Summary

Modifier and Type
Method
Description
`int`
`getDelta()`
Returns the delta value.
`int`
`getLength()`
For internal use only.
`int`
`getPadding()`
`PointList`
`getPoints()`
Returns the path connecting the edge's source and target.
`int`
`getSourceOffset()`
Returns the effective source offset for this edge.
`int`
`getTargetOffset()`
Returns the effective target offset for this edge.
`int`
`getWidth()`
`void`
`invert()`
Swaps the source and target nodes.
`boolean`
`isFeedback()`
Returns `true` if the edge was a feedback edge.
`Node`
`opposite(Node end)`
For internal use only.
`void`
`setDelta(int delta)`
Sets the delta value.
`void`
`setPadding(int padding)`
Sets the padding for this edge.
`void`
`setSource(Node node)`
Sets the source node and adds this edge to the new source's outgoing edges.
`void`
`setSourceOffset(int offset)`
`void`
`setTarget(Node node)`
Sets the target node and adds this edge to the new target's incoming edges.
`void`
`setTargetOffset(int offset)`
`void`
`setWidth(int width)`
Sets the width of the edge.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### data

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

### delta

@Deprecated(forRemoval=true, since="2025-12") public int delta
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead. This field will be made private after the 2027-12 release.
The minimum rank separation between the source and target nodes. The default value is 1.

### end

@Deprecated(forRemoval=true, since="2025-12") public Point end
Deprecated, for removal: This API element is subject to removal in a future version.
use `getPoints()`. This field will be made package-private after the 2027-12 release.
The ending point.

### isFeedback

@Deprecated(forRemoval=true, since="2025-12") public boolean isFeedback
Deprecated, for removal: This API element is subject to removal in a future version.
INTERNAL field, use accessor method Indicates an edge was inverted during the layout. This field will be made package-private after the 2027-12 release.

### offsetSource

@Deprecated(forRemoval=true, since="2025-12") public int offsetSource
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead. This field will be made package-private after the 2027-12 release.
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

@Deprecated(forRemoval=true, since="2025-12") public int offsetTarget
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead. This field will be made package-private after the 2027-12 release.
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.

### padding

@Deprecated(forRemoval=true, since="2025-12") public int padding
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead. This field will be made private after the 2027-12 release.
The minimum amount of space to leave on both the left and right sides of the edge.

### source

public Node source
The source Node.

### start

@Deprecated(forRemoval=true, since="2025-12") public Point start
Deprecated, for removal: This API element is subject to removal in a future version.
use `getPoints()`. This field will be made package-private after the 2027-12 release.
The starting point.

### target

public Node target
The target Node.

### 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 can use each virtual node's location (x, y, width, and height) as the way to position an edge which spans multiple 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

@Deprecated(forRemoval=true, since="2025-12") public int width
Deprecated, for removal: This API element is subject to removal in a future version.
use accessors instead. This field will be made private after the 2027-12 release.

## Constructor Details

### 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(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 Details

### getDelta

public int getDelta()
Returns the delta value. The delta is the minimum rank separation for the edge's source and target nodes.

Returns:
  the delta.
Since:
  3.2

### 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

### getPadding

public int getPadding()

### getPoints

public PointList getPoints()
Returns the path connecting the edge's source and target.

Returns:
  a point list
Since:
  3.2

### 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

### getWidth

public int getWidth()

### invert

public void invert()
Swaps the source and target nodes. If any positional data has been calculated, it is inverted as well to reflect the new direction.

Since:
  2.1.2

### isFeedback

public boolean isFeedback()
Returns `true` if the edge was a feedback edge. The layout algorithm may invert one or more edges to remove all cycles from the input. The set of edges that are inverted are referred to as the "feedback" set.

Returns:
  `true` if the edge is feedback
Since:
  3.2

### 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

### setDelta

public void setDelta(int delta)
Sets the delta value.

Parameters:
  `delta` - the new delta value
Since:
  3.2

### setPadding

public void setPadding(int padding)
Sets the padding for this edge.

Parameters:
  `padding` - the padding
Since:
  3.2

### setSource

public void setSource(Node node)
Sets the source node and adds this edge to the new source's outgoing edges. If the source node is previously set, removes this edge from the old source's outgoing edges.

Parameters:
  `node` - the new source
Since:
  3.2

### setSourceOffset

public void setSourceOffset(int offset)

### setTarget

public void setTarget(Node node)
Sets the target node and adds this edge to the new target's incoming edges. If the target node is previously set, removes this edge from the old target's incoming edges.

Parameters:
  `node` - the new target
Since:
  3.2

### setTargetOffset

public void setTargetOffset(int offset)

### setWidth

public void setWidth(int width)
Sets the width of the edge.

Parameters:
  `width` - the new width
Since:
  3.2