Package de.lessvoid.nifty.layout

Examples of de.lessvoid.nifty.layout.Box


    currentScreen.resetLayout();
    currentScreen.layoutLayers();
  }

  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


    final int y0 = y;
    final int y1 = y0 + srcH0;
    final int y2 = y1 + midlH;

    renderRow(device, image, m_row0, new Box(srcX, srcY0, srcW, srcH0), x, y0, width, srcH0, color, scale, cX, cY);
    renderRow(device, image, m_row1, new Box(srcX, srcY1, srcW, srcH1), x, y1, width, midlH, color, scale, cX, cY);
    renderRow(device, image, m_row2, new Box(srcX, srcY2, srcW, srcH2), x, y2, width, srcH2, color, scale, cX, cY);
  }
View Full Code Here

    }
  }

  @Override
  public Box getSourceArea(RenderImage renderImage) {
    return new Box(0, 0, renderImage.getWidth(), renderImage.getHeight());
  }
View Full Code Here

    int x = Integer.valueOf(args[0]);
    int y = Integer.valueOf(args[1]);
    int width = Integer.valueOf(args[2]);
    int height = Integer.valueOf(args[3]);

    m_subImageArea = new Box(x, y, width, height);
  }
View Full Code Here

    if (((imageX + m_width) > imageWidth) || ((imageY + m_height) > imageHeight)) {
      log.warning("Sprite's area exceeds image's bounds.");
    }

    return new Box(imageX, imageY, m_width, m_height);
  }
View Full Code Here

    int rootBoxHeight = getRootBoxHeight(rootElement);

    // 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

    if (elements.size() > 1) {
      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);
View Full Code Here

    int rootBoxHeight = getRootBoxHeight(root);

    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);
      } else {
        elementWidth = calcElementWidth(children, rootBoxWidth, boxConstraints, 0);
        box.setWidth(elementWidth);

        int elementHeight = processHeightConstraint(rootBoxHeight, box, boxConstraints, 0);
        box.setHeight(elementHeight);
      }

      box.setY(processVerticalAlignment(rootBoxY, rootBoxHeight, box, boxConstraints));
      box.setX(x);

      x += elementWidth;
    }
  }
View Full Code Here

    int rootBoxWidth = getRootBoxWidth(root);
    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);
      } else {
        int elementWidth = processWidthConstraints(rootBoxWidth, currentBoxConstraints, 0);
        currentBox.setWidth(elementWidth);

        elementHeight = calcElementHeight(children, rootBoxHeight, currentBoxConstraints, 0);
        currentBox.setHeight(elementHeight);
      }

      currentBox.setX(processHorizontalAlignment(rootBoxX, rootBoxWidth, currentBox.getWidth(), currentBoxConstraints));
      currentBox.setY(y);

      y += elementHeight;
    }
  }
View Full Code Here

    if (rootElement == null || elements == null || elements.size() == 0) {
      return;
    }

    // get the root box
    Box rootBox = rootElement.getBox();

    // now do the layout
    for (int i = 0; i < elements.size(); i++) {
      LayoutPart p = elements.get(i);
      Box box = p.getBox();
      box.setX(rootBox.getX());
      box.setY(rootBox.getY());
      box.setWidth(rootBox.getWidth());
      box.setHeight(rootBox.getHeight());
    }
  }
View Full Code Here

TOP

Related Classes of de.lessvoid.nifty.layout.Box

Copyright © 2018 www.massapicom. 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.