Examples of BoxConstraints


Examples of de.lessvoid.nifty.layout.BoxConstraints

  private void updateLayoutPart(final LayoutPart layoutPart, final int width, final int height) {
    Box box = layoutPart.getBox();
    box.setWidth(width);
    box.setHeight(height);
    BoxConstraints boxConstraints = layoutPart.getBoxConstraints();
    boxConstraints.setWidth(new SizeValue(width + "px"));
    boxConstraints.setHeight(new SizeValue(height + "px"));
  }
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

    // now do the layout
    for (int i = 0; i < elements.size(); i++) {
      LayoutPart p = elements.get(i);
      Box box = p.getBox();
      BoxConstraints cons = p.getBoxConstraints();

      // makes only sense with constraints given
      if (cons != null) {
        if (cons.getX() != null) {
          box.setX(rootBoxX + cons.getX().getValueAsInt(rootBoxWidth));
        }

        if (cons.getY() != null) {
          box.setY(rootBoxY + cons.getY().getValueAsInt(rootBoxHeight));
        }

        if (cons.getWidth() != null && cons.getWidth().hasHeightSuffix()) {
          if (cons.getHeight() != null) {
            box.setHeight(cons.getHeight().getValueAsInt(rootBoxHeight));
          }
          box.setWidth(cons.getWidth().getValueAsInt(box.getHeight()));
        } else if (cons.getHeight() != null && cons.getHeight().hasWidthSuffix()) {
          if (cons.getWidth() != null) {
            box.setWidth(cons.getWidth().getValueAsInt(rootBoxWidth));
          }
          box.setHeight(cons.getHeight().getValueAsInt(box.getWidth()));
        } else {
          if (cons.getWidth() != null) {
            box.setWidth(cons.getWidth().getValueAsInt(rootBoxWidth));
          }
          if (cons.getHeight() != null) {
            box.setHeight(cons.getHeight().getValueAsInt(rootBoxHeight));
          }
        }

        post.process(rootBoxX, rootBoxY, rootBoxWidth, rootBoxHeight, box);
      }
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

      log.warning("You're using a centerLayout element but you've added more than one child element to it. centerLayout only supports one element! Odd things will happen when used with more than one element :)");
    }

    // we only support center of the very first element
    Box rootBox = rootElement.getBox();
    BoxConstraints rootBoxConstraints = rootElement.getBoxConstraints();

    Box box = elements.get(0).getBox();
    BoxConstraints constraint = elements.get(0).getBoxConstraints();

    if (constraint.getWidth() != null && constraint.getWidth().hasHeightSuffix()) {
      handleVerticalAlignment(rootBox, rootBoxConstraints, box, constraint);
      handleHorizontalAlignment(rootBox, rootBoxConstraints, box, constraint);
    } else if (constraint.getHeight() != null && constraint.getHeight().hasWidthSuffix()) {
      handleHorizontalAlignment(rootBox, rootBoxConstraints, box, constraint);
      handleVerticalAlignment(rootBox, rootBoxConstraints, box, constraint);
    } else {
      handleVerticalAlignment(rootBox, rootBoxConstraints, box, constraint);
      handleHorizontalAlignment(rootBox, rootBoxConstraints, box, constraint);
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

    }
    LayoutPart firstChild = children.get(0);
    if (firstChild == null) {
      return null;
    }
    BoxConstraints constraint = firstChild.getBoxConstraints();
    if (constraint == null) {
      return null;
    }
    return
      new SizeValue(
          constraint.getWidth().getValueAsInt(0) +
          root.getBoxConstraints().getPaddingLeft().getValueAsInt(root.getBox().getWidth()) +
          root.getBoxConstraints().getPaddingRight().getValueAsInt(root.getBox().getWidth()) + "px");
  }
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

    }
    LayoutPart firstChild = children.get(0);
    if (firstChild == null) {
      return null;
    }
    BoxConstraints constraint = firstChild.getBoxConstraints();
    if (constraint == null) {
      return null;
    }
    return
      new SizeValue(
          constraint.getHeight().getValueAsInt(0) +
          root.getBoxConstraints().getPaddingTop().getValueAsInt(root.getBox().getHeight()) +
          root.getBoxConstraints().getPaddingBottom().getValueAsInt(root.getBox().getHeight()) + "px");

  }
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

    int x = rootBoxX;
    for (int i = 0; i < children.size(); i++) {
      LayoutPart current = children.get(i);
      Box box = current.getBox();
      BoxConstraints boxConstraints = current.getBoxConstraints();

      int elementWidth;
      if (boxConstraints.getWidth() != null && boxConstraints.getWidth().hasHeightSuffix()) {
        int elementHeight = processHeightConstraint(rootBoxHeight, box, boxConstraints, 0);
        box.setHeight(elementHeight);

        elementWidth = calcElementWidth(children, rootBoxWidth, boxConstraints, elementHeight);
        box.setWidth(elementWidth);
      } else if (hasHeightConstraint(boxConstraints) && boxConstraints.getHeight().hasWidthSuffix()) {
        elementWidth = calcElementWidth(children, rootBoxWidth, boxConstraints, 0);
        box.setWidth(elementWidth);

        int elementHeight = processHeightConstraint(rootBoxHeight, box, boxConstraints, elementWidth);
        box.setHeight(elementHeight);
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

      ) {
    int maxFixedWidth = 0;
    int fixedCount = 0;
    for (int i = 0; i < elements.size(); i++) {
      LayoutPart p = elements.get(i);
      BoxConstraints original = p.getBoxConstraints();

      if (original.getWidth() != null) {
        if (original.getWidth().isPercentOrPixel()) {
          maxFixedWidth += original.getWidth().getValue(parentWidth);
          fixedCount++;
        }
      }
    }
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

    int rootBoxHeight = getRootBoxHeight(root);

    int y = rootBoxY;
    for (int i = 0; i < children.size(); i++) {
      Box currentBox = children.get(i).getBox();
      BoxConstraints currentBoxConstraints = children.get(i).getBoxConstraints();

      int elementHeight;

      if (hasHeightConstraint(currentBoxConstraints) && currentBoxConstraints.getHeight().hasWidthSuffix()) {
        int elementWidth = processWidthConstraints(rootBoxWidth, currentBoxConstraints, 0);
        currentBox.setWidth(elementWidth);

        elementHeight = calcElementHeight(children, rootBoxHeight, currentBoxConstraints, elementWidth);
        currentBox.setHeight(elementHeight);
      } else if (hasWidthConstraint(currentBoxConstraints) && currentBoxConstraints.getWidth().hasHeightSuffix()) {
        elementHeight = calcElementHeight(children, rootBoxHeight, currentBoxConstraints, 0);
        currentBox.setHeight(elementHeight);

        int elementWidth = processWidthConstraints(rootBoxWidth, currentBoxConstraints, elementHeight);
        currentBox.setWidth(elementWidth);
View Full Code Here

Examples of de.lessvoid.nifty.layout.BoxConstraints

    int maxFixedHeight = 0;
    int fixedCount = 0;

    for (int i = 0; i < elements.size(); i++) {
      LayoutPart p = elements.get(i);
      BoxConstraints original = p.getBoxConstraints();
      if (hasHeightConstraint(original)) {
        if (original.getHeight().isPercentOrPixel()) {
          maxFixedHeight += original.getHeight().getValue(parentHeight);
          fixedCount++;
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.