Exemplo n.º 1
1
  private void playAudio(Media media) {
    if (mediaView.isVisible() == true) {
      mediaView.setVisible(false);
      display.setVisible(true);
    }
    if (mp != null) {
      mp.dispose();
    }

    mp = new MediaPlayer(media);
    mp.play();

    mp.setAudioSpectrumListener(
        (double timestamp, double duration1, float[] magnitudes, float[] phases) -> {
          display.getChildren().clear();
          int i = 0;
          int x = 10;
          double y = root.getScene().getHeight() / 2;
          Random rand = new Random(System.currentTimeMillis());
          for (float phase : phases) {
            int red = rand.nextInt(255);
            int green = rand.nextInt(255);
            int blue = rand.nextInt(255);
            Circle circle = new Circle(10);
            circle.setCenterX(x + i);
            circle.setCenterY(y + (phase * 100));
            circle.setFill(Color.rgb(red, green, blue, .70));
            display.getChildren().add(circle);
            i += 10;
          }
        });
  }
Exemplo n.º 2
0
 /** Writes the newest guest to the guesses pane for GUI */
 private void writeGuess() {
   // TODO Auto-generated method stub
   GuessSet lastGuess = Main.initBoard.guesses.get(Main.initBoard.guesses.size() - 1);
   int rowHeight = 66 * (Main.initBoard.guesses.size() - 1);
   int pinOffset = 320;
   // int circleWidth = 50;
   for (int i = 0; i < 4; i++) {
     Circle temp = new Circle(40 + 75 * i, rowHeight + 35, 30);
     temp.setFill(returnColor(lastGuess.pieceSet.get(i)));
     guesses.getChildren().add(temp);
   }
   for (int i = 0; i < (lastGuess.whitePins + lastGuess.blackPins); i++) {
     Color pinColor = Color.WHITE;
     int verticleOffset = 0;
     if (i >= lastGuess.whitePins) {
       pinColor = Color.BLACK;
     }
     if ((i / 2) > 0) {
       verticleOffset = 1;
     }
     Circle temp = new Circle(pinOffset + 20 * (i % 2), rowHeight + 25 + 20 * verticleOffset, 7);
     temp.setFill(pinColor);
     temp.setStroke(Color.BLACK);
     guesses.getChildren().add(temp);
   }
 }
Exemplo n.º 3
0
  /** Display a subtree rooted at position (x, y) */
  private void displayTree(BST.TreeNode<Integer> root, double x, double y, double hGap) {

    double adj = hGap + (hGap / 4);

    // left becomes bottom
    if (root.left != null) {
      double yVal = vGap - (vGap / 4);
      // Draw a line to the left node
      Line left = new Line(x + hGap, y + vGap, x, y);
      getChildren().add(left);
      // Draw the left subtree recursively
      displayTree(root.left, x + hGap, y + vGap, adj);
    }

    // right becomes top
    if (root.right != null) {
      double yVal = vGap + (vGap / 4);
      // Draw a line to the right node
      Line right = new Line(x + hGap, y - vGap, x, y);
      getChildren().add(right);
      // Draw the right subtree recursively
      displayTree(root.right, x + hGap, y - vGap, adj);
    }

    // Display a node
    Circle circle = new Circle(x, y, radius);
    circle.setFill(Color.WHITE);
    circle.setStroke(Color.BLACK);
    getChildren().addAll(circle, new Text(x - 4, y + 4, root.element + ""));
  }
  @Override
  protected void layoutChildren() {
    super.layoutChildren();

    mainIcon.relocate(getPadding().getLeft(), getPadding().getTop());
    mainIcon.resize(mainIcon.prefWidth(-1), mainIcon.prefHeight(-1));

    double titleX = mainIcon.getLayoutX() + mainIcon.getWidth() + 12;
    double titleY =
        mainIcon.getLayoutY() + (mainIcon.getHeight() - currentTitle.prefHeight(-1)) / 2;
    double titleWidth = getWidth() - titleX * 2;
    double titleHeight = currentTitle.prefHeight(-1);

    currentTitle.relocate(titleX, titleY);
    currentTitle.resize(titleWidth, titleHeight);

    actionBox.relocate(
        getWidth() - getPadding().getRight() - actionBox.prefWidth(-1), getPadding().getTop());
    actionBox.resize(actionBox.prefWidth(-1), actionBox.prefHeight(-1));

    changeViewAnimationTitle.relocate(titleX, titleY);
    changeViewAnimationTitle.resize(titleWidth, titleHeight);

    Insets borderInsets =
        Optional.ofNullable(getBorder()).map(border -> border.getInsets()).orElse(Insets.EMPTY);
    background.setX(borderInsets.getLeft());
    background.setY(borderInsets.getTop());
    background.setWidth(getWidth() - borderInsets.getLeft() - borderInsets.getRight());
    background.setHeight(getHeight() - borderInsets.getTop() - borderInsets.getBottom());

    changeViewAnimationCircle.setCenterX(mainIcon.getLayoutX() + mainIcon.getWidth() / 2);
    changeViewAnimationCircle.setCenterY(mainIcon.getLayoutY() + mainIcon.getHeight() / 2);
  }
