Example usage for com.google.gwt.user.client Window getClientHeight

List of usage examples for com.google.gwt.user.client Window getClientHeight

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window getClientHeight.

Prototype

public static int getClientHeight() 

Source Link

Usage

From source file:edu.caltech.ipac.firefly.core.layout.ResizableLayoutManager.java

@Override
public void resize() {
    int rh = Window.getClientHeight();
    int rw = Window.getClientWidth();

    int h = Math.max(getMinHeight(), rh - mainPanel.getAbsoluteTop() - 30 + yOffset);
    int w = Math.max(getMinWidth(), rw - 20);

    Region rr = getResizableRegion();
    if (rr != null) {
        int rrh = h - rr.getDisplay().getAbsoluteTop() + mainPanel.getAbsoluteTop();
        rr.getDisplay().setHeight(rrh + "px");
    }/*from  w  ww  .ja  v a 2 s  .  c  om*/
}

From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java

public static void showAtCenter(PopupPanel popup) {
    int h = Window.getClientHeight();
    int w = Window.getClientWidth();
    popup.show();/*  www .  j  a va2  s . com*/
    int offsetx = StringUtils.getInt(DOM.getStyleAttribute(popup.getElement(), "width"), 300);
    int offsety = StringUtils.getInt(DOM.getStyleAttribute(popup.getElement(), "height"), 200);
    int x = (w - offsetx) / 2;
    int y = (h - offsety) / 2;
    popup.setPopupPosition(x, y);
}

From source file:edu.caltech.ipac.firefly.ui.panels.ToolbarDropdown.java

public Dimension getDropDownSize() {
    int top = dpanel.getAbsoluteTop();
    int h = Window.getClientHeight() - top;
    int w = Window.getClientWidth() - 10;

    int minH = Application.getInstance().getLayoutManager().getMinHeight();
    return new Dimension(w, Math.max(minH, h));
}

From source file:edu.caltech.ipac.firefly.ui.PopupContainerForStandAlone.java

public Dimension getAvailableSize() {
    int w = Window.getClientWidth();
    int h = Window.getClientHeight();
    return new Dimension(w - 20, h - (HEIGHT_OFFSET + 20 + TOOLBAR_HEIGHT));
}

From source file:edu.caltech.ipac.firefly.ui.PopupContainerForStandAlone.java

public void computePosition(boolean offset) {
    if (_popout.isExpanded()) {
        if (BrowserUtil.isOldIE() || offset) {
            GwtUtil.setStyle(_main, "position", "absolute");
            GwtUtil.setStyle(_topBackground, "position", "absolute");
            int x = Window.getScrollLeft();
            int y = Window.getScrollTop();
            _main.setPopupPosition(x + 5, y + HEIGHT_OFFSET);
        } else {// w  w w  .j av  a2  s  . c om
            GwtUtil.setStyle(_main, "position", "fixed");
            GwtUtil.setStyle(_topBackground, "position", "fixed");
            GwtUtil.setStyles(_main, "left", "5px", "top", HEIGHT_OFFSET + "px");

        }
        int w = Window.getClientWidth();
        int h = Window.getClientHeight();
        _main.setPixelSize(w - 20, h - (HEIGHT_OFFSET + 20));
        _popout.onResize();
        _layout.onResize();
    }
}

From source file:edu.caltech.ipac.firefly.ui.PopupContainerForStandAlone.java

private void ensureSize() {
    Widget tlExpRoot = _popout.getToplevelExpandRoot();
    if (_popout.isExpanded() && GwtUtil.isOnDisplay(tlExpRoot)) {
        _topBackground.setHeight(Window.getClientHeight() + "px");
        Dimension dim = getAvailableSize();
        tlExpRoot.setPixelSize(dim.getWidth(), dim.getHeight());
        if (tlExpRoot instanceof RequiresResize) {
            ((RequiresResize) tlExpRoot).onResize();
        }/*from w ww .ja va 2s. c o m*/
    }
}

From source file:edu.caltech.ipac.firefly.ui.PopupPane.java

/**
 * resize the popup when the browser area is smaller then the popup size
 *//*from   w  w  w. java  2 s.  co  m*/
private void adjustResizable() {
    if (_expandW != null && optimalWidth > 0 && optimalHeight > 0) {
        int width = content.getOffsetWidth();
        int height = content.getOffsetHeight();

        if (width > Window.getClientWidth()) {
            width = Window.getClientWidth() - 20;
        } else if (width < optimalWidth) {
            width = Math.min(optimalWidth, Window.getClientWidth() - 20);
        }

        if (height > Window.getClientHeight()) {
            height = Window.getClientHeight() - 35;
        } else if (height < optimalHeight) {
            height = Math.min(optimalHeight, Window.getClientHeight() - 35);
        }

        if (width < minWidth) {
            width = minWidth;
            _doAlign = false; //turn off the automatic align, the dialog will jump around when users scrolls
        }
        if (height < minHeight) {
            height = minHeight;
            _doAlign = false; //turn off the automatic align, the dialog will jump around when users scrolls
        }

        if (height != content.getOffsetHeight() || width != content.getOffsetWidth()) {
            content.getWidget().setSize(width + "px", height + "px");
            ((RequiresResize) _expandW).onResize();
        }

    }
}

