Пример #1
0
  public Rect prepareDraw(Canvas _canvas) {
    if (isCollapsed()) {
      rect = Instruction.prepareDraw(_canvas, getCollapsedText(), this);
      return rect;
    }

    rect.top = 0;
    rect.left = 0;

    rect.right = 2 * Math.round(E_PADDING / 2);

    FontMetrics fm = _canvas.getFontMetrics(Element.font);

    rect.right = Math.round(2 * (Element.E_PADDING / 2));
    for (int i = 0; i < getText().count(); i++) {
      if (rect.right
          < getWidthOutVariables(_canvas, getText().get(i), this) + 2 * Math.round(E_PADDING / 2)) {
        rect.right =
            getWidthOutVariables(_canvas, getText().get(i), this) + 2 * Math.round(E_PADDING / 2);
      }
    }

    rect.bottom = 2 * Math.round(E_PADDING / 2) + getText().count() * fm.getHeight();

    r = q.prepareDraw(_canvas);

    rect.right = Math.max(rect.right, r.right + E_PADDING);
    rect.bottom += r.bottom + E_PADDING;
    return rect;
  }
Пример #2
0
  public Rect prepareDraw(Canvas _canvas) {
    Rect subrect = new Rect();

    rect.top = 0;
    rect.left = 0;
    rect.right = 0;
    rect.bottom = 0;

    if (children.size() > 0) {
      for (int i = 0; i < children.size(); i++) {
        subrect = ((Element) children.get(i)).prepareDraw(_canvas);
        rect.right = Math.max(rect.right, subrect.right);
        rect.bottom += subrect.bottom;
      }
    } else {
      rect.right = 2 * Element.E_PADDING;
      FontMetrics fm = _canvas.getFontMetrics(Element.font);
      rect.bottom = fm.getHeight() + 2 * Math.round(Element.E_PADDING / 2);
    }

    return rect;
  }