Interface LayoutContext
public interface LayoutContext
Objects implementing LayoutContext interface are used for exchanging of
information between layout algorithms and graphical objects displaying
graphs.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addContextListener
(ContextListener listener) Adds a listener to the context that will be notified about changes related to its configuration.void
Adds a listener to the context that will be notified about changes in graph structure, that is addition and removal of nodes and connections.void
addLayoutListener
(LayoutListener listener) Adds a listener to the context that will be notified about changes in this context's layout, that is movement and resizing of nodes / subgraphs.void
addPruningListener
(PruningListener listener) Adds a listener to the context that will be notified about changes in graph pruning, that is hiding and showing of nodes.createSubgraph
(NodeLayout[] nodes) Creates a subgraph containing given nodes and adds it to this context.void
flushChanges
(boolean animationHint) Causes all the changes made to elements in this context to affect the display.Returns all the connections between nodes that should be laid out.getConnections
(EntityLayout layoutEntity1, EntityLayout layoutEntity2) Returns all the connections between given source and target entities.Returns all entities that are currently placed on the graph, that is subgraphs and unpruned nodes.getNodes()
Returns all the nodes that should be laid out.Returns all the subgraphs this context's nodes were pruned to.boolean
Checks if this layout context allows layout algorithms to work continuously in background and change the layout with time or in reaction to some events.boolean
boolean
void
removeContextListener
(ContextListener listener) Removes a context listener from this context.void
Removes a graph structure listener from this context.void
removeLayoutListener
(LayoutListener listener) Removes a layout listener from this context.void
removePruningListener
(PruningListener listener) Removes a pruning structure listener from this context.void
setExpandCollapseManager
(ExpandCollapseManager expandCollapseManager) Sets the expand/collapse manager for this context.void
setMainLayoutAlgorithm
(LayoutAlgorithm algorithm) Sets the main layout algorithm for this context.
-
Method Details
-
getNodes
NodeLayout[] getNodes()Returns all the nodes that should be laid out. Replacing elements in the returned array does not affect this context.- Returns:
- array of nodes to lay out
-
getConnections
ConnectionLayout[] getConnections()Returns all the connections between nodes that should be laid out. Replacing elements in the returned array does not affect this context.- Returns:
- array of connections between nodes
-
getEntities
EntityLayout[] getEntities()Returns all entities that are currently placed on the graph, that is subgraphs and unpruned nodes. Replacing elements in the returned array does not affect this context.- Returns:
- array of entities to layout
-
getConnections
Returns all the connections between given source and target entities. If given entity is a subgraph, connections adjacent to each of its nodes will be included in the result. All the undirected nodes connecting the two nodes will be also included in the result. Replacing elements in the returned array does not affect this context.- Parameters:
layoutEntity1
-layoutEntity2
-
-
getBounds
DisplayIndependentRectangle getBounds()- Returns:
- bounds in which the graph elements can be placed
-
isBoundsExpandable
boolean isBoundsExpandable()- Returns:
- true if a layout algorithm is allowed to place graph elements outside of suggested bounds
-
getSubgraphs
SubgraphLayout[] getSubgraphs()Returns all the subgraphs this context's nodes were pruned to. Replacing elements in the returned array does not affect this context.- Returns:
- array of subgraphs (may be empty)
-
createSubgraph
Creates a subgraph containing given nodes and adds it to this context. If given nodes already belong to another subgraphs, they are removed from them prior to adding to the new subgraph.- Parameters:
nodes
- nodes to add to the new subgraph
-
isPruningEnabled
boolean isPruningEnabled()- Returns:
- true if this layout context allows pruning nodes into subgraphs
-
isBackgroundLayoutEnabled
boolean isBackgroundLayoutEnabled()Checks if this layout context allows layout algorithms to work continuously in background and change the layout with time or in reaction to some events. If background changes are not allowed, a layout algorithm can make changes in layout context only whenLayoutAlgorithm.applyLayout(boolean)
is called (otherwise a runtime exception will be thrown).- Returns:
- true if background layout changes are enabled
-
setMainLayoutAlgorithm
Sets the main layout algorithm for this context. Main algorithm will be used to relayout graph items usingLayoutAlgorithm.applyLayout(boolean)
after every event that is not intercepted by any listener.- Parameters:
algorithm
-
-
getMainLayoutAlgorithm
LayoutAlgorithm getMainLayoutAlgorithm()- Returns:
- the main algorithm of this context (see
setMainLayoutAlgorithm(LayoutAlgorithm)
for details)
-
setExpandCollapseManager
Sets the expand/collapse manager for this context. The manger will be used to handle expansion related methods called on the owner of this context.- Parameters:
expandCollapseManager
-
-
getExpandCollapseManager
ExpandCollapseManager getExpandCollapseManager()- Returns:
- current expand/collapse manager (can be null, which means that pruning is not enabled).
-
addLayoutListener
Adds a listener to the context that will be notified about changes in this context's layout, that is movement and resizing of nodes / subgraphs. The notifications will not include changes made with API included in layout related interfaces, so that layout algorithms won't be notified about changes they invoke. Only internal changes of the system will fire events.- Parameters:
listener
- listener to add
-
removeLayoutListener
Removes a layout listener from this context.- Parameters:
listener
- listener to remove
-
addGraphStructureListener
Adds a listener to the context that will be notified about changes in graph structure, that is addition and removal of nodes and connections. The notifications will not include changes made with API included in layout related interfaces, so that layout algorithms won't be notified about changes they invoke. Only internal changes of the system will fire events.- Parameters:
listener
- listener to add
-
removeGraphStructureListener
Removes a graph structure listener from this context.- Parameters:
listener
- listener to remove
-
addContextListener
Adds a listener to the context that will be notified about changes related to its configuration.- Parameters:
listener
- listener to add
-
removeContextListener
Removes a context listener from this context.- Parameters:
listener
- listener to remove
-
addPruningListener
Adds a listener to the context that will be notified about changes in graph pruning, that is hiding and showing of nodes. The notifications will not include changes made with API included in layout related interfaces, so that layout algorithms won't be notified about changes they invoke. Only internal changes of the system will fire events.- Parameters:
listener
- listener to add
-
removePruningListener
Removes a pruning structure listener from this context.- Parameters:
listener
- listener to remove
-
flushChanges
void flushChanges(boolean animationHint) Causes all the changes made to elements in this context to affect the display.- Parameters:
animationHint
- a hint for display mechanism indicating whether changes are major and should be animated (if true) or not.
-