:ocean: Implicit animations for JavaFX

Overview

animated

animated introduces implicit animations, a completely new concept in JavaFX strongly inspired by Flutter's animations and motion widgets.

Index

  1. Getting started
  2. Implicit animations
  3. Animated containers
  4. Animated switchers

Getting started

Maven:

<repositories>
    <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </repository>
</repositories>
...
<dependency>
    <groupId>com.github.iAmGio</groupId>
    <artifactId>animated</artifactId>
    <version>0.3.0</version>
</dependency>

Gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.iAmGio:animated:0.3.0'
}



Implicit animations

Forget about timelines, explicit animations and other stuff that pollutes your code. This animation system will provide versatility to your code and interface.

Demo
Code

Animated<Double> animated = new Animated<>(child, PropertyWrapper.of(child.opacityProperty()));
root.getChildren().add(animated);

// Later...
child.setOpacity(0.5); // Plays the transition

This approach instantiates an Animated node that contains one child and is bound to a property.
Now that we have set an animated bound, we'll see that child.setOpacity(someValue) creates a transition between the initial and final value.

PropertyWrapper.of automatically finds out the best kind of wrapper for a given property.
Currently supported wrappers are DoublePropertyWrapper and ObjectPropertyWrapper<T>.

There are some pre-made animated nodes that take the child as an argument as well (list will expand):

  • AnimatedBlur
  • AnimatedDropShadow
  • AnimatedColor (shapes only)
  • AnimatedOpacity
  • AnimatedPosition
  • AnimatedRotation
  • AnimatedSize
  • AnimatedScale

Multiple animations at once

In case you need to animate more than one property of a single node, AnimatedMulti comes to the rescue. At this time it only takes properties as arguments, so it won't be possible to use pre-made nodes (list above).

AnimatedMulti animated = new AnimatedMulti(child,
    PropertyWrapper.of(child.opacityProperty()),
    PropertyWrapper.of(child.prefWidthProperty()),
    PropertyWrapper.of(child.prefHeightProperty())
);
root.getChildren().add(animated);

// Later...
child.setOpacity(0.5);   // Plays the transition
child.setPrefWidth(100); // Plays the transition
child.setPrefHeight(50); // Plays the transition

Custom animations

The default animation is linear and lasts 1 second. It can be customized by calling either withSettings(AnimationSettings settings) or custom(Function<AnimationSettings, AnimationSettings> settings), both methods available on property wrappers and animated nodes.

Examples:

AnimatedOpacity animated = new AnimatedOpacity(child)
    .custom(settings -> settings.withDuration(Duration.seconds(.5)).withCurve(Curve.EASE_IN_OUT));
