Package org.eclipse.zest.core.widgets
Class DefaultSubgraph
java.lang.Object
org.eclipse.zest.core.widgets.DefaultSubgraph
- All Implemented Interfaces:
EntityLayout,SubgraphLayout
- Direct Known Subclasses:
FigureSubgraph
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefault factory forDefaultSubgraph.static classstatic classFactory forPrunedSuccessorsSubgraph.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.eclipse.zest.core.widgets.InternalLayoutContextprotected booleanprotected final Set<NodeLayout> Fields inherited from interface org.eclipse.zest.layouts.interfaces.SubgraphLayout
BOTTOM_UP, LEFT_RIGHT, RIGHT_LEFT, TOP_DOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNodes(NodeLayout[] nodes) Adds nodes to this subgraph.protected voidintprotected voiddispose()Item[]getItems()Returns all graph items that are represented using this single entity.Returns a point laying in the center of this entity.getNodes()Returns all the nodes belonging to this subgraph.Returns all entities that are direct predecessors of this entity.doubleReturns aspect ratio that is preferred for this entity.getSize()Returns all entities that are direct successors of this entity.booleanbooleanReturns true if this subgraph is visualized as a particular object on the graph.booleanbooleanprotected voidrefreshConnectionsVisibility(ConnectionLayout[] connections) protected voidMakes sure that value returned bygetLocation()will be equal to current location of this subgraph.protected voidMakes sure that value returned bygetSize()will be equal to current size of this subgraph.voidvoidremoveNodes(NodeLayout[] nodes) Removes nodes from this subgraph.voidsetDirection(int direction) Sets the direction of this subgraph (does nothing in case of subgraphs that don't depend on direction)voidsetLocation(double x, double y) Sets the position of this entity.voidsetSize(double width, double height)
-
Field Details
-
context
protected final org.eclipse.zest.core.widgets.InternalLayoutContext context -
nodes
-
disposed
protected boolean disposed
-
-
Constructor Details
-
DefaultSubgraph
-
-
Method Details
-
isGraphEntity
public boolean isGraphEntity()Description copied from interface:SubgraphLayoutReturns 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:
isGraphEntityin interfaceSubgraphLayout- 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:
setSizein interfaceEntityLayout
-
setLocation
public void setLocation(double x, double y) Description copied from interface:EntityLayoutSets the position of this entity. The node will be moved so that it's center is located in the given point.- Specified by:
setLocationin interfaceEntityLayout- Parameters:
x- the x-positiony- the y-position
-
isResizable
public boolean isResizable()- Specified by:
isResizablein interfaceEntityLayout
-
isMovable
public boolean isMovable()- Specified by:
isMovablein interfaceEntityLayout
-
getSuccessingEntities
Description copied from interface:EntityLayoutReturns 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
GraphEntitiesand contain at least one successor node of node N
GraphEntityare:- all unpruned nodes that are successor of at least one node from subgraph S
- all subgraphs that are
GraphEntitiesand contain at least one node that is a successor of at least one node from subgraph S
GraphEntitiesan 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:
getSuccessingEntitiesin interfaceEntityLayout- Returns:
- array of successors of this node
-
getSize
- Specified by:
getSizein interfaceEntityLayout
-
getPreferredAspectRatio
public double getPreferredAspectRatio()Description copied from interface:EntityLayoutReturns 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:
getPreferredAspectRatioin interfaceEntityLayout- Returns:
- aspect ratio (width / height)
-
getPredecessingEntities
Description copied from interface:EntityLayoutReturns 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
GraphEntitiesand contain at least one predecessor node of node N
GraphEntityare:- all unpruned nodes that are predecessor of at least one node from subgraph S
- all subgraphs that are
GraphEntitiesand contain at least one node that is a predecessor of at least one node from subgraph S
GraphEntitiesan 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:
getPredecessingEntitiesin interfaceEntityLayout- Returns:
- array of predecessors of this node
-
getLocation
Description copied from interface:EntityLayoutReturns a point laying in the center of this entity. Any subsequent changes to the returned point won't affect this node.- Specified by:
getLocationin interfaceEntityLayout- Returns:
- position of the center of this node
-
isDirectionDependant
public boolean isDirectionDependant()- Specified by:
isDirectionDependantin interfaceSubgraphLayout- Returns:
- true if this subgraph is visualized differently depending on direction
-
setDirection
public void setDirection(int direction) Description copied from interface:SubgraphLayoutSets the direction of this subgraph (does nothing in case of subgraphs that don't depend on direction)- Specified by:
setDirectionin interfaceSubgraphLayout- Parameters:
direction- one of constants:SubgraphLayout.TOP_DOWN,SubgraphLayout.BOTTOM_UP,SubgraphLayout.LEFT_RIGHT,SubgraphLayout.RIGHT_LEFT
-
removeNodes
Description copied from interface:SubgraphLayoutRemoves nodes from this subgraph.- Specified by:
removeNodesin interfaceSubgraphLayout- Parameters:
nodes- array of nodes to remove
-
removeDisposedNodes
public void removeDisposedNodes() -
getNodes
Description copied from interface:SubgraphLayoutReturns all the nodes belonging to this subgraph. Replacing elements in the returned array does not affect this subgraph.- Specified by:
getNodesin interfaceSubgraphLayout- Returns:
- array of nodes
-
getItems
Description copied from interface:EntityLayoutReturns 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:
getItemsin interfaceEntityLayout- Returns:
- an array of graph items
-
countNodes
public int countNodes()- Specified by:
countNodesin interfaceSubgraphLayout- Returns:
- number of nodes pruned into this subgraph
-
addNodes
Description copied from interface:SubgraphLayoutAdds nodes to this subgraph. If given nodes already belong to another subgraph, they are first removed from them.- Specified by:
addNodesin interfaceSubgraphLayout- Parameters:
nodes- array of nodes to add
-
refreshConnectionsVisibility
-
refreshLocation
protected void refreshLocation()Makes sure that value returned bygetLocation()will be equal to current location of this subgraph. -
refreshSize
protected void refreshSize()Makes sure that value returned bygetSize()will be equal to current size of this subgraph. -
applyLayoutChanges
protected void applyLayoutChanges() -
dispose
protected void dispose()
-