-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] Advanced JavaFX content #6
Comments
Hi, I recently wrote some introduction to |
Cool! Care to share and allow us to review the content to see if it'll work? |
Should I share it here before starting to make a PR? |
here works! Or you can send to [email protected] |
Ok so I am still unsure about the structure, but I want to at least mention every concept because this package is not that big. It currently includes some GIFs and screenshots because it was initially intended to share on discord, this would need some updates. The transition description might need some updates as well, because they are currently just copied from the Javadoc description. Introduction to javafx.animationThe AnimationThe KeyValue.java
KeyFrame
Timeline
Warning: A running Timeline is being referenced from the FX runtime. Infinite Timeline might result in a memory leak if not stopped properly. All the objects with animated properties would not be garbage collected. ExampleThis one basically moves the Circle 200px in x direction over the duration of 5 seconds: Circle object = new Circle(50, 150, 10, Color.GREEN);
KeyValue x = new KeyValue(object.translateXProperty(), 200);
KeyFrame frame = new KeyFrame(Duration.seconds(5), x);
Timeline timeline = new Timeline(frame);
timeline.play(); TransitionThe
InterpolatorThe
Here is a visualization of the Interpolator using the example from Timeline: DiscreteLinearEase InEase OutEase BothAdditionally, there are two static factory methods for SPLINE and TANGENT interpolation. ConclusionThe |
Hey @SquidXTV, thank you for the proposal! I really like the clear and well-structured approach to the topic. I didn't know anything about it before and now feel like I have a basic understanding; definitely enough to start creating some animations. 😃
|
Thanks a lot for the feedback, I can just agree. :D I would structure the explanation for each built-in I am not sure about the extra GIFs, I definitely would like to add more, but if I create an example for just I am also unsure about the Java Docs screenshots. I included them because the initial idea was to post it on discord. Should I do that differently for the website? If so, how would I do it? |
My progress for today. Still missing some stuff. I now included most of the built-in transition examples. It kinda feels too much though, I might drop some of them in the future. What do you think about it? Introduction to javafx.animationThe AnimationThe KeyValue.java
KeyFrame
Timeline
Warning: A running Timeline is being referenced from the FX runtime. Infinite Timeline might result in a memory leak if not stopped properly. All the objects with animated properties would not be garbage collected. ExampleThis one basically moves the Circle 200px in x direction over the duration of 5 seconds: Circle object = new Circle(50, 150, 10, Color.GREEN);
KeyValue x = new KeyValue(object.translateXProperty(), 200);
KeyFrame frame = new KeyFrame(Duration.seconds(5), x);
Timeline timeline = new Timeline(frame);
timeline.play(); TransitionThe
Note: By default, all transitions, excluding Here is a visualization of most built-in transitions: Fade TransitionFadeTransition transition = new FadeTransition(Duration.seconds(5), object);
transition.setFromValue(1.0);
transition.setToValue(0);
transition.setInterpolator(Interpolator.LINEAR); Fill TransitionFillTransition transition = new FillTransition(Duration.seconds(5), object);
transition.setFromValue(Color.GREEN);
transition.setToValue(Color.BLACK);
transition.setInterpolator(Interpolator.LINEAR); Path TransitionPath path = new Path();
path.getElements().add(new MoveTo(50, 50)); // starting point
path.getElements().add(new LineTo(250, 250));
PathTransition transition = new PathTransition(Duration.seconds(5), path, object);
transition.setInterpolator(Interpolator.LINEAR); Rotate TransitionRotateTransition transition = new RotateTransition(Duration.seconds(5), object);
transition.setFromAngle(0);
transition.setToAngle(360);
transition.setInterpolator(Interpolator.LINEAR); Scale TransitionScaleTransition transition = new ScaleTransition(Duration.seconds(5), object);
transition.setToX(0.1);
transition.setToY(0.1);
transition.setInterpolator(Interpolator.LINEAR); Stroke TransitionStrokeTransition transition = new StrokeTransition(Duration.seconds(5), object);
transition.setFromValue(Color.GREEN);
transition.setToValue(Color.BLACK);
transition.setInterpolator(Interpolator.LINEAR); Translate TransitionTranslateTransition transition = new TranslateTransition(Duration.seconds(5), object);
transition.setToX(200);
transition.setToY(200);
transition.setInterpolator(Interpolator.LINEAR); InterpolatorThe
Here is a visualization of the Interpolator using the example from Timeline: DiscreteLinearEase InEase OutEase BothAdditionally, there are two static factory methods for SPLINE and TANGENT interpolation. ConclusionThe |
Hey @SquidXTV, sorry that I didn't get back to you sooner. I like the addition of code and animations for the transitions. My other points above still apply, though, right? And I came up with two more changes that I think would make this even better:
Yeah, those work better in Discord than on dev.java. 😉 I think the sections containing them could do with a bit more explanation and maybe an example or two, anyway. There's no need to list, e.g., all constructors of a class but seeing how one or two of them work can be helpful. |
All good, didn't have the time myself. Going to improve it over the next days. |
Ok I have done some bigger revamp of the structure and changes to the text in general, Introduction to javafx.animationThe javafx.animation package in JavaFX offers a simple framework for creating animations and transitions in a JavaFX application. It operates on the principle of WritableValue<T> which are used across JavaFX. It additionally provides a variety of built-in transitions for common effects, support for parallel and sequential transitions, and the ability to handle events upon animation completion. I will go through all types of animations, including AnimationTimerThe AnimationTimer abstract class provides the lowest level option to create an animation. The Note that the handle implementation will be called on the JavaFX Application Thread and thus shouldn't do heavy computations. AnimationThe Animation abstract class provides the core functionality of all other animations. An
Additionally, it provides multiple TransitionThe Transition abstract class serves as the foundational class for all transitions, presenting a common form of JavaFX provides a variety of built-in transitions:
Note: By default, all transitions, excluding Here is a visualization of most built-in transitions: Fade TransitionFadeTransition transition = new FadeTransition(Duration.seconds(5), object);
transition.setFromValue(1.0);
transition.setToValue(0);
transition.setInterpolator(Interpolator.LINEAR); Fill TransitionFillTransition transition = new FillTransition(Duration.seconds(5), object);
transition.setFromValue(Color.GREEN);
transition.setToValue(Color.BLACK);
transition.setInterpolator(Interpolator.LINEAR); Path TransitionPath path = new Path();
path.getElements().add(new MoveTo(50, 50)); // starting point
path.getElements().add(new LineTo(250, 250));
PathTransition transition = new PathTransition(Duration.seconds(5), path, object);
transition.setInterpolator(Interpolator.LINEAR); Rotate TransitionRotateTransition transition = new RotateTransition(Duration.seconds(5), object);
transition.setFromAngle(0);
transition.setToAngle(360);
transition.setInterpolator(Interpolator.LINEAR); Scale TransitionScaleTransition transition = new ScaleTransition(Duration.seconds(5), object);
transition.setToX(0.1);
transition.setToY(0.1);
transition.setInterpolator(Interpolator.LINEAR); Stroke TransitionStrokeTransition transition = new StrokeTransition(Duration.seconds(5), object);
transition.setFromValue(Color.GREEN);
transition.setToValue(Color.BLACK);
transition.setInterpolator(Interpolator.LINEAR); Translate TransitionTranslateTransition transition = new TranslateTransition(Duration.seconds(5), object);
transition.setToX(200);
transition.setToY(200);
transition.setInterpolator(Interpolator.LINEAR); TimelineA Timeline is used to define a free form It consists of a sequential series of
KeyFrameA KeyFrame represents a specific moment in an animation sequence (Cue Point) and comprises a collection of A KeyFrame can have a name which then can be used to identify this KeyValueA KeyValue establishes a mapping between a ExampleThis example of Circle object = new Circle(50, 150, 10, Color.GREEN);
KeyValue x = new KeyValue(object.translateXProperty(), 200);
KeyFrame frame = new KeyFrame(Duration.seconds(5), x);
Timeline timeline = new Timeline(frame);
timeline.play(); InterpolatorThe Interpolator abstract class defines the rate of change at which values change over time, influencing the smoothness of animations. It provides several built-in implementations:
Additionally, there are two static factory methods for SPLINE and TANGENT interpolation. Here is a visualization of the Interpolator using the example from Timeline: DiscreteLinearEase InEase OutEase BothConclusionThe |
As somebody who knows the JavaFX basics but not the animation package, I'm pretty much your target audience. On closer reading, I struggle to understand the relation between For the fade example (since it's the first one): Can you show a bit more of the surrounding code, so readers can understand how exactly they can use a transition? As far as I can tell, the Overall, put yourself in the shoes of somebody who doesn't know the API at all. For every piece of information: Does the reader already know everything they need to understand it? Do they understand how they're supposed to use the information (e.g. as prerequisite for what comes next or to use it as explained?). When you've changed the text accordingly, feel free to open a PR, so we can do a more detailed preview. (I'll be out of office until early May, though, so no need to rush. 😉) |
Thanks for the feedback. |
ok great. when you're ready, go ahead and raise a PR! We'll get it reviewed quickly and try and bring it in for a landing by the end of May if that works for you. Good luck on finals! |
Hi, I have one more question, where should I place the content like the markdown and GIFs? I would place the GIFs into the |
Ya put into Thank you! |
Request Issue
No response
Website Section
No response
Proposal Details
No response
Author References
No response
The text was updated successfully, but these errors were encountered: