Example #1
2
 @Override
 public void handle(MouseEvent t) {
   // move circle back to origin
   TranslateTransition move =
       new TranslateTransition(new Duration(200), (Circle) (t.getSource()));
   move.setToX(translateX);
   move.setToY(translateY);
   move.playFromStart();
 }
  public void startOpenAnimation(boolean finished) {

    TranslateTransition transition = new TranslateTransition();
    transition.setNode(this);
    transition.setDuration(Duration.millis(500));

    if (finished) {
      transition.setToX(0);
      transition.setOnFinished(
          ev -> {
            drawerOpen = false;
            actionBar.setDrawerOpen(false);
            oldX = 0;
            startX = 0;
          });
    } else {
      transition.setToX(getPrefWidth());
      transition.setOnFinished(
          ev -> {
            drawerOpen = true;
            actionBar.setDrawerOpen(true);
            oldX = 0;
            startX = 0;
          });
    }
    transition.play();
    animationFinished = false;
  }
 private TranslateTransition createTranslateTransition(final Rectangle rect) {
   final TranslateTransition transition = new TranslateTransition(TRANSLATE_DURATION, rect);
   transition.setOnFinished(
       new EventHandler<ActionEvent>() {
         public void handle(ActionEvent t) {
           rect.setX(rect.getTranslateX() + rect.getX());
           rect.setY(rect.getTranslateY() + rect.getY());
           rect.setTranslateX(0);
           rect.setTranslateY(0);
         }
       });
   return transition;
 }
Example #4
0
 public Step move(double newX, double newY) {
   TranslateTransition transition = new TranslateTransition();
   transition.setNode(group);
   transition.setToX(newX - xCenter);
   transition.setToY(newY - yCenter);
   transition.setDuration(Duration.millis(1000d));
   return new TransitionStep(transition);
 }
Example #5
0
 public void readyToGoAnimation() {
   // Sync progress bar slides out ...
   TranslateTransition leave = new TranslateTransition(Duration.millis(600), syncBox);
   leave.setByY(80.0);
   // Buttons slide in and clickable address appears simultaneously.
   TranslateTransition arrive = new TranslateTransition(Duration.millis(600), controlsBox);
   arrive.setToY(0.0);
   FadeTransition reveal = new FadeTransition(Duration.millis(500), addressControl);
   reveal.setToValue(1.0);
   ParallelTransition group = new ParallelTransition(arrive, reveal);
   // Slide out happens then slide in/fade happens.
   SequentialTransition both = new SequentialTransition(leave, group);
   both.setCycleCount(1);
   both.setInterpolator(Interpolator.EASE_BOTH);
   both.play();
 }
Example #6
0
 public void slideUp() {
   if (stopAnyRunningAnimation() == State.VISIBLE) {
     toAnimate.setVisible(true);
     state = State.SLIDING_UP;
     SLIDE_UP.playFromStart();
   }
 }
