private ParallelTransition createFadeTransition(final ImageView iv, final Image img) {

    FadeTransition fadeOutTransition = new FadeTransition(Duration.seconds(.25), iv);
    fadeOutTransition.setFromValue(1.0);
    fadeOutTransition.setToValue(0.0);
    fadeOutTransition.setOnFinished(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            iv.setImage(img);
          }
        });

    FadeTransition fadeInTransition = new FadeTransition(Duration.seconds(.25), iv);
    fadeInTransition.setFromValue(0.0);
    fadeInTransition.setToValue(1.0);

    /*
     * FadeTransition fadeFlyCare = FadeOutTransition(ivFlyCard);
     */

    ParallelTransition parallelTransition = new ParallelTransition();
    parallelTransition.getChildren().addAll(fadeOutTransition, fadeInTransition);

    return parallelTransition;
  }
  private SequentialTransition createTransition(
      final Point2D pntStartPoint, final Point2D pntEndPoint, ImageView imView) {

    imView =
        new ImageView(
            new Image(getClass().getResourceAsStream("/res/img/b1fh.png"), 75, 75, true, true));

    imView.setX(pntStartPoint.getX());
    imView.setY(pntStartPoint.getY() - 30);

    APMainScreen.getChildren().add(imView);

    TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), imView);
    translateTransition.setFromX(0);
    translateTransition.setToX(pntEndPoint.getX() - pntStartPoint.getX());
    translateTransition.setFromY(0);
    translateTransition.setToY(pntEndPoint.getY() - pntStartPoint.getY());

    translateTransition.setCycleCount(1);
    translateTransition.setAutoReverse(false);

    int rnd = randInt(1, 3);

    RotateTransition rotateTransition = new RotateTransition(Duration.millis(150), imView);
    rotateTransition.setByAngle(90F);
    rotateTransition.setCycleCount(rnd);
    rotateTransition.setAutoReverse(false);

    ParallelTransition parallelTransition = new ParallelTransition();
    parallelTransition.getChildren().addAll(translateTransition, rotateTransition);

    SequentialTransition seqTrans = new SequentialTransition();
    seqTrans.getChildren().addAll(parallelTransition);

    final ImageView ivRemove = imView;
    seqTrans.setOnFinished(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            APMainScreen.getChildren().remove(ivRemove);
          }
        });

    return seqTrans;
  }
 protected void addAnimation(Transition transition, Animation child) {
   if (transition instanceof SequentialTransition) {
     ((SequentialTransition) transition).getChildren().add(child);
   } else if (transition instanceof ParallelTransition) {
     ((ParallelTransition) transition).getChildren().add(child);
   } else {
     throw new IllegalArgumentException(
         "Main transition must be either a Parallel or Sequential Transition");
   }
 }
Ejemplo n.º 4
0
  private ParallelTransition createTransition(
      final ImageView iv, final ImageView ivStart, final Image img) {

    FadeTransition fadeOutTransition = new FadeTransition(Duration.seconds(.25), iv);
    fadeOutTransition.setFromValue(1.0);
    fadeOutTransition.setToValue(0.0);
    fadeOutTransition.setOnFinished(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            iv.setImage(img);
            ;
          }
        });

    FadeTransition fadeInTransition = new FadeTransition(Duration.seconds(.25), iv);
    fadeInTransition.setFromValue(0.0);
    fadeInTransition.setToValue(1.0);

    /*
    TranslateTransition translateTransition = new TranslateTransition(Duration.millis(500), ivStart);

    translateTransition.setFromX(0);
    translateTransition.setToX(ivX - ivStartX1);
    translateTransition.setFromY(0);
    translateTransition.setToY(ivY - ivStartY1);

    translateTransition.setCycleCount(2);
    translateTransition.setAutoReverse(false);
     */
    //		RotateTransition rotateTransition = new RotateTransition(Duration.millis(150), ivStart);
    //		rotateTransition.setByAngle(90f);
    //		rotateTransition.setCycleCount(1);
    //		rotateTransition.setAutoReverse(false);

    ParallelTransition parallelTransition = new ParallelTransition();
    parallelTransition.getChildren().addAll(fadeOutTransition, fadeInTransition);

    return parallelTransition;
  }
Ejemplo n.º 5
0
    private void snapshotTweet(final Parent tweetContainer) throws InterruptedException {
      final CountDownLatch latch = new CountDownLatch(1);
      // render the chart in an offscreen scene (scene is used to allow css processing) and snapshot
      // it to an image.
      // the snapshot is done in runlater as it must occur on the javafx application thread.
      Platform.runLater(
          () -> {
            // animation
            obsFadeOutWords.stream().forEach(w -> parallelWords.getChildren().add(fadeOut(w)));
            obsFadeInWords.stream().forEach(w -> parallelTexts.getChildren().add(fadeIn(w)));

            sequential.setOnFinished(
                e -> {
                  parallelWords.getChildren().clear();
                  parallelTexts.getChildren().clear();
                  latch.countDown();
                });

            sequential.play();
          });

      latch.await();
    }
