I've got one more Canvas/2D graphics related example to share with you (for now) before we switch gears (no pun intended) to another topic. This example from PlanetJFX is an analog clock created by Chris Oliver, the founder of JavaFX Script, with some additions by Dean Iverson.
This clock example utilizes several of the concepts that are demonstrated in the JavaFX Canvas tutorial (see the Release Your Inner Artist post for instructions on running this very cool tutorial).
Just cut and paste the code from the analog clock link above into JavaFXPad. As a refresher, to run JavaFXPad directly from the Internet, see the instructions in the first post in this blog (it's really quick and easy). To install and run JavaFXPad on your machine, see this post.
As you run and examine the code in this example, the following sections of the JavaFX Canvas tutorial will help you understand the main concepts used:
- User-Defined Graphics Objects: In JavaFX Script, you can create your own graphical custom components by sub-classing CompositeNode. The clock example uses this technique so that it can be used as a component within a larger JavaFX Script application.
- Groups
- Transformations
- Animation
- Shapes
Have fun with this example!
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications
Comments