Package org.eclipse.draw2d.graph
Class Node
java.lang.Object
org.eclipse.draw2d.graph.Node
- Direct Known Subclasses:
Subgraph
,VirtualNode
A node in a DirectedGraph. A node has 0 or more incoming and outgoing
Edge
s. A node is given a width and height by the client. When a
layout places the node in the graph, it will determine the node's x and y
location. It may also modify the node's height.
A node represents both the input and the output for a
layout algorithm. The following fields are used as input to a graph layout:
width
- the node's width.height
- the node's height.outgoing
- the node's outgoing edges.incoming
- the node's incoming edges.- padding - the amount of space to be left around the outside of the node.
incomingOffset
- the default attachment point for incoming edges.outgoingOffset
- the default attachment point for outgoing edges.- parent - the parent subgraph containing this node.
The following fields are calculated by a graph layout and comprise the output:
- Since:
- 2.1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionClients may use this field to mark the Node with an arbitrary data object.int
The height of this node.The edges for which this node is the target.int
The default attachment point for incoming edges.The edges for which this node is the source.int
The node's outgoing offset attachment point.int
Deprecated.double
Deprecated.for internal use onlyint
The node's width.int
The node's x coordinate.int
The node's y coordinate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLeft()
Returns a reference to a node located left from this oneint
Returns the incoming attachment point.int
Returns the outgoing attachment point.Returns the padding for this node ornull
if the default padding for the graph should be used.Returns the parent Subgraph ornull
if there is no parent.getRight()
Returns a reference to a node located right from this oneint
Returns the row constraint for this node.void
setPadding
(Insets padding) Sets the padding.void
Sets the parent subgraph.void
setRowConstraint
(int value) Sets the row sorting constraint for this node.void
Sets the size of this node to the given dimension.toString()
-
Field Details
-
data
Clients may use this field to mark the Node with an arbitrary data object. -
height
public int heightThe height of this node. This value should be set prior to laying out the directed graph. Depending on the layout rules, a node's height may be expanded to match the height of other nodes around it. -
rowOrder
Deprecated. -
incoming
The edges for which this node is the target. -
incomingOffset
public int incomingOffsetThe default attachment point for incoming edges.-1
indicates that the node's horizontal center should be used. -
outgoing
The edges for which this node is the source. -
sortValue
Deprecated.for internal use only -
outgoingOffset
public int outgoingOffsetThe node's outgoing offset attachment point. -
width
public int widthThe node's width. The default value is 50. -
x
public int xThe node's x coordinate. -
y
public int yThe node's y coordinate.
-
-
Constructor Details
-
Node
public Node()Constructs a new node. -
Node
Constructs a node with the given data object- Parameters:
data
- an arbitrary data object
-
Node
Constructs a node inside the given subgraph.- Parameters:
parent
- the parent subgraph
-
Node
Constructs a node with the given data object and parent subgraph. This node is added to the set of members for the parent subgraph- Parameters:
data
- an arbitrary data objectparent
- the parent subgraph ornull
-
-
Method Details
-
getOffsetIncoming
public int getOffsetIncoming()Returns the incoming attachment point. This is the distance from the left edge to the default incoming attachment point for edges. Each incoming edge may have it's own attachment setting which takes priority over this default one.- Returns:
- the incoming offset
-
getOffsetOutgoing
public int getOffsetOutgoing()Returns the outgoing attachment point. This is the distance from the left edge to the default outgoing attachment point for edges. Each outgoing edge may have it's own attachment setting which takes priority over this default one.- Returns:
- the outgoing offset
-
getPadding
Returns the padding for this node ornull
if the default padding for the graph should be used.- Returns:
- the padding or
null
-
getParent
Returns the parent Subgraph ornull
if there is no parent. Subgraphs are only for use inCompoundDirectedGraphLayout
.- Returns:
- the parent or
null
-
setPadding
Sets the padding.null
indicates that the default padding should be used.- Parameters:
padding
- an insets ornull
-
setParent
Sets the parent subgraph. This method should not be called directly. The constructor will set the parent accordingly.- Parameters:
parent
- the parent
-
setRowConstraint
public void setRowConstraint(int value) Sets the row sorting constraint for this node. By default, a node's constraint is-1
. If two nodes have different values both >= 0, the node with the smaller constraint will be placed to the left of the other node. In all other cases no relative placement is guaranteed.- Parameters:
value
- the row constraint- Since:
- 3.2
-
getRowConstraint
public int getRowConstraint()Returns the row constraint for this node.- Returns:
- the row constraint
- Since:
- 3.2
-
setSize
Sets the size of this node to the given dimension.- Parameters:
size
- the new size- Since:
- 3.2
-
toString
-
getLeft
Returns a reference to a node located left from this one- Returns:
Node
on the left from this one- Since:
- 3.4
-
getRight
Returns a reference to a node located right from this one- Returns:
Node
on the right from this one- Since:
- 3.4
-
setRowConstraint(int)
andgetRowConstraint()