public class TextMetrics extends Object
Modifier and Type | Method and Description |
---|---|
void |
bind(Element el)
Binds this TextMetrics instance to an element from which to copy existing CSS styles that can affect the size of
the rendered text.
|
void |
bind(String className)
Binds the TextMetrics instance using the styles from the given class name.
|
void |
bind(XElement el)
Binds this TextMetrics instance to an element from which to copy existing CSS styles that can affect the size of
the rendered text.
|
static TextMetrics |
get()
Returns the singleton instance.
|
int |
getHeight(SafeHtml html)
Returns the measured height of the specified html.
|
int |
getHeight(String text)
Returns the measured height of the specified text.
|
Size |
getSize(SafeHtml html)
Returns the size of the specified text based on the internal element's style and width properties.
|
Size |
getSize(String text)
Returns the size of the specified text based on the internal element's style and width properties.
|
int |
getWidth(SafeHtml html)
Returns the measured width of the specified html.
|
int |
getWidth(String text)
Returns the measured width of the specified text.
|
void |
setFixedWidth(int width)
Sets a fixed width on the internal measurement element.
|
public static TextMetrics get()
public void bind(Element el)
el
- the elementpublic void bind(String className)
className
- the class namepublic void bind(XElement el)
el
- the elementpublic int getHeight(String text)
setFixedWidth(int)
if
necessary.text
- the text to be measuredpublic int getHeight(SafeHtml html)
setFixedWidth(int)
if
necessary.html
- the text to be measuredpublic Size getSize(String text)
text
- the text to measurepublic Size getSize(SafeHtml html)
html
- the html or text to measurepublic int getWidth(String text)
text
- the text to measurepublic int getWidth(SafeHtml html)
html
- the text to measurepublic void setFixedWidth(int width)
width
- the width to set on the elementCopyright © 2015. All rights reserved.