Example usage for com.google.gwt.dom.client Style setFontSize

List of usage examples for com.google.gwt.dom.client Style setFontSize

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style setFontSize.

Prototype

public void setFontSize(double value, Unit unit) 

Source Link

Usage

From source file:cc.kune.initials.InitialLabel.java

License:GNU Affero Public License

public void setStyle(final int height, final int fontSize) {
    final Style style = getElement().getStyle();
    style.setBackgroundColor(AvatarCompositeFactory.getColorProvider().getColor(name));
    style.setLineHeight(height, Unit.PX);
    style.setFontSize(fontSize, Unit.PX);
}

From source file:com.ephesoft.gxt.core.client.ui.widget.MultiFileUploader.java

License:Open Source License

private void setDimension(final Widget parent) {
    if (null != parent) {
        final Element element = dragDropLabel.getElement();
        final Style style = element.getStyle();
        final int height = parent.getOffsetHeight() - UPLOADER_BUTTON_HEIGHT - 2;
        final int heightToAssign = (height / 2) - FONT_SIZE;
        style.setHeight(heightToAssign, Unit.PX);
        style.setFontSize(FONT_SIZE, Unit.PX);
        style.setPaddingTop(heightToAssign, Unit.PX);
        style.setLineHeight(1, Unit.PX);
        dragDropLabel.setWidth("99%");
        style.setLeft(6, Unit.PX);//  w ww . ja va 2  s.c o m
        isInitialized = true;
        Style uploadProgressStyle = uploadProgress.getElement().getStyle();
        uploadProgressStyle.setMarginTop(height / 2, Unit.PX);
    }
}

From source file:com.google.gwt.sample.showcase.client.content.cell.AsyncContactProvider.java

private void installLoadingIndicator() {
    Style style = loadingStatus.getElement().getStyle();
    style.setFontSize(2, Unit.EM);
    style.setFontWeight(FontWeight.BOLD);
    style.setBackgroundColor("yellow");
    style.setTextAlign(TextAlign.CENTER);
    RootLayoutPanel.get().add(loadingStatus);
    RootLayoutPanel.get().setWidgetTopHeight(loadingStatus, 0, Unit.PX, 3, Unit.EM);
}

From source file:com.sciencegadgets.client.ui.FitParentHTML.java

License:Open Source License

private void resizeThis(double fontPercent) {
    Widget parent = this.getParent();
    if (parent == null) {
        return;/* w  ww.  ja v  a 2  s .  co m*/
    }
    Element parentElement = parent.getElement();
    Element htmlElement = this.getElement();
    Style htmlStyle = htmlElement.getStyle();

    htmlStyle.setFontSize((fontPercent), Unit.PCT);

    // Center vertically
    double extraBottom = (double) parentElement.getOffsetHeight() - (double) htmlElement.getOffsetHeight();
    htmlStyle.setPaddingTop(extraBottom / 2, Unit.PX);

}

From source file:com.sencha.gxt.chart.client.draw.engine.VML.java

License:sencha.com license

/**
 * Applies the attributes of the passed {@link TextSprite} to its VML element.
 * /* w  w  w  . ja v a 2 s  . c om*/
 * @param sprite the sprite whose attributes to use
 */
private void setTextAttributes(TextSprite sprite, XElement element) {
    Element textPath = element.childElement("textPath").cast();
    Style textStyle = textPath.getStyle();
    textBBoxCache.remove(sprite);

    if (sprite.isFontSizeDirty() || ignoreOptimizations) {
        if (sprite.getFontSize() > 0) {
            textStyle.setFontSize(sprite.getFontSize(), Unit.PX);
        } else {
            textStyle.clearFontSize();
        }
    }
    if (sprite.isFontStyleDirty() || ignoreOptimizations) {
        if (sprite.getFontStyle() != null) {
            textStyle.setFontStyle(sprite.getFontStyle());
        } else {
            textStyle.clearFontStyle();
        }
    }
    if (sprite.isFontWeightDirty() || ignoreOptimizations) {
        if (sprite.getFontWeight() != null) {
            textStyle.setFontWeight(sprite.getFontWeight());
        } else {
            textStyle.clearFontWeight();
        }
    }
    if (sprite.isFontDirty() || ignoreOptimizations) {
        if (sprite.getFont() != null) {
            textStyle.setProperty("fontFamily", sprite.getFont());
        } else {
            textStyle.clearProperty("fontFamily");
        }
    }

    // text-anchor emulation
    if (sprite.isTextAnchorDirty() || ignoreOptimizations) {
        if (sprite.getTextAnchor() == TextAnchor.MIDDLE) {
            setTextAlign(textStyle, "center");
        } else if (sprite.getTextAnchor() == TextAnchor.END) {
            setTextAlign(textStyle, "right");
        } else {
            setTextAlign(textStyle, "left");
        }
    }

    if (sprite.isTextDirty() || ignoreOptimizations) {
        if (sprite.getText() != null) {
            textPath.setPropertyString("string", sprite.getText());
        } else {
            textPath.setPropertyString("string", "");
        }
    }

    if (sprite.isTextBaselineDirty() || sprite.isXDirty() || sprite.isYDirty() || ignoreOptimizations) {
        double height = sprite.getFontSize();
        if (sprite.getTextBaseline() == TextBaseline.MIDDLE) {
            height = 0;
        } else if (sprite.getTextBaseline() == TextBaseline.BOTTOM) {
            height *= -1;
        }
        Element path = element.childElement("path").cast();
        path.setPropertyString("v",
                new StringBuilder().append("m").append(Math.round(sprite.getX() * zoom)).append(",")
                        .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).append(" l")
                        .append(Math.round(sprite.getX() * zoom) + 1).append(",")
                        .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).toString());
        textRenderedPoints.put(sprite, new PrecisePoint(sprite.getX(), sprite.getY()));
        textRenderedBaseline.put(sprite, sprite.getTextBaseline());
    }
}

