Java Code Examples for com.codename1.ui.Form#setTransitionOutAnimator()
The following examples show how to use
com.codename1.ui.Form#setTransitionOutAnimator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SocialChat.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
private void createMorphEffect(Label titleLabel) { // animate the components out of the previous form if we are coming in from the login form Form parent = Display.getInstance().getCurrent(); if(parent.getUIID().equals("MainForm")) { for(Component cmp : parent.getContentPane()) { cmp.setX(parent.getWidth()); } // moves all the components outside of the content pane to the right while fading them out over 400ms parent.getContentPane().animateUnlayoutAndWait(400, 0); parent.getContentPane().removeAll(); // we can't mutate a form into a component in another form so we need to convert the background to an image and then morph that // this is especially easy since we already removed all the components Label dummy = new Label(); dummy.setShowEvenIfBlank(true); dummy.setUIID("Container"); dummy.setUnselectedStyle(new Style(parent.getUnselectedStyle())); parent.setUIID("Form"); // special case to remove status bar on iOS 7 parent.getTitleArea().removeAll(); parent.setLayout(new BorderLayout()); parent.addComponent(BorderLayout.CENTER, dummy); parent.revalidate(); // animate the main panel to the new location at the top title area of the screen dummy.setName("fullScreen"); titleLabel.setName("titleImage"); parent.setTransitionOutAnimator(MorphTransition.create(1100).morph("fullScreen", "titleImage")); } }
Example 2
Source File: SwipeBackSupport.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
void startBackTransition(final Form currentForm, Form destination) { final Transition t = destination.getTransitionOutAnimator().copy(true); if(t instanceof CommonTransitions) { Transition originalTransition = currentForm.getTransitionOutAnimator(); currentForm.setTransitionOutAnimator(CommonTransitions.createEmpty()); Form blank = new Form() { protected boolean shouldSendPointerReleaseToOtherForm() { return true; } }; blank.addPointerDraggedListener(pointerDragged); blank.addPointerReleasedListener(pointerReleased); blank.addPointerPressedListener(pointerPressed); blank.setTransitionInAnimator(CommonTransitions.createEmpty()); blank.setTransitionOutAnimator(CommonTransitions.createEmpty()); blank.show(); currentForm.setTransitionOutAnimator(originalTransition); ((CommonTransitions)t).setMotion(new LazyValue<Motion>() { public Motion get(Object... args) { return new ManualMotion(((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), ((Integer)args[2]).intValue()); } }); t.init(currentForm, destination); t.initTransition(); blank.setGlassPane(new Painter() { public void paint(Graphics g, Rectangle rect) { t.animate(); t.paint(g); } }); } }
Example 3
Source File: UIBuilder.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Useful tool to refresh the current state of a form shown using show form * without pushing another instance to the back stack */ public void reloadForm() { Form currentForm = Display.getInstance().getCurrent(); Command backCommand = currentForm.getBackCommand(); Form newForm = (Form)createContainer(fetchResourceFile(), currentForm.getName()); newForm.setSourceCommand(currentForm.getSourceCommand()); if (backCommand != null) { setBackCommand(newForm, backCommand); // trigger listener creation if this is the only command in the form getFormListenerInstance(newForm, null); for(int iter = 0 ; iter < currentForm.getCommandCount() ; iter++) { if(backCommand == currentForm.getCommand(iter)) { newForm.addCommand(backCommand, newForm.getCommandCount()); break; } } } beforeShow(newForm); Transition tin = newForm.getTransitionInAnimator(); Transition tout = newForm.getTransitionOutAnimator(); currentForm.setTransitionInAnimator(CommonTransitions.createEmpty()); currentForm.setTransitionOutAnimator(CommonTransitions.createEmpty()); newForm.setTransitionInAnimator(CommonTransitions.createEmpty()); newForm.setTransitionOutAnimator(CommonTransitions.createEmpty()); newForm.layoutContainer(); newForm.show(); postShowImpl(newForm); newForm.setTransitionInAnimator(tin); newForm.setTransitionOutAnimator(tout); }
Example 4
Source File: FullScreenAdService.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Invoked on application startup, this code will download an ad or timeout */ public void showWelcomeAd() { if(!UIManager.getInstance().wasThemeInstalled()) { if(Display.getInstance().hasNativeTheme()) { Display.getInstance().installNativeTheme(); } } ConnectionRequest r = createAdRequest(); r.setPriority(ConnectionRequest.PRIORITY_HIGH); r.setTimeout(timeout); InfiniteProgress ip = new InfiniteProgress(); Dialog ipDialog = ip.showInifiniteBlocking(); NetworkManager.getInstance().addToQueueAndWait(r); if(failed()) { ipDialog.dispose(); if(!allowWithoutNetwork) { ipDialog.dispose(); Dialog.show("Network Error", "Please try again later", "Exit", null); Display.getInstance().exitApplication(); } else { return; } } Component c = getPendingAd(); if(c != null) { Form adForm = new AdForm(c); adForm.setTransitionInAnimator(CommonTransitions.createEmpty()); adForm.setTransitionOutAnimator(CommonTransitions.createEmpty()); adForm.show(); } }
Example 5
Source File: InterFormContainerSample.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void start_old() { if (current != null) { current.show(); return; } Form f1 = new Form("Form 1", new BorderLayout()); f1.setTransitionOutAnimator(CommonTransitions.createCover(CommonTransitions.SLIDE_VERTICAL, true, 300)); Form f2 = new Form("Form 2", new BorderLayout()); f2.setTransitionOutAnimator(CommonTransitions.createCover(CommonTransitions.SLIDE_VERTICAL, true, 300)); Form f3 = new Form("Form 3", new BorderLayout()); Button f3Back = new Button("Back"); f3Back.addActionListener(e -> { f2.showBack(); }); f3.add(BorderLayout.CENTER, new SpanLabel("This form doesn't have an interform container")); f3.add(BorderLayout.SOUTH, f3Back); f1.add(BorderLayout.CENTER, new Label("Hi World")); Button sharedButton = new Button("Shared Button"); sharedButton.addActionListener(e -> { if (sharedButton.getComponentForm() == f1) { f2.show(); } else { f1.showBack(); } }); InterFormContainer cnt = new InterFormContainer(sharedButton); f1.add(BorderLayout.SOUTH, cnt); Button goto3 = new Button("Goto Form 3"); goto3.addActionListener(e -> { f3.show(); }); InterFormContainer cnt2 = new InterFormContainer(sharedButton); f2.add(BorderLayout.CENTER, BoxLayout.encloseY(new Label("Now on Form 2"), goto3)); f2.add(BorderLayout.SOUTH, cnt2); f1.show(); }
Example 6
Source File: Poker.java From codenameone-demos with GNU General Public License v2.0 | 4 votes |
/** * The splash screen is relatively bare bones. Its important to have a splash screen for iOS * since the build process generates a screenshot of this screen to speed up perceived performance */ public void showSplashScreen() { final Form splash = new Form(); // a border layout places components in the center and the 4 sides. // by default it scales the center component so here we configure // it to place the component in the actual center BorderLayout border = new BorderLayout(); border.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE); splash.setLayout(border); // by default the form's content pane is scrollable on the Y axis // we need to disable it here splash.setScrollable(false); Label title = new Label("Poker Ace"); // The UIID is used to determine the appearance of the component in the theme title.setUIID("SplashTitle"); Label subtitle = new Label("By Codename One"); subtitle.setUIID("SplashSubTitle"); splash.addComponent(BorderLayout.NORTH, title); splash.addComponent(BorderLayout.SOUTH, subtitle); Label as = new Label(cards.getImage("as.png")); Label ah = new Label(cards.getImage("ah.png")); Label ac = new Label(cards.getImage("ac.png")); Label ad = new Label(cards.getImage("ad.png")); // a layered layout places components one on top of the other in the same dimension, it is // useful for transparency but in this case we are using it for an animation final Container center = new Container(new LayeredLayout()); center.addComponent(as); center.addComponent(ah); center.addComponent(ac); center.addComponent(ad); splash.addComponent(BorderLayout.CENTER, center); splash.show(); splash.setTransitionOutAnimator(CommonTransitions.createCover(CommonTransitions.SLIDE_VERTICAL, true, 800)); // postpone the animation to the next cycle of the EDT to allow the UI to render fully once Display.getInstance().callSerially(new Runnable() { public void run() { // We replace the layout so the cards will be laid out in a line and animate the hierarchy // over 2 seconds, this effectively creates the effect of cards spreading out center.setLayout(new BoxLayout(BoxLayout.X_AXIS)); center.setShouldCalcPreferredSize(true); splash.getContentPane().animateHierarchy(2000); // after showing the animation we wait for 2.5 seconds and then show the game with a nice // transition, notice that we use UI timer which is invoked on the Codename One EDT thread! new UITimer(new Runnable() { public void run() { showGameUI(); } }).schedule(2500, false, splash); } }); }
Example 7
Source File: KitchenSink.java From codenameone-demos with GNU General Public License v2.0 | 4 votes |
private void showSplashAnimation() { Form splash = new Form(); splash.setUIID("Splash"); splash.getContentPane().setUIID("Container"); splash.getTitleArea().setUIID("Container"); BorderLayout border = new BorderLayout(); border.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE); splash.setLayout(border); splash.setScrollable(false); Label title = new Label("Kitchen Sink Demo"); title.setUIID("SplashTitle"); Label subtitle = new Label("By Codename One"); subtitle.setUIID("SplashSubTitle"); splash.addComponent(BorderLayout.NORTH, title); splash.addComponent(BorderLayout.SOUTH, subtitle); Label beaker = new Label(res.getImage("beaker.png")); final Label beakerLogo = new Label(res.getImage("beaker_logo.png")); beakerLogo.setVisible(false); Container layeredLayout = new Container(new LayeredLayout()); splash.addComponent(BorderLayout.CENTER, layeredLayout); layeredLayout.addComponent(beaker); final Container logoParent = new Container(new BorderLayout()); layeredLayout.addComponent(logoParent); logoParent.addComponent(BorderLayout.CENTER, beakerLogo); splash.revalidate(); Display.getInstance().callSerially(new Runnable() { public void run() { beakerLogo.setVisible(true); beakerLogo.setX(0); beakerLogo.setY(0); beakerLogo.setWidth(3); beakerLogo.setHeight(3); logoParent.setShouldCalcPreferredSize(true); logoParent.animateLayoutFade(2000, 0); } }); splash.show(); splash.setTransitionOutAnimator(CommonTransitions.createFastSlide(CommonTransitions.SLIDE_VERTICAL, true, 300)); new UITimer(new Runnable() { public void run() { showMainUI(); } }).schedule(2500, false, splash); }