示例#1
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);
    }
  }
    private void configureBackground() {
      ImageView imageView = new ImageView();
      Image image = loadImage();
      imageView.setImage(image);

      Circle circle1 = new Circle();
      circle1.setCenterX(140);
      circle1.setCenterY(140);
      circle1.setRadius(120);
      circle1.setFill(Color.TRANSPARENT);
      circle1.setStroke(Color.web("#0A0A0A"));
      circle1.setStrokeWidth(0.3);

      Circle circle2 = new Circle();
      circle2.setCenterX(140);
      circle2.setCenterY(140);
      circle2.setRadius(118);
      circle2.setFill(Color.TRANSPARENT);
      circle2.setStroke(Color.web("#0A0A0A"));
      circle2.setStrokeWidth(0.3);

      Circle circle3 = new Circle();
      circle3.setCenterX(140);
      circle3.setCenterY(140);
      circle3.setRadius(140);
      circle3.setFill(Color.TRANSPARENT);
      circle3.setStroke(Color.web("#818a89"));
      circle3.setStrokeWidth(1);

      Ellipse ellipse = new Ellipse(140, 95, 180, 95);
      Circle ellipseClip = new Circle(140, 140, 140);
      ellipse.setFill(Color.web("#535450"));
      ellipse.setStrokeWidth(0);
      GaussianBlur ellipseEffect = new GaussianBlur();
      ellipseEffect.setRadius(10);
      ellipse.setEffect(ellipseEffect);
      ellipse.setOpacity(0.1);
      ellipse.setClip(ellipseClip);
      background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse);
    }
    @Override
    protected void layoutChildren() {
      // Position and size the circular background
      // double doneTextHeight = doneText.getLayoutBounds().getHeight();
      final Insets controlInsets = control.getInsets();
      final double left = snapSize(controlInsets.getLeft());
      final double right = snapSize(controlInsets.getRight());
      final double top = snapSize(controlInsets.getTop());
      final double bottom = snapSize(controlInsets.getBottom());

      /*
       ** use the min of width, or height, keep it a circle
       */
      final double areaW = control.getWidth() - left - right;
      final double areaH = control.getHeight() - top - bottom /*- textGap - doneTextHeight*/;
      final double radiusW = areaW / 2;
      final double radiusH = areaH / 2;
      final double radius = Math.round(Math.min(radiusW, radiusH)); // use round instead of floor
      final double centerX = snapPosition(left + radiusW);
      final double centerY = snapPosition(top + radius);

      // find radius that fits inside radius - insetsPadding
      final Insets indicatorInsets = indicator.getInsets();
      final double iLeft = snapSize(indicatorInsets.getLeft());
      final double iRight = snapSize(indicatorInsets.getRight());
      final double iTop = snapSize(indicatorInsets.getTop());
      final double iBottom = snapSize(indicatorInsets.getBottom());
      final double progressRadius =
          snapSize(
              Math.min(
                  Math.min(radius - iLeft, radius - iRight),
                  Math.min(radius - iTop, radius - iBottom)));

      indicatorCircle.setRadius(radius);
      indicator.setLayoutX(centerX);
      indicator.setLayoutY(centerY);

      arcShape.setRadiusX(progressRadius);
      arcShape.setRadiusY(progressRadius);
      progress.setLayoutX(centerX);
      progress.setLayoutY(centerY);

      // find radius that fits inside progressRadius - progressInsets
      final Insets progressInsets = progress.getInsets();
      final double pLeft = snapSize(progressInsets.getLeft());
      final double pRight = snapSize(progressInsets.getRight());
      final double pTop = snapSize(progressInsets.getTop());
      final double pBottom = snapSize(progressInsets.getBottom());
      final double indicatorRadius =
          snapSize(
              Math.min(
                  Math.min(progressRadius - pLeft, progressRadius - pRight),
                  Math.min(progressRadius - pTop, progressRadius - pBottom)));

      // find size of spare box that fits inside indicator radius
      double squareBoxHalfWidth = Math.ceil(Math.sqrt((indicatorRadius * indicatorRadius) / 2));
      // double squareBoxHalfWidth2 = indicatorRadius * (Math.sqrt(2) / 2);

      tick.setLayoutX(centerX - squareBoxHalfWidth);
      tick.setLayoutY(centerY - squareBoxHalfWidth);
      tick.resize(squareBoxHalfWidth + squareBoxHalfWidth, squareBoxHalfWidth + squareBoxHalfWidth);
      tick.setVisible(control.getProgress() >= 1);
    }
