Search in sources :

Example 1 with Alignment

use of com.minecolonies.blockout.Alignment in project minecolonies by Minecolonies.

the class View method adjustChild.

protected void adjustChild(final Pane child) {
    int childX = child.getX();
    int childY = child.getY();
    int childWidth = child.getWidth();
    int childHeight = child.getHeight();
    //  Negative width = 100% of parents width minus abs(width).
    if (childWidth < 0) {
        childWidth = Math.max(0, getInteriorWidth() + childWidth);
    }
    final Alignment alignment = child.getAlignment();
    //  Adjust for horizontal alignment.
    if (alignment.isRightAligned()) {
        childX = (getInteriorWidth() - childWidth) - childX;
    } else if (alignment.isHorizontalCentered()) {
        childX = ((getInteriorWidth() - childWidth) / 2) + childX;
    }
    //  Negative height = 100% of parents height minus abs(height).
    if (childHeight < 0) {
        childHeight = Math.max(0, getInteriorHeight() + childHeight);
    }
    //  Adjust for vertical alignment.
    if (alignment.isBottomAligned()) {
        childY = (getInteriorHeight() - childHeight) - childY;
    } else if (alignment.isVerticalCentered()) {
        childY = ((getInteriorHeight() - childHeight) / 2) + childY;
    }
    child.setSize(childWidth, childHeight);
    child.setPosition(childX, childY);
}
Also used : Alignment(com.minecolonies.blockout.Alignment)

Aggregations

Alignment (com.minecolonies.blockout.Alignment)1