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

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

    final GJointSkin jointSkin = skinLookup.lookupJoint(joint);

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

    final Region jointRegion = jointSkin.getRoot();

    final double jointRegionX = jointRegion.getLayoutX() + jointSkin.getWidth() / 2;
    final double jointRegionY = jointRegion.getLayoutY() + jointSkin.getHeight() / 2;

    if (jointRegionX != joint.getX()) {
        return true;
    } else if (jointRegionY != joint.getY()) {
        return true;
    }
    return false;
}
 
Example 3
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 4
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 5
Source File: Commands.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Updates the model's layout values to match those in the skin instances.
 *
 * <p>
 * This method adds set operations to the given compound command but does <b>not</b> execute it.
 * </p>
 *
 * @param command a {@link CompoundCommand} to which the set commands will be added
 * @param model the {@link GModel} whose layout values should be updated
 * @param skinLookup the {@link SkinLookup} in use for this graph editor instance
 */
public static void updateLayoutValues(final CompoundCommand command, final GModel model, final SkinLookup skinLookup) {

    final EditingDomain editingDomain = getEditingDomain(model);

    if (editingDomain != null) {

        for (final GNode node : model.getNodes()) {

            final Region nodeRegion = skinLookup.lookupNode(node).getRoot();

            command.append(SetCommand.create(editingDomain, node, NODE_X, nodeRegion.getLayoutX()));
            command.append(SetCommand.create(editingDomain, node, NODE_Y, nodeRegion.getLayoutY()));
            command.append(SetCommand.create(editingDomain, node, NODE_WIDTH, nodeRegion.getWidth()));
            command.append(SetCommand.create(editingDomain, node, NODE_HEIGHT, nodeRegion.getHeight()));
        }

        for (final GConnection connection : model.getConnections()) {

            for (final GJoint joint : connection.getJoints()) {

                final GJointSkin jointSkin = skinLookup.lookupJoint(joint);
                final Region jointRegion = jointSkin.getRoot();

                final double x = jointRegion.getLayoutX() + jointSkin.getWidth() / 2;
                final double y = jointRegion.getLayoutY() + jointSkin.getHeight() / 2;

                command.append(SetCommand.create(editingDomain, joint, JOINT_X, x));
                command.append(SetCommand.create(editingDomain, joint, JOINT_Y, y));
            }
        }
    }
}
 
Example 6
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 7
Source File: GeometryUtils.java    From graph-editor with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Gets the layout x and y values from all joints in a list of joint skins.
 *
 * @param jointSkins a list of joint skin instances
 *
 * @return a {@link List} of {@link Point2D} objects containing joint x and y values
 */
public static List<Point2D> getJointPositions(final List<GJointSkin> jointSkins) {

    final List<Point2D> jointPositions = new ArrayList<>();

    for (final GJointSkin jointSkin : jointSkins) {

        final Region region = jointSkin.getRoot();

        final double x = region.getLayoutX() + jointSkin.getWidth() / 2;
        final double y = region.getLayoutY() + jointSkin.getHeight() / 2;

        jointPositions.add(new Point2D(x, y));
    }

    return jointPositions;
}