示例#4
0
文件: Main.java 项目: 1j4k7/Graphics
  @Override
  public void start(Stage stage) {
    sun.setFitHeight(100);
    sun.setFitWidth(100);
    sun.setX(200);
    sun.setY(200);
    quas.setFitHeight(50);
    quas.setFitWidth(50);
    wex.setFitHeight(50);
    wex.setFitWidth(50);
    exort.setFitHeight(50);
    exort.setFitWidth(50);

    Circle orbit1 = new Circle();
    orbit1.setRotate(-90);
    orbit1.setRadius(100);
    orbit1.setCenterX(250);
    orbit1.setCenterY(250);
    PathTransition path1 = new PathTransition();
    path1.setPath(orbit1);
    path1.setNode(quas);
    path1.setDuration(Duration.seconds(5));
    path1.setCycleCount(Timeline.INDEFINITE);

    Circle orbit2 = new Circle();
    orbit2.setRotate(30);
    orbit2.setRadius(100);
    orbit2.setCenterX(250);
    orbit2.setCenterY(250);
    PathTransition path2 = new PathTransition();
    path2.setPath(orbit2);
    path2.setNode(wex);
    path2.setDuration(Duration.seconds(5));
    path2.setCycleCount(Timeline.INDEFINITE);

    Circle orbit3 = new Circle();
    orbit3.setRotate(150);
    orbit3.setRadius(100);
    orbit3.setCenterX(250);
    orbit3.setCenterY(250);
    PathTransition path3 = new PathTransition();
    path3.setPath(orbit3);
    path3.setNode(exort);
    path3.setDuration(Duration.seconds(5));
    path3.setCycleCount(Timeline.INDEFINITE);

    ComboBox<String> invoke = new ComboBox<String>();
    invoke.setEditable(false);
    invoke
        .getItems()
        .addAll(
            "Cold Snap",
            "Ghost Walk",
            "Tornado",
            "EMP",
            "Alacrity",
            "Chaos Meteor",
            "Sun Strike",
            "Forge Spirit",
            "Ice Wall",
            "Deafening Blast");
    invoke.setOnAction(
        e -> {
          switch (invoke.getValue()) {
            case "Cold Snap":
              path1.setNode(quas);
              path2.setNode(quas);
              path3.setNode(quas);
              break;
            case "Ghost Walk":
              path1.setNode(quas);
              path2.setNode(quas);
              path3.setNode(wex);
              break;
            case "Tornado":
              path1.setNode(wex);
              path2.setNode(wex);
              path3.setNode(quas);
              break;
            case "EMP":
              path1.setNode(wex);
              path2.setNode(wex);
              path3.setNode(wex);
              break;
            case "Alacrity":
              path1.setNode(wex);
              path2.setNode(wex);
              path3.setNode(exort);
              break;
            case "Chaos Meteor":
              path1.setNode(exort);
              path2.setNode(exort);
              path3.setNode(wex);
              break;
            case "Sun Strike":
              path1.setNode(exort);
              path2.setNode(exort);
              path3.setNode(exort);
              break;
            case "Forge Spirit":
              path1.setNode(exort);
              path2.setNode(exort);
              path3.setNode(quas);
              break;
            case "Ice Wall":
              path1.setNode(quas);
              path2.setNode(quas);
              path3.setNode(exort);
              break;
            case "Deafening Blast":
              path1.setNode(quas);
              path2.setNode(wex);
              path3.setNode(exort);
              break;
            default:
              path1.setNode(quas);
              path2.setNode(wex);
              path3.setNode(exort);
              break;
          }
        });

    path1.play();
    path2.play();
    path3.play();

    Pane pane = new Pane();
    pane.getChildren().addAll(quas, wex, exort, sun, invoke);
    stage.setScene(new Scene(pane, 500, 500));
    stage.setTitle("Spell Combinations");
    stage.show();
  }