Java Code Examples for javafx.scene.layout.Region#getHeight()

The following examples show how to use javafx.scene.layout.Region#getHeight() . 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: ModelLayoutUpdater.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks if a node's JavaFX region has different layout values than those currently stored in the model.
 *
 * @param node the model instance for the node
 *
 * @return {@code true} if any layout value has changed, {@code false if not}
 */
private boolean checkNodeChanged(final GNode node) {

    final GNodeSkin nodeSkin = skinLookup.lookupNode(node);

    if (nodeSkin == null) {
        return false;
    }

    final Region nodeRegion = nodeSkin.getRoot();

    if (nodeRegion.getLayoutX() != node.getX()) {
        return true;
    } else if (nodeRegion.getLayoutY() != node.getY()) {
        return true;
    } else if (nodeRegion.getWidth() != node.getWidth()) {
        return true;
    } else if (nodeRegion.getHeight() != node.getHeight()) {
        return true;
    }
    return false;
}
 
Example 2
Source File: SquareButton.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private void adjustDimension() {
    if (!(this.getParent() instanceof Region)) {
        return;
    }
    final Region titlePane = (Region) this.getParent();
    final double marginBar = titlePane.getInsets().getTop() + titlePane.getInsets().getBottom();
    final double paddingButton = this.getPadding().getTop() + this.getPadding().getBottom();
    final double max = titlePane.getHeight() - marginBar - paddingButton;
    this.setPrefSize(max, max);
    this.setMaxSize(MAX_BUTTON_SIZE, MAX_BUTTON_SIZE);
}
 
Example 3
Source File: WorkbenchOverlay.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private void initialize(Region overlay) {
  if (!isInitialized() && overlay.getWidth() > 0 && overlay.getHeight() > 0) {
    setInitialized(true);
    if (!Objects.isNull(getOnInitialized())) {
      getOnInitialized().handle(new Event(overlay, overlay, Event.ANY));
    }
  }
}
 
Example 4
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static void moveYCenter(Region pNnode, Node node) {
    if (node == null || pNnode == null) {
        return;
    }
    double yOffset = pNnode.getHeight() - node.getBoundsInLocal().getHeight();
    if (yOffset > 0) {
        node.setLayoutY(pNnode.getLayoutY() + yOffset / 2);
    }
}
 
Example 5
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 5 votes vote down vote up
private static void dragNorth(MouseEvent event, Wrapper<Point2D> mouseLocation, Region region, double handleRadius) {
	final double deltaY = event.getSceneY() - mouseLocation.value.getY();
	final double newY = region.getLayoutY() + deltaY;
	if(newY != 0 && newY >= handleRadius && newY <= region.getLayoutY() + region.getHeight() - handleRadius) {
		region.setLayoutY(newY);
		region.setPrefHeight(region.getPrefHeight() - deltaY);
	}
}
 
Example 6
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 5 votes vote down vote up
private static void dragSouth(MouseEvent event, Wrapper<Point2D> mouseLocation, Region region, double handleRadius) {
	final double deltaY = event.getSceneY() - mouseLocation.value.getY();
	final double newMaxY = region.getLayoutY() + region.getHeight() + deltaY;
	if(newMaxY >= region.getLayoutY() && newMaxY <= region.getParent().getBoundsInLocal().getHeight() - handleRadius) {
		region.setPrefHeight(region.getPrefHeight() + deltaY);
	}
}
 
Example 7
Source File: JFXChipViewSkin.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
public void updateEditorPosition() {
    final Insets insets = getInsets();
    final double width = getWidth();
    final double height = getHeight();
    final double top = insets.getTop();
    final double left = insets.getLeft();
    final double bottom = insets.getBottom();
    final double right = insets.getRight();
    final double insideWidth = width - left - right;
    final double insideHeight = height - top - bottom;
    final double newLineEditorX = right + initOffset;
    final double editorVInsets = editor.snappedTopInset() + editor.snappedBottomInset();

    final List<Node> managedChildren = getManagedChildren();
    final int mangedChildrenSize = managedChildren.size();
    if (mangedChildrenSize > 0) {
        Region lastChild = (Region) managedChildren.get(mangedChildrenSize - 1);
        double contentHeight = lastChild.getHeight() + lastChild.getLayoutY();
        availableWidth = insideWidth - lastChild.getBoundsInParent().getMaxX();
        double minWidth = editor.getMinWidth();
        minWidth = minWidth < 0 ? 100 : minWidth;
        minWidth = Math.max(minWidth, requiredWidth);

        if (availableWidth > requiredWidth) {
            moveToNewLine = false;
        }

        if (availableWidth < minWidth || moveToNewLine) {
            layoutInArea(editor,
                newLineEditorX,
                contentHeight + root.getVgap(),
                insideWidth - initOffset,
                editor.prefHeight(-1),
                0, getColumnHAlignmentInternal(), VPos.TOP);
            editorOnNewLine = true;
            ensureVisible(editor);
        } else {
            layoutInArea(editor,
                lastChild.getBoundsInParent().getMaxX() + root.getHgap(),
                lastChild.getLayoutY(),
                availableWidth - root.getHgap(),
                lastChild.getHeight() + editorVInsets,
                0, getColumnHAlignmentInternal(), getRowVAlignmentInternal());
            editorOnNewLine = false;
        }
    } else {
        layoutInArea(editor,
            newLineEditorX,
            top,
            insideWidth - initOffset,
            editor.prefHeight(-1)
            , 0, getColumnHAlignmentInternal(), VPos.TOP);
        editorOnNewLine = true;
        ensureVisible(editor);
    }
}
 
Example 8
Source File: XYChartInfo.java    From jfxutils with Apache License 2.0 4 votes vote down vote up
private Rectangle2D getComponentArea( Region childRegion ) {
	double xStart = getXShift( childRegion, referenceNode );
	double yStart = getYShift( childRegion, referenceNode );

	return new Rectangle2D( xStart, yStart, childRegion.getWidth(), childRegion.getHeight() );
}
 
Example 9
Source File: SelectionCopier.java    From graph-editor with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Gets the start and end x- and y-positions of the given region (including insets).
 *
 * @param region a {@link Region}
 * @return the bounds of the given region
 */
private Bounds getBounds(final Region region) {

    final Bounds bounds = new Bounds();

    bounds.startX = region.getInsets().getLeft();
    bounds.startY = region.getInsets().getTop();

    bounds.endX = region.getWidth() - region.getInsets().getRight();
    bounds.endY = region.getHeight() - region.getInsets().getBottom();

    return bounds;
}