Search this API

y.view
Class NodeStateChangeEdgeRouter

java.lang.Object
  extended by y.view.NodeStateChangeEdgeRouter
All Implemented Interfaces:
NodeStateChangeHandler

public class NodeStateChangeEdgeRouter
extends java.lang.Object
implements NodeStateChangeHandler

Implementation of NodeStateChangeHandler that adjusts the relative port offsets of edges to the state before the open/close action. In addition, this implementation can restore an orthogonal routing if the edge has been orthogonal before the group action.

This implementation expects that the relative port offset of an edge that must be rerouted is not changed between calls to preNodeStateChange(y.base.Node) (y.base.Node)}/postNodeStateChange(y.base.Node).

See Also:
isOrthogonalRouting(y.base.Edge,Graph2D)
 

Constructor Summary
NodeStateChangeEdgeRouter()
           
 
Method Summary
protected  EdgeList getConvertableEdges(Node node)
          Returns a list of edges that will be changed by this node state change.
protected  boolean hasChanged(Edge edge, Node groupNode, boolean atSource)
          Checks whether the edge's source or target should be considered as changed through the state change.
 boolean isNodePortAware()
          Returns true if this router resets source and target NodePorts of inter edges and false otherwise.
protected  boolean isOrthogonalRouting(Edge e, Graph2D g)
          Determine whether an edge is orthogonal before the state change.
protected  void postEdgeStateChange(Edge edge, Node groupNode)
          Method to perform necessary actions after groupNode has changed its state.
 void postNodeStateChange(Node groupNode)
          Performs actions before after the node state.
protected  void preEdgeStateChange(Edge edge, Node groupNode)
          Method to perform necessary actions before groupNode changes its state.
 void preNodeStateChange(Node groupNode)
          Performs actions before changing the node state.
 void setNodePortAware(boolean aware)
          Specifies whether or not this router may reset source and target NodePorts of inter edges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeStateChangeEdgeRouter

public NodeStateChangeEdgeRouter()
Method Detail

isNodePortAware

public boolean isNodePortAware()
Returns true if this router resets source and target NodePorts of inter edges and false otherwise.

If this feature is enabled, the router stores the original source and target NodePorts of inter edges when closing group nodes and resets the ports to the stored values when opening the corresponding folder node.

This feature is enabled by default.

Returns:
true if this router resets source and target NodePorts of inter edges when closing group nodes or opening folder nodes and false otherwise.
See Also:
setNodePortAware(boolean), HierarchyManager.isInterEdge(y.base.Edge)

setNodePortAware

public void setNodePortAware(boolean aware)
Specifies whether or not this router may reset source and target NodePorts of inter edges.

If this feature is enabled, the router stores the original source and target NodePorts of inter edges when closing group nodes and resets the ports to the stored values when opening the corresponding folder node.

This feature is enabled by default.

Parameters:
aware - if true this router resets ports of inter edges.
See Also:
isNodePortAware(), HierarchyManager.isInterEdge(y.base.Edge)

preNodeStateChange

public void preNodeStateChange(Node groupNode)
Description copied from interface: NodeStateChangeHandler
Performs actions before changing the node state. Typically, this involves saving some state of the groupNode and/or the edges that may be touched by the state change.

Specified by:
preNodeStateChange in interface NodeStateChangeHandler
Parameters:
groupNode - The group or folder node whose state is about to change.

postNodeStateChange

public void postNodeStateChange(Node groupNode)
Description copied from interface: NodeStateChangeHandler
Performs actions before after the node state. This method should be called after the actual state change if NodeStateChangeHandler.preNodeStateChange(y.base.Node) has been called to change state related properties of the groupNode and/or its edges, as well as to clean up state that may have been stored by NodeStateChangeHandler.preNodeStateChange(y.base.Node).

Specified by:
postNodeStateChange in interface NodeStateChangeHandler
Parameters:
groupNode - The group or folder node whose state has just changed.

getConvertableEdges

protected EdgeList getConvertableEdges(Node node)
Returns a list of edges that will be changed by this node state change.

Parameters:
node - the node whose state will be changed.
Returns:
a list of edges that will be changed by this node state change.

preEdgeStateChange

protected void preEdgeStateChange(Edge edge,
                                  Node groupNode)
Method to perform necessary actions before groupNode changes its state. This can be used to save state of the edge prior to the state change.

Parameters:
edge - The edge to consider
groupNode - The node whose state is about to change

postEdgeStateChange

protected void postEdgeStateChange(Edge edge,
                                   Node groupNode)
Method to perform necessary actions after groupNode has changed its state. This implementation restored the relative source/port offsets of edge in relation to the group/folder nodes bounds. In addition, the previous edge path is restored, and if this edge has been orthogonal before (as determined by isOrthogonalRouting(y.base.Edge,Graph2D)), orthogonality is restored.

Parameters:
edge - The edge to consider
groupNode - The node whose state has just changed

isOrthogonalRouting

protected boolean isOrthogonalRouting(Edge e,
                                      Graph2D g)
Determine whether an edge is orthogonal before the state change. This property is saved and is queried by postEdgeStateChange(y.base.Edge,y.base.Node) to restore orthogonality for e.

Parameters:
e - The edge to query
g - The graph where this edge lives currently
Returns:
true iff this edge should be kept orthogonal.

hasChanged

protected boolean hasChanged(Edge edge,
                             Node groupNode,
                             boolean atSource)
Checks whether the edge's source or target should be considered as changed through the state change.

Parameters:
edge - The edge to check
groupNode - The group or folder node whose state has been changed
atSource - specify whether to check the source or at the target.
Returns:
true iff the edge should be considered as changed.

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