Exemplo n.º 5
0
  @Override
  void setUpScene() {
    Line baseline = new Line(0, getMyHeight() * 2 / 3, getMyWidth(), getMyHeight() * 2 / 3);
    baseline.setStrokeWidth(8);
    baseline.setFill(Color.ROSYBROWN);
    Line midline =
        new Line(getMyWidth() * .55, getMyHeight() * 2 / 3, getMyWidth() * .45, getMyHeight());
    midline.setStrokeWidth(8);
    Circle midCirc = new Circle(getMyWidth() / 2, getMyHeight() * 5 / 6, 15);
    midCirc.setStrokeWidth(6);
    Label timerLabel = new Label(Double.toString(getTimeRemaining()));
    timerLabel.setTextFill(Color.BLACK);
    timerLabel.setStyle("-fx-font-size: 4em;");
    timerLabel.setLayoutX(getMyWidth() / 2 - getMyWidth() * .05);
    timerLabel.setLayoutY(getMyHeight() * .2);
    setTimerLabel(timerLabel);
    setThrowBalllbl(new Label("'Space' -> Throw Ball"));
    getThrowBalllbl().visibleProperty().set(false);
    getThrowBalllbl().setStyle("-fx-font-size: 3em;");
    getThrowBalllbl().setLayoutY(getMyHeight() - 50);

    getMyRoot()
        .getChildren()
        .addAll(
            getTimerLabel(),
            getTimerButtonVBox(),
            getThrowBalllbl(),
            baseline,
            midline,
            midCirc,
            getMyPlayerIV(),
            villainPlayerIV,
            getMyLivesHBox(),
            getEnemyLivesHBox());
  }
Exemplo n.º 6
0
 /** @param a Designates a color for the new circle in the inputBox */
 private void writeNewGuess(Color a) {
   // TODO Auto-generated method stub
   Circle newCircle =
       new Circle(45 + 100 * (Main.initBoard.currentGuess.pieceSet.size() - 1), 50, 40);
   newCircle.setFill(a);
   inputBox.getChildren().add(newCircle);
 }
Exemplo n.º 7
0
 /**
  * @param event Triggered on click of delete button next to inputBox
  *     <p>Utilized to remove the last entered item in the inputBox
  */
 public void deleteGuess(ActionEvent event) {
   if (inputBox.getChildren().size() < 1) {
     return;
   }
   Circle temp = (Circle) inputBox.getChildren().remove(inputBox.getChildren().size() - 1);
   temp.setFill(Color.WHITE);
   Main.initBoard.currentGuess.removePiece(inputBox.getChildren().size());
 }
Exemplo n.º 8
0
 private void handleExplode() {
   if (ballBounds.getMinY() > areaBounds.getMaxY()) {
     isExploding = false;
     resetBall();
   } else {
     ball.setTranslateX(ball.getTranslateX() + dx);
     ball.setTranslateY(ball.getTranslateY() - dy);
   }
 }
