Class FlipTransition
- All Implemented Interfaces:
Animation
A Transitions that flips between 2 components/forms using perspective transform where available.
Notice that this looks rather different on devices as perspective transform is available there but isn't on the simulator.
Toolbar.setGlobalToolbar(true);
Form hi = new Form("Transitions", new BoxLayout(BoxLayout.Y_AXIS));
Style bg = hi.getContentPane().getUnselectedStyle();
bg.setBgTransparency(255);
bg.setBgColor(0xff0000);
Button showTransition = new Button("Show");
Picker pick = new Picker();
pick.setStrings("Slide", "SlideFade", "Cover", "Uncover", "Fade", "Flip");
pick.setSelectedString("Slide");
TextField duration = new TextField("10000", "Duration", 6, TextArea.NUMERIC);
CheckBox horizontal = CheckBox.createToggle("Horizontal");
pick.addActionListener((e) -> {
String s = pick.getSelectedString().toLowerCase();
horizontal.setEnabled(s.equals("slide") || s.indexOf("cover") > -1);
});
horizontal.setSelected(true);
hi.add(showTransition).
add(pick).
add(duration).
add(horizontal);
Form dest = new Form("Destination");
bg = dest.getContentPane().getUnselectedStyle();
bg.setBgTransparency(255);
bg.setBgColor(0xff);
dest.setBackCommand(
dest.getToolbar().addCommandToLeftBar("Back", null, (e) -> hi.showBack()));
showTransition.addActionListener((e) -> {
int h = CommonTransitions.SLIDE_HORIZONTAL;
if(!horizontal.isSelected()) {
h = CommonTransitions.SLIDE_VERTICAL;
}
switch(pick.getSelectedString()) {
case "Slide":
hi.setTransitionOutAnimator(CommonTransitions.createSlide(h, true, duration.getAsInt(3000)));
dest.setTransitionOutAnimator(CommonTransitions.createSlide(h, true, duration.getAsInt(3000)));
break;
case "SlideFade":
hi.setTransitionOutAnimator(CommonTransitions.createSlideFadeTitle(true, duration.getAsInt(3000)));
dest.setTransitionOutAnimator(CommonTransitions.createSlideFadeTitle(true, duration.getAsInt(3000)));
break;
case "Cover":
hi.setTransitionOutAnimator(CommonTransitions.createCover(h, true, duration.getAsInt(3000)));
dest.setTransitionOutAnimator(CommonTransitions.createCover(h, true, duration.getAsInt(3000)));
break;
case "Uncover":
hi.setTransitionOutAnimator(CommonTransitions.createUncover(h, true, duration.getAsInt(3000)));
dest.setTransitionOutAnimator(CommonTransitions.createUncover(h, true, duration.getAsInt(3000)));
break;
case "Fade":
hi.setTransitionOutAnimator(CommonTransitions.createFade(duration.getAsInt(3000)));
dest.setTransitionOutAnimator(CommonTransitions.createFade(duration.getAsInt(3000)));
break;
case "Flip":
hi.setTransitionOutAnimator(new FlipTransition(-1, duration.getAsInt(3000)));
dest.setTransitionOutAnimator(new FlipTransition(-1, duration.getAsInt(3000)));
break;
}
dest.show();
});
hi.show();
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a Flip TransitionFlipTransition(int bgColor) Creates a Flip TransitionFlipTransition(int bgColor, int duration) Creates a Flip Transition -
Method Summary
Modifier and TypeMethodDescriptionbooleananimate()Allows the animation to reduce "repaint" calls when it returns false.voidcleanup()Optional operation to cleanup the garbage left over by a running transitioncopy(boolean reverse) Create a copy of the transition, usually the transition used is a copy.intThe background color that is painted behind the flipping effect or -1 to use the paintBackgrounds method insteadintThe duration for the flip transitionvoidCallback thats invoked before a transition begins, the source form may be null for the first form in the application.voidDraws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.voidsetBgColor(int bgColor) The background color that is painted behind the flipping effect or -1 to use the paintBackgrounds method insteadvoidsetDuration(int duration) The duration for the flip transitionMethods inherited from class Transition
cleanSource, getDestination, getSource, hideInterformContainers, init, paintInterformContainers, showInterformContainersModifier and TypeMethodDescriptionprotected final voidAllows setting the source form to null to save memory if the transition doesn't need it in memory.final ComponentReturns the destination form that should be set once animation is completedfinal ComponentReturns the source form which is the form from which the animation is starting.protected voidSets visibility on all shared InterFormContainers between the source and destination to be hidden.final voidInvoked bycom.codename1.ui.Displayto set the source and destination forms.protected voidPaints all shared InterFormContainers between the source and destination.protected voidSets 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, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(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 voidwait(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.
-
Constructor Details
-
FlipTransition
public FlipTransition()Creates a Flip Transition -
FlipTransition
public FlipTransition(int bgColor) Creates a Flip Transition
Parameters
bgColor: @param bgColor the color to paint in the background when the transition paints, use -1 to not paint a background color
-
FlipTransition
public FlipTransition(int bgColor, int duration) Creates a Flip Transition
Parameters
-
bgColor: @param bgColor the color to paint in the background when the transition paints, use -1 to not paint a background color -
duration: the duration of the transition
-
-
-
Method Details
-
initTransition
public void initTransition()Description copied from class:TransitionCallback thats invoked before a transition begins, the source form may be null for the first form in the application.- Overrides:
initTransitionin classTransition
-
animate
public boolean animate()Description copied from class:TransitionAllows 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.Displayclass.Returns
true if a repaint is desired or false if no repaint is necessary
- Specified by:
animatein interfaceAnimation- Specified by:
animatein classTransition
-
paint
Description copied from class:TransitionDraws 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:
paintin interfaceAnimation- Specified by:
paintin classTransition
-
cleanup
public void cleanup()Description copied from class:TransitionOptional operation to cleanup the garbage left over by a running transition- Overrides:
cleanupin classTransition
-
getDuration
public int getDuration()The duration for the flip transition
Returns
the duration
-
setDuration
public void setDuration(int duration) The duration for the flip transition
Parameters
duration: the duration to set
-
getBgColor
public int getBgColor()The background color that is painted behind the flipping effect or -1 to use the paintBackgrounds method instead
Returns
the bgColor
-
setBgColor
public void setBgColor(int bgColor) The background color that is painted behind the flipping effect or -1 to use the paintBackgrounds method instead
Parameters
bgColor: the bgColor to set
-
copy
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
Parameters
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
Returns
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:
copyin classTransition
-