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

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

Introduction

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

Prototype

public void setWidth(String width) 

Source Link

Document

Sets the object's width.

Usage

From source file:com.square.client.gwt.client.view.personne.coordonnees.AdresseCreationViewImpl.java

License:Open Source License

/**
 * Construit un bloc avec un label et un champ pour l'affichage.
 *//*from  w w w . ja v a 2  s .c o m*/
private HorizontalPanel construireBlocIcone(final Widget composant, final String nomChamp,
        AideComposant aideComposant) {
    final IconeErreurChamp icone = iconeErreurChampManager.createInstance(nomChamp, composant);
    final HorizontalPanel panel = new HorizontalPanel();
    panel.add(composant);
    panel.setSpacing(2);
    composant.setWidth("96%");
    HorizontalPanel panelIcone = new HorizontalPanel();
    // panelIcone.setSpacing(5);
    panelIcone.add(icone);
    panelIcone.add(aideComposant);
    panel.add(panelIcone);
    // panelIcone.setCellVerticalAlignment(aideComposant, HasVerticalAlignment.ALIGN_MIDDLE);
    panel.setCellVerticalAlignment(panelIcone, HasVerticalAlignment.ALIGN_MIDDLE);
    return panel;
}

From source file:com.sun.labs.aura.dbbrowser.client.viz.Util.java

License:Open Source License

