コード例 #1
0
 @Override
 protected double computePrefWidth(double height) {
   final Insets controlInsets = control.getInsets();
   final double left = snapSize(controlInsets.getLeft());
   final double right = snapSize(controlInsets.getRight());
   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 indicatorMax =
       snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom)));
   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 progressMax =
       snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom)));
   final Insets tickInsets = tick.getInsets();
   final double tLeft = snapSize(tickInsets.getLeft());
   final double tRight = snapSize(tickInsets.getRight());
   final double indicatorWidth =
       indicatorMax + progressMax + tLeft + tRight + progressMax + indicatorMax;
   return left
       + indicatorWidth
       + /*Math.max(indicatorWidth, doneText.getLayoutBounds().getWidth()) + */ right;
 }
コード例 #2
0
 @Override
 protected double computePrefHeight(double width) {
   final Insets controlInsets = control.getInsets();
   final double top = snapSize(controlInsets.getTop());
   final double bottom = snapSize(controlInsets.getBottom());
   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 indicatorMax =
       snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom)));
   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 progressMax =
       snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom)));
   final Insets tickInsets = tick.getInsets();
   final double tTop = snapSize(tickInsets.getTop());
   final double tBottom = snapSize(tickInsets.getBottom());
   final double indicatorHeight =
       indicatorMax + progressMax + tTop + tBottom + progressMax + indicatorMax;
   return top + indicatorHeight /*+ textGap  + doneText.getLayoutBounds().getHeight()*/ + bottom;
 }
コード例 #3
0
ファイル: FXUtils.java プロジェクト: michaelopes/jidefx-oss
 public static Insets add(Insets insets1, Insets insets2) {
   if (insets1 == null) {
     return insets2;
   } else if (insets2 == null) {
     return insets1;
   }
   return new Insets(
       insets1.getTop() + insets2.getTop(),
       insets1.getRight() + insets2.getRight(),
       insets1.getBottom() + insets2.getBottom(),
       insets1.getLeft() + insets2.getLeft());
 }
コード例 #4
0
  @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);
  }
コード例 #5
0
  public static void startValueSetAnimation(final Pane parent) {
    final javafx.scene.shape.Rectangle rectangle = new javafx.scene.shape.Rectangle();
    Insets margin = BorderPane.getMargin(parent);
    if (margin == null) {
      margin = new Insets(0);
    }
    rectangle
        .widthProperty()
        .bind(parent.widthProperty().subtract(margin.getLeft() + margin.getRight()));
    rectangle
        .heightProperty()
        .bind(parent.heightProperty().subtract(margin.getTop() + margin.getBottom()));
    rectangle.setFill(Color.rgb(0, 150, 201));
    parent.getChildren().add(rectangle);

    BoxBlur bb = new BoxBlur();
    bb.setWidth(5);
    bb.setHeight(5);
    bb.setIterations(3);
    rectangle.setEffect(bb);

    FadeTransition ft = new FadeTransition(Duration.millis(250), rectangle);
    ft.setFromValue(0.2);
    ft.setToValue(0.8);
    ft.setCycleCount(2);
    ft.setAutoReverse(true);
    ft.play();
    ft.setOnFinished(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            parent.getChildren().remove(rectangle);
          }
        });
  }
コード例 #6
0
 @Override
 protected void layoutChildren() {
   final Insets insets = getInsets();
   scrollPane.relocate(insets.getLeft(), insets.getTop());
   scrollPane.resize(
       getWidth() - insets.getLeft() - insets.getRight(),
       getHeight() - insets.getTop() - insets.getBottom());
 }
