public final class Utilities extends Object
Modifier and Type | Method and Description |
---|---|
static String |
applyPrecision(double value,
int precision)
Converts a double in the 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 in the chart.
|
static String |
getImageURLFromCanvasPattern(CanvasPatternItem pattern,
int width,
int height)
Returns a data URL for the current content of a canvas pattern instance.
|
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 |
toCSSBorderRadiusProperty(BorderRadiusItem borderRadius)
Builds the border radius string (shorthand property of CSS font) to use in the canvas object or in DOM element.
The format is [top-left | top-right | bottom-right | bottom-left]. |
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 toCSSBackgroundProperty(Pattern pattern)
pattern
- object to export in the CSSpublic static String toCSSBackgroundProperty(Pattern pattern, int squareSize)
pattern
- object to export in the CSSsquareSize
- size of image applied to canvasPattern to be a squarepublic static String toCSSBackgroundProperty(Pattern pattern, int width, int height)
pattern
- object to export in the 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 toCSSBorderRadiusProperty(BorderRadiusItem borderRadius)
borderRadius
- border radius item to usepublic static String getImageURLFromCanvasPattern(CanvasPatternItem pattern, int width, int height)
pattern
- canvas pattern instancewidth
- width of canvas applied to canvasPatternheight
- height of image applied to canvasPatternpublic static String toCSSBackgroundProperty(Gradient gradient)
gradient
- object to export in the 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 instancepublic static String applyTemplate(String template, Object... values)
{0} ... {1} ... {n}where the value in the the brackets represents the index of the obecjt in the the array, passed as argument.
template
- template of messagevalues
- values to apply in the 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