public static HorizontalPanel getHisto(String name, int value, int maxValue, int maxWidth, String text) {

    int leftWidth = Math.round(((float) value / (float) maxValue) * (float) maxWidth);
    if (leftWidth < 1) {
        leftWidth = 1;/*from ww w. jav a2  s.  c o m*/
    } else if (leftWidth > maxWidth) {
        leftWidth = maxWidth;
    }
    int rightWidth = maxWidth - leftWidth;
    boolean alert = false;
    if (value / (float) maxValue > 0.75) {
        alert = true;
    }

    HorizontalPanel all = new HorizontalPanel();
    all.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    all.add(new StyleLabel(name + ":", "viz-histoName"));

    HorizontalPanel table = new HorizontalPanel();
    table.setWidth(maxWidth + "px");
    table.setBorderWidth(0);
    table.setSpacing(0);

    Widget left = new Label("");
    if (alert) {
        left.setStyleName("viz-histoLeftAlert");
    } else {
        left.setStyleName("viz-histoLeft");
    }
    left.setWidth(leftWidth + "");
    left.setHeight("10px");
    left.getElement().getStyle().setPropertyPx("fontSize", 6);

    Widget right = new Label("");
    if (alert) {
        right.setStyleName("viz-histoRightAlert");
    } else {
        right.setStyleName("viz-histoRight");
    }
    right.setWidth(rightWidth + "");
    right.setHeight("10px");
    right.getElement().getStyle().setPropertyPx("fontSize", 6);

    table.add(left);
    table.add(right);
    all.add(table);
    all.add(new StyleLabel(text, "viz-histoText"));
    return all;
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.swidget.SimpleSearchSwidget.java

License:Open Source License

/**
 * Child method of invokeArtistSearchService
 * @param sr/*from   w  w  w  . jav a2s. c  om*/
 */
private void searchResultsToArtistList(SearchResults sr) {
    showTopMessage("Found " + sr.getItemResults(cdm).length + " matches");
    Widget searchResults = getItemInfoList("Pick one: ", sr.getItemResults(cdm), null, true, true,
            cdm.getArtistOracle());
    searchResults.setStyleName("searchResults");
    searchResults.setWidth("300px");
    setResults(sr.toString(), searchResults);
}

From source file:com.sun.labs.aura.music.wsitm.client.WebLib.java

License:Open Source License

/**
 * Returns a populatiry histrogram. To get it wrapped with a title, use other
 * utility functions getSmallPopularityWidget() or getPopularityWidget()
 * @param normPopularity popularity as a number between 0 and 1
 * @param log plot on log scale/*from   w  ww  .  ja v a2s  .c om*/
 * @param height maximum size of 15
 * @param maxWidth
 * @return
 */
public static HorizontalPanel getPopularityHisto(double normPopularity, boolean log, int height, int maxWidth) {

    if (log) {
        normPopularity = Math.log(normPopularity + 1) / Math.log(2); // get the base 2 log
    }
    int leftWidth = (int) (normPopularity * maxWidth);
    if (leftWidth < 1) {
        leftWidth = 1;
    } else if (leftWidth > maxWidth) {
        leftWidth = maxWidth;
    }
    int rightWidth = maxWidth - leftWidth;

    HorizontalPanel table = new HorizontalPanel();
    table.setWidth(maxWidth + "px");
    table.setBorderWidth(0);
    table.setSpacing(0);

    Widget left = new Label("");
    left.setStyleName("popLeft");
    left.setWidth(leftWidth + "");
    left.setHeight(height + "px");
    left.getElement().getStyle().setPropertyPx("fontSize", height - 2);

    Widget right = new Label("");
    right.setStyleName("popRight");
    right.setWidth(rightWidth + "");
    right.setHeight(height + "px");
    right.getElement().getStyle().setPropertyPx("fontSize", height - 2);

    table.add(left);
    table.add(right);

    return table;
}

From source file:com.tensegrity.wpalo.client.ui.mvc.cubeview.DimensionRepositoryRenderer.java

License:Open Source License

public Point render(int width, int height) {
    if (hide) {/*  w w w. j a  v a  2 s.  c  om*/
        return new Point(0, 0);
    }
    int left = INDENT, top = INDENT;
    if (width < getMinWidth())
        width = getMinWidth();
    // renderer empty label if visible
    Widget emptyLabel = container.getEmptyLabel();
    if (emptyLabel != null && emptyLabel.isVisible()) {
        emptyLabel.setWidth(width + "px");
        container.setWidgetPosition(emptyLabel, 0, top);
    }
    ContainerWidget[] widgets = container.getWidgets();
    for (int i = 0; i < widgets.length; i++) {
        ContainerWidget widget = widgets[i];
        if (i < firstVisible) {
            widget.setVisible(false);
        } else {
            widget.setVisible(true);
            container.setWidgetPosition(widget, left, top);
            top += widget.getOffsetHeight() + INDENT;
        }
    }
    return new Point(width, top);
}

From source file:com.vaadin.client.ui.calendar.schedule.DayToolbar.java

License:Apache License

public void updateCellWidths() {
    int count = getWidgetCount();
    if (count > 0) {
        setCellWidth(backLabel, MARGINLEFT + "px");
        setCellWidth(nextLabel, MARGINRIGHT + "px");
        setCellHorizontalAlignment(nextLabel, ALIGN_RIGHT);
        int cellw = width / (count - 2);
        if (cellw > 0) {
            int[] cellWidths = VCalendar.distributeSize(width, count - 2, 0);
            for (int i = 1; i < count - 1; i++) {
                Widget widget = getWidget(i);
                // if (remain > 0) {
                // setCellWidth(widget, cellw2 + "px");
                // remain--;
                // } else {
                // setCellWidth(widget, cellw + "px");
                // }
                setCellWidth(widget, cellWidths[i - 1] + "px");
                widget.setWidth(cellWidths[i - 1] + "px");
            }/*from w w  w.  j a  v a2s. c o  m*/
        }
    }
}

From source file:com.vaadin.terminal.gwt.client.ApplicationConnection.java

License:Open Source License

private void updateComponentSize(ComponentDetail cd, UIDL uidl) {
    String w = uidl.hasAttribute("width") ? uidl.getStringAttribute("width") : "";

    String h = uidl.hasAttribute("height") ? uidl.getStringAttribute("height") : "";

    float relativeWidth = Util.parseRelativeSize(w);
    float relativeHeight = Util.parseRelativeSize(h);

    // First update maps so they are correct in the setHeight/setWidth calls
    if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
        // One or both is relative
        FloatSize relativeSize = new FloatSize(relativeWidth, relativeHeight);
        if (cd.getRelativeSize() == null && cd.getOffsetSize() != null) {
            // The component has changed from absolute size to relative size
            relativeSizeChanges.add(cd.getComponent());
        }//from www . j av  a  2  s . c o  m
        cd.setRelativeSize(relativeSize);
    } else if (relativeHeight < 0.0 && relativeWidth < 0.0) {
        if (cd.getRelativeSize() != null) {
            // The component has changed from relative size to absolute size
            relativeSizeChanges.add(cd.getComponent());
        }
        cd.setRelativeSize(null);
    }

    Widget component = (Widget) cd.getComponent();
    // Set absolute sizes
    if (relativeHeight < 0.0) {
        component.setHeight(h);
    }
    if (relativeWidth < 0.0) {
        component.setWidth(w);
    }

    // Set relative sizes
    if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
        // One or both is relative
        handleComponentRelativeSize(cd);
    }

}

From source file:com.vaadin.terminal.gwt.client.ApplicationConnection.java

License:Open Source License

