Package org.pepstock.charba.client
Class Helpers
- java.lang.Object
- 
- org.pepstock.charba.client.Helpers
 
- 
 public final class Helpers extends Object Singleton object to use the helpers utility of CHART.JS.
 It maps the java script objectchart.helpers.- Author:
- Andrea "Stock" Stocchero
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclipArea(Canvas canvas, double width, double height)Clips an area on the canvas context, using theContext2dItemof the canvas.
 The area is specified by size.
 Starting points are 0.voidclipArea(Canvas canvas, double x, double y, double width, double height)Clips an area on the canvas context, using theContext2dItemof the canvas.
 The area is specified by coordinates and size.voidclipArea(Canvas canvas, IsArea area)Clips an area on the canvas context, using theContext2dItemof the canvas.voidclipArea(Context2dItem context, double width, double height)Clips an area on the canvas context.
 The area is specified by size.
 Starting points are 0.voidclipArea(Context2dItem context, double x, double y, double width, double height)Clips an area on the canvas context.
 The area is specified by coordinates and size.voidclipArea(Context2dItem context, IsArea area)Clips an area on the canvas context.voidclipArea(IsChart chart)Clips an area on the canvas context using theChartAreaNodeof the chart.voidclipArea(IsChart chart, double width, double height)Clips an area on the canvas context, using theCanvasof the chart.
 The area is specified by size.
 Starting points are 0.voidclipArea(IsChart chart, double x, double y, double width, double height)Clips an area on the canvas context, using theCanvasof the chart.
 The area is specified by coordinates and size.voidclipArea(IsChart chart, IsArea area)Clips an area on the canvas context, using theCanvasof the chart.NativeObjectclone(NativeObject source)Returns a deep copy of source without keeping references on objects and arrays.StringformatNumber(double number)Format a number using a localized number formatter.
 It uses the locale of the browser.StringformatNumber(double number, String locale)Format a number using a localized number formatter.StringformatNumber(double number, String locale, NumberFormatOptions options)Format a number using a localized number formatter.StringformatNumber(double number, CLocale locale)Format a number using a localized number formatter.StringformatNumber(double number, CLocale locale, NumberFormatOptions options)Format a number using a localized number formatter.static Helpersget()Singleton method to get the instanceEventPointgetRelativePosition(AbstractEvent event)A common occurrence is taking an event, such as a click, and finding the data coordinates on the chart where the event occurred.EventPointgetRelativePosition(IsChart chart, NativeBaseEvent event)A common occurrence is taking an event, such as a click, and finding the data coordinates on the chart where the event occurred.EventPointgetRelativePosition(IsChart chart, AbstractEvent event)A common occurrence is taking an event, such as a click, and finding the data coordinates on the chart where the event occurred.NativeObjectmergeIf(NativeObject target, NativeObject source)Recursively deep copies source properties in the target only if not defined in target.
 IMPORTANT: target is not cloned and will be updated with source properties.IsImmutableFonttoFont(IsDefaultFont font)Parses font options and returns a normalized font object.IsImmutableFonttoFont(FontItem font)Parses font options and returns a normalized font object.StringtoFontString(IsDefaultFont font)Builds the font string (shorthand property of CSS font) to use in the canvas object.
 See here CSS specification.StringtoFontString(FontItem font)Builds the font string (shorthand property of CSS font) to use in the canvas object.
 See here CSS specification.voidunclipArea(Context2dItem context)Unclips the area previously set.
 
- 
- 
- 
Method Detail- 
getpublic static Helpers get() Singleton method to get the instance- Returns:
- helper instance
 
 - 
mergeIfpublic NativeObject mergeIf(NativeObject target, NativeObject source) Recursively deep copies source properties in the target only if not defined in target.
 IMPORTANT: target is not cloned and will be updated with source properties.- Parameters:
- target- the target object in which all sources are merged into.
- source- object to merge in the target.
- Returns:
- the target object. If target and source are nulls, an empty native object is returned is returned.
 
 - 
clonepublic NativeObject clone(NativeObject source) Returns a deep copy of source without keeping references on objects and arrays.- Parameters:
- source- the object to clone.
- Returns:
- a clone of source object
 
 - 
getRelativePositionpublic EventPoint getRelativePosition(AbstractEvent event) A common occurrence is taking an event, such as a click, and finding the data coordinates on the chart where the event occurred. It provides the relative point on canvas.- Parameters:
- event- native event to be used for getting the point.
- Returns:
- a point object
 
 - 
getRelativePositionpublic EventPoint getRelativePosition(IsChart chart, AbstractEvent event) A common occurrence is taking an event, such as a click, and finding the data coordinates on the chart where the event occurred. It provides the relative point on canvas.- Parameters:
- chart- chart instance
- event- native event to be used for getting the point.
- Returns:
- a point object
 
 - 
getRelativePositionpublic EventPoint getRelativePosition(IsChart chart, NativeBaseEvent event) A common occurrence is taking an event, such as a click, and finding the data coordinates on the chart where the event occurred. It provides the relative point on canvas.- Parameters:
- chart- chart instance
- event- native event to be used for getting the point.
- Returns:
- a point object
 
 - 
toFontpublic IsImmutableFont toFont(IsDefaultFont font) Parses font options and returns a normalized font object.- Parameters:
- font- a object that contains font options to be parsed.
- Returns:
- a font object
 
 - 
