Search in sources :

Example 1 with SVGGlyph

use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.

the class ScrollPaneDemo method start.

@Override
public void start(Stage stage) {
    JFXListView<Label> list = new JFXListView<>();
    for (int i = 0; i < 100; i++) {
        list.getItems().add(new Label("Item " + i));
    }
    list.getStyleClass().add("mylistview");
    list.setMaxHeight(3400);
    StackPane container = new StackPane(list);
    container.setPadding(new Insets(24));
    JFXScrollPane pane = new JFXScrollPane();
    pane.setContent(container);
    JFXButton button = new JFXButton("");
    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);
    button.setGraphic(arrow);
    button.setRipplerFill(Color.WHITE);
    pane.getTopBar().getChildren().add(button);
    Label title = new Label("Title");
    pane.getBottomBar().getChildren().add(title);
    title.setStyle("-fx-text-fill:WHITE; -fx-font-size: 40;");
    JFXScrollPane.smoothScrolling((ScrollPane) pane.getChildren().get(0));
    StackPane.setMargin(title, new Insets(0, 0, 0, 80));
    StackPane.setAlignment(title, Pos.CENTER_LEFT);
    StackPane.setAlignment(button, Pos.CENTER_LEFT);
    StackPane.setMargin(button, new Insets(0, 0, 0, 20));
    final Scene scene = new Scene(new StackPane(pane), 600, 600, Color.WHITE);
    stage.setTitle("JFX ListView Demo ");
    stage.setScene(scene);
    stage.show();
}
Also used : JFXScrollPane(com.jfoenix.controls.JFXScrollPane) Insets(javafx.geometry.Insets) SVGGlyph(com.jfoenix.svg.SVGGlyph) Label(javafx.scene.control.Label) JFXListView(com.jfoenix.controls.JFXListView) JFXButton(com.jfoenix.controls.JFXButton) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 2 with SVGGlyph

use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.

the class SVGLoaderController method allGlyphs.

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;
}
Also used : JFXButton(com.jfoenix.controls.JFXButton) Pos(javafx.geometry.Pos) Scene(javafx.scene.Scene) ViewController(io.datafx.controller.ViewController) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) Insets(javafx.geometry.Insets) IndicatorPosition(com.jfoenix.controls.JFXSlider.IndicatorPosition) SVGGlyphLoader(com.jfoenix.svg.SVGGlyphLoader) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) SVGGlyph(com.jfoenix.svg.SVGGlyph) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) File(java.io.File) JFXSlider(com.jfoenix.controls.JFXSlider) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Consumer(java.util.function.Consumer) FileChooser(javafx.stage.FileChooser) ViewFlowContext(io.datafx.controller.flow.context.ViewFlowContext) List(java.util.List) FXMLViewFlowContext(io.datafx.controller.flow.context.FXMLViewFlowContext) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) PostConstruct(javax.annotation.PostConstruct) Comparator(java.util.Comparator) Insets(javafx.geometry.Insets) SVGGlyph(com.jfoenix.svg.SVGGlyph) JFXButton(com.jfoenix.controls.JFXButton) IOException(java.io.IOException)

Example 3 with SVGGlyph

use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.

the class JFXDatePickerContent method createCalendarArrowsPane.

/*
     * methods to create the content of the date picker
     */