AnimatedMulti animated = new AnimatedMulti(child,
    PropertyWrapper.of(child.opacityProperty())
        .custom(settings -> settings.withDuration(Duration.seconds(.8))),
    PropertyWrapper.of(child.rotateProperty())
        .custom(settings -> settings.withDuration(Duration.seconds(.5)),
).custom(settings -> settings.withCurve(Curve.EASE_OUT)); // 'custom' applies only these settings to the properties.
                                                          // 'withSettings' overrides all instead.
root.getChildren().add(animated);



Animated containers

animated provides custom implementations of VBox and HBox that animate their content whenever their children are affected by a change.
This feature is based on animations from AnimateFX.

Demo
Code

Constructors:

  • Animation in, Animation out wraps two AnimateFX objects into customizable animated objects;
  • AnimationFX in, AnimationFX out takes two raw AnimateFX animations that cannot be customized;
  • AnimationPair animation takes a pair of animations, mostly used with pre-made pairs (e.g. AnimationPair.fade()).

pause() and resume() allow disabling/enabling animations so that you can switch back to the regular implementation and forth.

Example:

AnimatedVBox vBox = new AnimatedVBox(AnimationPair.fade());

// Later...
vBox.getChildren().add(someNode);    // someNode fades in
vBox.getChildren().remove(someNode); // someNode fades out



Animated switchers

The library also provides an AnimatedSwitcher node that creates a transition whenever its child changes.
As for animated containers, this feature relies on AnimateFX.

Demo
Code

See animated containers for information about constructors.
Right after the instantiation, calling of(Node child) will set the initial child without any animation played.

Example:

AnimatedSwitcher switcher = new AnimatedSwitcher(
    new Animation(new FadeInDown()).setSpeed(2), 
    new Animation(new FadeOutDown()).setSpeed(1.5)
).of(firstChild);
root.getChildren().add(switcher);

// Later...
switcher.setChild(secondChild); // Plays the transition



Other examples

Shadow
Drop shadows + switcher

You might also like...

Allow runtime modification of JavaFX CSS

Allow runtime modification of JavaFX CSS

cssfx ⚠ WARNING ⚠ In version 11.3.0 we have relocated & refactored the project. maven groupId has been changed to fr.brouillard.oss java module name h

Jan 2, 2023

A JavaFX UI framework to create fully customized undecorated windows

A JavaFX UI framework to create fully customized undecorated windows

CustomStage A JavaFX undecorated stage which can fully be customized Donations If this project is helpful to you and love my work and feel like showin

Jan 6, 2023

MDI components for JavaFX

MDI components for JavaFX

DesktopPaneFX DesktopPaneFX is a JavaFX version of Swing’s JDesktopPane which can be used as a container for individual "child" similar to JInternalFr

Sep 23, 2022

Efficient VirtualFlow for JavaFX

Flowless Efficient VirtualFlow for JavaFX. VirtualFlow is a layout container that lays out cells in a vertical or horizontal flow. The main feature of

Nov 24, 2022

A framework for easily creating forms for a JavaFX UI.

A framework for easily creating forms for a JavaFX UI.

FormsFX Forms for business application made easy. Creating forms in Java has never been this easy! Maven To use this framework as part of your Maven b

Dec 30, 2022

:icecream: iOS frosty/translucent effect to JavaFX

:icecream: iOS frosty/translucent effect to JavaFX

FroXty is JavaFX library which replicates the famous iOS translucent effect with ease. Set-up FroXty can be imported into your project either by downl

Dec 11, 2022

💠 Undecorated JavaFX Scene with implemented move, resize, minimise, maximise, close and Windows Aero Snap controls.

💠 Undecorated JavaFX Scene with implemented move, resize, minimise, maximise, close and Windows Aero Snap controls.

Support me joining PI Network app with invitation code AlexKent FX-BorderlessScene ( Library ) 💠 Undecorated JavaFX Scene with implemented move, resi

Jan 4, 2023

Dynamic JavaFX form generation

FXForm 2 Stop coding forms: FXForm 2 can do it for you! About FXForm2 is a library providing automatic JavaFX form generation. How does it work? Write

Jan 9, 2023

A JavaFX library that allows Java2D code (Graphics2D) to be used to draw to a Canvas node.

A JavaFX library that allows Java2D code (Graphics2D) to be used to draw to a Canvas node.

FXGraphics2D Version 2.1, 3 October 2020. Overview FXGraphics2D is a free implementation of Java's Graphics2D API that targets the JavaFX Canvas. It m

Dec 31, 2022
Comments
  • Unsearchable name

    Unsearchable name

    Is it possible to change the library name? animated is a very generic name that is hard to get search results for, even when you search for animated javafx.

    question 
    opened by satsen 4
  •  add two node into AnimatedVBox at first and it cause a NullPointerException

    add two node into AnimatedVBox at first and it cause a NullPointerException

    I use the version 0.40

    I just add 2 node into the AnimatedVBox

    val contentVbox = AnimatedVBox(AnimationPair(null,BounceOutRight()))
            contentVbox.add(Text("hello"))
            contentVbox.add(Text("hell2o"))
    

    the exception is this

    java.lang.NullPointerException
    	at eu.iamgio.animated.AnimatedContainer$Handler.relocate(AnimatedContainer.java:180)
    	at eu.iamgio.animated.AnimatedContainer$Handler.lambda$null$0(AnimatedContainer.java:133)
    	at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:95)
    	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java)
    	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    	at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    	at java.lang.Thread.run(Thread.java:748)
    

    the image is this

    imageUrl: https://img2022.cnblogs.com/blog/1210268/202202/1210268-20220211160512243-1641573797.png

    by the way,the version of kotlin what you use is to high for my project :joy:

    I just use the kotlin 1.3.72 because of use the tornadofx framework

    good first issue 
    opened by stars-one 3
