com.vaadin.client.
Class ComputedStyle
- java.lang.Object
-
- com.vaadin.client.ComputedStyle
-
public class ComputedStyle extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.gwt.core.client.JavaScriptObject
computedStyle
-
Constructor Summary
Constructors Constructor Description ComputedStyle(com.google.gwt.dom.client.Element elem)
Gets this element's computed style object which can be used to gather information about the current state of the rendered node.
-
Method Summary
All Methods Modifier and Type Method Description int[]
getBorder()
Get current border values from the DOM.
double
getBorderHeight()
Returns the sum of the top and bottom border width.
double
getBorderWidth()
Returns the sum of the left and right border width.
double
getDoubleProperty(String name)
Retrieves the given computed property as a double.
double
getHeight()
Returns the current height from the DOM.
double
getHeightIncludingBorderPadding()
Returns the current height, padding and border from the DOM.
int
getIntProperty(String name)
Retrieves the given computed property as an integer.
int[]
getMargin()
Get current margin values from the DOM.
double
getMarginHeight()
Returns the sum of the top and bottom margin.
double
getMarginWidth()
Returns the sum of the left and right margin.
int[]
getPadding()
Get current padding values from the DOM.
double
getPaddingHeight()
Returns the sum of the top and bottom padding.
double
getPaddingWidth()
Returns the sum of the top and bottom padding.
String
getProperty(String name)
Gets the value of the given property.
double
getWidth()
Returns the current width from the DOM.
double
getWidthIncludingBorderPadding()
Returns the current width, padding and border from the DOM.
static Integer
parseInt(String value)
Deprecated.
Since 7.1.4, the methodparseIntNative(String)
is used internally and this method does not belong in the public API ofComputedStyle
.
-
-
-
Constructor Detail
-
ComputedStyle
public ComputedStyle(com.google.gwt.dom.client.Element elem)
Gets this element's computed style object which can be used to gather information about the current state of the rendered node.
Note that this method is expensive. Wherever possible, reuse the returned object.
Parameters:
elem
- the element
-
-
Method Detail
-
getProperty
public final String getProperty(String name)
Gets the value of the given property.
Parameters:
name
- name of the CSS property in camelCaseReturns:
the value of the property, normalized for across browsers (each browser returns pixel values whenever possible).
-
getIntProperty
public final int getIntProperty(String name)
Retrieves the given computed property as an integer. Returns 0 if the property cannot be converted to an integer
Parameters:
name
- the property to retrieveReturns:
the integer value of the property or 0
-
getDoubleProperty
public final double getDoubleProperty(String name)
Retrieves the given computed property as a double. Returns NaN if the property cannot be converted to a double
Parameters:
name
- the property to retrieveReturns:
the double value of the property
Since:
7.5.1
-
getMargin
public final int[] getMargin()
Get current margin values from the DOM.
Returns:
an array containing four values for the four edges, in the default CSS order: top, right, bottom, left.
-
getPadding
public final int[] getPadding()
Get current padding values from the DOM.
Returns:
an array containing four values for the four edges, in the default CSS order: top, right, bottom, left.
-
getBorder
public final int[] getBorder()
Get current border values from the DOM.
Returns:
an array containing four values for the four edges, in the default CSS order: top, right, bottom, left.
-
getWidth
public double getWidth()
Returns the current width from the DOM.
Returns:
the computed width
Since:
7.5.1
-
getHeight
public double getHeight()
Returns the current height from the DOM.
Returns:
the computed height
Since:
7.5.1
-
parseInt
@Deprecated public static Integer parseInt(String value)
Deprecated.Since 7.1.4, the methodparseIntNative(String)
is used internally and this method does not belong in the public API ofComputedStyle
.parseInt(String)
might be removed or moved to a utility class in future versions.Takes a String value e.g. "12px" and parses that to Integer 12.
Parameters:
value
- a value starting with a numberReturns:
Integer the value from the string before any non-numeric characters. If the value cannot be parsed to a number, returns
null
.
-
getBorderHeight
public double getBorderHeight()
Returns the sum of the top and bottom border width.
Returns:
the sum of the top and bottom border
Since:
7.5.3
-
getBorderWidth
public double getBorderWidth()
Returns the sum of the left and right border width.
Returns:
the sum of the left and right border
Since:
7.5.3
-
getPaddingHeight
public double getPaddingHeight()
Returns the sum of the top and bottom padding.
Returns:
the sum of the top and bottom padding
Since:
7.5.3
-
getPaddingWidth
public double getPaddingWidth()
Returns the sum of the top and bottom padding.
Returns:
the sum of the left and right padding
Since:
7.5.3
-
getMarginHeight
public double getMarginHeight()
Returns the sum of the top and bottom margin.
Returns:
the sum of the top and bottom margin
Since:
7.5.6
-
getMarginWidth
public double getMarginWidth()
Returns the sum of the left and right margin.
Returns:
the sum of the left and right margin
Since:
7.5.6
-
getHeightIncludingBorderPadding
public double getHeightIncludingBorderPadding()
Returns the current height, padding and border from the DOM.
Returns:
the computed height including padding and borders
-
getWidthIncludingBorderPadding
public double getWidthIncludingBorderPadding()
Returns the current width, padding and border from the DOM.
Returns:
the computed width including padding and borders
-
-