Java Code Examples for javafx.geometry.Side#equals()

The following examples show how to use javafx.geometry.Side#equals() . 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: DefaultNodeSkin.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Point2D getConnectorPosition(final GConnectorSkin connectorSkin) {

    final Node connectorRoot = connectorSkin.getRoot();

    final Side side = DefaultConnectorTypes.getSide(connectorSkin.getConnector().getType());

    // The following logic is required because the connectors are offset slightly from the node edges.
    final double x, y;
    if (side.equals(Side.LEFT)) {
        x = 0;
        y = connectorRoot.getLayoutY() + connectorSkin.getHeight() / 2;
    } else if (side.equals(Side.RIGHT)) {
        x = getRoot().getWidth();
        y = connectorRoot.getLayoutY() + connectorSkin.getHeight() / 2;
    } else if (side.equals(Side.TOP)) {
        x = connectorRoot.getLayoutX() + connectorSkin.getWidth() / 2;
        y = 0;
    } else {
        x = connectorRoot.getLayoutX() + connectorSkin.getWidth() / 2;
        y = getRoot().getHeight();
    }

    return new Point2D(x, y);
}
 
Example 2
Source File: DefaultSkinController.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Counts the number of connectors the given node currently has of the given type.
 *
 * @param node a {@link GNode} instance
 * @param side the {@link Side} the connector is on
 * @return the number of connectors this node has on the given side
 */
private int countConnectors(final GNode node, final Side side) {

    int count = 0;

    for (final GConnector connector : node.getConnectors()) {
        if (side.equals(DefaultConnectorTypes.getSide(connector.getType()))) {
            count++;
        }
    }

    return count;
}
 
Example 3
Source File: RectangularPathCreator.java    From graph-editor with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a rectangular path from the start to the end positions.
 * 
 * <p>
 * Tries to travel outwards from the start and end nodes by at least a minimum amount.
 * </p>
 * 
 * @param startPosition the start position
 * @param endPosition the end position
 * @param startSide the side of the node the path starts from
 * @param endSide the side of the node the path travels to
 * @return a list of points specifying the path
 */
public static List<Point2D> createPath(final Point2D startPosition, final Point2D endPosition,
        final Side startSide, final Side endSide) {

    if (startSide.equals(Side.LEFT) && endSide.equals(Side.LEFT)) {
        return connectLeftToLeft(startPosition, endPosition);

    } else if (startSide.equals(Side.LEFT) && endSide.equals(Side.RIGHT)) {
        return connectLeftToRight(startPosition, endPosition);

    } else if (startSide.equals(Side.LEFT) && endSide.equals(Side.TOP)) {
        return connectLeftToTop(startPosition, endPosition);

    } else if (startSide.equals(Side.LEFT) && endSide.equals(Side.BOTTOM)) {
        return connectLeftToBottom(startPosition, endPosition);

    } else if (startSide.equals(Side.RIGHT) && endSide.equals(Side.LEFT)) {
        return reverse(connectLeftToRight(endPosition, startPosition));

    } else if (startSide.equals(Side.RIGHT) && endSide.equals(Side.RIGHT)) {
        return connectRightToRight(startPosition, endPosition);

    } else if (startSide.equals(Side.RIGHT) && endSide.equals(Side.TOP)) {
        return connectRightToTop(startPosition, endPosition);

    } else if (startSide.equals(Side.RIGHT) && endSide.equals(Side.BOTTOM)) {
        return connectRightToBottom(startPosition, endPosition);

    } else if (startSide.equals(Side.TOP) && endSide.equals(Side.LEFT)) {
        return reverse(connectLeftToTop(endPosition, startPosition));

    } else if (startSide.equals(Side.TOP) && endSide.equals(Side.RIGHT)) {
        return reverse(connectRightToTop(endPosition, startPosition));

    } else if (startSide.equals(Side.TOP) && endSide.equals(Side.TOP)) {
        return connectTopToTop(startPosition, endPosition);

    } else if (startSide.equals(Side.TOP) && endSide.equals(Side.BOTTOM)) {
        return connectTopToBottom(startPosition, endPosition);

    } else if (startSide.equals(Side.BOTTOM) && endSide.equals(Side.LEFT)) {
        return reverse(connectLeftToBottom(endPosition, startPosition));

    } else if (startSide.equals(Side.BOTTOM) && endSide.equals(Side.RIGHT)) {
        return reverse(connectRightToBottom(endPosition, startPosition));

    } else if (startSide.equals(Side.BOTTOM) && endSide.equals(Side.TOP)) {
        return reverse(connectTopToBottom(endPosition, startPosition));

    } else {
        return connectBottomToBottom(startPosition, endPosition);
    }
}