Example usage for com.google.gwt.user.client.ui Widget getOffsetWidth

List of usage examples for com.google.gwt.user.client.ui Widget getOffsetWidth

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget getOffsetWidth.

Prototype

@Override
    public int getOffsetWidth() 

Source Link

Usage

From source file:org.thechiselgroup.biomixer.client.core.geometry.Rectangle.java

License:Apache License

public static Rectangle fromWidget(Widget widget) {
    int x = widget.getAbsoluteLeft();
    int y = widget.getAbsoluteTop();
    int height = widget.getOffsetHeight();
    int width = widget.getOffsetWidth();

    return new Rectangle(x, y, width, height);
}

From source file:org.thechiselgroup.biomixer.client.dnd.resources.DefaultResourceSetAvatarDragController.java

License:Apache License

/**
 * Creates a shade element that has bounds of drop target element, but an
 * absolute location, and is positioned behind the drop target.
 *//*from  w  w  w  . j a  va2s.com*/
private Element createShadeElement(Widget dropTarget) {
    Element shade = DOM.createSpan();

    shade.addClassName(CSS_SHADE_CLASS);

    CSS.setZIndex(shade, CSS_SHADE_Z_INDEX);

    WindowPanel window = getWindow(dropTarget);
    CSS.setAbsoluteBounds(shade, dropTarget.getAbsoluteLeft() - window.getAbsoluteLeft(),
            dropTarget.getAbsoluteTop() - window.getAbsoluteTop(), dropTarget.getOffsetWidth(),
            dropTarget.getOffsetHeight());

    return shade;
}

From source file:org.thechiselgroup.biomixer.client.visualization_component.graph.Graph.java

License:Apache License

@Override
public SizeInt getDisplayArea() {
    Widget displayWidget = graphDisplay.asWidget();
    int height = displayWidget.getOffsetHeight();
    int width = displayWidget.getOffsetWidth();
    return new DefaultSizeInt(width, height);
}

From source file:org.thechiselgroup.choosel.visualization_component.graph.client.Graph.java

License:Apache License

@Override
public Size getDisplayArea() {
    Widget displayWidget = graphDisplay.asWidget();
    int height = displayWidget.getOffsetHeight();
    int width = displayWidget.getOffsetWidth();
    return new DefaultSize(width, height);
}

From source file:org.thechiselgroup.choosel.visualization_component.graph.client.Graph.java

License:Apache License

private void positionNode(Node node) {
    // FIXME positioning: FlexVis takes care of positioning nodes into empty
    // space except for first node - if the node is the first node, we put
    // it in the center
    // TODO improve interface to access all resources

    assert node != null;

    if (getVisualItems().size() > 1) {
        return;//from w w w. j a  va 2  s . c  o m
    }

    Widget displayWidget = graphDisplay.asWidget();
    if (displayWidget == null) {
        return; // for tests
    }

    int height = displayWidget.getOffsetHeight();
    int width = displayWidget.getOffsetWidth();

    graphDisplay.setLocation(node, new Point(width / 2, height / 2));
}

From source file:org.uberfire.client.util.Layouts.java

License:Apache License

private static String widgetInfo(Widget w) {
    String widgetInfo;//from w  w  w  .  j  ava2 s . com
    try {
        String id = w.getElement().getId();
        widgetInfo = w.getOffsetWidth() + "x" + w.getOffsetHeight() + " - " + Debug.objectId(w)
                + (id != null && id.length() > 0 ? " id=" + id : "")
                + (w instanceof SplitPanel ? " divider at " + ((SplitPanel) w).getFixedWidgetSize() : "")
                + (w instanceof RequiresResize ? " RequiresResize" : "")
                + (w instanceof ProvidesResize ? " ProvidesResize" : "") + " position: "
                + w.getElement().getStyle().getPosition() + "\n";
    } catch (Throwable t) {
        widgetInfo = "?x? - " + Debug.objectId(w) + ": " + t.toString() + "\n";
    }
    return widgetInfo;
}

From source file:org.uberfire.client.views.pfly.dnd.CompassWidgetImpl.java

License:Apache License

