public DeterminateIndicator(
        ConfidenceProgressIndicator control,
        ConfidenceProgressIndicatorSkin s,
        Paint fillOverride) {
      this.control = control;

      getStyleClass().add("determinate-indicator");

      intProgress = (int) Math.round(control.getProgress() * 100.0);
      degProgress = (int) (360 * control.getProgress());

      InvalidationListener progressListener = valueModel -> updateProgress();
      control.progressProperty().addListener(progressListener);

      getChildren().clear();

      // The circular background for the progress pie piece
      indicator = new StackPane();
      indicator.setScaleShape(false);
      indicator.setCenterShape(false);
      indicator.getStyleClass().setAll("indicator");
      indicatorCircle = new Circle();
      indicator.setShape(indicatorCircle);

      // The shape for our progress pie piece
      arcShape = new Arc();
      arcShape.setType(ArcType.ROUND);
      arcShape.setStartAngle(90.0F);

      // Our progress pie piece
      progress = new StackPane();
      progress.getStyleClass().setAll("progress");
      progress.setScaleShape(false);
      progress.setCenterShape(false);
      progress.setShape(arcShape);
      progress.getChildren().clear();
      setFillOverride(fillOverride);

      // The check mark that's drawn at 100%
      tick = new StackPane();
      tick.getStyleClass().setAll("tick");

      getChildren().setAll(indicator, progress, /*text,*/ tick);
      updateProgress();
    }
  @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();
  }
示例#3
0
  private void drawSections() {
    if (sections.isEmpty()) return;
    sectionLayer.getChildren().clear();

    double centerX = width * 0.5;
    double centerY = height * 0.85;
    double barRadius = height * 0.54210526;
    double barWidth = width * 0.28472222;

    for (Section section : sections) {
      Arc sectionBar =
          new Arc(
              centerX,
              centerY,
              barRadius,
              barRadius,
              angleRange * 0.5 + 90 - (section.getStart() * angleStep),
              -((section.getStop() - section.getStart()) - minValue) * angleStep);
      sectionBar.setType(ArcType.OPEN);
      sectionBar.setStroke(section.getColor());
      sectionBar.setStrokeWidth(barWidth);
      sectionBar.setStrokeLineCap(StrokeLineCap.BUTT);
      sectionBar.setFill(null);
      Tooltip sectionTooltip =
          new Tooltip(
              new StringBuilder(section.getText())
                  .append("\n")
                  .append(String.format(Locale.US, "%.2f", section.getStart()))
                  .append(" - ")
                  .append(String.format(Locale.US, "%.2f", section.getStop()))
                  .toString());
      sectionTooltip.setTextAlignment(TextAlignment.CENTER);
      Tooltip.install(sectionBar, sectionTooltip);
      sectionLayer.getChildren().add(sectionBar);
    }
  }
示例#4
0
  // ******************** Initialization ************************************
  private void initGraphics() {
    // Set initial size
    if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0
        || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0
        || Double.compare(getSkinnable().getWidth(), 0.0) <= 0
        || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) {
      if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) {
        getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight());
      } else {
        getSkinnable().setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
      }
    }

    barBackground =
        new Arc(
            PREFERRED_WIDTH * 0.5,
            PREFERRED_HEIGHT * 0.696,
            PREFERRED_WIDTH * 0.275,
            PREFERRED_WIDTH * 0.275,
            angleRange * 0.5 + 90,
            -angleRange);
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(getSkinnable().getBarBackgroundColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);

    sectionLayer = new Pane();
    sectionLayer.setBackground(
        new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));

    bar =
        new Arc(
            PREFERRED_WIDTH * 0.5,
            PREFERRED_HEIGHT * 0.696,
            PREFERRED_WIDTH * 0.275,
            PREFERRED_WIDTH * 0.275,
            angleRange * 0.5 + 90,
            0);
    bar.setType(ArcType.OPEN);
    bar.setStroke(getSkinnable().getBarColor());
    bar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    bar.setStrokeLineCap(StrokeLineCap.BUTT);
    bar.setFill(null);
    // bar.setMouseTransparent(sectionsAlwaysVisible ? true : false);
    bar.setVisible(!sectionsAlwaysVisible);

    needleRotate = new Rotate((getSkinnable().getValue() - oldValue - minValue) * angleStep);

    needleMoveTo1 = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleCubicCurveTo5 = new CubicCurveTo();
    needleCubicCurveTo6 = new CubicCurveTo();
    needleCubicCurveTo7 = new CubicCurveTo();
    needleClosePath8 = new ClosePath();
    needle =
        new Path(
            needleMoveTo1,
            needleCubicCurveTo2,
            needleCubicCurveTo3,
            needleCubicCurveTo4,
            needleCubicCurveTo5,
            needleCubicCurveTo6,
            needleCubicCurveTo7,
            needleClosePath8);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);
    needle.setFill(getSkinnable().getNeedleColor());
    needle.setPickOnBounds(false);
    needle.setStrokeType(StrokeType.INSIDE);
    needle.setStrokeWidth(1);
    needle.setStroke(getSkinnable().getBackgroundPaint());

    needleTooltip = new Tooltip(String.format(locale, formatString, getSkinnable().getValue()));
    needleTooltip.setTextAlignment(TextAlignment.CENTER);
    Tooltip.install(needle, needleTooltip);

    minValueText =
        new Text(
            String.format(
                locale,
                "%." + getSkinnable().getTickLabelDecimals() + "f",
                getSkinnable().getMinValue()));
    minValueText.setFill(getSkinnable().getTitleColor());
    Helper.enableNode(minValueText, getSkinnable().getTickLabelsVisible());

    maxValueText =
        new Text(
            String.format(
                locale,
                "%." + getSkinnable().getTickLabelDecimals() + "f",
                getSkinnable().getMaxValue()));
    maxValueText.setFill(getSkinnable().getTitleColor());
    Helper.enableNode(maxValueText, getSkinnable().getTickLabelsVisible());

    titleText = new Text(getSkinnable().getTitle());
    titleText.setFill(getSkinnable().getTitleColor());
    Helper.enableNode(titleText, !getSkinnable().getTitle().isEmpty());

    if (!sections.isEmpty() && sectionsVisible && !sectionsAlwaysVisible) {
      barTooltip = new Tooltip();
      barTooltip.setTextAlignment(TextAlignment.CENTER);
      Tooltip.install(bar, barTooltip);
    }

    pane =
        new Pane(barBackground, sectionLayer, bar, needle, minValueText, maxValueText, titleText);
    pane.setBorder(
        new Border(
            new BorderStroke(
                getSkinnable().getBorderPaint(),
                BorderStrokeStyle.SOLID,
                CornerRadii.EMPTY,
                new BorderWidths(getSkinnable().getBorderWidth()))));
    pane.setBackground(
        new Background(
            new BackgroundFill(
                getSkinnable().getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
  }