public final class Utilities extends Object
Modifier and Type | Method and Description |
---|---|
static String |
applyPrecision(double value,
int precision)
Converts a double into a string setting the decimals places to maintain.
|
static String |
applyTemplate(String template,
Object... values)
Creates a string in order to change a template filling with the replacements.
The replacement must be set as following: |
static CursorType |
getCursorOfChart(IsChart chart)
Returns the cursor currently set into chart.
|
static String |
toCSSBackgroundProperty(Gradient gradient)
Returns the CSS syntax to represent the gradient.
The dimension of canvas pattern image will be the dimension of pattern. |
static String |
toCSSBackgroundProperty(Img image)
Returns a URL CSS property for the current content of an image element instance.
|
static String |
toCSSBackgroundProperty(Pattern pattern)
Returns the CSS syntax to represent the pattern.
The dimension of canvas pattern image will be the dimension of pattern. |
static String |
toCSSBackgroundProperty(Pattern pattern,
int squareSize)
Returns the CSS syntax to represent the pattern.
The dimension of canvas pattern image is unique then the image of pattern is a square. |
static String |
toCSSBackgroundProperty(Pattern pattern,
int width,
int height)
Returns the CSS syntax to represent the pattern.
|
static String |
toCSSBackgroundProperty(String dataUrl)
Returns a URL CSS property for the data URL for the current content of the canvas element.
|
static String |
toCSSBackgroundProperty(String dataUrl,
Repetition repetition)
Returns a URL CSS property for the data URL for the current content of the canvas element.
|
static String |
toCSSFontProperty(FontStyle style,
int size,
String family)
Builds the font string (shorthand property of CSS font) to use in the canvas object.
The format is [font-style] [font-variant] [font-weight] [font-size] [font-family]. See here CSS specification. |
static Img |
toImageElement(String url)
Creates a image element by a data URL which is a URI scheme that provides a way to in-line data in a document, and it's commonly used to embed images in HTML and CSS.
|
static Img |
toImageElement(String url,
int width,
int height)
Creates a image element by a data URL which is a URI scheme that provides a way to in-line data in a document, and it's commonly used to embed images in HTML and CSS,
forcing the size.
|
public static String toCSSFontProperty(FontStyle style, int size, String family)
style
- font style to usesize
- font sizefamily
- font familypublic static String toCSSBackgroundProperty(Pattern pattern)
pattern
- object to export into CSSpublic static String toCSSBackgroundProperty(Pattern pattern, int squareSize)
pattern
- object to export into CSSsquareSize
- size of image applied to canvasPattern to be a squarepublic static String toCSSBackgroundProperty(Pattern pattern, int width, int height)
pattern
- object to export into CSSwidth
- width of image applied to canvasPatternheight
- height of image applied to canvasPatternpublic static String toCSSBackgroundProperty(String dataUrl)
dataUrl
- the data URL for the current content of the canvas elementpublic static String toCSSBackgroundProperty(String dataUrl, Repetition repetition)
dataUrl
- the data URL for the current content of the canvas elementrepetition
- repetition of imagepublic static String toCSSBackgroundProperty(Img image)
image
- image element instance to fet as CSS propertypublic static String toCSSBackgroundProperty(Gradient gradient)
gradient
- object to export into CSSpublic static Img toImageElement(String url)
url
- a URI scheme that provides a way to in-line datanull
if argument is not consistentpublic static Img toImageElement(String url, int width, int height)
url
- a URI scheme that provides a way to in-line datawidth
- width of imageheight
- height of imagenull
if argument is not consistentpublic static CursorType getCursorOfChart(IsChart chart)
chart
- chart instanceCursorType.DEFAULT
.public static String applyTemplate(String template, Object... values)
{0} ... {1} ... {n}where the value into the brackets represents the index of the obecjt into the array, passed as argument.
template
- template of messagevalues
- values to apply into templatepublic static String applyPrecision(double value, int precision)
value
- value to convert. If is Double.NaN
, return Constants.NULL_STRING
precision
- decimals places to apply. If less than 0, uses 0