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

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

Introduction

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

Prototype

public String getProperty(String name) 

Source Link

Usage

From source file:com.alkacon.geranium.client.util.StyleSaver.java

License:Open Source License

/** 
 * Creates a new instance for an element and saves some of its style properties.<p>
 * //from  www.  ja v  a2 s. c  om
 * @param elem the DOM element 
 * @param properties the style properties to save 
 */
public StyleSaver(Element elem, String... properties) {

    m_element = elem;
    Style style = elem.getStyle();
    for (String prop : properties) {
        String val = style.getProperty(prop);
        m_propertyValues.put(prop, val);
    }
}

From source file:com.cgxlib.xq.client.css.BackgroundProperty.java

License:Apache License

public String getCssValue(Style s) {
    return s.getProperty(CSS_PROPERTY);
}

From source file:com.cgxlib.xq.client.css.BorderProperty.java

License:Apache License

public String getCssValue(Style s) {
    return s.getProperty(cssProperty);
}

From source file:com.cgxlib.xq.client.css.CssProperty.java

License:Apache License

public String getCssValue(Style s) {
    return s.getProperty(getCssName());
}

From source file:com.cgxlib.xq.client.impl.DocumentStyleImplIE.java

License:Apache License

@Override
public double getOpacity(Element e) {
    Style s = e.getStyle();
    String o = s.getProperty("filter");
    if (o != null) {
        return !o.matches(".*opacity=.*") ? 1 : Double.valueOf(o.replaceAll("[^\\d]", "")) / 100;
    }//w ww.jav  a2s. c o m
    return super.getOpacity(e);
}

From source file:com.googlecode.mgwt.dom.client.event.animation.SupportDetector.java

License:Apache License

public static String getEventNameForAnimationEnd() {
    Style style = Document.get().createDivElement().getStyle();
    // Test for webkit first since both are okay for chrome but
    // it only supports the prefixed version
    if ("".equals(style.getProperty("WebkitAnimation"))) {
        return "webkitAnimationEnd";
    }/*from  w  ww. j  a v a2  s. c o  m*/
    return "animationend";
}

From source file:com.googlecode.mgwt.dom.client.event.animation.SupportDetector.java

License:Apache License

public static String getEventNameForTransistionEnd() {
    Style style = Document.get().createDivElement().getStyle();
    // Test for webkit first since both are okay for chrome but
    // it only supports the prefixed version
    if ("".equals(style.getProperty("WebkitTransition"))) {
        return "webkitTransitionEnd";
    }/*from  w w w. j  ava 2 s  . co  m*/
    return "transitionend";
}

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

License:sencha.com license

/**
 * Applies transformation to passed sprite
 * /*ww  w .  j  av a2  s.  c o  m*/
 * @param sprite the sprite to be transformed
 */
private void transform(Sprite sprite) {
    double deltaDegrees = 0;
    double deltaScaleX = 1;
    double deltaScaleY = 1;
    Matrix matrix = new Matrix();
    Rotation rotation = sprite.getRotation();
    Scaling scaling = sprite.getScaling();
    Translation translation = sprite.getTranslation();
    sprite.transformMatrix();
    XElement element = getElement(sprite);
    Style style = element.getStyle();
    Element skew = element.getPropertyJSO("skew").cast();

    if (rotation != null) {
        matrix.rotate(rotation.getDegrees(), rotation.getX(), rotation.getY());
        deltaDegrees += rotation.getDegrees();
    }
    if (scaling != null) {
        matrix.scale(scaling.getX(), scaling.getY(), scaling.getCenterX(), scaling.getCenterY());
        deltaScaleX *= scaling.getX();
        deltaScaleY *= scaling.getY();
    }
    if (translation != null) {
        matrix.translate(translation.getX(), translation.getY());
    }
    if (viewBoxShift != null) {
        matrix.prepend(viewBoxShift.getX(), 0, 0, viewBoxShift.getX(),
                viewBoxShift.getCenterX() * viewBoxShift.getX(),
                viewBoxShift.getCenterY() * viewBoxShift.getX());
    }

    if (!(sprite instanceof ImageSprite) && skew != null) {
        // matrix transform via VML skew
        skew.setPropertyString("origin", "0,0");
        skew.setPropertyString("matrix",
                new StringBuilder().append(toFixed(matrix.get(0, 0), 4)).append(", ")
                        .append(toFixed(matrix.get(0, 1), 4)).append(", ").append(toFixed(matrix.get(1, 0), 4))
                        .append(", ").append(toFixed(matrix.get(1, 1), 4)).append(", 0, 0").toString());

        // ensure offset is less than or equal to 32767 and greater than or equal
        // to -32768, otherwise VMl crashes
        double offsetX = Math.max(Math.min(matrix.get(0, 2), 32767), -32768);
        double offsetY = Math.max(Math.min(matrix.get(1, 2), 32767), -32768);
        String offset = toFixed(offsetX, 4) + ", " + toFixed(offsetY, 4);
        skew.setPropertyString("offset", offset);
    } else {
        double deltaX = matrix.get(0, 2);
        double deltaY = matrix.get(1, 2);
        // Scale via coordsize property
        double zoomScaleX = zoom / deltaScaleX;
        double zoomScaleY = zoom / deltaScaleY;

        element.setPropertyString("coordsize", Math.abs(zoomScaleX) + " " + Math.abs(zoomScaleY));

        // Rotate via rotation property
        double newAngle = deltaDegrees * (deltaScaleX * ((deltaScaleY < 0) ? -1 : 1));
        if ((style.getProperty("rotation") == null && newAngle != 0)) {
            style.setProperty("rotation", String.valueOf(newAngle));
        } else if (style.getProperty("rotation") != null
                && newAngle != Double.valueOf(style.getProperty("rotation"))) {
            style.setProperty("rotation", String.valueOf(newAngle));
        }
        if (deltaDegrees != 0) {
            // Compensate x/y position due to rotation
            Matrix compMatrix = new Matrix();
            compMatrix.rotate(-deltaDegrees, deltaX, deltaY);
            deltaX = deltaX * compMatrix.get(0, 0) + deltaY * compMatrix.get(0, 1) + compMatrix.get(0, 2);
            deltaY = deltaX * compMatrix.get(1, 0) + deltaY * compMatrix.get(1, 1) + compMatrix.get(1, 2);
        }

        String flip = "";
        // Handle negative scaling via flipping
        if (deltaScaleX < 0) {
            flip += "x";
        }
        if (deltaScaleY < 0) {
            flip += " y";
        }
        if (!flip.equals("")) {
            style.setProperty("flip", flip);
        }

        // Translate via coordorigin property
        element.setPropertyString("coordorigin", (-zoomScaleX * (deltaX / ((ImageSprite) sprite).getWidth()))
                + " " + (-zoomScaleY * (deltaY / ((ImageSprite) sprite).getHeight())));
    }
}

