コード例 #1
0
  public Point getAbsolutePosition(final Point point, final boolean boundsChecking)
      throws UiObjectNotFoundException, InvalidCoordinatesException {
    final Rect rect = el.getBounds();
    final Point pos = new Point();
    Logger.debug("Element bounds: " + rect.toShortString());

    if (point.x == 0) {
      pos.x = rect.width() * 0.5 + rect.left;
    } else if (point.x <= 1) {
      pos.x = rect.width() * point.x + rect.left;
    } else {
      pos.x = rect.left + point.x;
    }
    if (boundsChecking == true) {
      if (pos.x > rect.right || pos.x < rect.left) {
        throw new InvalidCoordinatesException(
            "X coordinate ("
                + pos.x.toString()
                + " is outside of element rect: "
                + rect.toShortString());
      }
    }

    if (point.y == 0) {
      pos.y = rect.height() * 0.5 + rect.top;
    } else if (point.y <= 1) {
      pos.y = rect.height() * point.y + rect.top;
    } else {
      pos.y = rect.left + point.y;
    }
    if (boundsChecking == true) {
      if (pos.y > rect.bottom || pos.y < rect.top) {
        throw new InvalidCoordinatesException(
            "Y coordinate ("
                + pos.y.toString()
                + " is outside of element rect: "
                + rect.toShortString());
      }
    }

    return pos;
  }
コード例 #2
0
 public Rect getBounds() throws UiObjectNotFoundException {
   return el.getBounds();
 }