Search this API

y.view
Class LayoutMorpher

java.lang.Object
  extended by y.view.LayoutMorpher
All Implemented Interfaces:
AnimationObject

public class LayoutMorpher
extends java.lang.Object
implements AnimationObject

This class applies layout information provided by a suitable GraphLayout instance to a given Graph2DView's internal graph in an animated fashion.

 

Constructor Summary
LayoutMorpher()
          Creates a new uninitialized instance of this class.
LayoutMorpher(Graph2DView view, GraphLayout gli)
          Creates a new LayoutMorpher that applies the given GraphLayout to the graph that resides in the given view.
 
Method Summary
protected  java.awt.geom.Rectangle2D calcBoundingBox(Graph graph, GraphLayout gli, java.awt.geom.Rectangle2D tb)
          Calculates the true bounding box of the graph using the given GraphLayout.
 void calcFrame(double time)
          Calculates the next animation frame.
 void disposeAnimation()
          Disposes the animation.
 void execute()
          Deprecated. Use the no-argument constructor and the execute(Graph2DView, y.layout.GraphLayout) method instead.
 void execute(Graph2DView view, GraphLayout layout)
          Convenience method that executes the animation using a new AnimationPlayer.
 Node getFocusNode()
          Returns the node being focused at the end of the animation.
 void initAnimation()
          Initializes the animation.
protected  void initialize(Graph2DView view, GraphLayout layout)
          Initializes this instance to work on the provided view and morph to the given layout.
 boolean isEasedExecution()
          Returns true iff the layout morphing is animated using ease in/ease out effects for a smoother animation start/animation end feeling.
 boolean isEdgeLabelAnimationEnabled()
          Determines whether or not edge label placement changes are animated.
 boolean isKeepZoomFactor()
          Returns whether the zoom factor is kept when morphing.
 boolean isNodeLabelAnimationEnabled()
          Determines whether or not node label placement changes are animated.
 boolean isSmoothViewTransform()
          Returns whether the animation will smoothly transform the view's zoom level and translation.
 long preferredDuration()
          Returns the preferred duration for the animated layout morphing in milliseconds.
 void setEasedExecution(boolean easedExecution)
          Specifies whether the layout morphing should be animated using ease in/ ease out effects for a smoother animation start/animation end feeling.
 void setEdgeLabelAnimationEnabled(boolean enabled)
          Specifies whether or not edge label placement changes are animated.
 void setFocusNode(Node focusNode)
          Sets the node being focused at the end of the animation.
 void setKeepZoomFactor(boolean keepZoomFactor)
          Specifies whether the zoom factor of the view is kept when morphing the layout.
 void setNodeLabelAnimationEnabled(boolean enabled)
          Specifies whether or not node label placement changes are animated.
 void setPreferredDuration(long preferredDuration)
          Specifies the preferred duration for the animated layout morphing in milliseconds.
 void setSmoothViewTransform(boolean smoothViewTransform)
          Specifies whether the animation will smoothly transform the view's zoom level and translation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayoutMorpher

public LayoutMorpher()
Creates a new uninitialized instance of this class.


LayoutMorpher

public LayoutMorpher(Graph2DView view,
                     GraphLayout gli)
Creates a new LayoutMorpher that applies the given GraphLayout to the graph that resides in the given view. This is identical to using the no-arg constructor and calling initialize(Graph2DView, y.layout.GraphLayout) after that with the corresponding arguments.

Precondition:
The given GraphLayout must be valid for all nodes and edges of the graph that belongs to the given view.
Method Detail

isEasedExecution

public boolean isEasedExecution()
Returns true iff the layout morphing is animated using ease in/ease out effects for a smoother animation start/animation end feeling. By the default, layout morphing is eased.

Returns:
true iff the layout morphing is animated using ease in/ease out effects for a smoother animation start/animation end feeling.

setEasedExecution

public void setEasedExecution(boolean easedExecution)
Specifies whether the layout morphing should be animated using ease in/ ease out effects for a smoother animation start/animation end feeling. By the default, layout morphing is eased.

Parameters:
easedExecution - if true, layout morphing is animated using ease in/ease out effects

preferredDuration

public long preferredDuration()
Returns the preferred duration for the animated layout morphing in milliseconds.

Specified by:
preferredDuration in interface AnimationObject
Returns:
the preferred duration for the animated layout morphing in milliseconds.

setPreferredDuration

public void setPreferredDuration(long preferredDuration)
Specifies the preferred duration for the animated layout morphing in milliseconds.

Parameters:
preferredDuration - the animation duration in milliseconds

getFocusNode

public Node getFocusNode()
Returns the node being focused at the end of the animation.