Exemplo n.º 9
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Group root = new Group();
    Group circles = new Group();
    for (int i = 0; i < 30; i++) {
      Circle circle = new Circle(150, Color.web("white", 0.05));
      circle.setStrokeType(StrokeType.OUTSIDE);
      circle.setStroke(Color.web("white", 0.16));
      circle.setStrokeWidth(4);
      circles.getChildren().add(circle);
    }
    root.getChildren().add(circles);
    Scene scene = new Scene(root, 800, 600, Color.BLACK);
    Rectangle colors =
        new Rectangle(
            scene.getWidth(),
            scene.getHeight(),
            new LinearGradient(
                0f,
                1f,
                1f,
                0f,
                true,
                CycleMethod.NO_CYCLE,
                new Stop[] {
                  new Stop(0, Color.web("#f8bd55")),
                  new Stop(0.14, Color.web("#c0fe56")),
                  new Stop(0.28, Color.web("#5dfbc1")),
                  new Stop(0.43, Color.web("#64c2f8")),
                  new Stop(0.57, Color.web("#be4af7")),
                  new Stop(0.71, Color.web("#ed5fc2")),
                  new Stop(0.85, Color.web("#ef504c")),
                  new Stop(1, Color.web("#f2660f")),
                }));
    colors.widthProperty().bind(scene.widthProperty());
    colors.heightProperty().bind(scene.heightProperty());
    root.getChildren().add(colors);

    Timeline timeline = new Timeline();
    for (Node circle : circles.getChildren()) {
      timeline
          .getKeyFrames()
          .addAll(
              new KeyFrame(
                  Duration.ZERO, // set start position at 0
                  new KeyValue(circle.translateXProperty(), random() * 800),
                  new KeyValue(circle.translateYProperty(), random() * 600)),
              new KeyFrame(
                  new Duration(40000), // set end position at 40s
                  new KeyValue(circle.translateXProperty(), random() * 800),
                  new KeyValue(circle.translateYProperty(), random() * 600)));
    }
    timeline.play();
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Exemplo n.º 10
0
 private void updateCircles() {
   for (int i = 0; i < ballArray.length; i++) {
     Ball b = ballArray[i];
     Circle c = circleArray[i];
     if (b != null) {
       c.setCenterX(b.getXPos());
       c.setCenterY(b.getYPos());
     }
   }
 }
Exemplo n.º 11
0
 @Override
 protected void layoutChildren(final double x, final double y, final double w, final double h) {
   if (invalid) {
     toggledColor = (Color) ((JFXToggleButton) getSkinnable()).getToggleColor();
     transition = getToggleTransition();
     innerCircle.setFill(toggledColor);
     innerCircle.setStroke(toggledColor);
     rippler.setRipplerFill(toggledColor);
     invalid = false;
   }
 }
Exemplo n.º 12
0
 /** Add black pin to both the screen area and to the last guess */
 public void addBlackPin() {
   if (pinInput.getChildren().size() > 3) {
     return;
   }
   GuessSet currentGuess = Main.initBoard.guesses.get(Main.initBoard.guesses.size() - 1);
   currentGuess.blackPins++;
   int numPins = pinInput.getChildren().size();
   Circle newCircle = new Circle(20 + 40 * (numPins % 2), 20 + (40 * (numPins / 2)), 14);
   newCircle.setFill(Color.BLACK);
   newCircle.setStroke(Color.BLACK);
   pinInput.getChildren().add(newCircle);
 }
Exemplo n.º 13
0
  void animateRoute(List<Path> path, Circle entranceMarker, GraphicsContext gc) {
    double entranceX = entranceMarker.getCenterX();
    double entranceY = entranceMarker.getCenterY();

    int currentKeyFrameTimeInMs = 0, keyframeTimeInMs = 50;

    List<KeyFrame> keyFrames = new ArrayList<>();
    List<AnimationTimer> timers = new ArrayList<>();

    for (int i = 0; i < path.size(); i++) {
      Path pathEntry = path.get(i);
      DoubleProperty opacity = new SimpleDoubleProperty();
      keyFrames.add(
          new KeyFrame(Duration.millis(currentKeyFrameTimeInMs), new KeyValue(opacity, 0)));
      keyFrames.add(
          new KeyFrame(
              Duration.millis(currentKeyFrameTimeInMs + keyframeTimeInMs),
              new KeyValue(opacity, 0.3)));

      timeline.setAutoReverse(true);
      timeline.setCycleCount(1);

      currentKeyFrameTimeInMs += keyframeTimeInMs;

      timers.add(
          new AnimationTimer() {
            @Override
            public void handle(long now) {
              gc.setFill(Color.FORESTGREEN.deriveColor(0, 1, 1, opacity.get()));
              if (maze.representation().length > 24) {
                gc.fillRect(
                    entranceX + calculateNextPosX(pathEntry.x, 2) - 20,
                    entranceY + calculateNextPosY(pathEntry.y, 2) - 176,
                    CELL_LENGTH,
                    CELL_LENGTH);
              } else {
                gc.fillRect(
                    entranceX + calculateNextPosX(pathEntry.x, 5) - 23,
                    entranceY + calculateNextPosY(pathEntry.y, 5) - 178,
                    CELL_LENGTH,
                    CELL_LENGTH);
              }
            }
          });
    }

    timeline.getKeyFrames().addAll(keyFrames);

    for (int i = 0; i < path.size(); i++) {
      timers.get(i).start();
    }
    timeline.play();
  }
