Class Node

java.lang.Object
org.eclipse.draw2d.graph.Node
Direct Known Subclasses:
Subgraph, VirtualNode

public class Node extends Object
A node in a DirectedGraph. A node has 0 or more incoming and outgoing Edges. 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:

  • x - the node's x location
  • y - the node's y location
  • height - the node's height may be stretched to match the height of other nodes
Since:
2.1.2
  • Field Details

    • data

      public Object data
      Clients may use this field to mark the Node with an arbitrary data object.
    • height

      public int height
      The 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 public int rowOrder
    • incoming

      public EdgeList incoming
      The edges for which this node is the target.
    • incomingOffset

      public int incomingOffset
      The default attachment point for incoming edges. -1 indicates that the node's horizontal center should be used.
    • outgoing

      public EdgeList outgoing
      The edges for which this node is the source.
    • sortValue

      @Deprecated public double sortValue
      Deprecated.
      for internal use only
    • outgoingOffset

      public int outgoingOffset
      The node's outgoing offset attachment point.
    • width

      public int width
      The node's width. The default value is 50.
    • x

      public int x
      The node's x coordinate.
    • y

      public int y
      The node's y coordinate.
  • Constructor Details

    • Node

      public Node()
      Constructs a new node.
    • Node

      public Node(Object data)
      Constructs a node with the given data object
      Parameters:
      data - an arbitrary data object
    • Node

      public Node(Subgraph parent)
      Constructs a node inside the given subgraph.
      Parameters:
      parent - the parent subgraph
    • Node

      public Node(Object data, Subgraph parent)
      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 object
      parent - the parent subgraph or null
  • 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

      public Insets getPadding()
      Returns the padding for this node or null if the default padding for the graph should be used.
      Returns:
      the padding or null
    • getParent

      public Subgraph getParent()
      Returns the parent Subgraph or null if there is no parent. Subgraphs are only for use in CompoundDirectedGraphLayout.
      Returns:
      the parent or null
    • setPadding

      public void setPadding(Insets padding)
      Sets the padding. null indicates that the default padding should be used.
      Parameters:
      padding - an insets or null
    • setParent

      public void setParent(Subgraph parent)
      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

      public void setSize(Dimension size)
      Sets the size of this node to the given dimension.
      Parameters:
      size - the new size
      Since:
      3.2
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getLeft

      public Node getLeft()
      Returns a reference to a node located left from this one
      Returns:
      Node on the left from this one
      Since:
      3.4
    • getRight

      public Node getRight()
      Returns a reference to a node located right from this one
      Returns:
      Node on the right from this one
      Since:
      3.4