protected BorderPane createCalendarArrowsPane() {
    SVGGlyph leftChevron = new SVGGlyph(0, "CHEVRON_LEFT", "M 742,-37 90,614 Q 53,651 53,704.5 53,758 90,795 l 652,651 q 37,37 90.5,37 53.5,0 90.5,-37 l 75,-75 q 37,-37 37,-90.5 0,-53.5 -37,-90.5 L 512,704 998,219 q 37,-38 37,-91 0,-53 -37,-90 L 923,-37 Q 886,-74 832.5,-74 779,-74 742,-37 z", Color.GRAY);
    SVGGlyph rightChevron = new SVGGlyph(0, "CHEVRON_RIGHT", "m 1099,704 q 0,-52 -37,-91 L 410,-38 q -37,-37 -90,-37 -53,0 -90,37 l -76,75 q -37,39 -37,91 0,53 37,90 l 486,486 -486,485 q -37,39 -37,91 0,53 37,90 l 76,75 q 36,38 90,38 54,0 90,-38 l 652,-651 q 37,-37 37,-90 z", Color.GRAY);
    leftChevron.setFill(DEFAULT_COLOR);
    leftChevron.setSize(6, 11);
    rightChevron.setFill(DEFAULT_COLOR);
    rightChevron.setSize(6, 11);
    backMonthButton = new JFXButton();
    backMonthButton.setMinSize(40, 40);
    backMonthButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, new CornerRadii(40), Insets.EMPTY)));
    backMonthButton.getStyleClass().add("left-button");
    backMonthButton.setGraphic(leftChevron);
    backMonthButton.setRipplerFill(this.datePicker.getDefaultColor());
    backMonthButton.setOnAction(t -> forward(-1, MONTHS, false, true));
    forwardMonthButton = new JFXButton();
    forwardMonthButton.setMinSize(40, 40);
    forwardMonthButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, new CornerRadii(40), Insets.EMPTY)));
    forwardMonthButton.getStyleClass().add("right-button");
    forwardMonthButton.setGraphic(rightChevron);
    forwardMonthButton.setRipplerFill(this.datePicker.getDefaultColor());
    forwardMonthButton.setOnAction(t -> forward(1, MONTHS, false, true));
    BorderPane arrowsContainer = new BorderPane();
    arrowsContainer.setLeft(backMonthButton);
    arrowsContainer.setRight(forwardMonthButton);
    arrowsContainer.setPadding(new Insets(4, 12, 2, 12));
    arrowsContainer.setPickOnBounds(false);
    return arrowsContainer;
}
Also used : Insets(javafx.geometry.Insets) SVGGlyph(com.jfoenix.svg.SVGGlyph) JFXButton(com.jfoenix.controls.JFXButton)

Example 4 with SVGGlyph

use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.

the class MasonryPaneController method init.

/**
 * init fxml when loaded.
 */
@PostConstruct
public void init() {
    ArrayList<Node> children = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        StackPane child = new StackPane();
        double width = Math.random() * 100 + 100;
        child.setPrefWidth(width);
        double height = Math.random() * 100 + 100;
        child.setPrefHeight(height);
        JFXDepthManager.setDepth(child, 1);
        children.add(child);
        // create content
        StackPane header = new StackPane();
        String headerColor = getDefaultColor(i % 12);
        header.setStyle("-fx-background-radius: 5 5 0 0; -fx-background-color: " + headerColor);
        VBox.setVgrow(header, Priority.ALWAYS);
        StackPane body = new StackPane();
        body.setMinHeight(Math.random() * 20 + 50);
        VBox content = new VBox();
        content.getChildren().addAll(header, body);
        body.setStyle("-fx-background-radius: 0 0 5 5; -fx-background-color: rgb(255,255,255,0.87);");
        // create button
        JFXButton button = new JFXButton("");
        button.setButtonType(ButtonType.RAISED);
        button.setStyle("-fx-background-radius: 40;-fx-background-color: " + getDefaultColor((int) ((Math.random() * 12) % 12)));
        button.setPrefSize(40, 40);
        button.setRipplerFill(Color.valueOf(headerColor));
        button.setScaleX(0);
        button.setScaleY(0);
        SVGGlyph glyph = new SVGGlyph(-1, "test", "M1008 6.286q18.857 13.714 15.429 36.571l-146.286 877.714q-2.857 16.571-18.286 25.714-8 4.571-17.714 4.571-6.286 " + "0-13.714-2.857l-258.857-105.714-138.286 168.571q-10.286 13.143-28 13.143-7.429 " + "0-12.571-2.286-10.857-4-17.429-13.429t-6.571-20.857v-199.429l493.714-605.143-610.857 " + "528.571-225.714-92.571q-21.143-8-22.857-31.429-1.143-22.857 18.286-33.714l950.857-548.571q8.571-5.143 18.286-5.143" + " 11.429 0 20.571 6.286z", Color.WHITE);
        glyph.setSize(20, 20);
        button.setGraphic(glyph);
        button.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
            return header.getBoundsInParent().getHeight() - button.getHeight() / 2;
        }, header.boundsInParentProperty(), button.heightProperty()));
        StackPane.setMargin(button, new Insets(0, 12, 0, 0));
        StackPane.setAlignment(button, Pos.TOP_RIGHT);
        Timeline animation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(button.scaleXProperty(), 1, EASE_BOTH), new KeyValue(button.scaleYProperty(), 1, EASE_BOTH)));
        animation.setDelay(Duration.millis(100 * i + 1000));
        animation.play();
        child.getChildren().addAll(content, button);
    }
    masonryPane.getChildren().addAll(children);
    Platform.runLater(() -> scrollPane.requestLayout());
    JFXScrollPane.smoothScrolling(scrollPane);
}
Also used : Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) ArrayList(java.util.ArrayList) JFXButton(com.jfoenix.controls.JFXButton) Timeline(javafx.animation.Timeline) SVGGlyph(com.jfoenix.svg.SVGGlyph) KeyFrame(javafx.animation.KeyFrame) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane) PostConstruct(javax.annotation.PostConstruct)