Exemplo n.º 14
0
  private void resetBall() {
    ball.setFill(Color.BLUE);
    ball.setTranslateX(border.getX() + border.getWidth() / 2);

    double min = Math.toRadians(270) - STARTANGLE_VARIANCE;
    double max = Math.toRadians(270) + STARTANGLE_VARIANCE;
    ballAngle = Math.random() * (max - min) + min;
    dx = ballSpeed * Math.cos(ballAngle);
    dy = ballSpeed * Math.sin(ballAngle);

    // Note: translation point of circle is its middle point!
    ball.setTranslateY(border.getY() + ball.getRadius());
  }
Exemplo n.º 15
0
 private void configureHand() {
   Circle circle = new Circle(0, 0, radius / 18);
   circle.setFill(color);
   Rectangle rectangle1 =
       new Rectangle(
           -0.5 - radius / 140, +radius / 7 - radius / 1.08, radius / 70 + 1, radius / 1.08);
   Rectangle rectangle2 =
       new Rectangle(
           -0.5 - radius / 140, +radius / 3.5 - radius / 7, radius / 70 + 1, radius / 7);
   rectangle1.setFill(color);
   rectangle2.setFill(Color.BLACK);
   hand.getChildren().addAll(circle, rectangle1, rectangle2);
 }
Exemplo n.º 16
0
 /**
  * @param event Triggered by delete button next to pin input
  *     <p>Removes the last circle and pin from guesses
  */
 public void deletePin(ActionEvent event) {
   if (pinInput.getChildren().size() < 1) {
     return;
   }
   Circle temp = (Circle) pinInput.getChildren().get(pinInput.getChildren().size() - 1);
   GuessSet currentGuess = Main.initBoard.guesses.get(Main.initBoard.guesses.size() - 1);
   if (temp.getFill() == Color.BLACK) {
     currentGuess.blackPins--;
   } else if (temp.getFill() == Color.WHITE) {
     currentGuess.whitePins--;
   }
   pinInput.getChildren().remove(pinInput.getChildren().size() - 1);
 }
