Class DefaultSubgraph

java.lang.Object
org.eclipse.zest.core.widgets.DefaultSubgraph
All Implemented Interfaces:
EntityLayout, SubgraphLayout
Direct Known Subclasses:
FigureSubgraph

public class DefaultSubgraph extends Object implements SubgraphLayout
Default implementation of SubgraphLayout. Every subgraph added to Zest Graph should inherit from this class. The default implementation is very simple. A node pruned to this subgraph is minimized and all connections adjacent to it are made invisible. No additional graphic elements are added to the graph, but subclasses may add them.
Since:
1.14
  • Field Details

    • context

      protected final org.eclipse.zest.core.widgets.InternalLayoutContext context
    • nodes

      protected final Set<NodeLayout> nodes
    • disposed

      protected boolean disposed
  • Constructor Details

    • DefaultSubgraph

      protected DefaultSubgraph(LayoutContext context2)
  • Method Details

    • isGraphEntity

      public boolean isGraphEntity()
      Description copied from interface: SubgraphLayout
      Returns true if this subgraph is visualized as a particular object on the graph. If this method returns false, it means that this subgraph will not be visible so all methods related to location, size and direction should be ignored.
      Specified by:
      isGraphEntity in interface SubgraphLayout
      Returns:
      whether or not this subgraph is a graph entity that should be laid out.
    • setSize

      public void setSize(double width, double height)
      Specified by:
      setSize in interface EntityLayout
    • setLocation

      public void setLocation(double x, double y)
      Description copied from interface: EntityLayout
      Sets the position of this entity. The node will be moved so that it's center is located in the given point.
      Specified by:
      setLocation in interface EntityLayout
      Parameters:
      x - the x-position
      y - the y-position
    • isResizable

      public boolean isResizable()
      Specified by:
      isResizable in interface EntityLayout
    • isMovable

      public boolean isMovable()
      Specified by:
      isMovable in interface EntityLayout
    • getSuccessingEntities

      public EntityLayout[] getSuccessingEntities()
      Description copied from interface: EntityLayout
      Returns all entities that are direct successors of this entity. Successor entities of an unpruned node N are:
      • all unpruned successor nodes of node N
      • all subgraphs that are GraphEntities and contain at least one successor node of node N
      Successor entities of a subgraph S that is a GraphEntity are:
      • all unpruned nodes that are successor of at least one node from subgraph S
      • all subgraphs that are GraphEntities and contain at least one node that is a successor of at least one node from subgraph S
      For subgraphs that are not GraphEntities an empty array will be returned.
      Entities connected with this node by a bidirectional connection are considered both successors and predecessors. Any subsequent changes to the returned array do not affect this node.
      Specified by:
      getSuccessingEntities in interface EntityLayout
      Returns:
      array of successors of this node
    • getSize

      public DisplayIndependentDimension getSize()
      Specified by:
      getSize in interface EntityLayout
    • getPreferredAspectRatio

      public double getPreferredAspectRatio()
      Description copied from interface: EntityLayout
      Returns aspect ratio that is preferred for this entity. Can be 0 if this node can't be resized anyway or it doesn't care about about its ratio.
      Specified by:
      getPreferredAspectRatio in interface EntityLayout
      Returns:
      aspect ratio (width / height)
    • getPredecessingEntities

      public EntityLayout[] getPredecessingEntities()
      Description copied from interface: EntityLayout
      Returns all entities that are direct predecessors of this entity. Predecessor entities of an unpruned node A are:
      • all unpruned predecessor nodes of node N
      • all subgraphs that are GraphEntities and contain at least one predecessor node of node N
      Successor entities of a subgraph S that is a GraphEntity are:
      • all unpruned nodes that are predecessor of at least one node from subgraph S
      • all subgraphs that are GraphEntities and contain at least one node that is a predecessor of at least one node from subgraph S
      For subgraphs that are not GraphEntities an empty array will be returned.
      Entities connected with this node by a bidirectional connection are considered both successors and predecessors. Any subsequent changes to the returned array do not affect this node.
      Specified by:
      getPredecessingEntities in interface EntityLayout
      Returns:
      array of predecessors of this node
    • getLocation

      public DisplayIndependentPoint getLocation()
      Description copied from interface: EntityLayout
      Returns a point laying in the center of this entity. Any subsequent changes to the returned point won't affect this node.
      Specified by:
      getLocation in interface EntityLayout
      Returns:
      position of the center of this node
    • isDirectionDependant

      public boolean isDirectionDependant()
      Specified by:
      isDirectionDependant in interface SubgraphLayout
      Returns:
      true if this subgraph is visualized differently depending on direction
    • setDirection

      public void setDirection(int direction)
      Description copied from interface: SubgraphLayout
      Sets the direction of this subgraph (does nothing in case of subgraphs that don't depend on direction)
      Specified by:
      setDirection in interface SubgraphLayout
      Parameters:
      direction - one of constants: SubgraphLayout.TOP_DOWN, SubgraphLayout.BOTTOM_UP, SubgraphLayout.LEFT_RIGHT, SubgraphLayout.RIGHT_LEFT
    • removeNodes

      public void removeNodes(NodeLayout[] nodes)
      Description copied from interface: SubgraphLayout
      Removes nodes from this subgraph.
      Specified by:
      removeNodes in interface SubgraphLayout
      Parameters:
      nodes - array of nodes to remove
    • removeDisposedNodes

      public void removeDisposedNodes()
    • getNodes

      public NodeLayout[] getNodes()
      Description copied from interface: SubgraphLayout
      Returns all the nodes belonging to this subgraph. Replacing elements in the returned array does not affect this subgraph.
      Specified by:
      getNodes in interface SubgraphLayout
      Returns:
      array of nodes
    • getItems

      public Item[] getItems()
      Description copied from interface: EntityLayout
      Returns all graph items that are represented using this single entity. They are useful when a layout would get information about the graph it draws.
      Specified by:
      getItems in interface EntityLayout
      Returns:
      an array of graph items
    • countNodes

      public int countNodes()
      Specified by:
      countNodes in interface SubgraphLayout
      Returns:
      number of nodes pruned into this subgraph
    • addNodes

      public void addNodes(NodeLayout[] nodes)
      Description copied from interface: SubgraphLayout
      Adds nodes to this subgraph. If given nodes already belong to another subgraph, they are first removed from them.
      Specified by:
      addNodes in interface SubgraphLayout
      Parameters:
      nodes - array of nodes to add
    • refreshConnectionsVisibility

      protected void refreshConnectionsVisibility(ConnectionLayout[] connections)
    • refreshLocation

      protected void refreshLocation()
      Makes sure that value returned by getLocation() will be equal to current location of this subgraph.
    • refreshSize

      protected void refreshSize()
      Makes sure that value returned by getSize() will be equal to current size of this subgraph.
    • applyLayoutChanges

      protected void applyLayoutChanges()
    • dispose

      protected void dispose()