This is the code that produces the animation
Let's review the code step by step.
- A Model class is defined with two observable properties (s & ra). Creating observable beans with @Bindable is so easy I cannot do it in a different manner now
- A timeline is set to interpolate the model's properties. It will last for 4 seconds and will loop forever in a 'reverse' cycle. This means once the s property reaches 2.0 it will be animated back to 0.5 then back to 2.0, and so on.
- A closure named mouseHandler is defined, it will be used to pause/resume the animation. This will be triggered by clicking on the animated shape.
- The main content of the script follows. It is a JPanel that contains a GfxCanvas (GfxPanel was renamed to GfxCanvas) and a JLabel. The canvas contains all gfx nodes. Notice that the group's scaleX, scaleY and rotateAngle (sx, sy, and ra) properties are bound to the model's properties, using the short binding syntax. The mouseHandler closure is assigned to the group's mouseClicked property.
- Lastly, a repaint timeline is set on the canvas widget.
However, this is not yet possible with TridentBuilder 0.1, but I'd love to have that syntax finished before its next release.
Keep on Groovying!