Class ContainerTransformTransition

java.lang.Object
com.codename1.ui.animations.Transition
com.codename1.ui.animations.ContainerTransformTransition
All Implemented Interfaces:
Animation

public final class ContainerTransformTransition extends Transition

A transition in which one component GROWS into the whole of the next form, the way Material's container transform does: a card or a button becomes the page it opens.

The difference from MorphTransition is what is being animated. A morph moves a component from where it is in one form to where the same component is in the other, so it needs a counterpart on both sides and it animates a COMPONENT. This animates a SURFACE: a rounded rectangle travels from the tapped component's bounds out to the full form, its corners straightening as it goes, and the two contents cross-fade inside it -- the thing that was tapped fading out while the page fades in. Nothing needs to exist on both sides, which is the usual case: a button does not reappear on the page it opened.

Geometry follows a fast-out-slow-in curve and the cross-fade is deliberately not symmetric: the outgoing content is gone by the time the incoming content begins, so the two are never both half visible, which reads as a dissolve rather than a transformation.

Use it where a tap on something becomes a screen:

tappedCard.setName("card");
nextForm.setTransitionInAnimator(
        ContainerTransformTransition.create("card", 300));
nextForm.show();
  • Method Details

    • create

      public static ContainerTransformTransition create(String componentName, int duration)

      Creates a transition that grows the named component into the next form.

      Parameters
      • componentName: the Component.setName(String) of the component in the OUTGOING form that the next form grows out of. When no component carries that name the transition still runs, growing from the centre of the screen.

      • duration: the duration in milliseconds

      Returns

      the transition

    • initTransition

      public void initTransition()
      Description copied from class: Transition
      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()
      Description copied from class: Transition

      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)
      Description copied from class: Transition

      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
    • cleanup

      public void cleanup()
      Description copied from class: Transition
      Optional operation to cleanup the garbage left over by a running transition
      Overrides:
      cleanup in class Transition
    • copy

      public Transition copy(boolean reverse)
      Description copied from class: Transition

      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