Example 5 with SVGGlyph

use of com.jfoenix.svg.SVGGlyph in project JFoenix by jfoenixadmin.

the class SVGLoaderController method createIconButton.

private Button createIconButton(SVGGlyph glyph) {
    JFXButton button = new JFXButton(null, glyph);
    button.setPrefSize(30, 30);
    button.setMinSize(30, 30);
    button.setMaxSize(30, 30);
    button.ripplerFillProperty().bind(glyphDetailViewer.colorPicker.valueProperty());
    glyphDetailViewer.colorPicker.valueProperty().addListener((o, oldVal, newVal) -> {
        String webColor = "#" + Integer.toHexString(newVal.hashCode()).substring(0, 6).toUpperCase();
        Consumer<String> lookupConsumer = lookup -> {
            BackgroundFill fill = ((Region) glyphDetailViewer.sizeSlider.lookup(lookup)).getBackground().getFills().get(0);
            ((Region) glyphDetailViewer.sizeSlider.lookup(lookup)).setBackground(new Background(new BackgroundFill(Color.valueOf(webColor), fill.getRadii(), fill.getInsets())));
        };
        lookupConsumer.accept(THUMB);
        lookupConsumer.accept(COLORED_TRACK);
        lookupConsumer.accept(ANIMATED_THUMB);
        if (lastClicked != null) {
            final String currentColor = glyphDetailViewer.colorPicker.getValue().toString().substring(0, 8);
            final BackgroundFill backgroundFill = new BackgroundFill(Color.valueOf(currentColor + DEFAULT_OPACITY), lastClicked.getBackground().getFills().get(0).getRadii(), null);
            lastClicked.setBackground(new Background(backgroundFill));
        }
    });
    button.setOnAction(event -> {
        if (lastClicked != null) {
            lastClicked.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, lastClicked.getBackground().getFills().get(0).getRadii(), null)));
        }
        final String currentColor = glyphDetailViewer.colorPicker.getValue().toString().substring(0, 8);
        button.setBackground(new Background(new BackgroundFill(Color.valueOf(currentColor + DEFAULT_OPACITY), button.getBackground() == null ? null : button.getBackground().getFills().get(0).getRadii(), null)));
        lastClicked = button;
        viewGlyphDetail(glyph);
    });
    Tooltip.install(button, new Tooltip(glyph.getName()));
    return button;
}
Also used : JFXButton(com.jfoenix.controls.JFXButton) Pos(javafx.geometry.Pos) Scene(javafx.scene.Scene) ViewController(io.datafx.controller.ViewController) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) Insets(javafx.geometry.Insets) IndicatorPosition(com.jfoenix.controls.JFXSlider.IndicatorPosition) SVGGlyphLoader(com.jfoenix.svg.SVGGlyphLoader) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) SVGGlyph(com.jfoenix.svg.SVGGlyph) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) File(java.io.File) JFXSlider(com.jfoenix.controls.JFXSlider) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Consumer(java.util.function.Consumer) FileChooser(javafx.stage.FileChooser) ViewFlowContext(io.datafx.controller.flow.context.ViewFlowContext) List(java.util.List) FXMLViewFlowContext(io.datafx.controller.flow.context.FXMLViewFlowContext) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) PostConstruct(javax.annotation.PostConstruct) Comparator(java.util.Comparator) JFXButton(com.jfoenix.controls.JFXButton)

Aggregations

SVGGlyph (com.jfoenix.svg.SVGGlyph)10 Insets (javafx.geometry.Insets)6 JFXButton (com.jfoenix.controls.JFXButton)5 PostConstruct (javax.annotation.PostConstruct)5 Scene (javafx.scene.Scene)4 FXMLViewFlowContext (io.datafx.controller.flow.context.FXMLViewFlowContext)3 ViewFlowContext (io.datafx.controller.flow.context.ViewFlowContext)3 IOException (java.io.IOException)3 Platform (javafx.application.Platform)3 Pos (javafx.geometry.Pos)3 StackPane (javafx.scene.layout.StackPane)3 Color (javafx.scene.paint.Color)3 JFXSlider (com.jfoenix.controls.JFXSlider)2 IndicatorPosition (com.jfoenix.controls.JFXSlider.IndicatorPosition)2 SVGGlyphLoader (com.jfoenix.svg.SVGGlyphLoader)2 ViewController (io.datafx.controller.ViewController)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 Comparator (java.util.Comparator)2 List (java.util.List)2