Exemplo n.º 17
0
  private void adjustConnectorSize() {

    if (!inputList.isEmpty() && !outputList.isEmpty()) {
      inputConnectorSize = Math.min(inputConnectorSize, outputConnectorSize);
      outputConnectorSize = inputConnectorSize;
    }

    for (Circle connector : inputList) {
      connector.setRadius(inputConnectorSize / 2.0);
    }

    for (Circle connector : outputList) {
      connector.setRadius(outputConnectorSize / 2.0);
    }
  }
  /** *********************************************** */
  public void init() {
    mvl = new Line(0, 0, 0, h);
    mvl.setStrokeWidth(1);
    mvl.setStroke(Color.RED);
    mhl = new Line(0, 0, w, 0);
    mhl.setStrokeWidth(1);
    mhl.setStroke(Color.BLUE);
    TargetPoint = new Circle(5);
    TargetPoint.setFill(Color.CADETBLUE);
    drawPane.getChildren().add(TargetPoint);

    Line vl = new Line(w / 2, 0, w / 2, h);
    vl.setStrokeWidth(0.2);
    Line hl = new Line(0, h / 2, w, h / 2);
    vl.setStrokeWidth(0.2);
    robot = new robot(35, 45);
    robot.setSpeed(0);
    robot.get().setFill(Color.BROWN);
    robot.get().setStroke(Color.BLACK);
    robot.setTranslateX((w - 35) / 2);
    robot.setTranslateY(h - 90);
    drawPane.getChildren().addAll(mhl, mvl, hl, vl, robot);
    Algorithm.setRobot(robot);
    Algorithm.setSpeed(0);
    Static.RoboTC = RoboTC;
    Static.RobotS = RobotS;
    Static.RobotR = RobotR;
    Static.SensorDR = SensorDR;
    Static.SensorDL = SensorDL;
  }
  public MaterialToolbar() {
    getStyleClass().add("material-toolbar");
    mainIcon = new AnimatedIcon();
    mainIcon.setIconFill(Color.WHITE);

    changeViewAnimationCircle = new Circle();
    changeViewAnimationCircle.setOpacity(0);
    changeViewAnimationCircle.setManaged(false);

    currentTitle = new Label("Main");
    currentTitle.getStyleClass().add("material-toolbar-text");

    changeViewAnimationTitle = new Label();
    changeViewAnimationTitle.setOpacity(0);
    changeViewAnimationTitle.getStyleClass().add("material-toolbar-text");

    background = new Rectangle();
    background.setManaged(false);
    background.setFill(Color.DARKSLATEBLUE);

    backgroundClip = new Rectangle();
    backgroundClip.setFill(Color.BLACK);
    backgroundClip.xProperty().bind(background.xProperty());
    backgroundClip.yProperty().bind(background.yProperty());
    backgroundClip.widthProperty().bind(background.widthProperty());
    backgroundClip.heightProperty().bind(background.heightProperty());
    changeViewAnimationCircle.setClip(backgroundClip);

    actionBox = new HBox();
    actionBox.setSpacing(6);

    getChildren()
        .addAll(
            mainIcon,
            changeViewAnimationCircle,
            currentTitle,
            changeViewAnimationTitle,
            background,
            actionBox);

    background.toBack();
    changeViewAnimationCircle.toFront();
    changeViewAnimationTitle.toFront();
    currentTitle.toFront();
    mainIcon.toFront();
    actionBox.toFront();
  }
Exemplo n.º 20
0
  public ProcessingAnimationView(
      ProcessingAnimationModel
          animationModel) { // ProcessingAnimationModel animationModel, MachineTestController
                            // testController) {
    this.processingAnimationModel = animationModel;
    //        this.machineTestController = testController;

    imageViewTop = new ImageView();
    imageViewTop.setFitWidth(270);
    imageViewTop.setFitHeight(100);
    imageViewTop.setX(200);
    imgTop = new Image("file:Image\\animation\\presTop.png");
    imageViewTop.setImage(imgTop);

    imageViewBot = new ImageView();
    imageViewBot.setTranslateY(40);
    imageViewBot.setFitWidth(270);
    imageViewBot.setFitHeight(300);
    imgBot = new Image("file:Image\\animation\\presBot.png");
    imageViewBot.setPreserveRatio(true);
    imageViewBot.setX(200);
    imageViewBot.setImage(imgBot);

    Image imgStorage = new Image("file:Image\\animation\\storage.png");
    imageViewLeftStorage = new ImageView();
    imageViewLeftStorage.setFitWidth(200);
    imageViewLeftStorage.setFitHeight(80);
    imageViewLeftStorage.setY(185);
    imageViewLeftStorage.setImage(imgStorage);

    imageViewRightStorage = new ImageView();
    imageViewRightStorage.setFitWidth(200);
    imageViewRightStorage.setFitHeight(80);
    imageViewRightStorage.setY(185);
    imageViewRightStorage.setX(500);
    imageViewRightStorage.setImage(imgStorage);

    rectangle = new Rectangle(340, 185, 15, 5);
    //        rectangle.setVisible(false);
    rectangle.setFill(Color.CORAL);
    circle = new Circle(190, 180, 10);
    circle.setFill(Color.CORAL);

    this.getChildren()
        .addAll(
            imageViewLeftStorage,
            imageViewRightStorage,
            rectangle,
            circle,
            imageViewBot,
            imageViewTop);

    this.setMinSize(300, 300);

    timeline = new Timeline();
    transitionCircle = new TranslateTransition();
    transitionRect = new TranslateTransition();
    products = new Stack<>();
  }
