public final class ContainerTransformTransition

  1. Object
  2. Transition
  3. ContainerTransformTransition

ImplementsAnimation

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();

Methods

public static ContainerTransformTransition create(String componentName, int duration)Creates a transition that grows the named component into the next form.
public void initTransition()Callback thats invoked before a transition begins, the source form may be null for the first form in the application.
public boolean animate()Allows the animation to reduce “repaint” calls when it returns false.
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.
public void cleanup()Optional operation to cleanup the garbage left over by a running transition
public Transition copy(boolean reverse)Create a copy of the transition, usually the transition used is a copy.

Inherited methods

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 String
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 int
the duration in milliseconds

Returns

the transition

initTransition

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

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

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
graphics context

cleanup

public void cleanup()
Optional operation to cleanup the garbage left over by a running transition

copy

public Transition copy(boolean reverse)
Create a copy of the transition, usually the transition used is a copy.

Parameters

reverse boolean
creates a new transition instance with “reverse” behavior useful for signifying “back” operations

Returns

new transition instance