Example #7
0
 public Then slideDown() {
   stopAnyRunningAnimation();
   toAnimate.setVisible(true);
   state = State.SLIDING_DOWN;
   SLIDE_DOWN.playFromStart();
   return new Then(SLIDE_DOWN);
 }
  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;
  }
  /**
   * Defines the characteristics of a <i>TranslateTransition</i>. Each call results in ONE segment
   * of motion. When that segment is finished, it "chains" another call to <i>startMotion()</i>
   * (which is NOT recursion)! The initial call is made by the managing <i>Army</i> object;
   * subsequent calls are made through the "chaining" process described here.
   *
   * @param engageInCombat TODO
   */
  public void startMotion(boolean engageInCombat) {
    Army opposingArmy = armyAllegiance.getOpposingArmy();
    Actor opponent =
        opposingArmy.findNearestOpponent(
            this); // could legitimately return a null: 1) no one is visible 2) no Actors in
                   // opposing army

    Point2D newLocation;
    if (opponent != null) {
      System.out.printf(
          "ToMove:[%.1f:%.1f] Opponent:[%.1f:%.1f]\n",
          getAvatar().getTranslateX(),
          getAvatar().getTranslateY(),
          opponent.getAvatar().getTranslateX(),
          opponent.getAvatar().getTranslateX());
      double DISTANCE_FOR_BATTLE = 50.0;
      if (engageInCombat && distanceTo(opponent) < DISTANCE_FOR_BATTLE) {
        double h1, h2, h3, h4; // debug code
        h1 = this.getHealth();
        h2 = opponent.getHealth();

        combatRound(opponent);
        h3 = this.getHealth();
        h4 = opponent.getHealth();
        h4 = h4;
        if (this.getHealth() <= 0.0) {
          armyAllegiance.removeNowDeadActor(this);
        }
        if (opponent.getHealth() <= 0.0) {
          opponent.armyAllegiance.removeNowDeadActor(opponent);
        }
      } // end if (combat)
      newLocation = findNewLocation(opponent);
    } else // end if (test for null opponent)
    newLocation = meander(); // null opponent means we wander around close to our current location

    if (tt.getStatus()
        != Animation.Status.RUNNING) { // if NOT yet RUNNING, start . . . otherwise, do nothing.
      // tt.setToX(Math.random()*getAvatar().getScene().getWidth());
      // tt.setToY(Math.random()*getAvatar().getScene().getHeight());
      tt.setToX(validateCoordinate(newLocation).getX());
      tt.setToY(validateCoordinate(newLocation).getY());
      tt.setDuration(
          Duration.seconds(MAX_SPEED / (getSpeed() * (armyAllegiance.getSpeedControllerValue()))));
      tt.setOnFinished(event -> startMotion(true)); // NOT RECURSION!!!!
      tt
          .play(); // give assembled object to the render engine (of course, play() is an
                   // object-oriented method which has access to "this" inside, and it can use
                   // "this" to give to the render engine.
    }
  } // end startMotion()