toFontpublic IsImmutableFont toFont(FontItem font) Parses font options and returns a normalized font object.- Parameters:
- font- a object that contains font options to be parsed.
- Returns:
- a font object
 
 - 
toFontStringpublic String toFontString(IsDefaultFont font) Builds the font string (shorthand property of CSS font) to use in the canvas object.
 See here CSS specification.- Parameters:
- font- a object that contains font options to be parsed.
- Returns:
- the font string to use in the canvas object.
 
 - 
toFontStringpublic String toFontString(FontItem font) Builds the font string (shorthand property of CSS font) to use in the canvas object.
 See here CSS specification.- Parameters:
- font- a object that contains font options to be parsed.
- Returns:
- the font string to use in the canvas object.
 
 - 
clipAreapublic void clipArea(IsChart chart) Clips an area on the canvas context using theChartAreaNodeof the chart.- Parameters:
- chart- chart instance
 
 - 
clipAreapublic void clipArea(IsChart chart, IsArea area) Clips an area on the canvas context, using theCanvasof the chart.- Parameters:
- chart- chart instance
- area- area to clip on the context
 
 - 
clipAreapublic void clipArea(IsChart chart, double width, double height) Clips an area on the canvas context, using theCanvasof the chart.
 The area is specified by size.
 Starting points are 0.- Parameters:
- chart- chart instance
- width- the rectangle's width. Positive values are to the right, and negative to the left
- height- the rectangle's height. Positive values are down, and negative are up
 
 - 
clipAreapublic void clipArea(IsChart chart, double x, double y, double width, double height) Clips an area on the canvas context, using theCanvasof the chart.
 The area is specified by coordinates and size.- Parameters:
- chart- chart instance
- x- the x-axis coordinate of the rectangle's starting point
- y- the y-axis coordinate of the rectangle's starting point
- width- the rectangle's width. Positive values are to the right, and negative to the left
- height- the rectangle's height. Positive values are down, and negative are up
 
 - 
clipAreapublic void clipArea(Canvas canvas, IsArea area) Clips an area on the canvas context, using theContext2dItemof the canvas.- Parameters:
- canvas- canvas where to apply the clippping
- area- area to clip on the context
 
 - 
clipAreapublic void clipArea(Canvas canvas, double width, double height) Clips an area on the canvas context, using theContext2dItemof the canvas.
 The area is specified by size.
 Starting points are 0.- Parameters:
- canvas- canvas where to apply the clippping
- width- the rectangle's width. Positive values are to the right, and negative to the left
- height- the rectangle's height. Positive values are down, and negative are up
 
 - 
clipAreapublic void clipArea(Canvas canvas, double x, double y, double width, double height) Clips an area on the canvas context, using theContext2dItemof the canvas.
 The area is specified by coordinates and size.- Parameters:
- canvas- canvas where to apply the clippping
- x- the x-axis coordinate of the rectangle's starting point
- y- the y-axis coordinate of the rectangle's starting point
- width- the rectangle's width. Positive values are to the right, and negative to the left
- height- the rectangle's height. Positive values are down, and negative are up
 
 - 
clipAreapublic void clipArea(Context2dItem context, IsArea area) Clips an area on the canvas context.- Parameters:
- context- context of the canvas
- area- area to clip on the context
 
 - 
clipAreapublic void clipArea(Context2dItem context, double width, double height) Clips an area on the canvas context.
 The area is specified by size.
 Starting points are 0.- Parameters:
- context- context of the canvas
- width- the rectangle's width. Positive values are to the right, and negative to the left
- height- the rectangle's height. Positive values are down, and negative are up
 
 - 
clipAreapublic void clipArea(Context2dItem context, double x, double y, double width, double height) Clips an area on the canvas context.
 The area is specified by coordinates and size.- Parameters:
- context- context of the canvas
- x- the x-axis coordinate of the rectangle's starting point
- y- the y-axis coordinate of the rectangle's starting point
- width- the rectangle's width. Positive values are to the right, and negative to the left
- height- the rectangle's height. Positive values are down, and negative are up
 
 - 
unclipAreapublic void unclipArea(Context2dItem context) Unclips the area previously set.- Parameters:
- context- context of the canvas where an area has been clipped.
 
 - 
formatNumberpublic String formatNumber(double number) Format a number using a localized number formatter.
 It uses the locale of the browser.- Parameters:
- number- the number to format
- Returns:
- a number formatted string
 
 - 
formatNumberpublic String formatNumber(double number, CLocale locale) Format a number using a localized number formatter.- Parameters:
- number- the number to format
- locale- the locale to pass to the- Intl.NumberFormatconstructor
- Returns:
- a number formatted string
 
 - 
formatNumberpublic String formatNumber(double number, String locale) Format a number using a localized number formatter.- Parameters:
- number- the number to format
- locale- the locale to pass to the- Intl.NumberFormatconstructor
- Returns:
- a number formatted string
 
 - 
formatNumberpublic String formatNumber(double number, CLocale locale, NumberFormatOptions options) Format a number using a localized number formatter.- Parameters:
- number- the number to format
- locale- the locale to pass to the- Intl.NumberFormatconstructor
- options-- Intlnumber format options
- Returns:
- a number formatted string
 
 - 
formatNumberpublic String formatNumber(double number, String locale, NumberFormatOptions options) Format a number using a localized number formatter.- Parameters:
- number- the number to format
- locale- the locale to pass to the- Intl.NumberFormatconstructor
- options-- Intlnumber format options
- Returns:
- a number formatted string
 
 
- 
 
-