Issue Details (XML | Word | Printable)

Key: TIMINGFRAMEWORK-13
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: hallorant
Reporter: masterzen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
timingframework

PropertySetterToTimingTarget.begin should set the initial value (like if fraction was 0)

Created: 11/Apr/12 01:58 PM   Updated: 12/Apr/12 09:08 PM   Resolved: 12/Apr/12 07:35 PM
Component/s: core
Affects Version/s: trunk
Fix Version/s: 5.0 (swing, swt)

Time Tracking:
Not Specified

Tags:
Participants: hallorant and masterzen


 Description  « Hide

Current version of the PropertySetterToTimingTarget.begin.begin just initializes the KeyFrames.
Adding a call to:

timingEvent(source, 0.0);

in PropertySetterToTimingTarget.begin would be really helpful (especially in conjunction with http://java.net/jira/browse/TIMINGFRAMEWORK-12)



hallorant added a comment - 11/Apr/12 08:40 PM

Are you trying to get a fraction of 0.0 all the time? This isn't really the intent of the protocol – use the begin(). Perhaps I'm missing something.

The referenced bug is fixed.


masterzen added a comment - 11/Apr/12 09:34 PM

Actually the idea was to allow the example I pasted in the http://java.net/jira/browse/TIMINGFRAMEWORK-12 bug.

If the PropertySetter doesn't initialize the property during begin, but only during timingEvent, then other TimingTarget that might be dependent on this property value find uninitialized values.
In my sprite case, one of the TimingTarget begin makes the sprite visible during begin, but since the PropertySetter didn't set the "location", "angle" and "scale" property values during their respective begin, the sprite will appear in an undefined place.

To overcome this, I have to resort to this pattern:

Animator a = new Animator.Builder()
.addTarget(PropertySetter.getTarget(cardSprite, "alpha", 0.0, 1.0));
.addTarget(PropertySetter.getTarget(cardSprite, "location", src.getPosition(), dst.getPosition()))
.addTarget(PropertySetter.getTarget(cardSprite, "scale", src.getScale(), dst.getScale()))
.addTarget(new TimingTargetAdapter() {
	@Override
	public void timingEvent(Animator source, double fraction)
	{
		if (fraction == 0.0) {       
		  cardSprite.setVisible(true);
                }
	}
});

Which IMHO is another way of saying "begin".

Thus if the PropertySetterToTimingTarget.begin method would call timingEvent(source, 0.0); (or set the initial property value) after the KeyFrame is initialized that would greatly help.


hallorant added a comment - 12/Apr/12 01:53 PM

Ah ha, the example on http://java.net/jira/browse/TIMINGFRAMEWORK-12 confused me because the comment on the begin() didn't exclude the the cardSprite.setVisible(true) from the calls you wanted to avoid.

So, ideally, you want the code below:

Animator a = new Animator.Builder()
.addTarget(PropertySetter.getTarget(cardSprite, "alpha", 0.0, 1.0));
.addTarget(PropertySetter.getTarget(cardSprite, "location", src.getPosition(), dst.getPosition()))
.addTarget(PropertySetter.getTarget(cardSprite, "scale", src.getScale(), dst.getScale()))
.addTarget(new TimingTargetAdapter() {
  @Override
  public void begin(Animator source) {
    // alpha, location, and scale are set -- now make visible
    cardSprite.setVisible(true);
  }
});

I'll look into this, it seems reasonable.


masterzen added a comment - 12/Apr/12 01:59 PM

Yes, that's exactly that.
Sorry for the poor example.


hallorant added a comment - 12/Apr/12 07:35 PM

Fixed in trunk. Code like the example above should now work just fine.

JUnit added to test that this code idiom works.


hallorant added a comment - 12/Apr/12 09:08 PM

Released 5.0 – masterzen please let me know at hallorant at gmail dot com if this works for you (is your project that uses Timeing Framework open source? I could add a link.)