From source file:com.vaadin.client.ui.VAbstractSplitPanel.java

License:Apache License

private void setSplitPosition(String pos, boolean rememberPosition) {
    if (pos == null) {
        return;//from   w  ww .j a v  a 2  s.  c  om
    }

    pos = checkSplitPositionLimits(pos);
    if (rememberPosition && !pos.equals(position)) {
        position = convertToPositionUnits(pos);
    }

    // Convert percentage values to pixels
    if (pos.indexOf("%") > 0) {
        int size = orientation == Orientation.HORIZONTAL ? getOffsetWidth() : getOffsetHeight();
        float percentage = Float.parseFloat(pos.substring(0, pos.length() - 1));
        pos = percentage / 100 * size + "px";
    }

    String attributeName;
    if (orientation == Orientation.HORIZONTAL) {
        if (positionReversed) {
            attributeName = "right";
        } else {
            attributeName = "left";
        }
    } else {
        if (positionReversed) {
            attributeName = "bottom";
        } else {
            attributeName = "top";
        }
    }

    Style style = splitter.getStyle();
    if (!pos.equals(style.getProperty(attributeName))) {
        style.setProperty(attributeName, pos);
        updateSizes();
    }
}

From source file:com.vaadin.client.ui.VTabsheet.java

License:Apache License

/** For internal use only. May be removed or replaced in the future. */
public void updateDynamicWidth() {
    // Find width consumed by tabs
    TableCellElement spacerCell = ((TableElement) tb.getElement().cast()).getRows().getItem(0).getCells()
            .getItem(tb.getTabCount());//w  w  w.  j  a v a2  s .com

    int spacerWidth = spacerCell.getOffsetWidth();
    DivElement div = (DivElement) spacerCell.getFirstChildElement();

    int spacerMinWidth = spacerCell.getOffsetWidth() - div.getOffsetWidth();

    int tabsWidth = tb.getOffsetWidth() - spacerWidth + spacerMinWidth;

    // Find content width
    Style style = tabPanel.getElement().getStyle();
    String overflow = style.getProperty("overflow");
    style.setProperty("overflow", "hidden");
    style.setPropertyPx("width", tabsWidth);

    boolean hasTabs = tabPanel.getWidgetCount() > 0;

    Style wrapperstyle = null;
    if (hasTabs) {
        wrapperstyle = getCurrentlyDisplayedWidget().getElement().getParentElement().getStyle();
        wrapperstyle.setPropertyPx("width", tabsWidth);
    }
    // Get content width from actual widget

    int contentWidth = 0;
    if (hasTabs) {
        contentWidth = getCurrentlyDisplayedWidget().getOffsetWidth();
    }
    style.setProperty("overflow", overflow);

    // Set widths to max(tabs,content)
    if (tabsWidth < contentWidth) {
        tabsWidth = contentWidth;
    }

    int outerWidth = tabsWidth + getContentAreaBorderWidth();

    tabs.getStyle().setPropertyPx("width", outerWidth);
    style.setPropertyPx("width", tabsWidth);
    if (hasTabs) {
        wrapperstyle.setPropertyPx("width", tabsWidth);
    }

    contentNode.getStyle().setPropertyPx("width", tabsWidth);
    super.setWidth(outerWidth + "px");
    updateOpenTabSize();
}