Package net.mygwt.ui.client.util

Examples of net.mygwt.ui.client.util.Point


   * @param align the element to align to
   * @param pos the position to align to
   * @param offsets the offsets or <code>null</code>
   */
  public static void alignTo(Element elem, Element align, String pos, int[] offsets) {
    Point p = getAlignToXY(elem, align, pos, offsets);
    setXY(elem, p);
  }
View Full Code Here


    String[] m = pos.split("-");

    String p1 = m[0];
    String p2 = m[1];

    Point a1 = getAnchorXY(elem, p1, true);
    Point a2 = getAnchorXY(align, p2, false);

    if (offsets == null) {
      offsets = new int[] {0, 0};
    }

    int x = a2.x - a1.x + offsets[0];
    int y = a2.y - a1.y + offsets[1];

    if (m.length == 3) {
      int w = getComputedWidth(elem);
      int h = getHeight(elem);

      int dw = Window.getClientWidth() - 5;
      int dh = Window.getClientHeight() - 5;

      Region r = getRegion(elem);

      char p1y = p1.charAt(0), p1x = p1.charAt(p1.length() - 1);
      char p2y = p2.charAt(0), p2x = p2.charAt(p2.length() - 1);
      boolean swapY = ((p1y == 't' && p2y == 'b') || (p1y == 'b' && p2y == 't'));
      boolean swapX = ((p1x == 'r' && p2x == 'l') || (p1x == 'l' && p2x == 'r'));

      int scrollX = getBodyScrollLeft();
      int scrollY = getBodyScrollTop();

      if ((x + w) > dw + scrollX) {
        x = swapX ? r.left - w : dw + scrollX - w;
      }
      if (x < scrollX) {
        x = swapX ? r.right : scrollX;
      }
      if ((y + h) > dh + scrollY) {
        y = swapY ? r.top - h : dh + scrollY - h;
      }
      if (y < scrollY) {
        y = swapY ? r.bottom : scrollY;
      }
    }

    return new Point(x, y);
  }
View Full Code Here

      x = w;
      y = 0;
    }

    if (local) {
      return new Point(x, y);
    }

    Point p = getXY(elem);
    p.x += x;
    p.y += y;
    return p;
  }
View Full Code Here

   *
   * @param elem the element
   * @return the current location
   */
  public static Point getXY(Element elem) {
    return new Point(getX(elem), getY(elem));
  }
View Full Code Here

   * @param elem the element
   * @param to the to element
   * @return the xy page offsets
   */
  public static Point offsetsTo(Element elem, Element to) {
    Point o = getXY(elem);
    Point e = getXY(to);
    return new Point(o.x - e.x, o.y - e.y);
  }
View Full Code Here

   * @param elem
   * @param pos
   */
  public void show(Element elem, String pos) {
    DOM.appendChild(getElement(), widget.getElement());
    Point p = MyDOM.getAlignToXY(getElement(), elem, pos, null);
    MyDOM.setLeftTop(getElement(), p.x, p.y);
    show();
  }
View Full Code Here

    show();
  }

  public void show(Element elem, String pos, int[] offsets) {
    DOM.appendChild(getElement(), widget.getElement());
    Point p = MyDOM.getAlignToXY(getElement(), elem, pos, offsets);
    MyDOM.setLeftTop(getElement(), p.x, p.y);
    show();
  }
View Full Code Here

   *
   * @param widget the widget to use for alignment
   */
  public void show(Widget widget) {
    int[] offset = new int[] {0, 2};
    Point p = MyDOM.getAlignToXY(getElement(), widget.getElement(), null, offset);
    MyDOM.setLeftTop(getElement(), p.x, p.y);
    show();
  }
View Full Code Here

TOP

Related Classes of net.mygwt.ui.client.util.Point

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.