If the returned node is not null and part of the associated view's graph, then the coordinate system of the view will be smoothly translated during the animation to the effect that the focused node will be centered at the end of the animation process.
The zoom level of the view will not change if a focus node is defined.

Returns:
the node being focused at the end of the animation.

setFocusNode

public void setFocusNode(Node focusNode)
Sets the node being focused at the end of the animation.

If the given focusNode is unequal to null and part of the associated view's graph, then the coordinate system of the view will be smoothly translated during the animation to the effect that the focused node will be centered at the end of the animation process.
The zoom level of the view will remain unchanged if such a focus node is defined.

Note that this feature, smoothViewTransform, and keepZoomFactor are mutually exclusive in the sense that only one is obeyed. If two or more of these features are used, then this one precludes the others.

Parameters:
focusNode - The node that is to be focused at the end of the animation.

isSmoothViewTransform

public boolean isSmoothViewTransform()
Returns whether the animation will smoothly transform the view's zoom level and translation.

By default this feature is disabled.

Returns:
whether the animation will smoothly transform the view's zoom level and translation.

setSmoothViewTransform

public void setSmoothViewTransform(boolean smoothViewTransform)
Specifies whether the animation will smoothly transform the view's zoom level and translation.

By default this feature is disabled.

Note that this feature, focusNode, and keepZoomFactor are mutually exclusive in the sense that only one is obeyed. If two or more of these features are used, then this one precludes keepZoomFactor.

Parameters:
smoothViewTransform - if true, the animation will smoothly transform the view's zoom level and translation.

initAnimation

public void initAnimation()
Initializes the animation. Do not call this method directly. It is used by the animation framework classes.

Specified by:
initAnimation in interface AnimationObject

calcBoundingBox

protected java.awt.geom.Rectangle2D calcBoundingBox(Graph graph,
                                                    GraphLayout gli,
                                                    java.awt.geom.Rectangle2D tb)
Calculates the true bounding box of the graph using the given GraphLayout. The values in tb are updated and tb is finally returned.


calcFrame

public void calcFrame(double time)
Calculates the next animation frame. Do not call this method directly. It is used by the animation framework classes.

Specified by:
calcFrame in interface AnimationObject
Parameters:
time - a point in [0.0, 1.0]

disposeAnimation

public void disposeAnimation()
Disposes the animation. Do not call this method directly. It is used by the animation framework classes.

Specified by:
disposeAnimation in interface AnimationObject

execute

public void execute()
Deprecated. Use the no-argument constructor and the execute(Graph2DView, y.layout.GraphLayout) method instead.

Convenience method that executes the animation using a new AnimationPlayer. Note that this method can only be used if the constructor with the arguments has been used.


execute

public void execute(Graph2DView view,
                    GraphLayout layout)
Convenience method that executes the animation using a new AnimationPlayer.


initialize

protected void initialize(Graph2DView view,
                          GraphLayout layout)
Initializes this instance to work on the provided view and morph to the given layout.

Parameters:
view - The view to work in.
layout - The target layout.

isKeepZoomFactor

public boolean isKeepZoomFactor()
Returns whether the zoom factor is kept when morphing. The default value for this property is false.

Returns:
whether the zoom factor is kept when morphing.

setKeepZoomFactor

public void setKeepZoomFactor(boolean keepZoomFactor)
Specifies whether the zoom factor of the view is kept when morphing the layout. The default value for this property is false.

Note that this feature, smoothViewTransform, and focusNode are mutually exclusive in the sense that only one is obeyed. If two or more of these features are used, then this one is precluded by the others.

Parameters:
keepZoomFactor - if true, then the zoom factor is kept while morphing.

isEdgeLabelAnimationEnabled

public boolean isEdgeLabelAnimationEnabled()
Determines whether or not edge label placement changes are animated.

Default to true.

Returns:
true if edge label placement changes are animated; false otherwise.
See Also:
setEdgeLabelAnimationEnabled(boolean)

setEdgeLabelAnimationEnabled

public void setEdgeLabelAnimationEnabled(boolean enabled)
Specifies whether or not edge label placement changes are animated.

Parameters:
enabled - if true edge label placement changes are animated.
See Also:
isEdgeLabelAnimationEnabled()

isNodeLabelAnimationEnabled

public boolean isNodeLabelAnimationEnabled()
Determines whether or not node label placement changes are animated.

Default to true.

Returns:
true if node label placement changes are animated; false otherwise.
See Also:
setNodeLabelAnimationEnabled(boolean)

setNodeLabelAnimationEnabled

public void setNodeLabelAnimationEnabled(boolean enabled)
Specifies whether or not node label placement changes are animated.

Parameters:
enabled - if true node label placement changes are animated.
See Also:
isNodeLabelAnimationEnabled()

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