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 class
Default factory forDefaultSubgraph
.static class
static class
Factory forPrunedSuccessorsSubgraph
.static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.eclipse.zest.core.widgets.InternalLayoutContext
protected boolean
protected 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 TypeMethodDescriptionvoid
addNodes
(NodeLayout[] nodes) Adds nodes to this subgraph.protected void
int
protected void
dispose()
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.double
Returns aspect ratio that is preferred for this entity.getSize()
Returns all entities that are direct successors of this entity.boolean
boolean
Returns true if this subgraph is visualized as a particular object on the graph.boolean
boolean
protected void
refreshConnectionsVisibility
(ConnectionLayout[] connections) protected void
Makes sure that value returned bygetLocation()
will be equal to current location of this subgraph.protected void
Makes sure that value returned bygetSize()
will be equal to current size of this subgraph.void
void
removeNodes
(NodeLayout[] nodes) Removes nodes from this subgraph.void
setDirection
(int direction) Sets the direction of this subgraph (does nothing in case of subgraphs that don't depend on direction)void
setLocation
(double x, double y) Sets the position of this entity.void
setSize
(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: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 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:
setSize
in interfaceEntityLayout
-
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 interfaceEntityLayout
- Parameters:
x
- the x-positiony
- the y-position
-
isResizable
public boolean isResizable()- Specified by:
isResizable
in interfaceEntityLayout
-
isMovable
public boolean isMovable()- Specified by:
isMovable
in interfaceEntityLayout
-
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
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
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 interfaceEntityLayout
- Returns:
- array of successors of this node
-
getSize
- Specified by:
getSize
in interfaceEntityLayout
-
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 interfaceEntityLayout
- Returns:
- aspect ratio (width / height)
-
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
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
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 interfaceEntityLayout
- Returns:
- array of predecessors of this node
-
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 interfaceEntityLayout
- Returns:
- position of the center of this node
-
isDirectionDependant
public boolean isDirectionDependant()- Specified by:
isDirectionDependant
in interfaceSubgraphLayout
- 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 interfaceSubgraphLayout
- Parameters:
direction
- one of constants:SubgraphLayout.TOP_DOWN
,SubgraphLayout.BOTTOM_UP
,SubgraphLayout.LEFT_RIGHT
,SubgraphLayout.RIGHT_LEFT
-
removeNodes
Description copied from interface:SubgraphLayout
Removes nodes from this subgraph.- Specified by:
removeNodes
in interfaceSubgraphLayout
- Parameters:
nodes
- array of nodes to remove
-
removeDisposedNodes
public void removeDisposedNodes() -
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 interfaceSubgraphLayout
- Returns:
- array of nodes
-
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 interfaceEntityLayout
- Returns:
- an array of graph items
-
countNodes
public int countNodes()- Specified by:
countNodes
in interfaceSubgraphLayout
- Returns:
- number of nodes pruned into this subgraph
-
addNodes
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 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()
-