Example #10
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
Example #11
0
    public GameMenu() {

      VBox menu0 = new VBox(10);
      VBox menu1 = new VBox(10);
      VBox menu2 = new VBox(10);

      menu0.setTranslateX(100);
      menu0.setTranslateY(200);

      menu1.setTranslateX(100);
      menu1.setTranslateY(200);

      menu2.setTranslateX(100);
      menu2.setTranslateY(200);

      final int offset = 400;

      menu1.setTranslateX(offset);
      menu2.setTranslateX(offset);

      BlackjackMain.MenuButton btnNewGame = new BlackjackMain.MenuButton("NEW GAME");
      btnNewGame.setOnMouseClicked(
          event -> {
            FadeTransition ft = new FadeTransition(Duration.seconds(0.5), this);
            ft.setFromValue(1);
            ft.setToValue(0);
            ft.setOnFinished(evt -> setVisible(false));
            ft.play();
          });

      //			BlackjackMain.MenuButton btnResume = new BlackjackMain.MenuButton("RESUME");
      //			btnResume.setOnMouseClicked(event -> {
      //				FadeTransition ft = new FadeTransition(Duration.seconds(0.5), this);
      //				ft.setFromValue(1);
      //				ft.setToValue(0);
      //				ft.setOnFinished(evt -> setVisible(false));
      //				ft.play();
      //			});
      BlackjackMain.MenuButton btnOptions = new BlackjackMain.MenuButton("OPTIONS");
      btnOptions.setOnMouseClicked(
          event -> {
            getChildren().add(menu1);

            TranslateTransition tt = new TranslateTransition(Duration.seconds(0.25), menu0);
            tt.setToX(menu0.getTranslateX() - offset);

            TranslateTransition tt1 = new TranslateTransition(Duration.seconds(0.5), menu1);
            tt1.setToX(menu0.getTranslateX());

            tt.play();
            tt1.play();

            tt.setOnFinished(
                evt -> {
                  getChildren().remove(menu0);
                });
          });

      BlackjackMain.MenuButton btnExit = new BlackjackMain.MenuButton("EXIT");
      btnExit.setOnMouseClicked(
          event -> {
            System.exit(0);
          });

      BlackjackMain.MenuButton btnBack = new BlackjackMain.MenuButton("BACK");
      btnBack.setOnMouseClicked(
          event -> {
            getChildren().add(menu0);

            TranslateTransition tt = new TranslateTransition(Duration.seconds(0.25), menu1);
            tt.setToX(menu1.getTranslateX() + offset);

            TranslateTransition tt1 = new TranslateTransition(Duration.seconds(0.5), menu0);
            tt1.setToX(menu1.getTranslateX());

            tt.play();
            tt1.play();

            tt.setOnFinished(
                evt -> {
                  getChildren().remove(menu1);
                });
          });

      BlackjackMain.MenuButton btnSound = new BlackjackMain.MenuButton("SOUND");
      BlackjackMain.MenuButton btnVideo = new BlackjackMain.MenuButton("VIDEO");
      btnVideo.setOnMouseClicked(
          event -> {
            getChildren().add(menu2);

            TranslateTransition tt = new TranslateTransition(Duration.seconds(0.25), menu1);
            tt.setToX(menu1.getTranslateX() - offset);

            TranslateTransition tt1 = new TranslateTransition(Duration.seconds(0.5), menu2);
            tt1.setToX(menu1.getTranslateX());

            tt.play();
            tt1.play();

            tt.setOnFinished(
                evt -> {
                  getChildren().remove(menu1);
                });
          });

      BlackjackMain.MenuButton btnLowRes = new BlackjackMain.MenuButton("640x480");
      btnLowRes.setOnMouseClicked(
          event -> {
            windowWidth = 640;
            windowHeight = 480;
            /*stage.setHeight(windowHeight);
            stage.setWidth(windowWidth);
            */

          });

      BlackjackMain.MenuButton btnHighRes = new BlackjackMain.MenuButton("800x600");
      btnHighRes.setOnMouseClicked(
          event -> {
            windowWidth = 800;
            windowHeight = 600;
          });
      BlackjackMain.MenuButton btnBack2 = new BlackjackMain.MenuButton("BACK");
      btnBack2.setOnMouseClicked(
          event -> {
            getChildren().add(menu1);

            TranslateTransition tt = new TranslateTransition(Duration.seconds(0.25), menu2);
            tt.setToX(menu2.getTranslateX() + offset);

            TranslateTransition tt1 = new TranslateTransition(Duration.seconds(0.5), menu1);
            tt1.setToX(menu2.getTranslateX());

            tt.play();
            tt1.play();

            tt.setOnFinished(
                evt -> {
                  getChildren().remove(menu2);
                });
          });

      menu0.getChildren().addAll(btnNewGame, btnOptions, btnExit);
      menu1.getChildren().addAll(btnBack, btnSound, btnVideo);
      menu2.getChildren().addAll(btnBack2, btnLowRes, btnHighRes);

      Rectangle bg = new Rectangle(windowWidth, windowHeight);
      bg.setFill(Color.GREY);
      bg.setOpacity(0.8);

      getChildren().addAll(bg, menu0);
    }
