# Class MorphTransition

java.lang.Object
com.codename1.ui.animations.Transition
com.codename1.ui.animations.MorphTransition

All Implemented Interfaces:
  `Animation`

public final class MorphTransition extends Transition
A transition inspired by the Android L release morph activity effect allowing a set of components in one form/container to morph into another in a different container/form.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `animate()`
  Allows the animation to reduce "repaint" calls when it returns false.
  `Transition`
  `copy(boolean reverse)`
  Create a copy of the transition, usually the transition used is a copy.
  `static MorphTransition`
  `create(int duration)`
  Creates a transition with the given duration, this transition should be modified with the builder methods such as morph
  `void`
  `initTransition()`
  Callback thats invoked before a transition begins, the source form may be null for the first form in the application.
  `MorphTransition`
  `morph(String cmp)`
  Morphs the component with the given source name in the source container hierarchy to the component with the same name in the destination hierarchy
  `MorphTransition`
  `morph(String source, String to)`
  Morphs the component with the given source name in the source container hierarchy to the component with the given name in the destination hierarchy
  `void`
  `paint(Graphics g)`
  Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.

  ### Methods inherited from class Transition

  `cleanSource, cleanup, getDestination, getSource, hideInterformContainers, init, paintInterformContainers, showInterformContainers`
  Modifier and Type
  Method
  Description
  `protected final void`
  `cleanSource()`
  Allows setting the source form to null to save memory if the transition doesn't need it in memory.
  `void`
  `cleanup()`
  Optional operation to cleanup the garbage left over by a running transition
  `final Component`
  `getDestination()`
  Returns the destination form that should be set once animation is completed
  `final Component`
  `getSource()`
  Returns the source form which is the form from which the animation is starting.
  `protected void`
  `hideInterformContainers()`
  Sets visibility on all shared InterFormContainers between the source and destination to be hidden.
  `final void`
  `init(Component source, Component destination)`
  Invoked by `com.codename1.ui.Display` to set the source and destination forms.
  `protected void`
  `paintInterformContainers(Graphics g)`
  Paints all shared InterFormContainers between the source and destination.
  `protected void`
  `showInterformContainers()`
  Sets visibility on all shared InterFormContainers between the source and destination to be visible.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## Method Details

  - ### create

    public static MorphTransition create(int duration)

    Creates a transition with the given duration, this transition should be modified with the builder methods such as morph

    ###### Parameters

    - `duration`: the duration of the transition

    ###### Returns

    a new Morph transition instance

  - ### copy

    public Transition copy(boolean reverse)

    Create a copy of the transition, usually the transition used is a copy.

    ###### Parameters

    - `reverse`: @param reverse creates a new transition instance with "reverse" behavior useful for signifying "back" operations

    ###### Returns

    new transition instance

    Overrides:
      `copy` in class `Transition`

  - ### morph

    public MorphTransition morph(String cmp)

    Morphs the component with the given source name in the source container hierarchy to the component with the same name in the destination hierarchy

    ###### Parameters

    - `cmp`: the compoennt name

    ###### Returns

    this so morph operations can be chained as MorphTransition t = MorphTransition.create(300).morph("a").("c");

  - ### morph

    public MorphTransition morph(String source, String to)

    Morphs the component with the given source name in the source container hierarchy to the component with the given name in the destination hierarchy

    ###### Parameters

    - `source`

    - `to`

    ###### Returns

    this so morph operations can be chained as MorphTransition t = MorphTransition.create(300).morph("a", "b").("c", "d");

  - ### initTransition

    public void initTransition()
    Callback thats invoked before a transition begins, the source form may be null for the first form in the application.
    Overrides:
      `initTransition` in class `Transition`

  - ### animate

    public boolean animate()

    Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the `com.codename1.ui.Display` class.

    ###### Returns

    true if a repaint is desired or false if no repaint is necessary

    Specified by:
      `animate` in interface `Animation`
    Specified by:
      `animate` in class `Transition`

  - ### paint

    public void paint(Graphics g)

    Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.

    ###### Parameters

    - `g`: graphics context
    Specified by:
      `paint` in interface `Animation`
    Specified by:
      `paint` in class `Transition`