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

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

Introduction

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

Prototype

public void setProperty(String name, String value) 

Source Link

Usage

From source file:next.i.view.widgets.XPopup.java

License:Apache License

public void doPosition() {

    Style s = getWidget().getElement().getStyle();

    if (isCentered) {

        setBottom(null);/*  ww w .j a v  a2  s .co m*/
        setRight(null);
        setTop("50%");
        setLeft("50%");
        int height = getWidget().getOffsetHeight();
        int width = getWidget().getOffsetWidth();

        // XLog.info("height: " + height + ", getOffsetHeight(): " +
        // getOffsetHeight());

        int top_ = height >= getOffsetHeight() ? 0 : (height / 2);
        int left_ = width >= getOffsetWidth() ? 0 : (width / 2);

        s.setProperty("marginTop", "-" + top_ + "px");
        s.setProperty("marginLeft", "-" + left_ + "px");

    } else {

        if (top == null) {
            s.clearProperty("top");
        } else {
            s.setProperty("top", top);
        }

        if (right == null) {
            s.clearProperty("right");
        } else {
            s.setProperty("right", right);
        }

        if (bottom == null) {
            s.clearProperty("bottom");
        } else {
            s.setProperty("bottom", bottom);
        }

        if (left == null) {
            s.clearProperty("left");
        } else {
            s.setProperty("left", left);
        }

    }

}

From source file:next.i.view.widgets.XSpinner.java

License:Apache License

public XSpinner() {
    SimplePanel div = new SimplePanel();
    initWidget(div);//  w w w.  jav  a 2  s .c o m

    Style s = div.getElement().getStyle();

    s.setProperty("position", "absolute");
    s.setProperty("left", "50%");
    s.setProperty("top", "50%");
    s.setProperty("marginLeft", "-16px");
    s.setProperty("marginTop", "-16px");
    s.setProperty("width", "32px");
    s.setProperty("height", "32px");
    s.setProperty("backgroundImage", "url(images/all/spinner.gif)");
}

From source file:org.anstis.client.grid.widget.dom.BaseDOMElement.java

License:Apache License

/**
 * Transform the DOMElement based on the render context, such as scale and position.
 * @param context//from   w w  w .  j av  a  2 s.c  o  m
 */
protected void transform(final GridCellRenderContext context) {
    final Transform transform = context.getTransform();
    final double width = context.getWidth();
    final double height = context.getHeight();

    final Style style = container.getElement().getStyle();

    //Reposition and transform the DOM Element
    style.setLeft((context.getX() * transform.getScaleX()) + transform.getTranslateX(), Style.Unit.PX);
    style.setTop((context.getY() * transform.getScaleY()) + transform.getTranslateY(), Style.Unit.PX);
    style.setWidth(width, Style.Unit.PX);
    style.setHeight(height, Style.Unit.PX);

    if (isOne(transform.getScaleX()) && isOne(transform.getScaleY())) {
        style.clearProperty("WebkitTransform");
        style.clearProperty("MozTransform");
        style.clearProperty("Transform");
        return;
    }

    final String scale = "scale(" + FORMAT.format(transform.getScaleX()) + ", "
            + FORMAT.format(transform.getScaleY()) + ")";
    final String translate = "translate(" + FORMAT.format(((width - width * transform.getScaleX()) / -2.0))
            + "px, " + FORMAT.format(((height - height * transform.getScaleY()) / -2.0)) + "px)";
    style.setProperty("WebkitTransform", translate + " " + scale);
    style.setProperty("MozTransform", translate + " " + scale);
    style.setProperty("Transform", translate + " " + scale);
}

From source file:org.bioversityinternational.cisf.client.tools.Elements.java

License:Apache License

/**
 * Sets a DOM element's opacity//from   ww w .  ja v a2 s.co m
 * @param e
 * @param percent
 */
public static void setOpacity(final Element e, final int percent) {
    final Style s = e.getStyle();
    final double d = ((double) percent / (double) 100);
    s.setProperty("opacity", String.valueOf(d));
    s.setProperty("MozOpacity", String.valueOf(d));
    s.setProperty("KhtmlOpacity", String.valueOf(d));
    s.setProperty("filter", "alpha(opacity=" + percent + ")");
}

