Search in sources :

Example 51 with ScrollPane

use of javafx.scene.control.ScrollPane in project POL-POM-5 by PhoenicisOrg.

the class ApplicationPanel method populateCenter.

private void populateCenter() {
    this.appDescription = new WebView();
    this.appDescription.getEngine().loadContent("<body>" + application.getDescription() + "</body>");
    themeManager.bindWebEngineStylesheet(appDescription.getEngine().userStyleSheetLocationProperty());
    this.installers = new Label(tr("Installers"));
    this.installers.getStyleClass().add("descriptionTitle");
    this.scriptGrid = new GridPane();
    filteredScripts.addListener((InvalidationListener) change -> this.refreshScripts());
    this.refreshScripts();
    this.miniaturesPane = new HBox();
    this.miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
    this.miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
    this.miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
    for (URI miniatureUri : application.getMiniatures()) {
        Region image = new Region();
        image.getStyleClass().add("appMiniature");
        image.setStyle(String.format("-fx-background-image: url(\"%s\");", miniatureUri.toString()));
        image.prefHeightProperty().bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
        image.prefWidthProperty().bind(image.prefHeightProperty().multiply(1.5));
        miniaturesPane.getChildren().add(image);
    }
    this.center = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
    VBox.setVgrow(appDescription, Priority.ALWAYS);
    this.setCenter(center);
}
Also used : Button(javafx.scene.control.Button) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) javafx.scene.layout(javafx.scene.layout) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) InvalidationListener(javafx.beans.InvalidationListener) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Consumer(java.util.function.Consumer) ScrollPane(javafx.scene.control.ScrollPane) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) DetailsView(org.phoenicis.javafx.views.common.widgets.lists.DetailsView) PhoenicisFilteredList(org.phoenicis.javafx.views.common.lists.PhoenicisFilteredList) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) ThemeManager(org.phoenicis.javafx.views.common.ThemeManager) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) URI(java.net.URI)

Example 52 with ScrollPane

use of javafx.scene.control.ScrollPane in project bisq-desktop by bisq-network.

the class ProposalDisplay method getView.

public ScrollPane getView() {
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    // just enough to display overview at voting without scroller
    scrollPane.setMinHeight(280);
    AnchorPane anchorPane = new AnchorPane();
    scrollPane.setContent(anchorPane);
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(140);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    columnConstraints2.setMinWidth(300);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    AnchorPane.setBottomAnchor(gridPane, 20d);
    AnchorPane.setRightAnchor(gridPane, 10d);
    AnchorPane.setLeftAnchor(gridPane, 10d);
    AnchorPane.setTopAnchor(gridPane, 20d);
    anchorPane.getChildren().add(gridPane);
    return scrollPane;
}
Also used : ScrollPane(javafx.scene.control.ScrollPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) AnchorPane(javafx.scene.layout.AnchorPane)

Example 53 with ScrollPane

use of javafx.scene.control.ScrollPane in project CSCI-6461-Simulator by lkstc112233.

the class NewMain method getScrollBox.

private Node getScrollBox(GridPane grid, String hint, ObservableValue<? extends String> binding) {
    VBox box = new VBox();
    box.getChildren().add(new Text(hint));
    Text textBox = new Text();
    textBox.textProperty().bind(binding);
    ScrollPane scp = new ScrollPane(textBox);
    box.getChildren().add(scp);
    return box;
}
Also used : ScrollPane(javafx.scene.control.ScrollPane) Text(javafx.scene.text.Text) VBox(javafx.scene.layout.VBox)

Example 54 with ScrollPane

use of javafx.scene.control.ScrollPane in project JFoenix by jfoenixadmin.

the class JFXScrollPane method customScrolling.

private static void customScrolling(ScrollPane scrollPane, DoubleProperty scrollDriection, Function<Bounds, Double> sizeFunc) {
    final double[] frictions = { 0.99, 0.1, 0.05, 0.04, 0.03, 0.02, 0.01, 0.04, 0.01, 0.008, 0.008, 0.008, 0.008, 0.0006, 0.0005, 0.00003, 0.00001 };
    final double[] pushes = { 1 };
    final double[] derivatives = new double[frictions.length];
    Timeline timeline = new Timeline();
    final EventHandler<MouseEvent> dragHandler = event -> timeline.stop();
    final EventHandler<ScrollEvent> scrollHandler = event -> {
        if (event.getEventType() == ScrollEvent.SCROLL) {
            int direction = event.getDeltaY() > 0 ? -1 : 1;
            for (int i = 0; i < pushes.length; i++) {
                derivatives[i] += direction * pushes[i];
            }
            if (timeline.getStatus() == Animation.Status.STOPPED) {
                timeline.play();
            }
            event.consume();
        }
    };
    if (scrollPane.getContent().getParent() != null) {
        scrollPane.getContent().getParent().addEventHandler(MouseEvent.DRAG_DETECTED, dragHandler);
        scrollPane.getContent().getParent().addEventHandler(ScrollEvent.ANY, scrollHandler);
    }
    scrollPane.getContent().parentProperty().addListener((o, oldVal, newVal) -> {
        if (oldVal != null) {
            oldVal.removeEventHandler(MouseEvent.DRAG_DETECTED, dragHandler);
            oldVal.removeEventHandler(ScrollEvent.ANY, scrollHandler);
        }
        if (newVal != null) {
            newVal.addEventHandler(MouseEvent.DRAG_DETECTED, dragHandler);
            newVal.addEventHandler(ScrollEvent.ANY, scrollHandler);
        }
    });
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(3), (event) -> {
        for (int i = 0; i < derivatives.length; i++) {
            derivatives[i] *= frictions[i];
        }
        for (int i = 1; i < derivatives.length; i++) {
            derivatives[i] += derivatives[i - 1];
        }
        double dy = derivatives[derivatives.length - 1];
        double size = sizeFunc.apply(scrollPane.getContent().getLayoutBounds());
        scrollDriection.set(Math.min(Math.max(scrollDriection.get() + dy / size, 0), 1));
        if (Math.abs(dy) < 0.001) {
            timeline.stop();
        }
    }));
    timeline.setCycleCount(Animation.INDEFINITE);
}
Also used : EventHandler(javafx.event.EventHandler) Pos(javafx.geometry.Pos) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) javafx.scene.layout(javafx.scene.layout) Node(javafx.scene.Node) MouseEvent(javafx.scene.input.MouseEvent) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) DoubleProperty(javafx.beans.property.DoubleProperty) ScrollEvent(javafx.scene.input.ScrollEvent) Function(java.util.function.Function) Duration(javafx.util.Duration) Insets(javafx.geometry.Insets) ScrollPane(javafx.scene.control.ScrollPane) DefaultProperty(javafx.beans.DefaultProperty) Scale(javafx.scene.transform.Scale) Transform(javafx.scene.transform.Transform) Animation(javafx.animation.Animation) Bounds(javafx.geometry.Bounds) Timeline(javafx.animation.Timeline) MouseEvent(javafx.scene.input.MouseEvent) ScrollEvent(javafx.scene.input.ScrollEvent) KeyFrame(javafx.animation.KeyFrame)