Exemplo n.º 21
0
 private Circle drawCircle(double x, double y, double radius, Color color) {
   Circle circle = new Circle(x, y, radius, color);
   RadialGradient gradient1 =
       new RadialGradient(
           0,
           0.1,
           x,
           y,
           radius,
           false,
           CycleMethod.NO_CYCLE,
           new Stop(0, color),
           new Stop(1, Color.BLACK));
   circle.setFill(gradient1);
   circle.setStyle("-fx-opacity: 0.8;");
   return circle;
 }
Exemplo n.º 22
0
 /** Sets color of circles in the inputBox */
 private void setAllCircles() {
   // TODO Auto-generated method stub
   ArrayList<GuessSet> set = Main.initBoard.guesses;
   for (int i = 0; i < inputBox.getChildren().size(); i++) {
     Circle temp = (Circle) inputBox.getChildren().get(i);
     temp.setFill(returnColor(Main.initBoard.currentGuess.pieceSet.get(i)));
   }
   /*int k =0;
   for (int j=0; j<set.size(); j++){
   	GuessSet temp = set.get(j);
   	for (int l=0; l<4;l++){
   		Circle tempCircle = (Circle) guesses.getChildren().get(k);
   		tempCircle.setFill(returnColor(temp.pieceSet.get(l)));
   		k++;
   	}
   	k=+temp.whitePins+temp.blackPins;
   }*/
 }
  /** ********************************************************** */
  public void setObstacles() {
    drawPane.setOnMouseClicked(
        e -> {
          if (Init) {
            object obj = new object(33, 33);
            obj.get().setX(e.getX());
            obj.get().setY(e.getY());
            obj.get().setFill(new Color(0.1, 0.1, 0.7, 0.5));
            obj.setSpeed(3);
            drawPane.getChildren().add(obj);
            Algorithm.add(obj);
          } else {
            TargetPoint.setCenterX(e.getX());
            TargetPoint.setCenterY(e.getY());

            Algorithm.setTarget(e.getX(), e.getY());
          }
        });
  }
Exemplo n.º 24
0
  public JFXToggleButtonSkin(JFXToggleButton toggleButton) {
    super(toggleButton);
    // hide the togg	le button
    toggleButton.setStyle("-fx-background-color:TRANSPARENT");

    line = new Line(startX, startY, endX, startY);
    line.setStroke(unToggledColor);
    line.setStrokeWidth(1);

    circle = new Circle(startX - circleRadius, startY, circleRadius);
    circle.setFill(Color.TRANSPARENT);
    circle.setStroke(unToggledColor);
    circle.setStrokeWidth(strokeWidth);

    innerCircle = new Circle(startX - circleRadius, startY, 0);
    innerCircle.setStrokeWidth(0);

    StackPane circlePane = new StackPane();
    circlePane.getChildren().add(circle);
    circlePane.getChildren().add(innerCircle);
    circlePane.setPadding(new Insets(15));
    rippler = new JFXRippler(circlePane, RipplerMask.CIRCLE, RipplerPos.BACK);

    circles.getChildren().add(rippler);

    main.getChildren().add(line);
    main.getChildren().add(circles);
    main.setCursor(Cursor.HAND);
    AnchorPane.setTopAnchor(circles, -12.0);
    AnchorPane.setLeftAnchor(circles, -15.0);

    getSkinnable()
        .selectedProperty()
        .addListener(
            (o, oldVal, newVal) -> {
              rippler.setRipplerFill(newVal ? unToggledColor : toggledColor);
              transition.setRate(newVal ? 1 : -1);
              transition.play();
            });

    updateChildren();
  }
