Skip to main content

Animation bug: Trigger with autoreverse isn't working correct

3 replies [Last post]
mortennobel
Offline
Joined: 2004-11-03
Points: 0

The autoreverse feature of the trigger isn't working correct.

I have created a small applet to show the problem:

The applet have a MouseTrigger that listens for 'enter' events. When the mouse enters the applet, the background turns from white into black. And when the mouse leaves the applet, the background turns from black into white.

My problem is if the mouse leaves the applet when the color of the applet is between white and black, then the background turns into black and fades into white. :-(

In other words:
On mouse enter event
fraction
0.00
0.01
...
0.50
On mouse exit event
1.00
0.99
..
0.00

It this the intended behavior of autoreverse ?

Kind regards,
Morten

public class AnimationTest extends JApplet {
public void init(){
Color bgColorSrc = Color.white;
Color bgColorDest = Color.black;
Container contentPane = getContentPane();
contentPane.setBackground(bgColorSrc);
Clip clip = Clip.create(5000,contentPane,"background",bgColorSrc,bgColorDest);
clip.addTarget(new TimingTargetAdapter(){
public void timingEvent(float fraction, long duration) {
System.out.println("fraction = " + fraction);
}
});
clip.setInterpolator(Interpolators.getLinearInstance());
contentPane.addMouseListener(new MouseTrigger(clip, MouseTriggerEvent.ENTER,true));
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mortennobel
Offline
Joined: 2004-11-03
Points: 0

Hi Chris

Awesome! It works absolutely perfect!

Kind regards,
Morten

Chris Campbell

Hi Morten,

I've just checked in some changes to add proper autoReverse behavior to
Clip, and I've also updated the various Triggers accordingly. There is
no longer an autoReverse parameter to the Trigger constructors; use
Clip.setAutoReverse(true) instead for the Clip that is passed to the
Trigger, if such behavior is desired.

This means that your testcase will need to change from this:

contentPane.addMouseListener(new MouseTrigger(clip,
MouseTriggerEvent.ENTER,true));

to this:

clip.setAutoReverse(true);
contentPane.addMouseListener(new MouseTrigger(clip,
MouseTriggerEvent.ENTER));

You can also refer to the new demo.anim.TriggerTest demo in the
scenegraph-demos project.

Let me know if there are any issues.

Thanks,
Chris

scenario@javadesktop.org wrote:
> The autoreverse feature of the trigger isn't working correct.
>
> I have created a small applet to show the problem:
>
> The applet have a MouseTrigger that listens for 'enter' events. When the mouse enters the applet, the background turns from white into black. And when the mouse leaves the applet, the background turns from black into white.
>
> My problem is if the mouse leaves the applet when the color of the applet is between white and black, then the background turns into black and fades into white. :-(
>
> In other words:
> On mouse enter event
> fraction
> 0.00
> 0.01
> ...
> 0.50
> On mouse exit event
> 1.00
> 0.99
> ..
> 0.00
>
> It this the intended behavior of autoreverse ?
>
> Kind regards,
> Morten
>
> public class AnimationTest extends JApplet {
> public void init(){
> Color bgColorSrc = Color.white;
> Color bgColorDest = Color.black;
> Container contentPane = getContentPane();
> contentPane.setBackground(bgColorSrc);
> Clip clip = Clip.create(5000,contentPane,"background",bgColorSrc,bgColorDest);
> clip.addTarget(new TimingTargetAdapter(){
> public void timingEvent(float fraction, long duration) {
> System.out.println("fraction = " + fraction);
> }
> });
> clip.setInterpolator(Interpolators.getLinearInstance());
> contentPane.addMouseListener(new MouseTrigger(clip, MouseTriggerEvent.ENTER,true));
> }
> }
> [Message sent by forum member 'mortennobel' (mortennobel)]
>
> http://forums.java.net/jive/thread.jspa?messageID=268541
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

Chris Campbell

scenario@javadesktop.org wrote:
> The autoreverse feature of the trigger isn't working correct.
>
> I have created a small applet to show the problem:
>
> The applet have a MouseTrigger that listens for 'enter' events. When the mouse enters the applet, the background turns from white into black. And when the mouse leaves the applet, the background turns from black into white.
>
> My problem is if the mouse leaves the applet when the color of the applet is between white and black, then the background turns into black and fades into white. :-(
>
> In other words:
> On mouse enter event
> fraction
> 0.00
> 0.01
> ...
> 0.50
> On mouse exit event
> 1.00
> 0.99
> ..
> 0.00
>
> It this the intended behavior of autoreverse ?
>

No, this is a bug. Support for auto-reverse is admittedly half-baked,
and will need to be cleaned up in Scenario soon. I'll file a bug report.

Thanks,
Chris

> Kind regards,
> Morten
>
> public class AnimationTest extends JApplet {
> public void init(){
> Color bgColorSrc = Color.white;
> Color bgColorDest = Color.black;
> Container contentPane = getContentPane();
> contentPane.setBackground(bgColorSrc);
> Clip clip = Clip.create(5000,contentPane,"background",bgColorSrc,bgColorDest);
> clip.addTarget(new TimingTargetAdapter(){
> public void timingEvent(float fraction, long duration) {
> System.out.println("fraction = " + fraction);
> }
> });
> clip.setInterpolator(Interpolators.getLinearInstance());
> contentPane.addMouseListener(new MouseTrigger(clip, MouseTriggerEvent.ENTER,true));
> }
> }
> [Message sent by forum member 'mortennobel' (mortennobel)]
>
> http://forums.java.net/jive/thread.jspa?messageID=268541
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net