Java Code Examples for

The following are Jave code examples for showing how to use getOffsetWidth() of the class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: appinventor-extensions   File:   Source Code and License Vote up 5 votes
 * Returns the preferred size of the specified widget,
 * in an array of the form {@code [width, height]}.
 * <p>
 * It is assumed that:
 * <ul>
 *   <li>{@code w} has no parent</li>
 *   <li>{@code w} has not been configured to be invisible</li>
 * </ul>
public static int[] getPreferredSizeOfDetachedWidget(Widget w) {
  // Attach the widget to the DOM, so that its preferred size is calculated correctly

  String[] style = clearSizeStyle(w);
  int width = w.getOffsetWidth() + 4;
  int height = w.getOffsetHeight();
  restoreSizeStyle(w, style);

  // Detach the widget from the DOM before returning

  return new int[] { width, height };
Example 2
Project: empiria.player   File:   Source Code and License Vote up 4 votes
private Rectangle toRectangle(Widget widget) {
    return new Rectangle(widget.getAbsoluteLeft(), widget.getAbsoluteTop(), widget.getOffsetWidth(), widget.getOffsetHeight());
Example 3
Project: appinventor-extensions   File:   Source Code and License Vote up 3 votes
 * Returns whether the specified widget contains a position given
 * by the absolute coordinates.
 * @param w  widget to test
 * @param absX  absolute x coordinate of position
 * @param absY  absolute y coordinate of position
 * @return  {@code true} if the position is within the widget, {@code false}
 *          otherwise
private static boolean isInside(Widget w, int absX, int absY) {
  int wx = w.getAbsoluteLeft();
  int wy = w.getAbsoluteTop();
  int ww = w.getOffsetWidth();
  int wh = w.getOffsetHeight();

  return (wx <= absX) && (absX < wx + ww) && (wy <= absY) && (absY < wy + wh);