Ejemplo n.º 6
0
  @FXML
  private void handleDrawToCommunity() {
    communityCardDrawn++;

    Card c = gme.getGameDeck().drawFromDeck();
    String strCard = "/res/img/" + c.getCardImg();
    // ImageView img = new ImageView(new Image(getClass().getResourceAsStream(strCard), 75, 75,
    // true, true));
    // HboxCommunityCards.getChildren().add(img);

    ImageView i = (ImageView) HboxCommunityCards.getChildren().get(communityCardDrawn - 1);
    ImageView iCardFaceDown = (ImageView) HboxCommonArea.getChildren().get(0);
    final ParallelTransition transitionForward =
        createTransition(
            i,
            iCardFaceDown,
            new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

    transitionForward.play();

    if (communityCardDrawn == NbrCommunityCards) {
      btnDrawCenter.setVisible(false);
    }
  }
Ejemplo n.º 7
0
  @FXML
  private void handleDraw() {
    iCardDrawn++;

    // Draw a card for each player seated
    for (Player p : mainApp.GetSeatedPlayers()) {
      Card c = gme.getGameDeck().drawFromDeck();

      // Player 1
      if (p.getiPlayerPosition() == 1) {
        GamePlayPlayerHand GPPH = gme.FindPlayerGame(gme, p);
        GPPH.addCardToHand(c);
        String strCard = "/res/img/" + c.getCardImg();
        ImageView img =
            new ImageView(new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        ImageView i = (ImageView) h1P1.getChildren().get(iCardDrawn - 1);
        ImageView iCardFaceDown = (ImageView) HboxCommonArea.getChildren().get(0);
        final ParallelTransition transitionForward =
            createTransition(
                i,
                iCardFaceDown,
                new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        transitionForward.play();
        // h1P1.getChildren().add(img);

        if (iCardDrawn == NbrCards) {
          GPPH.getHand().EvalHand();
          handsInPlay.add(GPPH);
        }
      }

      // Player 2
      if (p.getiPlayerPosition() == 2) {
        GamePlayPlayerHand GPPH = gme.FindPlayerGame(gme, p);
        GPPH.addCardToHand(c);
        String strCard = "/res/img/" + c.getCardImg();
        ImageView img =
            new ImageView(new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        ImageView i = (ImageView) v2P2.getChildren().get(iCardDrawn - 1);
        ImageView iCardFaceDown = (ImageView) HboxCommonArea.getChildren().get(0);
        final ParallelTransition transitionForward =
            createTransition(
                i,
                iCardFaceDown,
                new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        transitionForward.play();
        // h1P1.getChildren().add(img);

        if (iCardDrawn == NbrCards) {
          GPPH.getHand().EvalHand();
          handsInPlay.add(GPPH);
        }
      }

      // Player 3
      if (p.getiPlayerPosition() == 3) {
        GamePlayPlayerHand GPPH = gme.FindPlayerGame(gme, p);
        GPPH.addCardToHand(c);
        String strCard = "/res/img/" + c.getCardImg();
        ImageView img =
            new ImageView(new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        ImageView i = (ImageView) h3P3.getChildren().get(iCardDrawn - 1);
        ImageView iCardFaceDown = (ImageView) HboxCommonArea.getChildren().get(0);
        final ParallelTransition transitionForward =
            createTransition(
                i,
                iCardFaceDown,
                new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        transitionForward.play();
        // h1P1.getChildren().add(img);

        if (iCardDrawn == NbrCards) {
          GPPH.getHand().EvalHand();
          this.handsInPlay.add(GPPH);
        }
      }

      // Player 4
      if (p.getiPlayerPosition() == 4) {
        GamePlayPlayerHand GPPH = gme.FindPlayerGame(gme, p);
        GPPH.addCardToHand(c);
        String strCard = "/res/img/" + c.getCardImg();
        ImageView img =
            new ImageView(new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        ImageView i = (ImageView) v4P4.getChildren().get(iCardDrawn - 1);
        ImageView iCardFaceDown = (ImageView) HboxCommonArea.getChildren().get(0);
        final ParallelTransition transitionForward =
            createTransition(
                i,
                iCardFaceDown,
                new Image(getClass().getResourceAsStream(strCard), 75, 75, true, true));

        transitionForward.play();
        // h1P1.getChildren().add(img);

        if (iCardDrawn == NbrCards) {
          GPPH.getHand().EvalHand();
          handsInPlay.add(GPPH);
        }
      }
    }

    if (iCardDrawn == NbrCards) {
      btnDraw.setVisible(false);

      if (NbrCommunityCards != 0) {
        btnDrawCenter.setVisible(true);
      }
    }
  }