Ejemplo n.º 1
0
  private void runProcessingAnimation(double duration) {
    timeline.setAutoReverse(true);
    timeline.setCycleCount(2);

    //        transitionRect = new TranslateTransition(Duration.millis(duration), rectangle);
    //        transitionCircle = new TranslateTransition(Duration.millis(duration), circle);
    transitionCircle.setDuration(Duration.millis(duration));
    transitionCircle.setNode(circle);
    transitionCircle.setAutoReverse(false);
    transitionCircle.setByX(150);
    transitionCircle.setFromX(0);

    transitionRect.setAutoReverse(false);
    transitionRect.setDuration(Duration.millis(duration));
    transitionRect.setNode(rectangle);
    transitionRect.setByX(150);
    transitionRect.setFromX(0);

    KeyValue keyValue = new KeyValue(imageViewTop.translateYProperty(), 90);
    KeyFrame keyFrame =
        new KeyFrame(
            Duration.millis(duration),
            (ActionEvent) -> {
              toggleHide(rectangle);
              transitionRect.play();
              transitionCircle.play();
              stackProducts(rectangle, imageViewRightStorage, this);
            },
            keyValue);

    timeline.getKeyFrames().clear();
    timeline.getKeyFrames().add(keyFrame);
    timeline.play();
  }
Ejemplo n.º 2
0
 /**
  * <i>Actor</i> constructor is used when building <i>Actor</i> objects automatically:
  * <i>strength</i>, <i>health</i>, <i>speed</i> fields are given randomly generated values within
  * their range; <i>name</i> is given a sequentially numbered name: <i>Auto:<b>n</b></i> where
  * <i><b>n</b></i> is the sequence number. The <i>name</i> can be edited to create an unique
  * <i>Actor</i>.
  *
  * @param subclassCount used to support automatic naming (which includes a unique serial number).
  * @param armyAllegiance used to support the <i>Army</i>-specific <i>DropShadow</i> glow around
  *     this Actor object.
  */
 public Actor(int subclassCount, Army armyAllegiance) {
   this.armyAllegiance = armyAllegiance;
   ++actorSerialNumber; // static class-oriented variable. There is one-and-only-one instance of
                        // this variable regardless of the number of Actor objects in existence
                        // (from none to infinity).
   setName(
       String.format(
           "%d:%s:%d:",
           actorSerialNumber,
           getClass().getSimpleName(),
           subclassCount)); // An alternate way to assemble a String to use as a name. Because of
                            // polymorphism "getClass().getName()" will return the subclass name
                            // when they exist.
   setStrength(SingletonRandom.instance.getNormalDistribution(MIN_STRENGTH, MAX_STRENGTH, 2.0));
   setHealth(SingletonRandom.instance.getNormalDistribution(MIN_HEALTH, MAX_HEALTH, 2.0));
   setSpeed(SingletonRandom.instance.getNormalDistribution(MIN_SPEED, MAX_SPEED, 2.0));
   createAvatar();
   tooltip = new Tooltip(toString());
   Tooltip.install(getAvatar(), tooltip);
   tt = new TranslateTransition();
   tt.setNode(getAvatar()); // reuse
 } // end Actor constructor