From source file:edu.caltech.ipac.firefly.ui.PopupPane.java

/**
 * Determine where the place the popup. This is a huge and central method to PopupPane - it needs come cleaning up
 * @param xoffset offset x added to alignment
 * @param yoffset offset y added to alignment
 *//* w  w  w.ja v  a  2s  .co m*/
private void alignPopup(final int xoffset, final int yoffset) {
    int x, y;

    if (popup != null)
        GwtUtil.setStyle(popup, "clip", "auto");
    if (firstAlign) {
        optimalWidth = content.getOffsetWidth();
        optimalHeight = content.getOffsetHeight();
        DeferredCommand.addCommand(new Command() {
            public void execute() {
                adjustResizable();
            }
        });
    }

    firstAlign = false;
    locateMask();

    PointerDir dir = PointerDir.NONE;

    if (alignAt == Align.DISABLE) {
        if (_pointerPopup)
            alignPointer(PointerDir.NORTH);
        return;
    }

    Widget alignWidget = this.alignWidget;
    if (alignWidget == null)
        alignWidget = RootPanel.get();

    int popupHeight = popup.getOffsetHeight();
    int popupWidth = popup.getOffsetWidth();
    int rootHeight = Window.getClientHeight();
    int rootWidth = Window.getClientWidth();

    int alignX = alignWidget.getAbsoluteLeft();
    int alignY = alignWidget.getAbsoluteTop();
    int alignWidth = alignWidget.getOffsetWidth();
    int alignHeight = alignWidget.getOffsetHeight();

    if (alignAt == Align.BOTTOM_LEFT) {
        x = alignX + xoffset;
        y = alignY + alignHeight + yoffset;

    } else if (alignAt == Align.BOTTOM_RIGHT) {
        x = alignX + alignWidth + xoffset;
        y = alignY + alignHeight + yoffset;

    } else if (alignAt == Align.AUTO_POINTER) {
        dir = PointerDir.NORTH;
        definePointerDirection(dir);
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = alignY + alignHeight + yoffset;
        if (y + popupHeight > Window.getClientHeight()) {
            dir = PointerDir.SOUTH_WEST;
            definePointerDirection(dir);
            x = alignX + alignWidth + xoffset;
            if (_pointerPopup)
                x += HOR_PTR_IMAGE_OFFSET;
            y = (alignY - popupHeight + 5) - yoffset;

        }
    } else if (alignAt == Align.BOTTOM_CENTER) {
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = alignY + alignHeight + yoffset;
    } else if (alignAt == Align.VISIBLE_BOTTOM) { //todo
        rootHeight = Window.getClientHeight();
        x = Window.getScrollLeft() + xoffset;
        y = Window.getScrollTop() + Window.getClientHeight() - popupHeight + yoffset;

    } else if (alignAt == Align.BOTTOM_CENTER_POPUP_BOTTOM) {
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = alignY + alignHeight - popupHeight + yoffset;

    } else if (alignAt == Align.TOP_CENTER) {
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = (alignY - popupHeight) - yoffset;

    } else if (alignAt == Align.TOP_RIGHT) {
        x = alignX + alignWidth + xoffset - popupWidth;
        y = alignY + yoffset;

    } else if (alignAt == Align.TOP_RIGHT_POPUP_RIGHT) {
        x = alignX + alignWidth + xoffset;
        y = alignY + yoffset;

    } else if (alignAt == Align.CENTER) {
        if (alignWidget == null) {
            int left = (Window.getClientWidth() - popupWidth) >> 1;
            int top = (Window.getClientHeight() - popupHeight) >> 1;
            x = Window.getScrollLeft() + left;
            y = Window.getScrollTop() + top;
        } else {
            int width = content.getOffsetWidth();
            int height = content.getOffsetHeight();
            x = alignX + alignWidth / 2;
            x = x - width / 2 + xoffset;
            y = alignY + alignHeight / 2;
            y = y - height / 2 + yoffset;
        }
        if (y < 0)
            y = 10;
        if (x < 0)
            x = 10;
    } else if (alignAt == Align.TOP_LEFT_POPUP_RIGHT) {
        x = alignX + xoffset - popupWidth;
        if (x < 0)
            x = 0;
        y = alignY + yoffset;
    } else if (alignAt == Align.TOP_LEFT_POPUP_BOTTOM) {
        x = alignX + xoffset;
        if (x < 0)
            x = 0;
        y = alignY + yoffset - popupHeight;
    } else if (alignAt == Align.TOP_RIGHT_OR_LEFT) {
        if (Window.getClientWidth() < (alignWidth + popupWidth)) {
            x = Window.getClientWidth() - ((xoffset + 35) + popupWidth);
            if (x < 0)
                x = 0;
            y = alignY + yoffset;
        } else {
            x = alignX + alignWidth + xoffset;
            y = alignY + yoffset;
        }

    } else {

        // default to TOP_LEFT
        x = 1 + xoffset;
        y = 1 + yoffset;
    }

    //----
    // Now adjust the popup to fit in the viewable area
    //----

    if (x + popupWidth > rootWidth) {
        x = x - ((x + popupWidth) - rootWidth); // move if over by the amount it is off the side
    }

    if (y + popupHeight > rootHeight && rootHeight > 10) { //if bottom of dialog is off the bottom, if root height is near 0 then don't adjust
        y = y - ((y + popupHeight) - rootHeight); // move if up by the amount it is off the bottom
    }

    if (y < Window.getScrollTop())
        y = Window.getScrollTop() + 1; // if it is off the top set it to the top +1
    if (x < Window.getScrollLeft())
        x = Window.getScrollLeft() + 1;// if it is off the left set it to the left +1

    if (_doAlign)
        _doAlign = _autoAlign;

    alignPointer(dir);

    if (popup.isVisible()) {
        if (popup.getAbsoluteLeft() != x || popup.getAbsoluteTop() != y) {
            popup.setPopupPosition(x, y);
        }
    }

}

