本文整理汇总了Java中javafx.scene.control.ScrollPane.getHmin方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollPane.getHmin方法的具体用法?Java ScrollPane.getHmin怎么用?Java ScrollPane.getHmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ScrollPane
的用法示例。
在下文中一共展示了ScrollPane.getHmin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureVisible
import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
protected void ensureVisible(Node target) {
ScrollPane scrollPane = getParentScrollPane(target);
if (scrollPane == null) {
return;
}
Node content = scrollPane.getContent();
Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
Bounds viewportBounds = scrollPane.getViewportBounds();
Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
if (scrollPane.contains(nodeBounds.getMinX() - contentBounds.getMinX(), nodeBounds.getMinY() - contentBounds.getMinY())) {
return;
}
double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
* ((scrollPane.getVmax() - scrollPane.getVmin()) / (contentBounds.getHeight() - viewportBounds.getHeight()));
scrollPane.setVvalue(toVScroll);
double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
* ((scrollPane.getHmax() - scrollPane.getHmin()) / (contentBounds.getWidth() - viewportBounds.getWidth()));
scrollPane.setHvalue(toHScroll);
}
示例2: scrollTo
import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
private void scrollTo(Node target) {
ScrollPane scrollPane = getParentScrollPane(target);
if (scrollPane == null)
return;
Node content = scrollPane.getContent();
Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
Bounds viewportBounds = scrollPane.getViewportBounds();
Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
* ((scrollPane.getVmax() - scrollPane.getVmin())
/ (contentBounds.getHeight() - viewportBounds.getHeight()));
if (toVScroll >= scrollPane.getVmin() && toVScroll < scrollPane.getVmax())
scrollPane.setVvalue(toVScroll);
double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
* ((scrollPane.getHmax() - scrollPane.getHmin())
/ (contentBounds.getWidth() - viewportBounds.getWidth()));
if (toHScroll >= scrollPane.getHmin() && toHScroll < scrollPane.getHmax())
scrollPane.setHvalue(toHScroll);
}
示例3: start
import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
@Override
public void start(Stage stage) {
Node content = new Rectangle(1000, 700, Color.GREEN);
ScrollPane scrollPane = new ScrollPane(content);
scrollPane.setPrefSize(500, 300);
ChangeListener<Object> changeListener = new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<? extends Object> observable, Object oldValue, Object newValue) {
double hmin = scrollPane.getHmin();
double hmax = scrollPane.getHmax();
double hvalue = scrollPane.getHvalue();
double contentWidth = content.getLayoutBounds().getWidth();
double viewportWidth = scrollPane.getViewportBounds().getWidth();
double hoffset =
Math.max(0, contentWidth - viewportWidth) * (hvalue - hmin) / (hmax - hmin);
double vmin = scrollPane.getVmin();
double vmax = scrollPane.getVmax();
double vvalue = scrollPane.getVvalue();
double contentHeight = content.getLayoutBounds().getHeight();
double viewportHeight = scrollPane.getViewportBounds().getHeight();
double voffset =
Math.max(0, contentHeight - viewportHeight) * (vvalue - vmin) / (vmax - vmin);
System.out.printf("Offset: [%.1f, %.1f] width: %.1f height: %.1f %n",
hoffset, voffset, viewportWidth, viewportHeight);
}
};
scrollPane.viewportBoundsProperty().addListener(changeListener);
scrollPane.hvalueProperty().addListener(changeListener);
scrollPane.vvalueProperty().addListener(changeListener);
Scene scene = new Scene(scrollPane, 640, 480);
stage.setScene(scene);
stage.show();
}
示例4: start
import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
@Override
public void start(Stage stage) {
// Node content = new Rectangle(1000, 700, Color.GREEN);
Pane pane = new Pane();
pane.setPrefSize(TEN_BILLIONS, TEN_BILLIONS);
ScrollPane scrollPane = new ScrollPane(pane);
scrollPane.setPrefSize(500, 300);
ChangeListener<Object> changeListener = new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<? extends Object> observable, Object oldValue, Object newValue) {
System.out.println("source=" + observable.toString());
double hmin = scrollPane.getHmin();
double hmax = scrollPane.getHmax();
double hvalue = scrollPane.getHvalue();
double contentWidth = pane.getLayoutBounds().getWidth();
double viewportWidth = scrollPane.getViewportBounds().getWidth();
double hoffset =
Math.max(0, contentWidth - viewportWidth) * (hvalue - hmin) / (hmax - hmin);
double vmin = scrollPane.getVmin();
double vmax = scrollPane.getVmax();
double vvalue = scrollPane.getVvalue();
double contentHeight = pane.getLayoutBounds().getHeight();
double viewportHeight = scrollPane.getViewportBounds().getHeight();
double voffset =
Math.max(0, contentHeight - viewportHeight) * (vvalue - vmin) / (vmax - vmin);
System.out.printf("Offset: [%.1f, %.1f] width: %.1f height: %.1f %n",
hoffset, voffset, viewportWidth, viewportHeight);
}
};
scrollPane.viewportBoundsProperty().addListener(changeListener);
scrollPane.hvalueProperty().addListener(changeListener);
scrollPane.vvalueProperty().addListener(changeListener);
/* Drawing on the region */
Canvas canvas1 = new Canvas(100, 100);
canvas1.relocate(TEN_BILLIONS - 100, 0);
canvas1.getGraphicsContext2D().strokeOval(60, 60, 30, 30);
Canvas canvas2 = new Canvas(100, 100);
canvas2.relocate(TEN_BILLIONS - 100, TEN_BILLIONS - 100);
canvas2.getGraphicsContext2D().fillOval(60, 60, 30, 30);
pane.getChildren().addAll(canvas1, canvas2);
/* Showing the scene */
Scene scene = new Scene(scrollPane, 640, 480);
stage.setScene(scene);
stage.show();
}