private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.setPadding(new Insets(8, 12, 8, 12)); }
@Override protected void layoutChildren() { performingLayout = true; List<Node> managed = getManagedChildren(); final double width = getWidth(); double height = getHeight(); double top = getInsets().getTop(); double right = getInsets().getRight(); double left = getInsets().getLeft(); double bottom = getInsets().getBottom(); double contentWidth = width - left - right; double contentHeight = height - top - bottom; for (int i = 0, size = managed.size(); i < size; i++) { Node child = managed.get(i); layoutInArea(child, left, top, contentWidth, contentHeight, 0, Insets.EMPTY, HPos.CENTER, VPos.CENTER); } performingLayout = false; }
@Override protected double computePrefWidth(double height) { final int nCols = daysPerWeek + (datePicker.isShowWeekNumbers() ? 1 : 0); final double leftSpace = snapSpace(getInsets().getLeft()); final double rightSpace = snapSpace(getInsets().getRight()); final double hgaps = snapSpace(getHgap()) * (nCols - 1); // compute content width final double contentWidth = super.computePrefWidth(height) - leftSpace - rightSpace - hgaps; return ((snapSize(contentWidth / nCols)) * nCols) + leftSpace + rightSpace + hgaps; }
this.setPadding(new Insets(this.getPadding().getTop(), 0, this.getPadding().getBottom(), 0)); StackPane.setMargin(dropIcon, new Insets(0, 19, 0, 0)); StackPane.setAlignment(dropIcon, Pos.CENTER_RIGHT); sublistContainer.setTranslateY(this.snappedBottomInset()); sublistContainer.setOpacity(0); StackPane.setMargin(newNode, new Insets(-1, -1, 0, -1));
Platform.runLater(new Runnable() { @Override public void run() { final StackPane region = (StackPane) tabPane.lookup(".headers-region"); final StackPane regionTop = (StackPane) tabPane.lookup(".tab-pane:top *.tab-header-area"); regionTop.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { Insets in = regionTop.getPadding(); regionTop.setPadding(new Insets( in.getTop(), in.getRight(), in.getBottom(), arg2.doubleValue() / 2 - region.getWidth() / 2)); } }); // force re-layout so the tabs aligned to center at initial state stage.setWidth(stage.getWidth() + 1); } });
double borderWidth = ripplerPane.getBorder() != null ? ripplerPane.getBorder().getInsets().getTop() : 0; Bounds bounds = control.getBoundsInParent(); double width = control.getLayoutBounds().getWidth();
private int getInnerMarginBottom() { return (int) Math.ceil(getMarginHeight() + getMarginBottom() + getPadding().getBottom()); }
private int getInnerMarginRight() { return (int) Math.ceil(getMarginWidth() + getMarginRight() + getPadding().getRight()); }
private int getInnerMarginLeft() { return (int) Math.ceil(getMarginWidth() + getMarginLeft() + getPadding().getLeft()); }
public Bounds getRangeBoundsOnScreen(int from, int to) { layout(); // ensure layout, is a no-op if not dirty PathElement[] rangeShape = getRangeShapeSafely(from, to); Path p = new Path(); p.setManaged(false); p.setLayoutX(getInsets().getLeft()); p.setLayoutY(getInsets().getTop()); getChildren().add(p); p.getElements().setAll(rangeShape); Bounds localBounds = p.getBoundsInLocal(); Bounds rangeBoundsOnScreen = p.localToScreen(localBounds); getChildren().remove(p); return rangeBoundsOnScreen; }
private int getInnerMarginTop() { return (int) Math.ceil(getMarginHeight() + getMarginTop() + getPadding().getTop()); }
private int getInnerMarginBottom() { return (int) Math.ceil(getMarginHeight() + getMarginBottom() + getPadding().getBottom()); }
private int getInnerMarginRight() { return (int) Math.ceil(getMarginWidth() + getMarginRight() + getPadding().getRight()); }
private int getInnerMarginLeft() { return (int) Math.ceil(getMarginWidth() + getMarginLeft() + getPadding().getLeft()); }
@Override protected void layoutChildren() { performingLayout = true; List<Node> managed = getManagedChildren(); final double width = getWidth(); double height = getHeight(); double top = getInsets().getTop(); double right = getInsets().getRight(); double left = getInsets().getLeft(); double bottom = getInsets().getBottom(); double contentWidth = width - left - right; double contentHeight = height - top - bottom; for (Node child : managed) { layoutInArea(child, left, top, contentWidth, contentHeight, 0, Insets.EMPTY, HPos.CENTER, VPos.CENTER); } performingLayout = false; }
private ScrollPane allGlyphs() { List<SVGGlyph> glyphs = SVGGlyphLoader.getAllGlyphsIDs() .stream() .map(glyphName -> { try { return SVGGlyphLoader.getIcoMoonGlyph(glyphName); } catch (Exception e) { return null; } }) .collect(Collectors.toList()); glyphs.sort(Comparator.comparing(SVGGlyph::getName)); glyphs.forEach(glyph -> glyph.setSize(16)); List<Button> iconButtons = glyphs.stream().map(this::createIconButton).collect(Collectors.toList()); // important to improve the performance of animation in scroll pane so buttons are treated as images iconButtons.forEach(button -> button.setCache(true)); Platform.runLater(()->iconButtons.get(0).fire()); FlowPane glyphLayout = new FlowPane(); glyphLayout.setHgap(10); glyphLayout.setVgap(10); glyphLayout.setPadding(new Insets(10)); glyphLayout.getChildren().setAll(iconButtons); glyphLayout.setPrefSize(600, 300); ScrollPane scrollableGlyphs = new ScrollPane(glyphLayout); scrollableGlyphs.setFitToWidth(true); return scrollableGlyphs; }