javafx.scene.Node#setLayoutX ( )源码实例Demo

下面列出了javafx.scene.Node#setLayoutX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: chart-fx   文件: DragResizerUtil.java
protected void setNodeSize(final Node node, final double x, final double y, final double width, final double height) {
    node.setLayoutX(x);
    node.setLayoutY(y);
    // TODO find generic way to set width and height of any node
    // here we cannot set height and width to node directly.

    if (node instanceof Canvas) {
        ((Canvas) node).setWidth(width);
        ((Canvas) node).setHeight(height);
    } else if (node instanceof Rectangle) {
        ((Rectangle) node).setWidth(width);
        ((Rectangle) node).setHeight(height);
    } else if (node instanceof Region) {
        ((Region) node).setPrefWidth(width);
        ((Region) node).setPrefHeight(height);
    }
}
 
源代码2 项目: MyBox   文件: FxmlControl.java
public static void moveXCenter(Region pNnode, Node node) {
        try {
            if (node == null || pNnode == null) {
                return;
            }
            double xOffset = pNnode.getWidth() - node.getBoundsInLocal().getWidth();

            if (xOffset > 0) {
//                logger.debug(pNnode.getWidth() + " " + node.getBoundsInLocal().getWidth());
                node.setLayoutX(pNnode.getLayoutX() + xOffset / 2);
//                logger.debug(pNnode.getLayoutX() + " " + xOffset / 2 + " " + node.getLayoutX());
            } else {
                node.setLayoutX(0);
            }
        } catch (Exception e) {
        }
    }
 
源代码3 项目: marathonv5   文件: MultiTouchSample.java
@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);
        }
    }
}
 
源代码4 项目: marathonv5   文件: MultiTouchSample.java
@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);
        }
    }
}
 
源代码5 项目: DeskChan   文件: OverlayStage.java
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);

}
 
@Override
void layoutOverlayNodes(int paragraphIndex, List<Node> nodes) {
	Insets insets = getInsets();
	double leftInsets = insets.getLeft();
	double topInsets = insets.getTop();

	// all paragraphs except last one have line separators
	boolean showEOL = (paragraphIndex < getTextArea().getParagraphs().size() - 1);
	Node eolNode = nodes.get(nodes.size() - 1);
	if (eolNode.isVisible() != showEOL)
		eolNode.setVisible(showEOL);

	for (Node node : nodes) {
		Range range = (Range) node.getUserData();
		Rectangle2D bounds = getBounds(range.start, range.end);
		node.setLayoutX(leftInsets + (node == eolNode ? bounds.getMaxX() : bounds.getMinX()));
		node.setLayoutY(topInsets + bounds.getMinY());
	}
}
 
源代码7 项目: ShootOFF   文件: TargetEditorController.java
@FXML
public void mouseMoved(MouseEvent event) {
	if (freeformButton.isSelected()) {
		drawTempPolygonEdge(event);
	}

	if (!cursorRegion.isPresent() || cursorButton.isSelected()) return;

	final Node selected = cursorRegion.get();

	lastMouseX = event.getX() - (selected.getLayoutBounds().getWidth() / 2);
	lastMouseY = event.getY() - (selected.getLayoutBounds().getHeight() / 2);

	if (lastMouseX < 0) lastMouseX = 0;
	if (lastMouseY < 0) lastMouseY = 0;

	if (event.getX() + (selected.getLayoutBounds().getWidth() / 2) <= canvasPane.getWidth())
		selected.setLayoutX(lastMouseX - selected.getLayoutBounds().getMinX());

	if (event.getY() + (selected.getLayoutBounds().getHeight() / 2) <= canvasPane.getHeight())
		selected.setLayoutY(lastMouseY - selected.getLayoutBounds().getMinY());

	event.consume();
}
 
