Search this API

y.layout
Class PlaceNodesAtBarycenterStage

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.PlaceNodesAtBarycenterStage
All Implemented Interfaces:
Layouter, LayoutStage

public class PlaceNodesAtBarycenterStage
extends AbstractLayoutStage

PlaceNodesAtBarycenterStage temporarily hides the affected nodes, applies the specified core layout algorithm (if any) to the resulting graph and, finally, reinserts the hidden nodes by placing them on the barycenter of their neighbors using the specified node sizes.

A possible application for this stage are animated incremental layouts, i.e., if there are new elements, you can first place them near the barycenter of their existing neighbors before starting the animation. Hence, the animation will produce smoother layouts since the new elements "start" from suitable initial positions. If the new elements should be placed on their original coordinates and/or get their original sizes after starting the animation and before calling the core layout, then you can use the GivenCoordinatesStage.

See Also:
GivenCoordinatesStage
 

Field Summary
static java.lang.Object AFFECTED_NODES_DPKEY
          A DataProvider key for determining which nodes should be placed by this stage.
static java.lang.Object AFFECTED_NODES_SIZE_DPKEY
          A DataProvider key for specifying the size of affected nodes.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
PlaceNodesAtBarycenterStage()
          Creates a new PlaceNodesAtBarycenterStage instance with default settings.
PlaceNodesAtBarycenterStage(Layouter coreLayouter)
          Creates a new PlaceNodesAtBarycenterStage instance using the given core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that can be handled by the core layout algorithm.
 void doLayout(LayoutGraph graph)
          Starts the layout.
 boolean isBendRemovalEnabled()
          Returns whether or not bends of edges incident to affected nodes should be removed.
 boolean isGroupingConsiderationEnabled()
          Returns whether or not the grouping structure should be considered.
 boolean isPortResettingEnabled()
          Returns whether or not ports of edges incident to affected nodes should be set to the center of the corresponding nodes.
 void setBendRemovalEnabled(boolean removeBends)
          Specifies whether or not bends of edges incident to affected nodes should be removed.
 void setGroupingConsiderationEnabled(boolean groupingConsiderationEnabled)
          Specifies whether or not the grouping structure should be considered.
 void setPortResettingEnabled(boolean portResettingEnabled)
          Specifies whether or not ports of edges incident to affected nodes should be set to the center of the corresponding nodes.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AFFECTED_NODES_DPKEY

public static final java.lang.Object AFFECTED_NODES_DPKEY
A DataProvider key for determining which nodes should be placed by this stage.


AFFECTED_NODES_SIZE_DPKEY

public static final java.lang.Object AFFECTED_NODES_SIZE_DPKEY
A DataProvider key for specifying the size of affected nodes.

 
Affected nodes that are not mapped to a specific size keep their current size.
Constructor Detail

PlaceNodesAtBarycenterStage

public PlaceNodesAtBarycenterStage()
Creates a new PlaceNodesAtBarycenterStage instance with default settings.


PlaceNodesAtBarycenterStage

public PlaceNodesAtBarycenterStage(Layouter coreLayouter)
Creates a new PlaceNodesAtBarycenterStage instance using the given core layout algorithm.

Parameters:
coreLayouter - the core layout routine
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm.

If there is no core layout algorithm, all graphs are accepted.

Parameters:
graph - the input graph
Returns:
true if there is no core layout algorithm or the core layout algorithm accepts the graph, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

isBendRemovalEnabled

public boolean isBendRemovalEnabled()
Returns whether or not bends of edges incident to affected nodes should be removed.

Returns:
true if bends are removed, false otherwise
See Also:
setBendRemovalEnabled(boolean), setPortResettingEnabled(boolean)

setBendRemovalEnabled

public void setBendRemovalEnabled(boolean removeBends)
Specifies whether or not bends of edges incident to affected nodes should be removed.

Default Value:
The default value is true. Bends should be removed.
Parameters:
removeBends - true if bends should be removed, false otherwise
See Also:
setPortResettingEnabled(boolean)

isPortResettingEnabled

public boolean isPortResettingEnabled()
Returns whether or not ports of edges incident to affected nodes should be set to the center of the corresponding nodes.

 
This property is only considered if setBendRemovalEnabled(boolean) is enabled.
Returns:
true if ports are set to the center of the corresponding node, false otherwise
See Also:
setPortResettingEnabled(boolean), setBendRemovalEnabled(boolean)

setPortResettingEnabled

public void setPortResettingEnabled(boolean portResettingEnabled)
Specifies whether or not ports of edges incident to affected nodes should be set to the center of the corresponding nodes.

 
This property is only considered if setBendRemovalEnabled(boolean) is enabled.
Default Value:
The default value is false. Ports are not set to the center.
Parameters:
portResettingEnabled - true if ports should be set to the center of the corresponding node, false otherwise
See Also:
setBendRemovalEnabled(boolean)

isGroupingConsiderationEnabled

public boolean isGroupingConsiderationEnabled()
Returns whether or not the grouping structure should be considered.

If this option is enabled, the layout algorithm considers the hierarchic grouping structure as follows:

If this option is disabled, there is no special treatment of group nodes.

Returns:
true if the grouping structure is considered, false otherwise
See Also:
setGroupingConsiderationEnabled(boolean)

setGroupingConsiderationEnabled

public void setGroupingConsiderationEnabled(boolean groupingConsiderationEnabled)
Specifies whether or not the grouping structure should be considered.

If this option is enabled, the layout algorithm considers the hierarchic grouping structure as follows:

If this option is disabled, there is no special treatment of group nodes.

Default Value:
The default value is true. The grouping structure is considered.
Parameters:
groupingConsiderationEnabled - true if the grouping structure should be considered, false otherwise

doLayout

public void doLayout(LayoutGraph graph)
Starts the layout.

Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.