From source file:edu.caltech.ipac.firefly.visualize.PlotWidgetOps.java

public void plot3Internal(final WebPlotRequest red, final WebPlotRequest green, final WebPlotRequest blue,
        final boolean addToHistory, final boolean enableMods, final boolean plotExpanded,
        final boolean canCollapse, final AsyncCallback<WebPlot> notify) {
    _mpw.setDefaultPlotRequest(new DefaultRequestInfo(red, green, blue));
    _mpw.setCanCollapse(canCollapse);//w  w  w .  j a  v a 2  s  . c  o  m
    if (plotExpanded) {
        for (WebPlotRequest r : new WebPlotRequest[] { red, green, blue }) {
            if (r != null) {
                r.setZoomType(ZoomType.FULL_SCREEN);
                r.setZoomToWidth(Window.getClientWidth());
                r.setZoomToHeight(Window.getClientHeight() - 125);
            }
        }
    }

    if (plotExpanded) {
        Vis.init(_mpw, new Vis.InitComplete() {
            public void done() {
                DeferredCommand.addCommand(new Command() {
                    public void execute() {
                        doExpand3Color(red, green, blue, addToHistory, enableMods, notify);
                    }
                });
            }
        });
    } else {
        _mpw.initAndPlot(red, green, blue, true, addToHistory, enableMods, notify);
    }
}

From source file:edu.caltech.ipac.firefly.visualize.WebMouseReadout.java

private ScreenPt computeTopBottom(int mouseX, int mouseY, Side side, boolean choose) {

    WebAssert.argTst((side == Side.Top || side == Side.Bottom), "Side must be Top or Bottom");

    Side otherSide;/*from  w w  w.  ja  v  a  2 s.  c om*/
    int y = 0;
    int popHeight = _popupPanel.getPopupPanel().getOffsetHeight();
    if (side == Side.Top) {
        otherSide = Side.Bottom;

        switch (_mode) {
        case Quick:
            y = _plotView.getAbsoluteTop() - popHeight;
            break;
        case Group:
            y = 3;
            break;
        default:
            WebAssert.argTst(false, "not a supported mode");
            break;
        }

    } else {
        otherSide = Side.Top;

        switch (_mode) {
        case Quick:
            y = _plotView.getAbsoluteTop() + _plotView.getOffsetHeight();
            break;
        case Group:
            y = Window.getClientHeight() - popHeight - 3;
            break;
        default:
            WebAssert.argTst(false, "not a supported mode");
            break;
        }

    }

    int x = 0;

    switch (_mode) {
    case Quick:
        x = _plotView.getAbsoluteLeft();
        break;
    case Group:
        x = 3;
        break;
    default:
        WebAssert.argTst(false, "not a supported mode");
        break;
    }

    ScreenPt op1Pt = adjustXY(x, y);

    ScreenPt op2Pt = null;
    ScreenPt op3Pt = null;

    Choice op2Choice = Choice.Bad;
    Choice op3Choice = Choice.Bad;
    Choice op1Choice = computeChoice(op1Pt, mouseX, mouseY);

    if (op1Choice != Choice.Good) {
        x = _plotView.getAbsoluteLeft() + _plotView.getOffsetWidth();
        op2Pt = adjustXY(x, y);

        op2Choice = computeChoice(op2Pt, mouseX, mouseY);
    }

    if (op1Choice != Choice.Good && op2Choice != Choice.Good) {
        int popWidth = _popupPanel.getPopupPanel().getOffsetWidth();
        x = _plotView.getAbsoluteLeft() - popWidth;
        op3Pt = adjustXY(x, y);

        op3Choice = computeChoice(op3Pt, mouseX, mouseY);
    }

    ScreenPt retval = chooseBest(op1Choice, op1Pt, op2Choice, op2Pt, op3Choice, op3Pt);

    if (retval == null && choose) {
        retval = computeLeftRight(mouseX, mouseY, otherSide, false);
        if (retval == null)
            retval = op1Pt;
    }

    return retval;
}