Java Animation V2

0 views
Skip to first unread message

Scottie Marberry

unread,
Aug 5, 2024, 5:25:07 AM8/5/24
to patlemico
Im trying to make an animation of a red oval that will move to the right of the screen. But it just draws the oval. I don't know what I'm doing wrong and I literally can't find anything about how to do this. Any help would be awesome, thanks.

Animation is hard, I mean, really good animation is hard. There is a lot of theory which goes into creating good animation, things like easement, anticipation, squish ... I could go on, but I'm boring myself.


The point is, simply incrementing a value (AKA linear progression) is a poor approach to animation. If the system is slow, busy or for some other reason isn't keeping up, the animation will suffer because of it (stuttering, pauses, etc).


A "better" solution is to use a time based progression. That is, you specify the amount of time it will take to move from the current state to it's new state and then continuously loop and update the state until you run out of time.


In most cases, you should avoid using Canvas, for many of the reasons mentioned above, but one of the reasons you might consider using Canvas is if you want to take full control over the painting process. You might do this if you want to create a complex game which and you want to get the best possible performance out of the rendering pipeline.


If you're able to use classes from Swing, the javax.swing.Timer class is very useful for animation. It executes your callback on the AWT thread, and therefore means that you don't have to take special measures to ensure thread safety.


Here's an example using javax.swing.Timer (assuming Java 8 or later). Note that all of the animation logic is in the ActionListener attached to the Timer, so the overridden update method has been removed:


I'm attempting to code a simple animation or physics example in a Java Swing application. I have the actual windows application open and working, but I can't figure out how to actually draw my shapes, and how I'd format the code for calculations between frames, that sort of stuff.


So I have some blank space above my button where I'd like to draw maybe a square or circle moving across the screen to start off with, once I get that down I can start getting into the more advanced stuff. Any hints on how to do that would be appriciated :D


So you've overridden actionPerformed, so you know what an @Override is. As you'll notice from the ActionListener, you never actually explicitly call actionPerformed, but whatever you put in the there, still get's used. That's because the ActionListener implicitly call it for you.


The same is true with painting. In the Swing painting process, there is a paint chain that Swing uses to paint components. Along the way paint is called somewhere. So just like actionPerformed, you can override paint and it will get implicitly called for you.


The Graphics object passed to the method is the graphics context that Swing will use for the painting. You can look at the Graphics API to see the methods you can use. You can use drawOval to draw a circle


Now here's the thing. You don't actually want to override paint. In the tutorials linked above, some of the examples will use applets and override paint, but you shouldn'y paint on top level containers like JFrame or JApplet. Instead paint on a JPanel or JComponent and just add it the JFrame. When you do paint on JPanel or JComponent, you'll instead override paintComponent (which also gets called along the paint chain), instead of paint


You see how I used variables for the drawOval method. The x is the x location from the top-let of the screen, and y and the y point. width and height are width and height of the circle. The great thing about using variables is that their values can be changed at runtime.


The delay is the milliseconds to delay each call to the listener. The listener will have your actionPerformed call back that will do what's inside, every delay milliseconds. So what you can do, is just change the x from the drawOval and repaint(), and it will animate. Something like


Which are all examples of animation engines in Swing. While I prefer the Timing Framework as it provides me with a lower level API, this is a personal opinion. Both Trident and the JUWE seem to be geared more towards component/property based animation (which the Timing Framework can do if you want to build some of the feature sets up)


It works fine, it's just that I looks a little choppy. The motion for the analogous example with a draggable square (see Draggable Components in Java Swing) appears much smoother so I believe there should be a way to make this look better. Any suggestions would be much appreciated.


You are entering a tricky area for the Swing library. However, nothing is impossible. You can create such animation using Timer, but I really recommend you do not do it. So you can move components as best as possible, I suggest you make use of the Timing Framework library.