Exemplo n.º 25
0
  @Override
  public void start(Stage primaryStage) {

    Circle circle = new Circle();

    StackPane root = new StackPane();
    root.getChildren().add(circle);

    Scene scene = new Scene(root, 100, 100);

    circle.centerXProperty().bind(scene.widthProperty().divide(2));
    circle.centerYProperty().bind(scene.heightProperty().divide(2));
    circle
        .radiusProperty()
        .bind(Bindings.min(scene.widthProperty(), scene.heightProperty()).divide(2));

    primaryStage.setTitle("Bindings in java fx");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
  @Override
  public void start(Stage primaryStage) throws Exception {

    Pane pane = new Pane();
    int x = RADIUS + GAP;
    int y = RADIUS + GAP;

    for (int i = 0; i < 2; i++) {

      // drawing a 2 Circles in each row
      for (int j = 0; j < 2; j++) {
        // create circle
        Circle c = new Circle(RADIUS);
        c.setCenterX(x);
        c.setCenterY(y);
        c.setStroke(Color.BLACK);
        c.setFill(Color.WHITE);
        pane.getChildren().add(c);

        // create 4 arcs in each circle with 90 degree increment
        for (int k = 30; k < 360; k += 90) {
          Arc arc = new Arc(x, y, RADIUS - 15, RADIUS - 15, k, 30);
          arc.setFill(Color.BLACK);
          arc.setType(ArcType.ROUND);
          pane.getChildren().add(arc);
        }

        x += RADIUS * 2 + GAP;
      }
      // reset center for the next row
      x = RADIUS + GAP;
      y += RADIUS * 2 + GAP;
    }

    Scene scene = new Scene(pane, 425, 425);
    primaryStage.setScene(scene);
    primaryStage.setTitle("Fans");
    primaryStage.show();
  }
Exemplo n.º 27
0
  private void setJointPoint() {
    rightElbowPoint.centerXProperty().bind(speaker.rightElbowXProperty());
    rightElbowPoint.centerYProperty().bind(speaker.rightElbowYProperty());

    leftElbowPoint.centerXProperty().bind(speaker.leftElbowXProperty());
    leftElbowPoint.centerYProperty().bind(speaker.leftElbowYProperty());

    rightKneePoint.centerXProperty().bind(speaker.rightKneeXProperty());
    rightKneePoint.centerYProperty().bind(speaker.rightKneeYProperty());

    leftKneePoint.centerXProperty().bind(speaker.leftKneeXProperty());
    leftKneePoint.centerYProperty().bind(speaker.leftKneeYProperty());

    getChildren().addAll(rightElbowPoint, leftElbowPoint, rightKneePoint, leftKneePoint);
  }
Exemplo n.º 28
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Pane pane = new Pane();

    Circle circle = new Circle(250, 250, 50);
    circle.setStroke(Color.BLACK);

    Slider slider = new Slider(0, 250, 0);
    slider.setTranslateY(390);
    slider
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              circle.setStrokeWidth(newValue.intValue());
            });

    pane.getChildren().addAll(slider, circle);

    Scene scene = new Scene(pane, 500, 500);
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(event -> System.exit(0));
    primaryStage.show();
  }
Exemplo n.º 29
0
 /** Sets fill of each circle button to color picker color */
 private void setCircles() {
   // TODO Auto-generated method stub
   A.setFill(ASet.getValue());
   B.setFill(BSet.getValue());
   C.setFill(CSet.getValue());
   D.setFill(DSet.getValue());
   E.setFill(ESet.getValue());
   F.setFill(FSet.getValue());
 }
Exemplo n.º 30
0
 private Timeline getToggleTransition() {
   return new Timeline(
       new KeyFrame(
           Duration.ZERO,
           new KeyValue(circles.translateXProperty(), 0, Interpolator.LINEAR),
           new KeyValue(line.strokeProperty(), unToggledColor, Interpolator.EASE_BOTH),
           new KeyValue(innerCircle.strokeWidthProperty(), 0, Interpolator.EASE_BOTH),
           new KeyValue(innerCircle.radiusProperty(), 0, Interpolator.EASE_BOTH)),
       new KeyFrame(
           Duration.millis(30),
           new KeyValue(circles.translateXProperty(), 0, Interpolator.LINEAR),
           new KeyValue(line.strokeProperty(), unToggledColor, Interpolator.EASE_BOTH)),
       new KeyFrame(
           Duration.millis(70),
           new KeyValue(
               circles.translateXProperty(),
               endX - startX + 2 * circleRadius,
               Interpolator.LINEAR),
           new KeyValue(line.strokeProperty(), toggledColor, Interpolator.EASE_BOTH)),
       new KeyFrame(
           Duration.millis(100),
           new KeyValue(innerCircle.radiusProperty(), circleRadius, Interpolator.EASE_BOTH),
           new KeyValue(innerCircle.strokeWidthProperty(), strokeWidth, Interpolator.EASE_BOTH)));
 }