changeset 3645:673463d3ca84

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/scrum/graphics/jfx/rt
author Martin Sladecek <martin.sladecek@oracle.com>
date Tue, 21 May 2013 16:37:16 +0200
parents 890cb75f91f2 8e7f2b0e9348
children f197a76ee364
files
diffstat 2 files changed, 90 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/animation/ParallelTransition.java	Tue May 21 16:11:07 2013 +0200
+++ b/javafx-ui-common/src/javafx/animation/ParallelTransition.java	Tue May 21 16:37:16 2013 +0200
@@ -53,21 +53,21 @@
  * <p>
  * Children of this {@code Transition} inherit {@link #nodeProperty() node}, if their
  * {@code node} property is not specified.
- * 
+ *
  * <p>
  * Code Segment Example:
  * </p>
- * 
+ *
  * <pre>
  * <code>
  *     Rectangle rect = new Rectangle (100, 40, 100, 100);
  *     rect.setArcHeight(50);
  *     rect.setArcWidth(50);
  *     rect.setFill(Color.VIOLET);
- * 
+ *
  *     final Duration SEC_2 = Duration.millis(2000);
  *     final Duration SEC_3 = Duration.millis(3000);
- * 
+ *
  *     FadeTransition ft = new FadeTransition(SEC_3);
  *     ft.setFromValue(1.0f);
  *     ft.setToValue(0.3f);
@@ -87,15 +87,15 @@
  *     st.setByY(1.5f);
  *     st.setCycleCount(2f);
  *     st.setAutoReverse(true);
- * 
+ *
  *     ParallelTransition pt = new ParallelTransition(rect, ft, tt, rt, st);
  *     pt.play();
  * </code>
  * </pre>
- * 
+ *
  * @see Transition
  * @see Animation
- * 
+ *
  */
 public final class ParallelTransition extends Transition {
 
@@ -112,7 +112,7 @@
     private long cycleTime;
     private boolean childrenChanged = true;
     private boolean toggledRate;
-    
+
     private final InvalidationListener childrenListener = new InvalidationListener() {
         @Override
         public void invalidated(Observable observable) {
@@ -122,7 +122,7 @@
             }
         }
     };
-    
+
     private final ChangeListener<Number> rateListener = new ChangeListener<Number>() {
 
         @Override
@@ -252,7 +252,7 @@
 
     /**
      * The constructor of {@code ParallelTransition}.
-     * 
+     *
      * @param node
      *            The target {@link javafx.scene.Node} to be used in child
      *            {@link Transition Transitions} that have no {@code Node} specified
@@ -269,7 +269,7 @@
 
     /**
      * The constructor of {@code ParallelTransition}.
-     * 
+     *
      * @param children
      *            The child {@link javafx.animation.Animation Animations} of
      *            this {@code ParallelTransition}
@@ -280,7 +280,7 @@
 
     /**
      * The constructor of {@code ParallelTransition}.
-     * 
+     *
      * @param node
      *            The target {@link javafx.scene.Node} to be used in child
      *            {@link Transition Transitions} that have no {@code Node} specified
@@ -297,7 +297,7 @@
     public ParallelTransition() {
         this((Node) null);
     }
-    
+
     // For testing purposes
     ParallelTransition(AbstractMasterTimer timer) {
         super(timer);
@@ -318,7 +318,7 @@
         Duration maxTime = Duration.ZERO;
         for (final Animation animation : getChildren()) {
             final double absRate = Math.abs(animation.getRate());
-            final Duration totalDuration = (absRate < EPSILON) ? 
+            final Duration totalDuration = (absRate < EPSILON) ?
                     animation.getTotalDuration() : animation.getTotalDuration().divide(absRate);
             final Duration childDuration = totalDuration.add(animation.getDelay());
             if (childDuration.isIndefinite()) {
@@ -459,7 +459,8 @@
         if (getCurrentRate() > 0) {
             int i = 0;
             for (final Animation animation : cachedChildren) {
-                if ((newTicks >= delays[i]) && ((oldTicks <= delays[i]) || ((oldTicks < add(delays[i], durations[i])) && (animation.getStatus() == Status.STOPPED)))) {
+                if ((newTicks >= delays[i]) && ((oldTicks <= delays[i]) ||
+                        ((newTicks < add(delays[i], durations[i])) && (animation.getStatus() == Status.STOPPED)))) {
                     final boolean enteringCycle = oldTicks <= delays[i];
                     if (startChild(animation, i)) {
                         animation.clipEnvelope.jumpTo(0);
@@ -487,7 +488,7 @@
             int i = 0;
             for (final Animation animation : cachedChildren) {
                 if (newTicks < add(durations[i], delays[i])) {
-                    if ((oldTicks >= add(durations[i], delays[i])) || ((oldTicks >= delays[i]) && (animation.getStatus() == Status.STOPPED))){
+                    if ((oldTicks >= add(durations[i], delays[i])) || ((newTicks >= delays[i]) && (animation.getStatus() == Status.STOPPED))){
                         final boolean enteringCycle = oldTicks >= add(durations[i], delays[i]);
                         if (startChild(animation, i)) {
                             animation.clipEnvelope.jumpTo(Math.round(durations[i] * rates[i]));
@@ -587,5 +588,5 @@
             cachedChildren[i].impl_jumpTo(0, durations[i], true);
         }
     }
-    
+
 }
--- a/javafx-ui-common/test/unit/javafx/animation/ParallelTransitionPlayTest.java	Tue May 21 16:11:07 2013 +0200
+++ b/javafx-ui-common/test/unit/javafx/animation/ParallelTransitionPlayTest.java	Tue May 21 16:37:16 2013 +0200
@@ -115,7 +115,7 @@
         assertEquals(10000, yProperty.get());
 
         amt.pulse();
-        
+
         assertEquals(Status.RUNNING, pt.getStatus());
         assertEquals(Status.RUNNING, child1X.getStatus());
         assertEquals(Status.STOPPED, child1Y.getStatus());
@@ -175,7 +175,7 @@
         assertEquals(10000, yProperty.get());
 
         amt.pulse();
-        
+
         assertEquals(Status.RUNNING, pt.getStatus());
         assertEquals(Status.RUNNING, child1X.getStatus());
         assertEquals(Status.RUNNING, child1Y.getStatus());
@@ -467,7 +467,7 @@
         assertEquals(Status.RUNNING, pt.getStatus());
         assertEquals(Status.RUNNING, child1X.getStatus());
         assertEquals(Status.STOPPED, child1Y.getStatus());
-        
+
         assertEquals(10000 + TICK_STEP, xProperty.get());
         assertEquals(10000, yProperty.get());
     }
@@ -827,4 +827,73 @@
         assertEquals(0 + TICK_STEP, yProperty.get());
     }
 
+
+    @Test public void testNestedParallelTransition() {
+        ParallelTransition pt2 = new ParallelTransition();
+
+        pt.getChildren().addAll(pt2, child1X);
+        pt2.getChildren().add(child1Y);
+
+        pt.play();
+
+        amt.pulse();
+
+        assertEquals(Status.RUNNING, pt.getStatus());
+        assertEquals(Status.RUNNING, pt2.getStatus());
+        assertEquals(Status.RUNNING, child1X.getStatus());
+        assertEquals(Status.RUNNING, child1Y.getStatus());
+        assertEquals(TICK_STEP, xProperty.get());
+        assertEquals(TICK_STEP, yProperty.get());
+
+        amt.pulse();
+
+        assertEquals(Status.RUNNING, pt.getStatus());
+        assertEquals(Status.RUNNING, pt2.getStatus());
+        assertEquals(Status.RUNNING, child1X.getStatus());
+        assertEquals(Status.RUNNING, child1Y.getStatus());
+        assertEquals(Math.round(TICK_MILLIS * 2), xProperty.get());
+        assertEquals(Math.round(TICK_MILLIS * 2), yProperty.get());
+
+
+        pt.jumpTo(Duration.seconds(60).subtract(TickCalculation.toDuration(100)));
+
+        amt.pulse();
+
+        assertEquals(Status.STOPPED, pt.getStatus());
+        assertEquals(Status.STOPPED, pt2.getStatus());
+        assertEquals(Status.STOPPED, child1X.getStatus());
+        assertEquals(Status.STOPPED, child1Y.getStatus());
+
+        pt.play();
+
+
+        amt.pulse();
+
+        assertEquals(Status.RUNNING, pt.getStatus());
+        assertEquals(Status.RUNNING, pt2.getStatus());
+        assertEquals(Status.RUNNING, child1X.getStatus());
+        assertEquals(Status.RUNNING, child1Y.getStatus());
+        assertEquals(TICK_STEP, xProperty.get());
+        assertEquals(TICK_STEP, yProperty.get());
+
+        amt.pulse();
+
+        assertEquals(Status.RUNNING, pt.getStatus());
+        assertEquals(Status.RUNNING, pt2.getStatus());
+        assertEquals(Status.RUNNING, child1X.getStatus());
+        assertEquals(Status.RUNNING, child1Y.getStatus());
+        assertEquals(Math.round(TICK_MILLIS * 2), xProperty.get());
+        assertEquals(Math.round(TICK_MILLIS * 2), yProperty.get());
+
+
+        pt.jumpTo(Duration.seconds(60).subtract(TickCalculation.toDuration(100)));
+
+        amt.pulse();
+
+        assertEquals(Status.STOPPED, pt.getStatus());
+        assertEquals(Status.STOPPED, pt2.getStatus());
+        assertEquals(Status.STOPPED, child1X.getStatus());
+        assertEquals(Status.STOPPED, child1Y.getStatus());
+    }
+
 }