This was one reason that the JavaFX technology came into our hands. With such technology, we can concern ourselves with less stuff (deploy the application in different programs) and do much more (including the one you're having trouble). Consider migrating to this technology. So you see what JavaFX can do, download the demo program Ensemble. If you gain interest in this technology, I suggest you start learning it here. If you don't want to download the demo, you can also find videos on the internet that demonstrate how it works.


If this alternative is too laborious for you, check out the link I gave you about the Timing Framework library. There you will find examples of Java code that make smooth animations on various Swing things with a high performance. To learn how to use this library, I suggest you to get the book Filthy Rich Clients, written by Chet Haase and Romain Guy. Although the book is out of date and things have been changed in the library code, you can get updated on the library website. As I said earlier, download the library, and also download the code samples. With time, you will end up doing what you want in the best possible way.


Processing is an environment that is built as a plugin for programming animations as well as visual applications, with good and easy interaction with the user.It is written in Java and can be treated as a plugin that contains support ie. An API with functions for creating animations and visual applications. It is based on writing a sketch (skatch).


I was asked to find out if there is a way to exprt a Maya file to a Java 3D format (they tell me JSON is the name, with the extension .js ). I was able to find a python script that take an OBJ file and exports it to .js, and which appears to work. Unfortunately OBJ format does not support animation, and JSON does, so this script is not useful to me. I looked everywhere but I couldn't find anything usable.


Here are my questions: has anyone developed a MEL or Python script to export a maya skin animation to this Java 3D format? Is there a plug-in that accomplishes the same thing? Is there a stand-alone application that converts FBX files to JSON format?


All - looking for some direction on the use of Oracle Java by Adobe in products such as Animate. The version is licenseable. With Oracle's recent change to an enterprise employee metric, how is this being addressed by Adobe or is there alternate Java products to use? A single installation of Adobe Animate (or another Creative Suite product that uses Java) could cost a significant amount of money for any organization. I have not been able to find any clear documentation on the web on Adobe's stance. Any help or guidance would be extremely appreciated.


We have tried to get information regarding this for some months now. Since our LSP wasnt able to get clarifying information from Adobe, I recently raised a support case.

We need official documents ensuring the rights to install and use Java SE (Adobe) is included in Adobe Creative Cloud for Teams

c:\program files\adobe\adobe animate 2023\jre\bin\javaw.exe

c:\program files\adobe\adobe animate 2023\jre\bin\java.exe


The right to install and use Oracle Java SE requires Java SE Universal Subscription for all users in our organisation - any prohibited installation puts our organisation at very high at compliance risks.


@Ray29604625mejq yes, it seems too risky and surprising that Adobe are packaging new versions of Oracle Java for Animate without underpinning clarity on license. Have you removed Animate now and / or replaced with different, third party JRE?


See the latest response below. I really dont have the time to investigate this any further - our organization wont allow any users to install Animate as long as there is no better description on the terms.


The information refers to the older version of Java, which is subject to the Binary Code License for Java SE Platform Products (for releases prior to April 2019 for JDK 10 and earlier) and thus does not cover the current scenario, where Adobe distributes with Java SE version 11.


This is regarding the query you had regarding Java licensing document. We have checked with all the relevant teams available in Adobe however we do not have any public facing document that we can share with you.


Adobe, the Adobe logo, Adobe Marketing Cloud, and the Adobe Marketing Cloud logo are either registered trademarks of Adobe in the United States and/or other countries. 2019. Adobe. All rights reserved. To manage your email subscription settings, click here.


Thank you for sharing. Am I reading this correctly that Adobe is expecting that the customer license the embedded Oracle Java (since it is v11)? This pretty much makes organizations forced to look for alternative applications (assuming that I am understanding the response correctly).


Please find the screenshot attached for the section of agreement which you can refer to . Information referred in notice indicates a separate Agreement. Please note that Adobe and Oracle has executed a private written agreement BLRA, separate from OTN, which provides for redistribution rights albeit certain restrictions. Adobe also has support as per roadmap Oracle Java SE Support Roadmap which covers Java Se 11 release. Please let us know specific concerns so that we can address them accordingly.

3a8082e126
Reply all
Reply to author
Forward
0 new messages