Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

December/2024
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425 262728
293031    

[ Archives News
for 'Developers' ]

home > news > developers > add effects to the right container!

Add Effects to the right Container!

The Flubber application I described earlier has an old stop-watch style timer with second and minute hands: Making the clock hand move was trivial using value binding and a rotation transform on the hand graphics object: transforms: Rotate { angle: bind (360.0 / 60 * minutes) - 90.0 } Since we are using a binding expression, setting the minutes variable anywhere (and yes, assigning to it!) will cause the hand angle to be recomputed and the graphics updated. Anyway - once we had the clock moving, the first thing we wanted to do was improve the look of the clock by adding a drop shadow. That was trivial; all we had to add was this: effect: DropShadow { offsetX: 5 offsetY: 5 color: Color.BLACK radius: 10 } That looked pretty good: But look what happened when we let the timer run... Where is the light source? What's happening here is that the drop shadow is rotating with the hand. Not what we want. We were all learning JavaFX that day, so we hacked it, using the following code: effect: DropShadow { offsetX: bind Math.sin(Math.toRadians(handAngle + 45)) * 5.0 offsetY: bind Math.cos(Math.toRadians(handAngle + 45)) * 5.0 color: Color.BLACK radius: 10 } Now, the drop shadow offset moves along with the rotation such that the shadow always appears in the right place. It worked, and we moved on. Now that I understand JavaFX and the scenegraph a bit better I realize that this...


Date: April, 07 2009
Url: http://blogs.sun.com/tor/entry/add_effects_to_the_right


Others News

©2002-2019Java-Virtual-Machine.net website maker | best website maker | web editor | free icons | css menu maker