Java Code Examples for javafx.scene.Node#relocate()
The following examples show how to use
javafx.scene.Node#relocate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@Override public void handle(MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { final Node node = (Node) event.getSource(); double offsetX = event.getScreenX() + dragContext.x; double offsetY = event.getScreenY() + dragContext.y; // adjust the offset in case we are zoomed final double scale = graph.getScale(); offsetX /= scale; offsetY /= scale; node.relocate(offsetX, offsetY); } }
Example 2
Source File: DynamicAnchorConnectionSnippet.java From gef with Eclipse Public License 2.0 | 5 votes |
private EventHandler<ActionEvent> createMoveHandler(final String label, final Node node, final double x, final double y0, final double y1) { return new EventHandler<ActionEvent>() { boolean flag = false; @Override public void handle(ActionEvent event) { node.relocate(x, flag ? y0 : y1); flag = !flag; } }; }
Example 3
Source File: GroupLayoutPane.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override protected void layoutChildren() { performingLayout = true; Insets insets = getInsets(); double width = getWidth(); double height = getHeight(); double top = snapSpace(insets.getTop()); double left = snapSpace(insets.getLeft()); double bottom = snapSpace(insets.getBottom()); double right = snapSpace(insets.getRight()); nodeWidths.clear(); nodeHeights.clear(); nodeX.clear(); nodeY.clear(); currentAxis = Axis.HORIZONTAL; horizontalGroup.recalculateSizes(); double effectiveWidth = width - left - right; horizontalGroup.resizeRelocate(left, effectiveWidth); currentAxis = Axis.VERTICAL; verticalGroup.recalculateSizes(); double effectiveHeight = height - top - bottom; verticalGroup.resizeRelocate(top, effectiveHeight); for (Node child : getManagedChildren()) { child.resize(nodeWidths.get(child), nodeHeights.get(child)); child.relocate(nodeX.get(child), nodeY.get(child)); } performingLayout = false; }
Example 4
Source File: StructuredListCellSkin.java From dolphin-platform with Apache License 2.0 | 4 votes |
@Override protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) { double leftContentWidth = 0; if (getSkinnable().getLeftContent() != null) { Node leftContent = getSkinnable().getLeftContent(); leftContentWidth = leftContent.prefWidth(contentHeight); double leftContentHeight = Math.min(leftContent.prefHeight(leftContentWidth), contentHeight); leftContent.resize(leftContentWidth, leftContentHeight); if (leftContentAlignment.get().equals(VPos.TOP)) { leftContent.relocate(contentX, contentY); } else if (leftContentAlignment.get().equals(VPos.CENTER)) { leftContent.relocate(contentX, contentY + (contentHeight - leftContentHeight) / 2); } else { leftContent.relocate(contentX, contentY + (contentHeight - leftContentHeight)); } } double rightContentWidth = 0; if (getSkinnable().getRightContent() != null) { Node rightContent = getSkinnable().getRightContent(); rightContentWidth = rightContent.prefWidth(contentHeight); double rightContentHeight = Math.min(rightContent.prefHeight(rightContentWidth), contentHeight); rightContent.resize(rightContentWidth, rightContentHeight); if (rightContentAlignment.get().equals(VPos.TOP)) { rightContent.relocate(contentX + contentWidth - rightContentWidth, contentY); } else if (rightContentAlignment.get().equals(VPos.CENTER)) { rightContent.relocate(contentX + contentWidth - rightContentWidth, contentY + (contentHeight - rightContentHeight) / 2); } else { rightContent.relocate(contentX + contentWidth - rightContentWidth, contentY + (contentHeight - rightContentHeight)); } } if (getSkinnable().getCenterContent() != null) { Node centerContent = getSkinnable().getCenterContent(); double maxWidthForCenterContent = contentWidth - leftContentWidth - rightContentWidth - spacing.get().doubleValue() * 2; double maxHeigthForCenterContent = contentHeight; double centerContentWidth = Math.min(centerContent.maxWidth(contentHeight), maxWidthForCenterContent); double centerContentHeight = Math.min(centerContent.maxHeight(centerContentWidth), maxHeigthForCenterContent); centerContent.resize(centerContentWidth, centerContentHeight); if (centerContentAlignment.get().equals(Pos.TOP_LEFT)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue(), contentY); } else if (centerContentAlignment.get().equals(Pos.TOP_CENTER)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue() + (maxWidthForCenterContent - centerContentWidth) / 2, contentY); } else if (centerContentAlignment.get().equals(Pos.TOP_RIGHT)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue() + (maxWidthForCenterContent - centerContentWidth), contentY); } else if (centerContentAlignment.get().equals(Pos.CENTER_LEFT)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue(), contentY + (maxHeigthForCenterContent - centerContentHeight) / 2); } else if (centerContentAlignment.get().equals(Pos.CENTER)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue() + (maxWidthForCenterContent - centerContentWidth) / 2, contentY + (maxHeigthForCenterContent - centerContentHeight) / 2); } else if (centerContentAlignment.get().equals(Pos.CENTER_RIGHT)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue() + (maxWidthForCenterContent - centerContentWidth), contentY + (maxHeigthForCenterContent - centerContentHeight) / 2); } else if (centerContentAlignment.get().equals(Pos.BOTTOM_LEFT)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue(), contentY + (maxHeigthForCenterContent - centerContentHeight)); } else if (centerContentAlignment.get().equals(Pos.BOTTOM_CENTER)) { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue() + (maxWidthForCenterContent - centerContentWidth) / 2, contentY + (maxHeigthForCenterContent - centerContentHeight)); } else { centerContent.relocate(contentX + leftContentWidth + spacing.get().doubleValue() + (maxWidthForCenterContent - centerContentWidth), contentY + (maxHeigthForCenterContent - centerContentHeight)); } } }
Example 5
Source File: OrientationHelper.java From Flowless with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void relocate(Node node, double b0, double l0) { node.relocate(l0, b0); }
Example 6
Source File: OrientationHelper.java From Flowless with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void relocate(Node node, double b0, double l0) { node.relocate(b0, l0); }