Search in sources :

Example 1 with ScrollPane

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

the class JFXScrollPane method smoothScrolling.

public static void smoothScrolling(ScrollPane scrollPane) {
    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();
    scrollPane.getContent().addEventHandler(MouseEvent.DRAG_DETECTED, event -> timeline.stop());
    scrollPane.getContent().addEventHandler(ScrollEvent.ANY, event -> {
        if (event.getEventType().equals(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().equals(Animation.Status.STOPPED))
                timeline.play();
            event.consume();
        }
    });
    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 height = scrollPane.getContent().getLayoutBounds().getHeight();
        scrollPane.setVvalue(Math.min(Math.max(scrollPane.getVvalue() + dy / height, 0), 1));
        if (Math.abs(dy) < 0.001)
            timeline.stop();
    }));
    timeline.setCycleCount(Animation.INDEFINITE);
}
Also used : 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) ScrollEvent(javafx.scene.input.ScrollEvent) 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) Timeline(javafx.animation.Timeline) KeyFrame(javafx.animation.KeyFrame)

Example 2 with ScrollPane

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

the class AppPanel 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) FilteredList(javafx.collections.transformation.FilteredList) 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) DetailsView(org.phoenicis.javafx.views.common.widgets.lists.DetailsView) SettingsManager(org.phoenicis.settings.SettingsManager) 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 3 with ScrollPane

use of javafx.scene.control.ScrollPane in project TeachingInSimulation by ScOrPiOzzy.

the class Table method loadItems.

@SuppressWarnings("unchecked")
private void loadItems(JSONArray newItems) {
    // 添加新的数据
    if (newItems == null) {
        return;
    }
    try {
        content.getChildren().clear();
        ScrollPane scrollPane = new ScrollPane(content);
        scrollPane.setFitToWidth(true);
        scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
        this.getChildren().add(scrollPane);
        for (int i = 0; i < newItems.size(); i++) {
            JSONObject object = newItems.getJSONObject(i);
            Row row = new Row(normalStyleClass, hoverStyleClass, selectedStyleClass);
            row.setEditable(isEditable());
            this.addRow(row);
            if (getSerial()) {
                Cell<String> index = new Cell<>(null);
                index.setItem((i + 1) + ".");
                index.setMinWidth(20);
                index.setAlignment(Pos.CENTER_RIGHT);
                row.addCell(index);
            }
            for (Column<?> column : getColumns()) {
                String key = column.getKey();
                Cell<Object> cell = ((Column<Object>) column).cellFactoryProperty().get().call((Column<Object>) column);
                if (Util.notEmpty(key)) {
                    cell.setUserData(key);
                    if (key.indexOf(".") > -1) {
                        String[] keys = key.split("\\.");
                        JSONObject jsonObject = object.getJSONObject(keys[0]);
                        cell.setItem(jsonObject.get(keys[1]));
                    } else {
                        cell.setItem(object.get(key));
                    }
                }
                if (getRowHeight() != -1) {
                    cell.setPrefHeight(getRowHeight());
                }
                cell.updateTableColumn((Column<Object>) column);
                row.addCell(cell);
            }
            if (isSeparatorable()) {
                addSeparator();
            }
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : JSONException(com.alibaba.fastjson.JSONException) JSONObject(com.alibaba.fastjson.JSONObject) ScrollPane(javafx.scene.control.ScrollPane) JSONObject(com.alibaba.fastjson.JSONObject)

Example 4 with ScrollPane

use of javafx.scene.control.ScrollPane in project Gargoyle by callakrsos.

the class XY method convert.

public static ScrollPane convert(Node target) {
    StackPane stackPane = new StackPane();
    ScrollPane scrollPane = new ScrollPane(stackPane);
    stackPane.getChildren().add(target);
    stackPane.getChildren().add(draw());
    return scrollPane;
}
Also used : ScrollPane(javafx.scene.control.ScrollPane) StackPane(javafx.scene.layout.StackPane)

Example 5 with ScrollPane

use of javafx.scene.control.ScrollPane in project bitsquare by bitsquare.

the class MarketView method loadView.

private void loadView(Class<? extends View> viewClass) {
    final Tab tab;
    View view = viewLoader.load(viewClass);
    if (view instanceof OfferBookChartView)
        tab = chartsTab;
    else if (view instanceof TradesChartsView)
        tab = tradesTab;
    else if (view instanceof SpreadView)
        tab = statisticsTab;
    else
        throw new IllegalArgumentException("Navigation to " + viewClass + " is not supported");
    if (tab.getContent() != null && tab.getContent() instanceof ScrollPane) {
        ((ScrollPane) tab.getContent()).setContent(view.getRoot());
    } else {
        tab.setContent(view.getRoot());
    }
    root.getSelectionModel().select(tab);
}
Also used : TradesChartsView(io.bitsquare.gui.main.market.trades.TradesChartsView) SpreadView(io.bitsquare.gui.main.market.spread.SpreadView) Tab(javafx.scene.control.Tab) ScrollPane(javafx.scene.control.ScrollPane) OfferBookChartView(io.bitsquare.gui.main.market.offerbook.OfferBookChartView) MainView(io.bitsquare.gui.main.MainView) OfferBookChartView(io.bitsquare.gui.main.market.offerbook.OfferBookChartView) SpreadView(io.bitsquare.gui.main.market.spread.SpreadView) TradesChartsView(io.bitsquare.gui.main.market.trades.TradesChartsView)

Aggregations

ScrollPane (javafx.scene.control.ScrollPane)65 VBox (javafx.scene.layout.VBox)14 Scene (javafx.scene.Scene)13 Label (javafx.scene.control.Label)13 Insets (javafx.geometry.Insets)12 Text (javafx.scene.text.Text)12 BorderPane (javafx.scene.layout.BorderPane)11 Button (javafx.scene.control.Button)10 HBox (javafx.scene.layout.HBox)9 TextFlow (javafx.scene.text.TextFlow)8 Node (javafx.scene.Node)7 TextArea (javafx.scene.control.TextArea)7 Pane (javafx.scene.layout.Pane)7 Color (javafx.scene.paint.Color)7 FXCollections (javafx.collections.FXCollections)6 Alert (javafx.scene.control.Alert)6 javafx.scene.layout (javafx.scene.layout)6 List (java.util.List)5 InvalidationListener (javafx.beans.InvalidationListener)5 ObservableList (javafx.collections.ObservableList)5