Example 55 with ScrollPane

use of javafx.scene.control.ScrollPane in project JFoenix by jfoenixadmin.

the class JFXResponsiveHandler method scanAllNodes.

/**
 * scans all nodes in the scene and apply the css pseduoClass to them.
 *
 * @param parent      stage parent node
 * @param pseudoClass css class for certain device
 */
private void scanAllNodes(Parent parent, PseudoClass pseudoClass) {
    parent.getChildrenUnmodifiable().addListener(new ListChangeListener<Node>() {

        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> c) {
            while (c.next()) {
                if (!c.wasPermutated() && !c.wasUpdated()) {
                    for (Node addedNode : c.getAddedSubList()) {
                        if (addedNode instanceof Parent) {
                            scanAllNodes((Parent) addedNode, pseudoClass);
                        }
                    }
                }
            }
        }
    });
    for (Node component : parent.getChildrenUnmodifiable()) {
        if (component instanceof Pane) {
            ((Pane) component).getChildren().addListener(new ListChangeListener<Node>() {

                @Override
                public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> c) {
                    while (c.next()) {
                        if (!c.wasPermutated() && !c.wasUpdated()) {
                            for (Node addedNode : c.getAddedSubList()) {
                                if (addedNode instanceof Parent) {
                                    scanAllNodes((Parent) addedNode, pseudoClass);
                                }
                            }
                        }
                    }
                }
            });
            // if the component is a container, scan its children
            scanAllNodes((Pane) component, pseudoClass);
        } else if (component instanceof ScrollPane) {
            ((ScrollPane) component).contentProperty().addListener((o, oldVal, newVal) -> {
                scanAllNodes((Parent) newVal, pseudoClass);
            });
            // if the component is a container, scan its children
            if (((ScrollPane) component).getContent() instanceof Parent) {
                scanAllNodes((Parent) ((ScrollPane) component).getContent(), pseudoClass);
            }
        } else if (component instanceof Control) {
            // if the component is an instance of IInputControl, add to list
            component.pseudoClassStateChanged(PSEUDO_CLASS_EX_SMALL, pseudoClass == PSEUDO_CLASS_EX_SMALL);
            component.pseudoClassStateChanged(PSEUDO_CLASS_SMALL, pseudoClass == PSEUDO_CLASS_SMALL);
            component.pseudoClassStateChanged(PSEUDO_CLASS_MEDIUM, pseudoClass == PSEUDO_CLASS_MEDIUM);
            component.pseudoClassStateChanged(PSEUDO_CLASS_LARGE, pseudoClass == PSEUDO_CLASS_LARGE);
        }
    }
}
Also used : Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) ListChangeListener(javafx.collections.ListChangeListener) Stage(javafx.stage.Stage) PseudoClass(javafx.css.PseudoClass) Node(javafx.scene.Node) Control(javafx.scene.control.Control) Pane(javafx.scene.layout.Pane) Control(javafx.scene.control.Control) Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) Node(javafx.scene.Node) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane) ListChangeListener(javafx.collections.ListChangeListener)

Aggregations

ScrollPane (javafx.scene.control.ScrollPane)71 VBox (javafx.scene.layout.VBox)18 Text (javafx.scene.text.Text)15 Scene (javafx.scene.Scene)14 Label (javafx.scene.control.Label)13 Insets (javafx.geometry.Insets)11 Button (javafx.scene.control.Button)11 BorderPane (javafx.scene.layout.BorderPane)11 HBox (javafx.scene.layout.HBox)10 GridPane (javafx.scene.layout.GridPane)9 TextFlow (javafx.scene.text.TextFlow)8 FXCollections (javafx.collections.FXCollections)7 Node (javafx.scene.Node)7 TextArea (javafx.scene.control.TextArea)7 javafx.scene.layout (javafx.scene.layout)7 Pane (javafx.scene.layout.Pane)7 InvalidationListener (javafx.beans.InvalidationListener)6 Observable (javafx.beans.Observable)6 ObservableList (javafx.collections.ObservableList)6 Alert (javafx.scene.control.Alert)6