Example #12
0
  public void start(final Stage stage) {
    for (ConditionalFeature f : EnumSet.allOf(ConditionalFeature.class)) {
      System.err.println(f + ": " + Platform.isSupported(f));
    }
    Rectangle2D screen = Screen.getPrimary().getVisualBounds();
    final Random rand = new Random();

    /*
    final Group starfield = new Group();
    for(int i=0;i<66;i++) {
        int size = rand.nextInt(3)+1;
        if(size==3) {
            size = rand.nextInt(3)+1;
        }
        Circle circ = new Circle(rand.nextInt((int)screen.getWidth()), rand.nextInt(200+(int)screen.getHeight())-200,
            size);
        circ.setFill(Color.rgb(200,200,200+rand.nextInt(56)));
        circ.setTranslateZ(1+rand.nextInt(40));
        starfield.getChildren().add(circ);
    }
    */
    final List<Starfield> stars = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
      int sw = (int) screen.getWidth(), sh = (int) screen.getHeight();
      Starfield sf = new Starfield(rand, -sw, -sh, 2 * sw, 2 * sh, rand.nextInt(30) + 10);
      sf.setTranslateZ(rand.nextInt(2000) + 50);
      stars.add(sf);
    }
    // final Starfield starfield2 = new Starfield(rand, -200, -200, (int)screen.getWidth(),
    // (int)screen.getHeight()+200, 40);

    final Ruleset1D rules =
        new Ruleset1D(new int[] {Colors.randomColor(rand), Colors.randomColor(rand)});
    final Ruleset rules2 = new Rulespace1D(rules);
    // Rule rule = rules.random(rand).next();
    Iterator<Rule> it = rules.iterator();
    GridPane gridp = new GridPane();
    int i = 0, j = 0;
    while (it.hasNext()) {
      Rule rule = it.next();
      CA ca = new CA(rule, new RandomInitializer(), rand, 42, 100, 100);
      Plane plane = ca.createPlane();
      ImageView imview = new ImageView(plane.toImage());
      imview.setSmooth(true);
      imview.setFitWidth(30);
      imview.setPreserveRatio(true);
      gridp.add(imview, i, j);
      if (++i == 16) {
        i = 0;
        j++;
      }
    }
    // gridp.setScaleX(0.3);
    // gridp.setScaleY(0.3);
    // gridp.setPrefSize(100*3/3, 100*3/3);
    // gridp.setMaxSize(100*3/3, 100*3/3);

    final double XTRANS = screen.getWidth() / 2 - 30 * 16 / 2;
    final double YTRANS = screen.getHeight() / 2 - 30 * 16 / 2;
    // gridp.setTranslateX((screen.getWidth()/2+100*16/2)*0.3);
    // gridp.setTranslateX(0);
    gridp.setTranslateX(XTRANS);
    gridp.setTranslateY(YTRANS);
    // gridp.setAlignment(Pos.CENTER);
    Group grid = new Group(gridp);
    // grid.setTranslateX(0);
    // grid.setTranslateY(0);

    // gridp.relocate(-400, -400);
    // gridp.setTranslateX(-300);
    // gridp.setTranslateY(-150);

    /*
    final RotateTransition rt = new RotateTransition(Duration.millis(3000), gridp);
    rt.setByAngle(180);
    rt.setCycleCount(4);
    rt.setAutoReverse(true);
    */
    // rt.setAutoReverse(false);

    /*`
    final BorderPane border = new BorderPane();
    */
    // Label title = new Label("EXPLORATIONS IN CELLULAR SPACES");
    Label title = new Label("E  X  P  L  O  R  A  T  I  O  N  S");
    title.setFont(new Font("Helvetica Neue Condensed Bold", 36));
    title.setTextFill(Color.WHITE);
    // Label title2 = new Label("IN CELLULAR SPACES");
    Label title2 = new Label("EXPLORATIONS IN CELLULAR SPACES");
    title2.setFont(new Font("Helvetica Neue Condensed Bold", 28));
    title2.setTextFill(Color.WHITE);
    /*`
    title.setAlignment(Pos.CENTER);
    title.setContentDisplay(ContentDisplay.CENTER);
    title.setTextAlignment(TextAlignment.CENTER);
    */
    final HBox toptitle = new HBox();
    toptitle.setAlignment(Pos.CENTER);
    toptitle.getChildren().add(title);
    toptitle.setTranslateX(XTRANS);
    toptitle.setTranslateY(YTRANS - 36);

    final HBox btitle = new HBox();
    btitle.setAlignment(Pos.CENTER);
    title2.setAlignment(Pos.CENTER);
    btitle.getChildren().add(title2);
    btitle.setTranslateX(XTRANS);
    // btitle.setTranslateX(screen.getWidth()/2-title2.getPrefWidth()/2);
    btitle.setTranslateY(YTRANS + 30 * 16);

    Group border = new Group();
    // border.getChildren().add(toptitle);
    for (Starfield st : stars) {
      border.getChildren().add(st);
    }
    // border.getChildren().add(starfield2);
    border.getChildren().add(btitle);
    border.getChildren().add(grid);

    final List<TranslateTransition> tts = new ArrayList<>();
    final TranslateTransition tt = new TranslateTransition(Duration.millis(6000), grid);
    tt.setByY(2000);
    tts.add(tt);
    for (Starfield sf : stars) {
      TranslateTransition st = new TranslateTransition(Duration.millis(6000), sf);
      st.setByY(200);
      st.setByZ(100 + rand.nextInt(100));
      tts.add(st);
    }
    /*
    final TranslateTransition tt2 = new TranslateTransition(Duration.millis(6000), starfield1);
    tt2.setByY(200);
    tt2.setByZ(200);
    final TranslateTransition tt3 = new TranslateTransition(Duration.millis(6000), starfield2);
    tt3.setByY(300);
    tt3.setByZ(200);
    */
    // final ParallelTransition infinite = new ParallelTransition(tt, tt2, tt3);
    final ParallelTransition infinite =
        new ParallelTransition(tts.toArray(new TranslateTransition[0]));

    final BorderPane ctrl = new BorderPane();
    // ctrl.setPrefSize(200, 100);
    // ctrl.setMaxSize(200, 100);
    Label start = new Label("Start");
    start.setTextFill(Color.WHITE);
    start.setFont(new Font("Helvetica", 28));
    start.setAlignment(Pos.CENTER_LEFT);
    start.setContentDisplay(ContentDisplay.CENTER);
    start.setTranslateX(XTRANS + 30 * 16 + 100);
    start.setTranslateY(screen.getHeight() / 2);
    // start.setTranslateX(-400);
    Circle ico = new Circle(15);
    ico.setOnMouseClicked(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {
            FadeTransition ft = new FadeTransition(Duration.millis(500), ctrl);
            ft.setFromValue(1.0);
            ft.setToValue(0.0);
            FadeTransition tft = new FadeTransition(Duration.millis(500), btitle);
            tft.setFromValue(1.0);
            tft.setToValue(0.0);
            ParallelTransition pt = new ParallelTransition(ft, tft);
            // TranslateTransition fft = new TranslateTransition(Duration.millis(3000), border);
            // tt.setByY(2000);
            SequentialTransition st = new SequentialTransition(pt, infinite);
            st.setOnFinished(
                new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent e) {
                    State state = State.state().rules(rules2).random(new Rand()).size(400);
                    Iterator<Rule> it = state.rules().random(state.random().create());
                    CA ca =
                        new CA(
                            it.next(),
                            new RandomInitializer(),
                            state.random().create(),
                            0,
                            state.size(),
                            state.size());
                    state.ca(ca);
                    // final Futures futures = new Futures(rules2, new Rand());
                    final Controls controls = new Controls(state);
                    // controls.setTranslateX(screen.getWidth()/2 -
                    // futures.getPossibilityWidth()/2);
                    // controls.setTranslateY(screen.getHeight()/2 -
                    // futures.getPossiblityHeight()/2-20);

                    // controls.setTranslateX(screen.getWidth()/2 - (3*200+2*10)/2);
                    // controls.setTranslateY(screen.getHeight()/2 - (3*200+2*10)/2-20);

                    for (Starfield sf : stars) {
                      state.addListener(sf);
                      // futures.addFutureListener(sf);
                    }
                    // futures.addFutureListener(starfield1);
                    // futures.addFutureListener(starfield2);
                    border.getChildren().remove(grid);
                    border.getChildren().remove(btitle);
                    // border.getChildren().add(futures);
                    border.getChildren().add(controls);
                    // futures.setTranslateX(screen.getWidth()/2 - futures.getPossibilityWidth()/2);
                    // futures.setTranslateY(screen.getHeight()/2 -
                    // futures.getPossiblityHeight()/2);
                    // border.setCenter(futures);
                    // border.setAlignment(futures, Pos.CENTER);
                  }
                });
            st.play();
          }
        });
    // Sphere ico = new Sphere(15);
    // ico.setDrawMode(DrawMode.LINE);
    ico.setFill(Color.rgb(10, 10, 10));
    ico.setStroke(Color.WHITE);
    ico.setStrokeWidth(3);
    ico.setTranslateX(XTRANS + 30 * 16 + 100);
    ico.setTranslateY(screen.getHeight() / 2);
    // ctrl.setTop(ico);
    ctrl.setCenter(ico);
    /*
    border.setRight(ctrl);

    border.setMaxSize(800,600);
    border.setPrefSize(800,600);
    */
    border.getChildren().add(ctrl);
    Group root = new Group();
    root.getChildren().add(border);
    // root.setAutoSizeChildren(false);
    // root.setLayoutX(-400);
    // root.setLayoutY(-400);
    // Scene scene = new Scene(root, 1200, 1000);
    Scene scene = new Scene(root, 1280, 1024, true, SceneAntialiasing.DISABLED);
    scene.setFill(Color.BLACK);
    scene.setCamera(new PerspectiveCamera());

    // set Stage boundaries to visible bounds of the main screen
    stage.setX(screen.getMinX());
    stage.setY(screen.getMinY());
    stage.setWidth(screen.getWidth());
    stage.setHeight(screen.getHeight());

    stage.setTitle("Explorations in Cellular Spaces");
    stage.setScene(scene);
    stage.setResizable(false);
    // root.autosize();
    // stage.sizeToScene();
    stage.show();
  }