コード例 #7
0
 @Override
 protected double computePrefHeight(double forWidth) {
   final Insets insets = getInsets();
   if (getOrientation() == HORIZONTAL) {
     // horizontal
     double maxRunWidth =
         forWidth != -1 ? forWidth - insets.getLeft() - insets.getRight() : getPrefWrapLength();
     List<Run> hruns = getRuns(maxRunWidth);
     return insets.getTop() + computeContentHeight(hruns) + insets.getBottom();
   } else {
     // vertical
     double maxRunHeight = getPrefWrapLength();
     List<Run> vruns = getRuns(maxRunHeight);
     double h = computeContentHeight(vruns);
     h = getPrefWrapLength() > h ? getPrefWrapLength() : h;
     return insets.getTop() + snapSize(h) + insets.getBottom();
   }
 }
コード例 #8
0
 /*     */ protected void layoutChildren() {
   /*  50 */ super.layoutChildren();
   /*     */
   /*  52 */ if (((ProgressBar) getSkinnable()).isIndeterminate()) {
     /*  53 */ return;
     /*     */ }
   /*     */
   /*  56 */ StackPane track = (StackPane) getChildren().get(0);
   /*  57 */ StackPane bar = (StackPane) getChildren().get(1);
   /*     */
   /*  59 */ if (!bar.getChildren().contains(this.topGradient)) {
     /*  60 */ bar.getChildren().add(this.topGradient);
     /*     */ }
   /*     */
   /*  63 */ if (!bar.getChildren().contains(this.bottomGradient)) {
     /*  64 */ bar.getChildren().add(this.bottomGradient);
     /*     */ }
   /*     */
   /*  67 */ if (!getChildren().contains(this.verticalLines)) {
     /*  68 */ getChildren().add(this.verticalLines);
     /*     */ }
   /*     */
   /*  71 */ Insets insets = getInsets();
   /*  72 */ double x = insets.getLeft();
   /*  73 */ double y = insets.getTop();
   /*  74 */ double w = getWidth() - (insets.getLeft() + insets.getRight());
   /*  75 */ double h = getHeight() - (insets.getTop() + insets.getBottom());
   /*     */
   /*  78 */ double scale = Math.floor(w / 14.0D) * 14.0D / w;
   /*     */
   /*  80 */ double barWidth = bar.getWidth() * scale;
   /*  81 */ double barHeight = bar.getHeight();
   /*     */
   /*  83 */ track.resize(track.getWidth() * scale, track.getHeight());
   /*  84 */ bar.resize(barWidth, barHeight);
   /*     */
   /*  86 */ this.topGradient.setX(x + this.gradientMargin);
   /*  87 */ this.topGradient.setY(y + 0.5D);
   /*  88 */ this.topGradient.setWidth(barWidth - 2.0D * this.gradientMargin);
   /*  89 */ this.topGradient.setHeight(
       barHeight * 0.3D / this.gradientRadius * this.gradientTweak);
   /*     */
   /*  91 */ this.bottomGradient.setX(x + this.gradientMargin);
   /*  92 */ this.bottomGradient.setWidth(barWidth - 2.0D * this.gradientMargin);
   /*  93 */ double gh = barHeight * 0.21D / this.gradientRadius * this.gradientTweak;
   /*  94 */ this.bottomGradient.setY(barHeight - gh - 0.5D);
   /*  95 */ this.bottomGradient.setHeight(gh);
   /*     */
   /*  97 */ this.verticalLines.setX(x);
   /*  98 */ this.verticalLines.setY(y);
   /*  99 */ this.verticalLines.setWidth(w * scale);
   /* 100 */ this.verticalLines.setHeight(h);
   /*     */ }
