/** * 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); } }
this.glyphId = glyphId; this.name = name; getStyleClass().add(DEFAULT_STYLE_CLASS); this.fill.addListener((observable) -> setBackground(new Background( new BackgroundFill(getFill() == null ? Color.BLACK : getFill(), null, null)))); shapeProperty().addListener(observable -> { Shape shape = getShape(); if (getShape() != null) { widthHeightRatio = shape.prefWidth(-1) / shape.prefHeight(-1); if (getSize() != Region.USE_COMPUTED_SIZE) { setSizeRatio(getSize()); SVGPath shape = new SVGPath(); shape.setContent(svgPathContent); setShape(shape); setFill(fill); setPrefSize(DEFAULT_PREF_SIZE, DEFAULT_PREF_SIZE);
@Override public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() { if (STYLEABLES == null) { final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(Pane.getClassCssMetaData()); styleables.addAll(getClassCssMetaData()); STYLEABLES = Collections.unmodifiableList(styleables); } return STYLEABLES; }
/** * will retrieve icons from the glyphs map for a certain glyphName * * @param glyphName the glyph name * @return SVGGlyph node */ public static SVGGlyph getIcoMoonGlyph(String glyphName) throws Exception{ SVGGlyphBuilder builder = glyphsMap.get(glyphName); if(builder == null) throw new Exception("Glyph '" + glyphName + "' not found!"); SVGGlyph glyph = builder.build(); // we need to apply transformation to correct the icon since // its being inverted after importing from icomoon glyph.getTransforms().add(new Scale(1, -1)); Translate height = new Translate(); height.yProperty().bind(Bindings.createDoubleBinding(() -> -glyph.getHeight(), glyph.heightProperty())); glyph.getTransforms().add(height); return glyph; }
public HeaderControl(ArrowPosition pos) { getStyleClass().setAll("control-buttons-tab"); isLeftArrow = pos == ArrowPosition.LEFT; arrowButton = new SVGGlyph(); arrowButton.pseudoClassStateChanged(isLeftArrow ? left : right, true); arrowButton.getStyleClass().setAll("tab-down-button"); arrowButton.setVisible(isControlButtonShown()); StackPane.setMargin(arrowButton, new Insets(0, 0, 0, isLeftArrow ? -4 : 4));
SVGGlyph dropIcon = new SVGGlyph(0, "ANGLE_RIGHT", "M340 548.571q0 7.429-5.714 13.143l-266.286 266.286q-5.714 5.714-13.143 5.714t-13.143-5.714l-28.571-28.571q-5.714-5.714-5.714-13.143t5.714-13.143l224.571-224.571-224.571-224.571q-5.714-5.714-5.714-13.143t5.714-13.143l28.571-28.571q5.714-5.714 13.143-5.714t13.143 5.714l266.286 266.286q5.714 5.714 5.714 13.143z", Color.BLACK); dropIcon.setStyle( "-fx-min-width:0.4em;-fx-max-width:0.4em;-fx-min-height:0.6em;-fx-max-height:0.6em;"); dropIcon.getStyleClass().add("drop-icon"); if (newVal) { new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 90, Interpolator.EASE_BOTH))).play(); } else { new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 0, Interpolator.EASE_BOTH))).play();
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()); }
SVGGlyph full = new SVGGlyph(0, "FULLSCREEN", "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, "RESIZE_MAX", "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");
final SVGGlyph arrow = new SVGGlyph("M366 698l196-196-196-196 60-60 256 256-256 256z", Color.BLACK); arrow.setSizeForWidth(6); arrow.setMouseTransparent(true); StackPane.setAlignment(arrow, Pos.CENTER_RIGHT); container.getChildren().add(arrow);
SVGGlyph build() { return new SVGGlyph(glyphId, name, svgPathContent, Color.BLACK); } }
/** * 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); }
pickerDecorator.lookupAll(".jfx-decorator-button").forEach(button -> { ((JFXButton) button).setRipplerFill(fontColor); ((SVGGlyph) ((JFXButton) button).getGraphic()).setFill(fontColor); });
suggestions.put("Music", new MyShape("Music", SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.music"))); final SVGGlyph icoMoonGlyph = SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.heart"); icoMoonGlyph.getStyleClass().add("heart"); suggestions.put("Heart", new MyShape("Heart", icoMoonGlyph)); suggestions.put("Film", new MyShape("Film", SVGGlyphLoader.getIcoMoonGlyph("icomoon.svg.film")));
@Override public void invalidated() { setSizeRatio(getSize()); } };
public HeaderControl(ArrowPosition pos) { getStyleClass().setAll("control-buttons-tab"); isLeftArrow = pos == ArrowPosition.LEFT; arrowButton = new SVGGlyph(); arrowButton.pseudoClassStateChanged(isLeftArrow ? left : right, true); arrowButton.getStyleClass().setAll("tab-down-button"); arrowButton.setVisible(isControlButtonShown()); StackPane.setMargin(arrowButton, new Insets(0, 0, 0, isLeftArrow ? -4 : 4));
SVGGlyph dropIcon = new SVGGlyph(0, "ANGLE_RIGHT", "M340 548.571q0 7.429-5.714 13.143l-266.286 266.286q-5.714 5.714-13.143 5.714t-13.143-5.714l-28.571-28.571q-5.714-5.714-5.714-13.143t5.714-13.143l224.571-224.571-224.571-224.571q-5.714-5.714-5.714-13.143t5.714-13.143l28.571-28.571q5.714-5.714 13.143-5.714t13.143 5.714l266.286 266.286q5.714 5.714 5.714 13.143z", Color.BLACK); dropIcon.setStyle( "-fx-min-width:0.4em;-fx-max-width:0.4em;-fx-min-height:0.6em;-fx-max-height:0.6em;"); dropIcon.getStyleClass().add("drop-icon"); if (newVal) { new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 90, Interpolator.EASE_BOTH))).play(); } else { new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 0, Interpolator.EASE_BOTH))).play();
SVGGlyph full = new SVGGlyph(0, "FULLSCREEN", "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, "RESIZE_MAX", "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");
final SVGGlyph arrow = new SVGGlyph("M366 698l196-196-196-196 60-60 256 256-256 256z", Color.BLACK); arrow.setSizeForWidth(6); arrow.setMouseTransparent(true); StackPane.setAlignment(arrow, Pos.CENTER_RIGHT); container.getChildren().add(arrow);