SlideShare a Scribd company logo
1 of 10
Download to read offline
Animations - Part I
Animations
© Codename One 2017 all rights reserved
✦Animations are here to signify & draw attention. Not just
for frivolous appearance there are 2 common purposes
✦Draw attention
✦Confirm
✦Codename One has multiple types of animations and
each use case is served by a different type
Transitions
© Codename One 2017 all rights reserved
✦The first animation you will probably notice. Moves
between forms or replaces one component with another
✦The easiest one to use…
✦Builtin implementations include: CommonTransition,
FlipTransition, MorphTransition & BubbleTransition
✦Common transitions include: Slide, cover/uncover, fade,
slide-fade title, timeline & dialog pulsate
✦Default transitions can be defined globally in the look
and feel class or thru the theme constants
Transition direction, In & Out
© Codename One 2017 all rights reserved
✦Transitions have a transition in & out
✦For dialogs in is shown when showing and out when
dismissing
✦For forms out is usually used by convention, using
transition-in makes sense in some edge cases
✦Some transitions have navigational direction which is
why we have show() and showBack() where the
direction is flipped
© Codename One 2017 all rights reserved
© Codename One 2017 all rights reserved
CheckoutForm
public static void showCheckOut() {
Form existingForm = Display.getInstance().getCurrent();
CheckoutForm f = new CheckoutForm(existingForm);
f.oldTransition = existingForm.getTransitionOutAnimator();
Image background = Image.createImage(existingForm.getWidth(),
existingForm.getHeight());
Graphics g = background.getGraphics();
existingForm.paintComponent(g, true);
g.setAlpha(150);
g.setColor(0);
g.fillRect(0, 0, background.getWidth(), background.getHeight());
background = Display.getInstance().gaussianBlurImage(background, 10);
f.getUnselectedStyle().setBgImage(background);
f.getUnselectedStyle().setBackgroundType(BACKGROUND_IMAGE_SCALED_FILL);
f.setTransitionOutAnimator(CommonTransitions.createUncover(
CommonTransitions.SLIDE_VERTICAL, true, 200));
existingForm.setTransitionOutAnimator(CommonTransitions.createCover(
CommonTransitions.SLIDE_VERTICAL, false, 200));
f.show();
}
CheckoutForm
public static void showCheckOut() {
Form existingForm = Display.getInstance().getCurrent();
CheckoutForm f = new CheckoutForm(existingForm);
f.oldTransition = existingForm.getTransitionOutAnimator();
Image background = Image.createImage(existingForm.getWidth(),
existingForm.getHeight());
Graphics g = background.getGraphics();
existingForm.paintComponent(g, true);
g.setAlpha(150);
g.setColor(0);
g.fillRect(0, 0, background.getWidth(), background.getHeight());
background = Display.getInstance().gaussianBlurImage(background, 10);
f.getUnselectedStyle().setBgImage(background);
f.getUnselectedStyle().setBackgroundType(BACKGROUND_IMAGE_SCALED_FILL);
f.setTransitionOutAnimator(CommonTransitions.createUncover(
CommonTransitions.SLIDE_VERTICAL, true, 200));
existingForm.setTransitionOutAnimator(CommonTransitions.createCover(
CommonTransitions.SLIDE_VERTICAL, false, 200));
f.show();
}
CheckoutForm
private CheckoutForm(Form previous) {
super(new BorderLayout());
Button x = new Button("", "Title");
FontImage.setMaterialIcon(x, FontImage.MATERIAL_CLOSE);
x.addActionListener(e -> {
previous.showBack();
previous.setTransitionOutAnimator(oldTransition);
});
MainMenuForm
private Container createDishContainer(Dish dish) {
TextArea ta = new TextArea(dish.description.get(), 3, 80);
ta.setEditable(false);
ta.setFocusable(false);
ta.setGrowByContent(false);
ta.setUIID("DishListBody");
Button order = new Button("Order " + Restaurant.getInstance().
formatCurrency(dish.price.get()), "AddToOrderButton");
Button moreInfo = new Button("More Info", "MoreInfoButton");
moreInfo.addActionListener(e -> {
DishViewForm dvf = new DishViewForm(dish);
MorphTransition mt = MorphTransition.create(400);
mt.morph("thumb" + dish.id.get(), "backgroundImage");
Transition original = getTransitionOutAnimator();
setTransitionOutAnimator(mt);
CommonTransitions uncover = CommonTransitions.createUncover(
CommonTransitions.SLIDE_VERTICAL, true, 350);
dvf.setTransitionOutAnimator(uncover);
dvf.addShowListener(ee -> setTransitionOutAnimator(original));
dvf.show();
});

More Related Content

Similar to Animations - Part 1.pdf

ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013
Mathias Seguy
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 

Similar to Animations - Part 1.pdf (20)

Animations - Part 2.pdf
Animations - Part 2.pdfAnimations - Part 2.pdf
Animations - Part 2.pdf
 
Graphics in C++
Graphics in C++Graphics in C++
Graphics in C++
 
Creating an Uber Clone - Part X.pdf
Creating an Uber Clone - Part X.pdfCreating an Uber Clone - Part X.pdf
Creating an Uber Clone - Part X.pdf
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
 
Performance and Memory Tuning - Part III.pdf
Performance and Memory Tuning - Part III.pdfPerformance and Memory Tuning - Part III.pdf
Performance and Memory Tuning - Part III.pdf
 
Demystifying Angular Animations
Demystifying Angular AnimationsDemystifying Angular Animations
Demystifying Angular Animations
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animations
 
How to Create Animation Using the AnimatedAlign Widget.pptx
How to Create Animation Using the AnimatedAlign Widget.pptxHow to Create Animation Using the AnimatedAlign Widget.pptx
How to Create Animation Using the AnimatedAlign Widget.pptx
 
Creating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdfCreating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdf
 
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
 
Css3
Css3Css3
Css3
 
Seven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose AnimationSeven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose Animation
 
ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIView
 
[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshell[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshell
 
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
 
Graphiti presentation
Graphiti presentationGraphiti presentation
Graphiti presentation
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
 
Advanced iOS
Advanced iOSAdvanced iOS
Advanced iOS
 
Java 8 Default Methods
Java 8 Default MethodsJava 8 Default Methods
Java 8 Default Methods
 

More from ShaiAlmog1

More from ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Animations - Part 1.pdf

  • 2. Animations © Codename One 2017 all rights reserved ✦Animations are here to signify & draw attention. Not just for frivolous appearance there are 2 common purposes ✦Draw attention ✦Confirm ✦Codename One has multiple types of animations and each use case is served by a different type
  • 3. Transitions © Codename One 2017 all rights reserved ✦The first animation you will probably notice. Moves between forms or replaces one component with another ✦The easiest one to use… ✦Builtin implementations include: CommonTransition, FlipTransition, MorphTransition & BubbleTransition ✦Common transitions include: Slide, cover/uncover, fade, slide-fade title, timeline & dialog pulsate ✦Default transitions can be defined globally in the look and feel class or thru the theme constants
  • 4. Transition direction, In & Out © Codename One 2017 all rights reserved ✦Transitions have a transition in & out ✦For dialogs in is shown when showing and out when dismissing ✦For forms out is usually used by convention, using transition-in makes sense in some edge cases ✦Some transitions have navigational direction which is why we have show() and showBack() where the direction is flipped
  • 5. © Codename One 2017 all rights reserved
  • 6. © Codename One 2017 all rights reserved
  • 7. CheckoutForm public static void showCheckOut() { Form existingForm = Display.getInstance().getCurrent(); CheckoutForm f = new CheckoutForm(existingForm); f.oldTransition = existingForm.getTransitionOutAnimator(); Image background = Image.createImage(existingForm.getWidth(), existingForm.getHeight()); Graphics g = background.getGraphics(); existingForm.paintComponent(g, true); g.setAlpha(150); g.setColor(0); g.fillRect(0, 0, background.getWidth(), background.getHeight()); background = Display.getInstance().gaussianBlurImage(background, 10); f.getUnselectedStyle().setBgImage(background); f.getUnselectedStyle().setBackgroundType(BACKGROUND_IMAGE_SCALED_FILL); f.setTransitionOutAnimator(CommonTransitions.createUncover( CommonTransitions.SLIDE_VERTICAL, true, 200)); existingForm.setTransitionOutAnimator(CommonTransitions.createCover( CommonTransitions.SLIDE_VERTICAL, false, 200)); f.show(); }
  • 8. CheckoutForm public static void showCheckOut() { Form existingForm = Display.getInstance().getCurrent(); CheckoutForm f = new CheckoutForm(existingForm); f.oldTransition = existingForm.getTransitionOutAnimator(); Image background = Image.createImage(existingForm.getWidth(), existingForm.getHeight()); Graphics g = background.getGraphics(); existingForm.paintComponent(g, true); g.setAlpha(150); g.setColor(0); g.fillRect(0, 0, background.getWidth(), background.getHeight()); background = Display.getInstance().gaussianBlurImage(background, 10); f.getUnselectedStyle().setBgImage(background); f.getUnselectedStyle().setBackgroundType(BACKGROUND_IMAGE_SCALED_FILL); f.setTransitionOutAnimator(CommonTransitions.createUncover( CommonTransitions.SLIDE_VERTICAL, true, 200)); existingForm.setTransitionOutAnimator(CommonTransitions.createCover( CommonTransitions.SLIDE_VERTICAL, false, 200)); f.show(); }
  • 9. CheckoutForm private CheckoutForm(Form previous) { super(new BorderLayout()); Button x = new Button("", "Title"); FontImage.setMaterialIcon(x, FontImage.MATERIAL_CLOSE); x.addActionListener(e -> { previous.showBack(); previous.setTransitionOutAnimator(oldTransition); });
  • 10. MainMenuForm private Container createDishContainer(Dish dish) { TextArea ta = new TextArea(dish.description.get(), 3, 80); ta.setEditable(false); ta.setFocusable(false); ta.setGrowByContent(false); ta.setUIID("DishListBody"); Button order = new Button("Order " + Restaurant.getInstance(). formatCurrency(dish.price.get()), "AddToOrderButton"); Button moreInfo = new Button("More Info", "MoreInfoButton"); moreInfo.addActionListener(e -> { DishViewForm dvf = new DishViewForm(dish); MorphTransition mt = MorphTransition.create(400); mt.morph("thumb" + dish.id.get(), "backgroundImage"); Transition original = getTransitionOutAnimator(); setTransitionOutAnimator(mt); CommonTransitions uncover = CommonTransitions.createUncover( CommonTransitions.SLIDE_VERTICAL, true, 350); dvf.setTransitionOutAnimator(uncover); dvf.addShowListener(ee -> setTransitionOutAnimator(original)); dvf.show(); });