From source file:org.cruxframework.crux.core.client.screen.widgets.ScreenBlocker.java

License:Apache License

private static void expandElementToScreen(Widget widget) {
    Style style = widget.getElement().getStyle();
    style.setProperty("position", "absolute");
    style.setPropertyPx("top", 0);
    style.setPropertyPx("left", 0);
    style.setProperty("width", "100%");
    style.setProperty("height", "100%");
}

From source file:org.cruxframework.crux.smartfaces.client.dialog.PopupPanel.java

License:Apache License

private void centralizeMe() {
    Style style = getElement().getStyle();
    style.setLeft(50, Unit.PCT);//from  w w  w . j  ava  2  s  .c o  m
    style.setTop(50, Unit.PCT);
    style.setProperty("webkitTransform", "translateY(-50%) translateX(-50%)");
    style.setProperty("transform", "translateY(-50%) translateX(-50%)");
    left = -1;
    top = -1;
    centered = true;
}

From source file:org.cruxframework.crux.widgets.client.promobanner.BannerImpl.java

License:Apache License

protected void addBanner(ImageResource image, String title, String text, String styleName, String buttonLabel,
        final SelectHandler selectHandler) {
    SimplePanel panel = new SimplePanel();
    Style style = panel.getElement().getStyle();
    style.setProperty("background", "url(" + Screen.rewriteUrl(image.getSafeUri().asString()) + ") no-repeat "
            + (-image.getLeft() + "px ") + (-image.getTop() + "px"));
    style.setPropertyPx("width", image.getWidth());
    style.setPropertyPx("height", image.getHeight());

    doAddBanner(title, text, styleName, buttonLabel, selectHandler, panel);
}

From source file:org.cruxframework.crux.widgets.client.styledpanel.StyledPanel.java

License:Apache License

public StyledPanel() {
    initWidget(externalPanel);//from   w  ww . ja  v  a2 s .c o m
    externalPanel.add(internalPanel);

    Style extrnStyle = externalPanel.getElement().getStyle();
    extrnStyle.setProperty("display", "table");
    extrnStyle.setProperty("boxSizing", "border-box");

    Style intrnStyle = internalPanel.getElement().getStyle();
    intrnStyle.setProperty("display", "table-cell");
    intrnStyle.setWidth(100, Unit.PCT);

    externalPanel.setStyleName(DEFAULT_OUTER_STYLE_NAME);
    internalPanel.setStyleName(DEFAULT_STYLE_NAME);

    setHorizontalAlignment(horizontalAlignment);
    setVerticalAlignment(verticalAlignment);
}

From source file:org.cruxframework.crux.widgets.client.styledpanel.StyledPanel.java

License:Apache License

@Override
public void setVerticalAlignment(VerticalAlignmentConstant align) {
    String verticalAlign = "";

    if (align != null) {
        this.verticalAlignment = align;

        if (this.verticalAlignment.equals(HasVerticalAlignment.ALIGN_MIDDLE)) {
            verticalAlign = "middle";
        } else if (this.verticalAlignment.equals(HasVerticalAlignment.ALIGN_BOTTOM)) {
            verticalAlign = "bottom";
        }/*  ww  w.  j  a va2s . co m*/
    }

    Style style = internalPanel.getElement().getStyle();
    style.setProperty("verticalAlign", verticalAlign);
}

From source file:org.cruxframework.crux.widgets.client.styledpanel.StyledPanel.java

License:Apache License

@Override
public void setHorizontalAlignment(HorizontalAlignmentConstant align) {
    String marginLeft = "";
    String marginRight = "";

    if (align != null) {
        this.horizontalAlignment = align;

        if (this.horizontalAlignment.equals(HasHorizontalAlignment.ALIGN_RIGHT)) {
            marginRight = "auto";
        }/*from   w w w.  ja v a2s . co  m*/
        if (this.horizontalAlignment.equals(HasHorizontalAlignment.ALIGN_CENTER)) {
            marginLeft = "auto";
            marginRight = "auto";
        }
    }

    if (internalPanel.getWidget() != null) {
        Style childStyle = internalPanel.getWidget().getElement().getStyle();
        childStyle.setProperty("marginLeft", marginLeft);
        childStyle.setProperty("marginRight", marginRight);
    }
}