Example #13
0
 /** Pauses a <i>TranslateTransition</i> if it is actively running. */
 public void pauseMotion() {
   if (tt.getStatus() == Animation.Status.RUNNING) tt.pause();
 } // end suspendMotion()
Example #14
0
  // for shots created with the space bar, trigonometry is
  // used to find the angle that the user's mouse was to the
  // origin and to extend the shot past the user's click to
  // the edge of the screen.
  private void initializeShot() {

    double miniHypot;
    double largeHypot;
    double edgePoint;
    double distance;
    TranslateTransition translate;

    // four different quadrants of the screen mean that the angles
    // must be processed four different ways, and that the
    // transitions must be added to the shots in four different ways.
    // the algebra is different in each if statement; the first is
    // commented as an example

    // if the click was on the left of Earth
    if (_mouse.getXCoord() < Constants.ORIGIN) {
      // if the click was above Earth
      if (_mouse.getYCoord() <= Constants.ORIGIN) {
        // get the distance of the mini hypoteneuse made with the click
        miniHypot =
            Math.sqrt(
                Math.pow((Constants.ORIGIN - _mouse.getXCoord()), 2)
                    + Math.pow((Constants.ORIGIN - _mouse.getYCoord()), 2));
        // extend that distance to the edge of the screen
        largeHypot = ((Constants.ORIGIN / (Constants.ORIGIN - _mouse.getXCoord())) * miniHypot);
        // calculate the y point based on that distance
        edgePoint = Math.sqrt(Math.pow(largeHypot, 2) - Math.pow(Constants.ORIGIN, 2));

        // get the distance between the new point and the origin
        distance = (Math.sqrt(Math.pow(-Constants.ORIGIN, 2) + Math.pow((-edgePoint), 2)));

        // create a translation with a constant rate for almost all angles
        translate =
            new TranslateTransition(
                Duration.millis(
                    Constants.SHOT_RATE_CONSTANT
                        * ((distance % Constants.SHOT_RATE_UPPER_BOUND)
                            + Constants.SHOT_RATE_LOWER_BOUND)));
        // send the shot all the way to the left
        translate.setToX(-Constants.ORIGIN);
        // send the shot up to the right point
        translate.setToY(-edgePoint);
      } else {
        miniHypot =
            Math.sqrt(
                Math.pow((Constants.ORIGIN - _mouse.getXCoord()), 2)
                    + Math.pow((_mouse.getYCoord() - Constants.ORIGIN), 2));
        largeHypot = ((Constants.ORIGIN / (Constants.ORIGIN - _mouse.getXCoord())) * miniHypot);
        edgePoint = Math.sqrt(Math.pow(largeHypot, 2) - Math.pow(Constants.ORIGIN, 2));

        distance = (Math.sqrt(Math.pow(-Constants.ORIGIN, 2) + Math.pow((edgePoint), 2)));

        translate =
            new TranslateTransition(
                Duration.millis(
                    Constants.SHOT_RATE_CONSTANT
                        * ((distance % Constants.SHOT_RATE_UPPER_BOUND)
                            + Constants.SHOT_RATE_LOWER_BOUND)));
        translate.setToX(-Constants.ORIGIN);
        translate.setToY(edgePoint);
      }
    } else if (_mouse.getXCoord() > Constants.ORIGIN) {
      if (_mouse.getYCoord() <= Constants.ORIGIN) {
        miniHypot =
            Math.sqrt(
                Math.pow((_mouse.getXCoord() - Constants.ORIGIN), 2)
                    + Math.pow((Constants.ORIGIN - _mouse.getYCoord()), 2));
        largeHypot =
            (((_scene.getWidth() - Constants.ORIGIN) / (_mouse.getXCoord() - Constants.ORIGIN))
                * miniHypot);
        edgePoint =
            Math.sqrt(
                Math.pow(largeHypot, 2) - Math.pow((_scene.getWidth() - Constants.ORIGIN), 2));

        distance =
            (Math.sqrt(
                Math.pow((_scene.getWidth() - Constants.ORIGIN), 2) + Math.pow((-edgePoint), 2)));

        translate =
            new TranslateTransition(
                Duration.millis(
                    Constants.SHOT_RATE_CONSTANT
                        * ((distance % Constants.SHOT_RATE_UPPER_BOUND)
                            + Constants.SHOT_RATE_LOWER_BOUND)));
        translate.setToX(_scene.getWidth() - Constants.ORIGIN);
        translate.setToY(-edgePoint);
      } else {
        miniHypot =
            Math.sqrt(
                Math.pow((_mouse.getXCoord() - Constants.ORIGIN), 2)
                    + Math.pow((_mouse.getYCoord() - Constants.ORIGIN), 2));
        largeHypot =
            (((_scene.getWidth() - Constants.ORIGIN) / (_mouse.getXCoord() - Constants.ORIGIN))
                * miniHypot);
        edgePoint =
            Math.sqrt(
                Math.pow(largeHypot, 2) - Math.pow((_scene.getWidth() - Constants.ORIGIN), 2));

        distance =
            (Math.sqrt(
                Math.pow((_scene.getWidth() - Constants.ORIGIN), 2) + Math.pow((edgePoint), 2)));

        translate =
            new TranslateTransition(
                Duration.millis(
                    Constants.SHOT_RATE_CONSTANT
                        * ((distance % Constants.SHOT_RATE_UPPER_BOUND)
                            + Constants.SHOT_RATE_LOWER_BOUND)));
        translate.setToX(_scene.getWidth() - Constants.ORIGIN);
        translate.setToY(edgePoint);
      }
    }
    // the case if the X coordinate of the mouse is equal to the origin
    // prevents a divide by zero error by substituting in a fake edgepoint calculation
    else {
      if (_mouse.getYCoord() <= Constants.ORIGIN) {
        edgePoint =
            Math.sqrt(Math.pow(Constants.DIVIDE_BY_ZERO_CATCH, 2) - Math.pow(Constants.ORIGIN, 2));

        distance = (Math.sqrt(Math.pow(-Constants.ORIGIN, 2) + Math.pow((edgePoint), 2)));

        translate =
            new TranslateTransition(
                Duration.millis(
                    Constants.SHOT_RATE_CONSTANT
                        * ((distance % Constants.SHOT_RATE_UPPER_BOUND)
                            + Constants.SHOT_RATE_LOWER_BOUND)));
        translate.setToX(-Constants.ORIGIN);
        translate.setToY(-edgePoint);
      } else {
        edgePoint =
            Math.sqrt(Math.pow(Constants.DIVIDE_BY_ZERO_CATCH, 2) - Math.pow(Constants.ORIGIN, 2));

        distance = (Math.sqrt(Math.pow(-Constants.ORIGIN, 2) + Math.pow((edgePoint), 2)));

        translate =
            new TranslateTransition(
                Duration.millis(
                    Constants.SHOT_RATE_CONSTANT
                        * ((distance % Constants.SHOT_RATE_UPPER_BOUND)
                            + Constants.SHOT_RATE_LOWER_BOUND)));
        translate.setToX(-Constants.ORIGIN);
        translate.setToY(edgePoint);
      }
    }

    ArrayList<Transition> animations = new ArrayList<Transition>();
    animations.add(translate);

    this.setAnimations(animations);
  }
  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();
  }