From source file:com.sencha.gxt.widget.core.client.ListView.java

License:sencha.com license

private void ensureFocusElement() {
    if (focusEl != null) {
        focusEl.removeFromParent();/*from   ww  w.  ja v a 2 s  .  c  om*/
    }
    focusEl = (XElement) getElement().appendChild(focusImpl.createFocusable());
    focusEl.addClassName(CommonStyles.get().noFocusOutline());
    if (focusEl.hasChildNodes()) {
        focusEl.getFirstChildElement().addClassName(CommonStyles.get().noFocusOutline());
        com.google.gwt.dom.client.Style focusElStyle = focusEl.getFirstChildElement().getStyle();
        focusElStyle.setBorderWidth(0, Unit.PX);
        focusElStyle.setFontSize(1, Unit.PX);
        focusElStyle.setPropertyPx("lineHeight", 1);
    }
    focusEl.setLeft(0);
    focusEl.setTop(0);
    focusEl.makePositionable(true);
    focusEl.addEventsSunk(Event.FOCUSEVENTS);

}

From source file:com.vaadin.client.metadata.ConnectorBundleLoader.java

License:Apache License

private void notice(String productName) {
    if (notice == null) {
        notice = new HTML();
        notice.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                notice.removeFromParent();
            }/*from   ww w.j a va2s  . c om*/
        });
        notice.addTouchStartHandler(new TouchStartHandler() {
            public void onTouchStart(TouchStartEvent event) {
                notice.removeFromParent();
            }
        });
    }
    String msg = notice.getText().trim();
    msg += msg.isEmpty() ? "Using Evaluation License of: " : ", ";
    notice.setText(msg + productName);
    RootPanel.get().add(notice);

    notice.getElement().setClassName("");
    Style s = notice.getElement().getStyle();

    s.setPosition(Position.FIXED);
    s.setTextAlign(TextAlign.CENTER);
    s.setRight(0, Unit.PX);
    s.setLeft(0, Unit.PX);
    s.setBottom(0, Unit.PX);
    s.setProperty("padding", "0.5em 1em");

    s.setProperty("font-family", "sans-serif");
    s.setFontSize(12, Unit.PX);
    s.setLineHeight(1.1, Unit.EM);

    s.setColor("white");
    s.setBackgroundColor("black");
    s.setOpacity(0.7);

    s.setZIndex(2147483646);
    s.setProperty("top", "auto");
    s.setProperty("width", "auto");
    s.setDisplay(Display.BLOCK);
    s.setWhiteSpace(WhiteSpace.NORMAL);
    s.setVisibility(Visibility.VISIBLE);
    s.setMargin(0, Unit.PX);
}

From source file:fr.mncc.gwttoolbox.ui.client.Indicator.java

License:Open Source License

public void setMessage(String msg, String bkgColor, String txtColor) {

    label_.setText(msg);//from ww  w. ja  va  2 s. c o m

    Style labelStyle = label_.getElement().getStyle();
    labelStyle.setFontSize(1.6, Style.Unit.EM);
    labelStyle.setBackgroundColor(bkgColor);
    labelStyle.setColor(txtColor);
    labelStyle.setPadding(5, Style.Unit.PX);
}

From source file:ilarkesto.gwt.client.desktop.fields.AEditableMultiFieldField.java

License:Open Source License

public Widget createLabelWidget(AEditableField field) {
    String labelText = field.getLabel();
    if (labelText == null)
        labelText = "";

    String html = "<strong>" + Str.toHtml(labelText) + "</strong>";

    String tooltip = field.getTooltip();
    if (!Str.isBlank(tooltip))
        html += " - " + Str.toHtml(tooltip);

    HTML widget = new HTML(html);
    Style style = widget.getElement().getStyle();
    style.setFontSize(65, Unit.PCT);
    style.setColor("#999999");
    return widget;
}

From source file:ilarkesto.gwt.client.desktop.Widgets.java

License:Open Source License

public static Label textTitleInverted(Object object) {
    if (object == null)
        return null;
    Label label = new Label(Str.format(object));
    Style style = label.getElement().getStyle();
    style.setFontWeight(FontWeight.BOLD);
    style.setFontSize(105, Unit.PCT);
    style.setBackgroundColor(Colors.googleBlue);
    style.setColor("white");
    return label;
}