/** * resize the svg to certain width while keeping the width/height ratio * * @param width in pixel */ public void setSizeForWidth(double width) { double height = width / widthHeightRatio; setSize(width, height); }
/** * resize the svg to certain width while keeping the width/height ratio * * @param height in pixel */ public void setSizeForHeight(double height) { double width = height * widthHeightRatio; setSize(width, height); }
/** * resize the svg to this size while keeping the width/height ratio * * @param size in pixel */ private void setSizeRatio(double size) { double width = widthHeightRatio * size; double height = size / widthHeightRatio; if (width <= size) { setSize(width, size); } else if (height <= size) { setSize(size, height); } else { setSize(size, size); } }
final void setGlyph(SVGGlyph glyph) { glyph.setSize(sizeSlider.getValue()); this.glyph.set(glyph); } }
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; }
/** * init fxml when loaded. */ @PostConstruct public void init() { for (int i = 0; i < 100; i++) { contentList.getItems().add("Item " + i); } contentList.setMaxHeight(3400); JFXScrollPane.smoothScrolling((ScrollPane) scroll.getChildren().get(0)); SVGGlyph arrow = new SVGGlyph(0, "FULLSCREEN", "M402.746 877.254l-320-320c-24.994-24.992-24.994-65.516 0-90.51l320-320c24.994-24.992 65.516-24.992 90.51 0 24.994 24.994 " + "24.994 65.516 0 90.51l-210.746 210.746h613.49c35.346 0 64 28.654 64 64s-28.654 64-64 64h-613.49l210.746 210.746c12.496 " + "12.496 18.744 28.876 18.744 45.254s-6.248 32.758-18.744 45.254c-24.994 24.994-65.516 24.994-90.51 0z", Color.WHITE); arrow.setSize(20, 16); backButton.setGraphic(arrow); backButton.setRipplerFill(Color.WHITE); } }
null); ((SVGGlyph) arrow).setFill(timePicker.getDefaultColor()); ((SVGGlyph) arrow).setSize(20, 20); arrowButton.getChildren().setAll(arrow);
null); ((SVGGlyph) arrow).setFill(jfxDatePicker.getDefaultColor()); ((SVGGlyph) arrow).setSize(20, 20); arrowButton.getChildren().setAll(arrow);
"M598 214h212v212h-84v-128h-128v-84zM726 726v-128h84v212h-212v-84h128zM214 426v-212h212v84h-128v128h-84zM298 598v128h128v84h-212v-212h84z", Color.WHITE); full.setSize(16, 16); SVGGlyph minus = new SVGGlyph(0, "MINUS", "M804.571 420.571v109.714q0 22.857-16 38.857t-38.857 16h-694.857q-22.857 0-38.857-16t-16-38.857v-109.714q0-22.857 16-38.857t38.857-16h694.857q22.857 0 38.857 16t16 38.857z", Color.WHITE); minus.setSize(12, 2); minus.setTranslateY(4); SVGGlyph resizeMax = new SVGGlyph(0, "M726 810v-596h-428v596h428zM726 44q34 0 59 25t25 59v768q0 34-25 60t-59 26h-428q-34 0-59-26t-25-60v-768q0-34 25-60t59-26z", Color.WHITE); resizeMax.setSize(12, 12); SVGGlyph resizeMin = new SVGGlyph(0, "RESIZE_MIN", "M80.842 943.158v-377.264h565.894v377.264h-565.894zM0 404.21v619.79h727.578v-619.79h-727.578zM377.264 161.684h565.894v377.264h-134.736v80.842h215.578v-619.79h-727.578v323.37h80.842v-161.686z", Color.WHITE); resizeMin.setSize(12, 12); SVGGlyph close = new SVGGlyph(0, "CLOSE", "M810 274l-238 238 238 238-60 60-238-238-238 238-60-60 238-238-238-238 60-60 238 238 238-238z", Color.WHITE); close.setSize(12, 12); btnFull = new JFXButton(); btnFull.getStyleClass().add("jfx-decorator-button");
private void refreshView() { if (glyph.getValue() == null) { idLabel.setText(""); nameLabel.setText(""); return; } sizeSlider.valueProperty().addListener(observable -> glyph.get().setSize(sizeSlider.getValue())); idLabel.setText(String.format("%04d", glyph.get().getGlyphId())); nameLabel.setText(glyph.get().getName()); glyph.get().setFill(colorPicker.getValue()); glyph.get().fillProperty().bind(colorPicker.valueProperty()); centeredGlyph.getChildren().setAll(glyph.get()); }
+ "12.496 18.744 28.876 18.744 45.254s-6.248 32.758-18.744 45.254c-24.994 24.994-65.516 24.994-90.51 0z", Color.WHITE); arrow.setSize(20, 16); button.setGraphic(arrow); button.setRipplerFill(Color.WHITE);
+ " 11.429 0 20.571 6.286z", Color.WHITE); glyph.setSize(20, 20); button.setGraphic(glyph); button.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
/** * resize the svg to certain width while keeping the width/height ratio * * @param width in pixel */ public void setSizeForWidth(double width) { double height = width / widthHeightRatio; setSize(width, height); }
/** * resize the svg to certain width while keeping the width/height ratio * * @param height in pixel */ public void setSizeForHeight(double height) { double width = height * widthHeightRatio; setSize(width, height); }
/** * resize the svg to this size while keeping the width/height ratio * * @param size in pixel */ private void setSizeRatio(double size) { double width = widthHeightRatio * size; double height = size / widthHeightRatio; if (width <= size) { setSize(width, size); } else if (height <= size) { setSize(size, height); } else { setSize(size, size); } }
"M598 214h212v212h-84v-128h-128v-84zM726 726v-128h84v212h-212v-84h128zM214 426v-212h212v84h-128v128h-84zM298 598v128h128v84h-212v-212h84z", Color.WHITE); full.setSize(16, 16); SVGGlyph minus = new SVGGlyph(0, "MINUS", "M804.571 420.571v109.714q0 22.857-16 38.857t-38.857 16h-694.857q-22.857 0-38.857-16t-16-38.857v-109.714q0-22.857 16-38.857t38.857-16h694.857q22.857 0 38.857 16t16 38.857z", Color.WHITE); minus.setSize(12, 2); minus.setTranslateY(4); SVGGlyph resizeMax = new SVGGlyph(0, "M726 810v-596h-428v596h428zM726 44q34 0 59 25t25 59v768q0 34-25 60t-59 26h-428q-34 0-59-26t-25-60v-768q0-34 25-60t59-26z", Color.WHITE); resizeMax.setSize(12, 12); SVGGlyph resizeMin = new SVGGlyph(0, "RESIZE_MIN", "M80.842 943.158v-377.264h565.894v377.264h-565.894zM0 404.21v619.79h727.578v-619.79h-727.578zM377.264 161.684h565.894v377.264h-134.736v80.842h215.578v-619.79h-727.578v323.37h80.842v-161.686z", Color.WHITE); resizeMin.setSize(12, 12); SVGGlyph close = new SVGGlyph(0, "CLOSE", "M810 274l-238 238 238 238-60 60-238-238-238 238-60-60 238-238-238-238 60-60 238 238 238-238z", Color.WHITE); close.setSize(12, 12); btnFull = new JFXButton(); btnFull.getStyleClass().add("jfx-decorator-button");