y.view
Class LayoutMorpher

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

public class LayoutMorpher
extends 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(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 static void assignLayout(Graph2D targetGraph, GraphLayout sourceGraph)
           
protected  Rectangle2D calcBoundingBox(Graph graph, GraphLayout gli, 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
 void calcFrame(double time)
          Calculates the next animation frame.
 void disposeAnimation()
          Disposes the animation.
 void execute()
           
 void initAnimation()
          Initializes the animation.
 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 isKeepZoomFactor()
           
 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 setFocusNode(Node focusNode)
          Sets the node being focused at the end of the animation.
 void setKeepZoomFactor(boolean keepZoomFactor)
          Sets whether the zoom factor is kept when morphing the layout.
 void setPreferredDuration(long preferredDuration)
          Specifies the preferred duration for the animated layout morphing in milliseconds.
 void setSmoothViewTransform(boolean smoothViewTransform)
          If set, 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(Graph2DView view,
                     GraphLayout gli)
Creates a new LayoutMorpher that applies the given GraphLayout to the graph that resides in the given view.

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

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.

setSmoothViewTransform

public void setSmoothViewTransform(boolean smoothViewTransform)
If set, 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.


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 Rectangle2D calcBoundingBox(Graph graph,
                                      GraphLayout gli,
                                      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()

assignLayout

protected static void assignLayout(Graph2D targetGraph,
                                   GraphLayout sourceGraph)

isKeepZoomFactor

public boolean isKeepZoomFactor()
Returns:
whether the zoom factor is kept when morphing.

setKeepZoomFactor

public void setKeepZoomFactor(boolean keepZoomFactor)
Sets whether the zoom factor is kept when morphing the layout.

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.

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