源代码8 项目: DevToolBox   文件: Undecorator.java
/**
     * Set the layout of different layers of the stage
     */
    @Override
    public void layoutChildren() {
        Bounds b = super.getLayoutBounds();
        double w = b.getWidth();
        double h = b.getHeight();
        ObservableList<Node> list = super.getChildren();
//        ROUNDED_DELTA=shadowRectangle.getArcWidth()/4;
        ROUNDED_DELTA = 0;
        for (Node node : list) {
            if (node == shadowRectangle) {
                shadowRectangle.setWidth(w - SHADOW_WIDTH * 2);
                shadowRectangle.setHeight(h - SHADOW_WIDTH * 2);
                shadowRectangle.setX(SHADOW_WIDTH);
                shadowRectangle.setY(SHADOW_WIDTH);
            } else if (node == backgroundRect) {
                backgroundRect.setWidth(w - SHADOW_WIDTH * 2);
                backgroundRect.setHeight(h - SHADOW_WIDTH * 2);
                backgroundRect.setX(SHADOW_WIDTH);
                backgroundRect.setY(SHADOW_WIDTH);
            } else if (node == stageDecoration) {
                stageDecoration.resize(w - SHADOW_WIDTH * 2 - ROUNDED_DELTA * 2, h - SHADOW_WIDTH * 2 - ROUNDED_DELTA * 2);
                stageDecoration.setLayoutX(SHADOW_WIDTH + ROUNDED_DELTA);
                stageDecoration.setLayoutY(SHADOW_WIDTH + ROUNDED_DELTA);
            } //            else if (node == resizeRect) {
            //                resizeRect.setWidth(w - SHADOW_WIDTH * 2);
            //                resizeRect.setHeight(h - SHADOW_WIDTH * 2);
            //                resizeRect.setLayoutX(SHADOW_WIDTH);
            //                resizeRect.setLayoutY(SHADOW_WIDTH);
            //            }
            else {
                node.resize(w - SHADOW_WIDTH * 2 - ROUNDED_DELTA * 2, h - SHADOW_WIDTH * 2 - ROUNDED_DELTA * 2);
                node.setLayoutX(SHADOW_WIDTH + ROUNDED_DELTA);
                node.setLayoutY(SHADOW_WIDTH + ROUNDED_DELTA);
//                node.resize(w - SHADOW_WIDTH * 2 - RESIZE_PADDING * 2, h - SHADOW_WIDTH * 2 - RESIZE_PADDING * 2);
//                node.setLayoutX(SHADOW_WIDTH + RESIZE_PADDING);
//                node.setLayoutY(SHADOW_WIDTH + RESIZE_PADDING);
            }
        }
    }
 
源代码9 项目: MyBox   文件: FxmlControl.java
public static void moveXCenter(Node node) {
    if (node == null || node.getParent() == null) {
        return;
    }
    double xOffset = node.getParent().getBoundsInLocal().getWidth() - node.getBoundsInLocal().getWidth();
    if (xOffset > 0) {
        node.setLayoutX(xOffset / 2);
    } else {
        node.setLayoutX(0);
    }
}
 
源代码10 项目: DeskChan   文件: OverlayStage.java
public void relocate(Node node, double x, double y){
	node.setLayoutX(x - this.getX());
	node.setLayoutY(y - this.getY());
}
 
源代码11 项目: ShootOFF   文件: TargetEditorController.java
public void regionKeyPressed(KeyEvent event) {
	final Node selected = (Node) event.getTarget();
	final TargetRegion region = (TargetRegion) selected;

	switch (event.getCode()) {
	case DELETE:
	case BACK_SPACE:
		targetRegions.remove(selected);
		canvasPane.getChildren().remove(selected);
		toggleShapeControls(false);
		if (tagEditor.isPresent()) {
			tagsButton.setSelected(false);
			toggleTagEditor();
		}
		break;

	case LEFT:
		if (event.isShiftDown()) {
			region.changeWidth(SCALE_DELTA * -1);
		} else {
			selected.setLayoutX(selected.getLayoutX() - MOVEMENT_DELTA);
		}
		break;

	case RIGHT:
		if (event.isShiftDown()) {
			region.changeWidth(SCALE_DELTA);
		} else {
			selected.setLayoutX(selected.getLayoutX() + MOVEMENT_DELTA);
		}
		break;

	case UP:
		if (event.isShiftDown()) {
			region.changeHeight(SCALE_DELTA * -1);
		} else {
			selected.setLayoutY(selected.getLayoutY() - MOVEMENT_DELTA);
		}
		break;

	case DOWN:
		if (event.isShiftDown()) {
			region.changeHeight(SCALE_DELTA);
		} else {
			selected.setLayoutY(selected.getLayoutY() + MOVEMENT_DELTA);
		}
		break;

	default:
		break;
	}

	event.consume();
}