コード例 #9
0
  @Override
  protected void layoutChildren() {
    final Insets insets = getInsets();
    final double width = getWidth();
    final double height = getHeight();
    final double top = insets.getTop();
    final double left = insets.getLeft();
    final double bottom = insets.getBottom();
    final double right = insets.getRight();
    final double insideWidth = width - left - right;
    final double insideHeight = height - top - bottom;

    // REMIND(aim): need to figure out how to cache the runs to avoid over-calculation
    final List<Run> runs = getRuns(getOrientation() == HORIZONTAL ? insideWidth : insideHeight);

    // Now that the nodes are broken into runs, figure out alignments
    for (int i = 0, max = runs.size(); i < max; i++) {
      final Run run = runs.get(i);
      final double xoffset =
          left
              + computeXOffset(
                  insideWidth,
                  getOrientation() == HORIZONTAL ? run.width : computeContentWidth(runs),
                  getAlignmentInternal().getHpos());
      final double yoffset =
          top
              + computeYOffset(
                  insideHeight,
                  getOrientation() == VERTICAL ? run.height : computeContentHeight(runs),
                  getAlignmentInternal().getVpos());
      for (int j = 0; j < run.rects.size(); j++) {
        final LayoutRect lrect = run.rects.get(j);
        //              System.out.println("flowpane.layout: run="+i+" "+run.width+"x"+run.height+"
        // xoffset="+xoffset+" yoffset="+yoffset+" lrect="+lrect);
        final double x = xoffset + lrect.x;
        final double y = yoffset + lrect.y;
        layoutInArea(
            lrect.node,
            x,
            y,
            getOrientation() == HORIZONTAL ? lrect.width : run.width,
            getOrientation() == VERTICAL ? lrect.height : run.height,
            run.baselineOffset,
            getMargin(lrect.node),
            getColumnHalignmentInternal(),
            getRowValignmentInternal());
      }
    }
  }
コード例 #10
0
 @Override
 protected double computeMinHeight(double width) {
   if (getContentBias() == VERTICAL) {
     double maxPref = 0;
     final List<Node> children = getChildren();
     for (int i = 0, size = children.size(); i < size; i++) {
       Node child = children.get(i);
       if (child.isManaged()) {
         maxPref = Math.max(maxPref, child.prefHeight(-1));
       }
     }
     final Insets insets = getInsets();
     return insets.getTop() + snapSize(maxPref) + insets.getBottom();
   }
   return computePrefHeight(width);
 }
コード例 #11
0
 @Override
 protected void layoutChildren() {
   Insets controlInsets = control.getInsets();
   final double w = control.getWidth() - controlInsets.getLeft() - controlInsets.getRight();
   final double h = control.getHeight() - controlInsets.getTop() - controlInsets.getBottom();
   final double prefW = pathsG.prefWidth(-1);
   final double prefH = pathsG.prefHeight(-1);
   double scaleX = w / prefW;
   double scale = scaleX;
   if ((scaleX * prefH) > h) {
     scale = h / prefH;
   }
   double indicatorW = prefW * scale - 3;
   double indicatorH = prefH * scale - 3;
   pathsG.resizeRelocate((w - indicatorW) / 2, (h - indicatorH) / 2, indicatorW, indicatorH);
 }
コード例 #12
0
    @Override
    protected double computePrefHeight(double width) {
      if (width == -1) width = 400;
      final Insets insets = getInsets();
      width = width - insets.getLeft() - insets.getRight();

      double h = eventTitle.prefHeight(width) + GAP;

      final double labelWidth = computeLabelWidth();
      final double valueWidth = width - labelWidth - GAP;

      // Add the heights of the 3 values, plus the 12 pixel gap between them
      h += item1Value.prefHeight(valueWidth);

      if (item2Value != null) {
        h += GAP;
        h += item2Value.prefHeight(valueWidth);
      }

      if (item3Value != null) {
        h += GAP;
        h += item3Value.prefHeight(valueWidth);
      }

      // Add the height of the desc plus padding
      if (desc != null) {
        h += GAP;
        h += desc.prefHeight(width);
      }

      // Add the height of the button plus padding
      if (button != null) {
        h += GAP;
        h += button.prefHeight(width);
      }

      return insets.getTop() + h + insets.getBottom();
    }
コード例 #13
0
    @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);
    }
コード例 #14
0
 @Override
 protected double computePrefHeight(double width) {
   final Insets insets = getInsets();
   return insets.getTop() + content.prefHeight(width) + insets.getBottom();
 }