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);
}
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);
}
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();
}
}
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;
}
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);
}
Aggregations