当前位置: 首页>>代码示例>>Java>>正文


Java Node.localToScene方法代码示例

本文整理汇总了Java中javafx.scene.Node.localToScene方法的典型用法代码示例。如果您正苦于以下问题:Java Node.localToScene方法的具体用法?Java Node.localToScene怎么用?Java Node.localToScene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.Node的用法示例。


在下文中一共展示了Node.localToScene方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureVisible

import javafx.scene.Node; //导入方法依赖的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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:FXEventQueueDevice.java

示例2: getIndexAt

import javafx.scene.Node; //导入方法依赖的package包/类
protected int getIndexAt(ListView<?> listView, Point2D point) {
    if (point == null) {
        return listView.getSelectionModel().getSelectedIndex();
    }
    point = listView.localToScene(point);
    Set<Node> lookupAll = getListCells(listView);
    ListCell<?> selected = null;
    for (Node cellNode : lookupAll) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (ListCell<?>) cellNode;
            break;
        }
    }
    if (selected == null) {
        return -1;
    }
    return selected.getIndex();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaFXElementPropertyAccessor.java

示例3: getRowAt

import javafx.scene.Node; //导入方法依赖的package包/类
public int getRowAt(TreeView<?> treeView, Point2D point) {
    if (point == null) {
        return treeView.getSelectionModel().getSelectedIndex();
    }
    point = treeView.localToScene(point);
    int itemCount = treeView.getExpandedItemCount();
    @SuppressWarnings("rawtypes")
    List<TreeCell> cells = new ArrayList<>();
    for (int i = 0; i < itemCount; i++) {
        cells.add(getCellAt(treeView, i));
    }
    TreeCell<?> selected = null;
    for (Node cellNode : cells) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (TreeCell<?>) cellNode;
            break;
        }
    }
    if (selected == null) {
        return -1;
    }
    return selected.getIndex();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:JavaFXElementPropertyAccessor.java

示例4: scrollTo

import javafx.scene.Node; //导入方法依赖的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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:ScrollPaneSample2.java

示例5: getTableCellAt

import javafx.scene.Node; //导入方法依赖的package包/类
private TableCell<?, ?> getTableCellAt(TableView<?> tableView, Point2D point) {
    point = tableView.localToScene(point);
    Set<Node> lookupAll = getTableCells(tableView);
    TableCell<?, ?> selected = null;
    for (Node cellNode : lookupAll) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (TableCell<?, ?>) cellNode;
            break;
        }
    }
    return selected;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JavaFXElementPropertyAccessor.java

示例6: getTreeTableCellAt

import javafx.scene.Node; //导入方法依赖的package包/类
public TreeTableCell<?, ?> getTreeTableCellAt(TreeTableView<?> treeTableView, Point2D point) {
    point = treeTableView.localToScene(point);
    Set<Node> lookupAll = getTreeTableCells(treeTableView);
    TreeTableCell<?, ?> selected = null;
    for (Node cellNode : lookupAll) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (TreeTableCell<?, ?>) cellNode;
            break;
        }
    }
    return selected;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JavaFXElementPropertyAccessor.java

示例7: recordRawMouseEvent

import javafx.scene.Node; //导入方法依赖的package包/类
@Override public void recordRawMouseEvent(final RFXComponent r, MouseEvent e) {
    final JSONObject event = new JSONObject();
    event.put("type", "click_raw");
    int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
    event.put("button", button);
    event.put("clickCount", e.getClickCount());
    event.put("modifiersEx", buildModifiersText(e));
    Node source = (Node) e.getSource();
    Node target = r.getComponent();
    Point2D sts = source.localToScene(new Point2D(e.getX(), e.getY()));
    Point2D tts = target.sceneToLocal(sts);
    event.put("x", tts.getX());
    event.put("y", tts.getY());
    final JSONObject o = new JSONObject();
    o.put("event", event);
    fill(r, o);
    if (e.getClickCount() == 1) {
        clickTimer = new Timer();
        clickTimer.schedule(new TimerTask() {
            @Override public void run() {
                sendRecordMessage(o);
            }
        }, timerinterval.intValue());
    } else if (e.getClickCount() == 2) {
        if (clickTimer != null) {
            clickTimer.cancel();
            clickTimer = null;
        }
        sendRecordMessage(o);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:32,代码来源:WSRecorder.java

示例8: snapshotNode

import javafx.scene.Node; //导入方法依赖的package包/类
private void snapshotNode(Scene scene, Node node) {
    SnapshotParameters params = new SnapshotParameters();
    Bounds layoutBounds = node.getLayoutBounds();
    Bounds bounds = node.localToScene(layoutBounds);

    if (!(bounds.getWidth() > 0 && bounds.getHeight() > 0)) {
        return;
    }

    params.setViewport(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
    WritableImage writable = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
    writable = scene.getRoot().snapshot(params, writable);

    ImageView imageView = new ImageView(writable);
    imageView.getStyleClass().add("snapshot-image");
    imageView.setManaged(false);
    imageView.setLayoutX(bounds.getMinX());
    imageView.setLayoutY(bounds.getMinY());
    imageView.setFitWidth(bounds.getWidth());
    imageView.setFitHeight(bounds.getHeight());

    Region rect = new Region();
    rect.getStyleClass().add("snapshot-background");
    rect.setLayoutX(bounds.getMinX() - 5);
    rect.setLayoutY(bounds.getMinY() - 5);
    rect.resize(bounds.getWidth() + 10, bounds.getHeight() + 10);
    rect.setManaged(false);

    Line line = new Line();
    line.setStartX(bounds.getMaxX() + 4);
    line.setStartY(bounds.getMaxY() + 4);
    line.setEndX(bounds.getMaxX() + 200);
    line.setEndY(bounds.getMaxY() + 200);
    line.setStroke(imagePattern);
    line.setStrokeWidth(5);
    line.setManaged(false);

    getChildren().addAll(rect, imageView); //, line);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:40,代码来源:IntroPaneSkin.java


注:本文中的javafx.scene.Node.localToScene方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。