Releases(v0.7.0)
  • v0.7.0(Dec 17, 2022)

    • Animated containers are more optimized;
    • Stricter rules have been applied to constructors (AnimatedSwitcher, AnimatedContainer, AnimatedThemeSwitcher, ...) regarding null animations, that aren't accepted now;
    • Added the Animation.none() method (equivalent to new Animation(null) to represent a non-animation;
    • Implemented PropertyWrapper#registerAnimation as a preferred alternative to new AnimationProperty(propertyWrapper).register().
    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Oct 19, 2022)

    • AnimationProperty was moved out of the internal package as a valid, flexible alternative to Animated;
    • PropertyWrapper.of and the Kotlin extension function Property#animated now feature different overloads for each supported wrapper type in order to minimize ambiguity;
    • Added Automatic-Module-Name (#2);
    • Fixed some missing Javadocs due to syntax errors.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jul 31, 2022)

    • AnimatedThemeSwitcher is now completely implicit: it now directly affects the scene's stylesheets and does not need to be carried around;
    • Implemented AnimatedLabel to animate text changes;
    • Fixed a relocation issue with AnimatedHBox;
    • Added 9 more curves (expo, back and bounce for ease in/out/in-out) and add Curve#getCurveFunction;
    • Some classes that are intended to be used internally have been moved to the internal sub-package.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Jul 14, 2022)

  • v0.5.0(Mar 29, 2022)

    Fixed animations getting stuck if a bound property was updated by the user while an animation was playing.
    PropertyWrapper#createParallelProperty is now deprecated.

    Source code(tar.gz)
    Source code(zip)
  • v0.4.2(Mar 6, 2022)

    • Added two AnimationPair constructors to cover all the possible cases: (Animation in, AnimationFX out) and (AnimationFX out, Animation out);
    • Added a specific IllegalArgumentException error when passing one or more null values to AnimationPair (from #1);
    • Downgraded Kotlin from 1.5.31 to 1.4.31 for compatibility reasons (from #1).
    Source code(tar.gz)
    Source code(zip)
  • v0.4.1(Oct 21, 2021)

  • v0.4.0(Oct 12, 2021)

  • v0.3.0(Jun 9, 2021)

  • v0.2.1(Jun 8, 2021)

  • v0.2.0(Jun 6, 2021)

  • v0.1.0(May 31, 2021)

  • v0.0.1(Apr 20, 2021)

Owner
Giorgio Garofalo
A 19 years old mix of creativity, laziness, dedication and head in the clouds. I am also a UI designer and artist.
Giorgio Garofalo
CSS keyframe animation for JavaFX. Create animations like you would do with CSS.

JFXAnimation CSS keyframe animation for JavaFX. If you are using JFoenix JFXAnimation is included (currently version 1.0.0 only) Requirements JDK 8 an

Marcel Schlegel 49 Dec 28, 2022
A Java Animations.

Java Animations What is this? Animations is java util which can you help animate with some animation types. What i can do with it? You can use some de

Hogoshi 28 Dec 22, 2022
A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

⚡ A powerful & easy to use chart library for Android ⚡ Charts is the iOS version of this library Table of Contents Quick Start Gradle Maven Documentat

Philipp Jahoda 36k Jan 9, 2023
Tray Icon implementation for JavaFX applications. Say goodbye to using AWT's SystemTray icon, instead use a JavaFX Tray Icon.

FXTrayIcon Library intended for use in JavaFX applications that makes adding a System Tray icon easier. The FXTrayIcon class handles all the messy AWT

Dustin Redmond 248 Dec 30, 2022
Lib-Tile is a multi Maven project written in JavaFX and NetBeans IDE 8 and provides the functionalities to use and handle easily Tiles in your JavaFX application.

Lib-Tile Intention Lib-Tile is a multi Maven project written in JavaFX and NetBeans IDE and provides the functionalities to use and handle easily Tile

Peter Rogge 13 Apr 13, 2022
DataFX - is a JavaFX frameworks that provides additional features to create MVC based applications in JavaFX by providing routing and a context for CDI.

What you’ve stumbled upon here is a project that intends to make retrieving, massaging, populating, viewing, and editing data in JavaFX UI controls ea

Guigarage 110 Dec 29, 2022
Collection of Binding helpers for JavaFX(8)

Advanced-Bindings for JavaFX (8) advanced-bindings is a collection of useful helpers and custom binding implementations to simplify the development of

Manuel Mauky 63 Nov 19, 2022
Docking framework for JavaFX platform

Docking framework for JavaFX platform AnchorFX is a gratis and open source library for JavaFX to create graphical interfaces with docking features Anc

Alessio Vinerbi 197 Oct 15, 2022
BootstrapFX: Bootstrap for JavaFX

BootstrapFX BootstrapFX is a partial port of Twitter Bootstrap for JavaFX. It mainly provides a CSS stylesheet that closely resembles the original whi

Kordamp 810 Dec 28, 2022
A Java framework for creating sophisticated calendar views (JavaFX 8, 9, 10, and 11)

CalendarFX A Java framework for creating sophisticated calendar views based on JavaFX. A detailed developer manual can be found online: CalendarFX 8 D

DLSC Software & Consulting GmbH 660 Jan 6, 2023