本文整理汇总了Java中javafx.scene.Node.getLayoutX方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getLayoutX方法的具体用法?Java Node.getLayoutX怎么用?Java Node.getLayoutX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.getLayoutX方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SeparatedStage
import javafx.scene.Node; //导入方法依赖的package包/类
SeparatedStage(Node node){
super();
position = new Point2D(node.getLayoutX(),node.getLayoutY());
root.getChildren().add(node);
//scene.setFill(Color.WHITE);
this.node = node;
setOnShowing(showHandler);
setOnHiding(showHandler);
root.setOnMouseDragged(startDragHandler);
root.setOnMouseExited(stopDragHandler);
root.setOnMouseReleased(stopDragHandler);
setAlwaysOnTop();
try {
node.setLayoutX(0);
node.setLayoutY(0);
} catch (Exception e){ }
show();
stage.setX(position.getX());
stage.setY(position.getY());
Bounds bounds = node.getLayoutBounds();
stage.setHeight(bounds.getHeight()+5);
stage.setWidth(bounds.getWidth()+5);
}
示例2: layoutChildren
import javafx.scene.Node; //导入方法依赖的package包/类
@Override protected void layoutChildren() {
final double w = getWidth();
final double h = getHeight();
clipRect.setWidth(w);
clipRect.setHeight(h);
for (Node child : getChildren()) {
if (child == postView) {
postView.relocate(w - 15 - postView.getLayoutBounds().getWidth(), 0);
} else if (child.getLayoutX() == 0 && child.getLayoutY() == 0) {
final double iw = child.getBoundsInParent().getWidth();
final double ih = child.getBoundsInParent().getHeight();
child.setLayoutX((w - iw) * Math.random() + 100);
child.setLayoutY((h - ih) * Math.random() + 100);
}
}
}
示例3: press
import javafx.scene.Node; //导入方法依赖的package包/类
private void press(MouseEvent e) {
Node node = get();
if (isEnable() && e.isConsumed() == false && node != null) {
Corner corner = calcCorner(e);
if (corner != Corner.CENTER) {
pressedCorner = corner;
startX = e.getScreenX();
startY = e.getScreenY();
startWidth = width.get() == -1 ? node.prefWidth(-1) : width.get();
startHeight = height.get() == -1 ? node.prefHeight(-1) : height.get();
startPosX = node.getLayoutX();
startPosY = node.getLayoutY();
e.consume();
}
}
}
示例4: makeLocationScale
import javafx.scene.Node; //导入方法依赖的package包/类
private static void makeLocationScale(Scene scene, Node node) {
double nodeX = node.getLayoutX();
double sceneWidth = scene.getWidth();
double nodeY = node.getLayoutY();
double sceneHeight = scene.getHeight();
if (nodeX != 0.0) {
ChangeListener<Number> xResizer = (arg0, oldValue, newValue) -> node.relocate(nodeX / sceneWidth * newValue.doubleValue(), node.getLayoutY());
scene.widthProperty().addListener(xResizer);
}
if (nodeY != 0.0) {
ChangeListener<Number> yResizer = (arg0, oldValue, newValue) -> node.relocate(node.getLayoutX(), nodeY / sceneHeight * newValue.doubleValue());
scene.heightProperty().addListener(yResizer);
}
}
示例5: onPressed
import javafx.scene.Node; //导入方法依赖的package包/类
private void onPressed(Node dragged, MouseEvent event) {
if (event.getButton() == MouseButton.PRIMARY) {
dragActive = true;
inertiaOvercome = false;
nodeXOnPress = dragged.getLayoutX();
mouseXOnPress = event.getScreenX();
minWidthBackup = container.getMinWidth();
prefWidthBackup = container.getPrefWidth();
maxWidthBackup = container.getMaxWidth();
container.setMinWidth(container.getWidth());
container.setPrefWidth(container.getWidth());
container.setMaxWidth(container.getWidth());
translates = moveableChildren().collect(Collectors.toMap(Function.identity(), child -> new TranslateAnimation(child, dragged)));
moveableChildren().forEach(child -> child.setManaged(false));
// Move dragged node temporarily to front. Reset to original index on mouse release.
dragged.toFront();
}
}
示例6: TranslateAnimation
import javafx.scene.Node; //导入方法依赖的package包/类
public TranslateAnimation(Node child, Node dragged) {
initialX = child.getLayoutX();
initialIndex = container.getChildren().indexOf(child);
if (child != dragged) {
translate = new TranslateTransition(DURATION, child);
double displacement = dragged.getLayoutBounds().getWidth() + container.getSpacing();
if (initialIndex < container.getChildren().indexOf(dragged)) {
translate.setFromX(0);
translate.setToX(displacement);
} else {
translate.setFromX(-displacement);
translate.setToX(0);
translate.jumpTo(DURATION);
forward.set(true);
}
forward.addListener((v, o, n) -> {
translate.setRate(n ? 1 : -1);
translate.play();
});
} else {
translate = null;
}
}
示例7: press
import javafx.scene.Node; //导入方法依赖的package包/类
@Override
public void press(MouseEvent e) {
Node node = get();
if (isEnable() && e.isConsumed() == false && node != null) {
Bounds boundsInLocal = node.getBoundsInLocal();
if (canDrag(node.screenToLocal(e.getScreenX(), e.getScreenY()), boundsInLocal.getMaxX(), boundsInLocal.getMaxY())) {
startX = e.getScreenX() - node.getLayoutX();
startY = e.getScreenY() - node.getLayoutY();
e.consume();
pressed = true;
}
}
}