private void showDropTarget(final DragContext context, final CompassPosition p) {
    int x = 0;/*w  w  w . j  a  va 2  s  . co m*/
    int y = 0;
    int width = 0;
    int height = 0;
    final Widget dropTargetParent = context.dropController.getDropTarget();
    switch (p) {
    case SELF:
        x = dropTargetParent.getAbsoluteLeft();
        y = dropTargetParent.getAbsoluteTop();
        width = dropTargetParent.getOffsetWidth();
        height = dropTargetParent.getOffsetHeight();
        highlightActiveDropTarget(centre);
        showDropTarget(x, y, width, height);
        break;
    case NORTH:
        x = dropTargetParent.getAbsoluteLeft();
        y = dropTargetParent.getAbsoluteTop();
        width = dropTargetParent.getOffsetWidth();
        height = (int) (dropTargetParent.getOffsetHeight() * 0.50);
        highlightActiveDropTarget(north);
        showDropTarget(x, y, width, height);
        break;
    case SOUTH:
        x = dropTargetParent.getAbsoluteLeft();
        height = (int) (dropTargetParent.getOffsetHeight() * 0.50);
        y = dropTargetParent.getOffsetHeight() + dropTargetParent.getAbsoluteTop() - height;
        width = dropTargetParent.getOffsetWidth();
        highlightActiveDropTarget(south);
        showDropTarget(x, y, width, height);
        break;
    case EAST:
        width = (int) (dropTargetParent.getOffsetWidth() * 0.50);
        x = dropTargetParent.getOffsetWidth() + dropTargetParent.getAbsoluteLeft() - width;
        y = dropTargetParent.getAbsoluteTop();
        height = dropTargetParent.getOffsetHeight();
        highlightActiveDropTarget(east);
        showDropTarget(x, y, width, height);
        break;
    case WEST:
        x = dropTargetParent.getAbsoluteLeft();
        y = dropTargetParent.getAbsoluteTop();
        width = (int) (dropTargetParent.getOffsetWidth() * 0.50);
        height = dropTargetParent.getOffsetHeight();
        highlightActiveDropTarget(west);
        showDropTarget(x, y, width, height);
        break;
    default:
        highlightActiveDropTarget(null);
        hideDropTarget();
    }
}

From source file:org.uberfire.client.views.pfly.tab.ResizeTabPanel.java

License:Apache License

@Override
public void onResize() {
    final Widget parent = this.getParent();

    int width = parent.getOffsetWidth();
    int height = parent.getOffsetHeight();

    if (width == 0 && height == 0) {
        //it's `invisible` = makes no sense try to resize
        return;//from  w w  w.j a  va 2s . c  om
    }

    height = height - getTabBarHeight();
    Layouts.setToFillParent(this);

    // TabContent is just a container for all the TabPane divs, one of which is made visible at a time.
    // For compatibility with GWT LayoutPanel, we have to set both layers of children to fill their parents.
    // We do it in onResize() to get to the TabPanes no matter how they were added.
    for (Widget child : tabContent) {
        child.setPixelSize(width, height);
        Layouts.setToFillParent(child);
        if (child instanceof TabPane) {
            final TabPane tabPane = (TabPane) child;
            if (tabPane.isActive()) {
                for (int i = 0; i < tabPane.getWidgetCount(); i++) {
                    final Widget tabChild = tabPane.getWidget(i);
                    tabChild.setPixelSize(width, height);
                    Layouts.setToFillParent(tabChild);
                    if (tabChild instanceof RequiresResize) {
                        ((RequiresResize) tabChild).onResize();
                    }
                }
            }
        }
    }
}

From source file:org.uberfire.client.workbench.panels.impl.AbstractDockingWorkbenchPanelView.java

License:Apache License

/**
 * Retrieves the application-requested initial size for a child panel, or calculates a good default based on the
 * available space.//from  w w w  .j ava 2 s. c om
 * @param position the position the panel will be added within its parent.
 * @param definition the new panel's definition.
 * @param parent the widget whose space will be used up by the insertion of the new panel.
 */
static int initialWidthOrHeight(CompassPosition position, PanelDefinition definition, Widget parent) {
    Integer requestedSize;
    int availableSize;
    switch (position) {
    case NORTH:
    case SOUTH:
        requestedSize = definition.getHeight();
        availableSize = parent.getOffsetHeight();
        break;
    case EAST:
    case WEST:
        requestedSize = definition.getWidth();
        availableSize = parent.getOffsetWidth();
        break;
    default:
        throw new IllegalArgumentException("Position " + position + " has no horizontal or vertial aspect.");
    }
    if (requestedSize == null || requestedSize <= 0) {
        return availableSize / 2;
    } else {
        return requestedSize;
    }
}

From source file:org.uberfire.client.workbench.panels.impl.AbstractDockingWorkbenchPanelView.java

License:Apache License

private static int getWidthOrHeight(CompassPosition position, Widget w) {
    switch (position) {
    case NORTH://from  w w w  .ja v a2  s.c  o  m
    case SOUTH:
        return w.getOffsetHeight();
    case EAST:
    case WEST:
        return w.getOffsetWidth();
    default:
        throw new IllegalArgumentException("Position " + position + " has no horizontal or vertial aspect.");
    }
}