/**
 * Converts relative sizes into pixel sizes.
 * /*  www. j ava2  s . c  o m*/
 * @param child
 * @return true if the child has a relative size
 */
private boolean handleComponentRelativeSize(ComponentDetail cd) {
    if (cd == null) {
        return false;
    }
    boolean debugSizes = false;

    FloatSize relativeSize = cd.getRelativeSize();
    if (relativeSize == null) {
        return false;
    }
    Widget widget = (Widget) cd.getComponent();

    boolean horizontalScrollBar = false;
    boolean verticalScrollBar = false;

    Container parent = Util.getLayout(widget);
    RenderSpace renderSpace;

    // Parent-less components (like sub-windows) are relative to browser
    // window.
    if (parent == null) {
        renderSpace = new RenderSpace(Window.getClientWidth(), Window.getClientHeight());
    } else {
        renderSpace = parent.getAllocatedSpace(widget);
    }

    if (relativeSize.getHeight() >= 0) {
        if (renderSpace != null) {

            if (renderSpace.getScrollbarSize() > 0) {
                if (relativeSize.getWidth() > 100) {
                    horizontalScrollBar = true;
                } else if (relativeSize.getWidth() < 0 && renderSpace.getWidth() > 0) {
                    int offsetWidth = widget.getOffsetWidth();
                    int width = renderSpace.getWidth();
                    if (offsetWidth > width) {
                        horizontalScrollBar = true;
                    }
                }
            }

            int height = renderSpace.getHeight();
            if (horizontalScrollBar) {
                height -= renderSpace.getScrollbarSize();
            }
            if (validatingLayouts && height <= 0) {
                zeroHeightComponents.add(cd.getComponent());
            }

            height = (int) (height * relativeSize.getHeight() / 100.0);

            if (height < 0) {
                height = 0;
            }

            if (debugSizes) {
                VConsole.log("Widget " + Util.getSimpleName(widget) + "/" + getPid(widget.getElement())
                        + " relative height " + relativeSize.getHeight() + "% of " + renderSpace.getHeight()
                        + "px (reported by "

                        + Util.getSimpleName(parent) + "/" + (parent == null ? "?" : parent.hashCode()) + ") : "
                        + height + "px");
            }
            widget.setHeight(height + "px");
        } else {
            widget.setHeight(relativeSize.getHeight() + "%");
            VConsole.error(Util.getLayout(widget).getClass().getName() + " did not produce allocatedSpace for "
                    + widget.getClass().getName());
        }
    }

    if (relativeSize.getWidth() >= 0) {

        if (renderSpace != null) {

            int width = renderSpace.getWidth();

            if (renderSpace.getScrollbarSize() > 0) {
                if (relativeSize.getHeight() > 100) {
                    verticalScrollBar = true;
                } else if (relativeSize.getHeight() < 0 && renderSpace.getHeight() > 0
                        && widget.getOffsetHeight() > renderSpace.getHeight()) {
                    verticalScrollBar = true;
                }
            }

            if (verticalScrollBar) {
                width -= renderSpace.getScrollbarSize();
            }
            if (validatingLayouts && width <= 0) {
                zeroWidthComponents.add(cd.getComponent());
            }

            width = (int) (width * relativeSize.getWidth() / 100.0);

            if (width < 0) {
                width = 0;
            }

            if (debugSizes) {
                VConsole.log("Widget " + Util.getSimpleName(widget) + "/" + getPid(widget.getElement())
                        + " relative width " + relativeSize.getWidth() + "% of " + renderSpace.getWidth()
                        + "px (reported by " + Util.getSimpleName(parent) + "/"
                        + (parent == null ? "?" : getPid(parent)) + ") : " + width + "px");
            }
            widget.setWidth(width + "px");
        } else {
            widget.setWidth(relativeSize.getWidth() + "%");
            VConsole.error(Util.getLayout(widget).getClass().getName() + " did not produce allocatedSpace for "
                    + widget.getClass().getName());
        }
    }

    return true;
}

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

protected Region makeDownload() {
    BaseRegion r = new BaseRegion(DOWNLOAD_REGION);
    r.setAlign(BaseRegion.ALIGN_MIDDLE);
    Widget w = r.getDisplay();
    w.setWidth("100%");
    return r;//from  ww w  .j  a  va2 s  .c  o m
}

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

protected Region makeResult() {
    BaseRegion r = new BaseRegion(RESULT_REGION);
    //        r.setAlign(BaseRegion.ALIGN_MIDDLE);
    Widget w = r.getDisplay();
    w.setWidth("100%");
    return r;//w w  w .  ja  va  2 s  .c  o m
}