Tag Archives: Animation

JavaFx – Exciting 2.0

Yesterday I received an e-mail from javafx4you with the following title : “JavaFx 2.0 beta is now available for download”. I had only a few moment to process this information because I already had plans, but I take time to download the beta version and install it on my computer.

After 2 minutes of coding I wrote a simple Stage just to see it running before leaving, but unfortunately my JDK version (64bit) did not fit the JavaFx jar (only 32 bit available for now). So I Took some time to download the 32 bit version of the last JDK… and Yes, the code did work !

So I go on and took time to write the full demo code availabe here.

The result is a cool cicle animation and blur effect stage. It seems to be very powerfull as the animation are really easy to describe and run… And graphical effects seem to be easy to compose.

I then tried to play with the event and add a mouseEnter mouseExited listener on each circle of the scene. The API is very close to Swing listeners, swing guy will not be very surprise, except that it seems to be the same approach than Android API, it is not a addMouseListener() method but a setOnMouseEntered(). So not a list of observer but a single observer ? I tried to add two different listener, and only the second one was called !

Moreover, JavaFx follow the same Single Threading rule than Swing. When in swing you use SwingUtilities.invokeLater() you shall now use Platform.runLater() for JavaFx. Swing/JavaFx integration seems to be managed through the javafx.embed.JFXPanel component that is a swing component. So integrating JavaFx into Swing is done ! Don’t forget to transfer event from Swing Thread to JavaFx Thread to respect the coding rule !

Now new experience can start, with easier graphic manipulation. I hope I will have time to try things again.

LoNee

Swing Animation – Fifth Shot

A quick post to propose an upgrade of the AnimatedPanel that provide a new AnimationListener interface that allow to listen to AnimationEvent. For now there is two main event type, one for animationStarted() and one for animationFinished(). You will find in the AnimationEvent the source objet (the AnimatedPanel) and the AnimationState that indicates if it is a ShowingAnimation or HidingAnimation.

I have also corrected some bugs. Previous release use a single snapshot version of the panel to perform the animation. Now a new snapshot is done every time animation starts. It is no longer allowed to perform double showing animation or hiding animation.

Many thanks to NPI that used for the first time my libs on a real business application. I appreciate the new features you proposed and how you give me feedback on the existing bugs 😉

Coming soon a release that contains all the swing animation I wrote where animation event will be included for all components.

LoNee

Swing Animation – Fourth shot

A quick post to notify an update of the AnimatedTabbedPane. Writing some new animations for this swing component makes me realize that animations shall be custom writable, and i might try to write some code that allow to easily create animated visual beans, without starting from scratch all the time…

I will not describe the new animations of the tabbed pane here, you’ll just have to play with the demo !

Jar with code and example to launch available on download page !

Lonee

Swing Animation – Third shot

Still playing with swing component and animation, I tried to make a generic panel that propose animations on visibility change. Here is the AnimatedPanel swing component.

Note AnimatedPanel inherits from JPanel. It only offers extra methods setAnimationType(AnimationType animationType) with the following possibilities :

  • None : no animation, it works like a classic JPanel
  • SlideAnimationFromBackground : a sliding animation where the panel arrives from the background
  • SlideAnimationFromLeft : a sliding animation where the panel arrives from the left
  • SlideAnimationFromRight : a sliding animation where the panel arrives from the right
  • SlideAnimationFromTop : a sliding animation where the panel arrives from the top
  • SlideAnimationFromBottom : a sliding animation where the panel arrives from the bottom
  • Custom : use the setCustomAnimation(Animation animation) method to propose your own animation implementation !

Here is the interface contract an animation must match:
public AffineTransform getAnimationAffineTransform(
AffineTransform affineTransform, float animationStep,
AnimatedPanel animatedPanel);

In fact it has to modify and return the affineTransform. It shall use the animationStep (0.0<=step<=1.0) and maybe the animatedPanel informations (width, height ?) to do the affineTransform update.

It also offers a setTransparencyOnAnimation(boolean use) method in order to use a panel fading effect on visibility change.

You can find a custom animation exemple in the test code.

Hope you will enjoy this.

Jar with code and example to launch available on download page !

Lonee