Example usage for com.google.gwt.user.client DOM getStyleAttribute

List of usage examples for com.google.gwt.user.client DOM getStyleAttribute

Introduction

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

Prototype

@Deprecated
public static String getStyleAttribute(Element elem, String attr) 

Source Link

Document

Gets an attribute of the given element's style.

Usage

From source file:asquare.gwt.tk.client.util.DomUtil.java

License:Apache License

/**
 * Gets a CSS style property for the specified UIObject's element.
 * /*w ww  .  ja  v  a2 s.  c o m*/
 * @param uio a UIObject
 * @param name a CSS style property name, in "camelCase"
 * @return value the style property value, or <code>null</code> if the
 *         property is not set
 */
public static String getStyleAttribute(UIObject uio, String name) {
    return DOM.getStyleAttribute(uio.getElement(), name);
}

From source file:at.ait.dme.yuma.client.colorpicker.TransparencyImpl.java

License:Artistic License

public static void setTransparency(Element elem, int alpha) {
    float ieVersion = getIEVersion();

    if (ieVersion >= 5.5 && ieVersion < 7.0) {
        elem = DOM.getChild(elem, 0);/*from w  w  w . j  a v a2 s. co m*/

        // Cache existing filters on the image, then re-apply everything with our Alpha filter
        // stacked on the end.
        if (map.containsKey(elem)) {
            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }
        } else {
            map.put(elem, DOM.getStyleAttribute(elem, "filter"));

            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }
        }
    }
    // If IE 7 (or better)
    else if (ieVersion >= 7.0) {
        DOM.setStyleAttribute(elem, "filter", "alpha(opacity=" + alpha + ")");
    } else // Everyone else
    {
        DOM.setStyleAttribute(elem, "opacity", "" + (new Integer(alpha).floatValue() / 100) + "");
    }
}

From source file:at.researchstudio.dme.imageannotation.client.colorpicker.TransparencyImpl.java

License:Artistic License

public static void setTransparency(Element elem, int alpha) {
    float ieVersion = getIEVersion();

    if (ieVersion >= 5.5 && ieVersion < 7.0) {
        elem = DOM.getChild(elem, 0);//w w w .ja v  a 2  s  .  c  om

        // Cache existing filters on the image, then re-apply everything with our Alpha filter
        // stacked on the end.
        if (map.containsKey(elem)) {
            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }
        } else {
            map.put(elem, DOM.getStyleAttribute(elem, "filter"));

            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }
        }
    }
    // If IE 7 (or better)
    else if (ieVersion >= 7.0) {
        DOM.setStyleAttribute(elem, "filter", "alpha(opacity=" + alpha + ")");
    } else // Everyone else
    {
        DOM.setStyleAttribute(elem, "-moz-opacity", "" + (new Integer(alpha).floatValue() / 100) + "");
        DOM.setStyleAttribute(elem, "opacity", "" + (new Integer(alpha).floatValue() / 100) + "");
    }
}

From source file:com.ait.toolkit.flash.widget.client.swf.ui.SWFWidget.java

License:Open Source License

/**
 * Gets the width.
 * 
 * @return the width
 */
public String getWidth() {
    return DOM.getStyleAttribute(getElement(), "width");
}

From source file:com.ait.toolkit.flash.widget.client.swf.ui.SWFWidget.java

License:Open Source License

/**
 * Gets the height.
 * 
 * @return the height
 */
public String getHeight() {
    return DOM.getStyleAttribute(getElement(), "height");
}

From source file:com.allen_sauer.gwt.dnd.client.PickupDragController.java

License:Apache License

/**
 * Save the selected widgets' current location in case they much be restored due to a cancelled
 * drop./*from w w w.j a v  a 2  s.c o  m*/
 *
 * @see #restoreSelectedWidgetsLocation()
 */
protected void saveSelectedWidgetsLocationAndStyle() {
    savedWidgetInfoMap = new HashMap<Widget, SavedWidgetInfo>();
    for (Widget widget : context.selectedWidgets) {
        SavedWidgetInfo info = new SavedWidgetInfo();
        info.initialDraggableParent = widget.getParent();

        if (info.initialDraggableParent instanceof AbsolutePanel) {
            info.initialDraggableParentLocation = new WidgetLocation(widget, info.initialDraggableParent);
        } else if (info.initialDraggableParent instanceof InsertPanel) {
            info.initialDraggableIndex = ((InsertPanel) info.initialDraggableParent).getWidgetIndex(widget);
        } else if (info.initialDraggableParent instanceof SimplePanel) {
            // save nothing
        } else {
            throw new RuntimeException("Unable to handle 'initialDraggableParent instanceof "
                    + info.initialDraggableParent.getClass().getName() + "'; Please create your own "
                    + PickupDragController.class.getName()
                    + " and override saveSelectedWidgetsLocationAndStyle(), restoreSelectedWidgetsLocation() and restoreSelectedWidgetsStyle()");
        }

        info.initialDraggableMargin = DOM.getStyleAttribute(widget.getElement(), "margin");
        widget.getElement().getStyle().setProperty("margin", "0px");
        savedWidgetInfoMap.put(widget, info);
    }
}

From source file:com.google.appinventor.client.editor.simple.components.MockButtonBase.java

License:Open Source License

private void setShapeProperty(String text) {
    shape = Integer.parseInt(text);
    // Android Buttons with images take the shape of the image and do not
    // use one of the defined Shapes.
    if (hasImage) {
        return;//from w ww . java2  s.c o  m
    }
    switch (shape) {
    case 0:
        // Default Button
        DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "0px");
        break;
    case 1:
        // Rounded Button.
        // The corners of the Button are rounded by 10 px.
        // The value 10 px was chosen strictly for style.
        // 10 px is the same as ROUNDED_CORNERS_RADIUS defined in
        // com.google.appinventor.components.runtime.ButtonBase.
        DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "10px");
        break;
    case 2:
        // Rectangular Button
        DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "0px");
        break;
    case 3:
        // Oval Button
        String height = DOM.getStyleAttribute(buttonWidget.getElement(), "height");
        DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", height);
        break;
    default:
        // This should never happen
        throw new IllegalArgumentException("shape:" + shape);
    }
}

From source file:com.google.appinventor.client.editor.simple.components.MockComponentsUtil.java

License:Open Source License

static String[] clearSizeStyle(Widget w) {
    Element element = w.getElement();
    String widthStyle = DOM.getStyleAttribute(element, "width");
    String heightStyle = DOM.getStyleAttribute(element, "height");
    if (widthStyle != null) {
        DOM.setStyleAttribute(element, "width", null);
    }//from w w  w .j  a v  a  2 s  .c o  m
    if (heightStyle != null) {
        DOM.setStyleAttribute(element, "height", null);
    }
    return new String[] { widthStyle, heightStyle };
}

From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java

License:Open Source License

/**
 * Returns the x-coordinate where the cursor appears in the specified
 * drag-widget's coordinate system.//from   w w w .j  a v a  2s  .c om
 */
private static int getDragWidgetOffsetX(Widget w) {
    return -parsePixelValue(DOM.getStyleAttribute(w.getElement(), "left"));
}

From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java

License:Open Source License

/**
 * Returns the y-coordinate where the cursor appears in the specified
 * drag-widget's coordinate system.//from w w  w.j ava 2 s.  c  o  m
 */
private static int getDragWidgetOffsetY(Widget w) {
    return -parsePixelValue(DOM.getStyleAttribute(w.getElement(), "top"));
}