Class Label
- java.lang.Object
-
- org.pepstock.charba.client.commons.NativeObjectContainer
-
- org.pepstock.charba.client.commons.AbstractNode
-
- org.pepstock.charba.client.labels.Label
-
- All Implemented Interfaces:
IsScriptableFontProvider<LabelsContext>
public final class Label extends AbstractNode implements IsScriptableFontProvider<LabelsContext>
This is the object to map theLabelsPlugin.ID
plugin options, both at chart and global level.- Author:
- Andrea "Stock" Stocchero
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_ARC
Default to enable drawing label in arc, false.static int
DEFAULT_OUTSIDE_PADDING
Default padding when position isPosition.OUTSIDE
, 2.static boolean
DEFAULT_OVERLAP
Default to enable drawing label even it's overlap, true.static Position
DEFAULT_POSITION
Default position to draw label,Position.DEFAULT
.static int
DEFAULT_PRECISION
Default the precision for percentage, 0.static Render
DEFAULT_RENDER
Default rendering (what data must be showed),Render.VALUE
.static int
DEFAULT_SHADOW_BLUR
Default text shadow intensity, 6.static String
DEFAULT_SHADOW_COLOR
Default text shadow color, "rgba(0,0,0,0.3)".static int
DEFAULT_SHADOW_OFFSET_X
Default text shadow X offset, 3.static int
DEFAULT_SHADOW_OFFSET_Y
Default text shadow Y offset, 3.static boolean
DEFAULT_SHOW_ACTUAL_PERCENTAGES
Default to enable showing the real calculated percentages from the values, false.static boolean
DEFAULT_SHOW_ZERO
Default to enable whether or not labels of value 0 are displayed, false.static int
DEFAULT_TEXT_MARGIN
Default the margin of text when position isPosition.OUTSIDE
orPosition.BORDER
, 2.static boolean
DEFAULT_TEXT_SHADOW
Default to enable if draws text shadows under labels, false.
-
Constructor Summary
Constructors Constructor Description Label()
Creates newLabelsPlugin.ID
plugin label, using an incremental id.Label(String id)
Creates newLabelsPlugin.ID
plugin label, using the id passed as argument as label id.Label(LabelId id)
Creates newLabelsPlugin.ID
plugin label, using the id passed as argument as label id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IsColor
getColor()
Returns the font color.String
getColorAsString()
Returns the font color as string.ColorCallback<LabelsContext>
getColorCallback()
Returns the font color callback, if set, otherwisenull
.Font
getFont()
Returns the font object.FontCallback<LabelsContext>
getFontCallback()
Returns the font callback, if set, otherwisenull
.LabelId
getId()
Returns the id of label.List<Img>
getImages()
Returns the images whenRender
isRender.IMAGE
.int
getOutsidePadding()
Returns the padding when position isPosition.OUTSIDE
.Position
getPosition()
Returns the position to draw label.int
getPrecision()
Returns the precision for percentage.Render
getRender()
Returns what data must be showed.RenderCallback
getRenderCallback()
Returns the render callback, if set, otherwisenull
.int
getShadowBlur()
Returns the text shadow intensity.IsColor
getShadowColor()
Returns the text shadow color as color.String
getShadowColorAsString()
Returns the text shadow color as string.int
getShadowOffsetX()
Returns the text shadow X offset.int
getShadowOffsetY()
Returns the text shadow Y offset.int
getTextMargin()
Returns the margin of text when position isPosition.OUTSIDE
orPosition.BORDER
.boolean
isArc()
Returns if draws label in arc.boolean
isOverlap()
Returns if draws label even it's overlap.boolean
isShowActualPercentages()
Returns if shows the real calculated percentages from the values and don't apply the additional logic to fit the percentages to 100 in total.boolean
isShowZero()
Returns whether or not labels of value 0 are displayed.boolean
isTextShadow()
Returns if draws text shadows under labels.void
setArc(boolean arc)
Sets if draws label in arc.void
setColor(String color)
Sets the font color.void
setColor(ColorCallback<LabelsContext> colorCallback)
Sets the font color callback.void
setColor(NativeCallback colorCallback)
Sets the font color callback.void
setColor(IsColor color)
Sets the font color.void
setFont(FontCallback<LabelsContext> fontCallback)
Sets the font callback.void
setFont(NativeCallback fontCallback)
Sets the font callback.void
setImages(Img... images)
Sets the images whenRender
isRender.IMAGE
.void
setOutsidePadding(int outsidePadding)
Sets the padding when position isPosition.OUTSIDE
.void
setOverlap(boolean overlap)
Sets if draws label even it's overlap.void
setPosition(Position position)
+ Sets the position to draw label.void
setPrecision(int precision)
Sets the precision for percentage.void
setRender(NativeCallback renderCallback)
Sets the render callback.void
setRender(RenderCallback renderCallback)
Sets the render callback.void
setRender(Render render)
Sets what data must be showed.void
setShadowBlur(int shadowBlur)
Sets the text shadow intensity.void
setShadowColor(String shadowColor)
Sets the text shadow color as string.void
setShadowColor(IsColor shadowColor)
Sets the text shadow color as color.void
setShadowOffsetX(int shadowOffsetX)
Sets the text shadow X offset.void
setShadowOffsetY(int shadowOffsetY)
Sets the text shadow Y offset.void
setShowActualPercentages(boolean showActualPercentages)
Sets if shows the real calculated percentages from the values and don't apply the additional logic to fit the percentages to 100 in total.void
setShowZero(boolean showZero)
Sets whether or not labels of value 0 are displayed.void
setTextMargin(int textMargin)
Sets the margin of text when position isPosition.OUTSIDE
orPosition.BORDER
.void
setTextShadow(boolean textShadow)
Sets if draws text shadows under labels.-
Methods inherited from class org.pepstock.charba.client.commons.AbstractNode
checkAndAddToParent, getChildKey, getParentNode, getRootNode, retrieveRoot, setArrayValueAndAddToParent, setArrayValueAndAddToParent, setArrayValueAndAddToParent, setElementAndAddToParent, setInternalCallbackToModel, setInternalCallbackToModel, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent
-
Methods inherited from class org.pepstock.charba.client.commons.NativeObjectContainer
checkDefaultValuesArgument, empty, getArrayValue, getElement, getIncrementalId, getNativeChart, getNativeEvent, getNativeObject, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, has, has, isType, keys, loadNativeObject, remove, remove, setArrayValue, setArrayValue, setArrayValue, setElement, setEmptyValue, setNewIncrementalId, setNewIncrementalId, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, toJSON, type
-
-
-
-
Field Detail
-
DEFAULT_RENDER
public static final Render DEFAULT_RENDER
Default rendering (what data must be showed),Render.VALUE
.
-
DEFAULT_PRECISION
public static final int DEFAULT_PRECISION
Default the precision for percentage, 0.- See Also:
- Constant Field Values
-
DEFAULT_SHOW_ZERO
public static final boolean DEFAULT_SHOW_ZERO
Default to enable whether or not labels of value 0 are displayed, false.- See Also:
- Constant Field Values
-
DEFAULT_TEXT_SHADOW
public static final boolean DEFAULT_TEXT_SHADOW
Default to enable if draws text shadows under labels, false.- See Also:
- Constant Field Values
-
DEFAULT_SHADOW_BLUR
public static final int DEFAULT_SHADOW_BLUR
Default text shadow intensity, 6.- See Also:
- Constant Field Values
-
DEFAULT_SHADOW_OFFSET_X
public static final int DEFAULT_SHADOW_OFFSET_X
Default text shadow X offset, 3.- See Also:
- Constant Field Values
-
DEFAULT_SHADOW_OFFSET_Y
public static final int DEFAULT_SHADOW_OFFSET_Y
Default text shadow Y offset, 3.- See Also:
- Constant Field Values
-
DEFAULT_SHADOW_COLOR
public static final String DEFAULT_SHADOW_COLOR
Default text shadow color, "rgba(0,0,0,0.3)".- See Also:
- Constant Field Values
-
DEFAULT_ARC
public static final boolean DEFAULT_ARC
Default to enable drawing label in arc, false.- See Also:
- Constant Field Values
-
DEFAULT_POSITION
public static final Position DEFAULT_POSITION
Default position to draw label,Position.DEFAULT
.
-
DEFAULT_OVERLAP
public static final boolean DEFAULT_OVERLAP
Default to enable drawing label even it's overlap, true.- See Also:
- Constant Field Values
-
DEFAULT_SHOW_ACTUAL_PERCENTAGES
public static final boolean DEFAULT_SHOW_ACTUAL_PERCENTAGES
Default to enable showing the real calculated percentages from the values, false.- See Also:
- Constant Field Values
-
DEFAULT_OUTSIDE_PADDING
public static final int DEFAULT_OUTSIDE_PADDING
Default padding when position isPosition.OUTSIDE
, 2.- See Also:
- Constant Field Values
-
DEFAULT_TEXT_MARGIN
public static final int DEFAULT_TEXT_MARGIN
Default the margin of text when position isPosition.OUTSIDE
orPosition.BORDER
, 2.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Label
public Label()
Creates newLabelsPlugin.ID
plugin label, using an incremental id.
-
Label
public Label(String id)
Creates newLabelsPlugin.ID
plugin label, using the id passed as argument as label id.- Parameters:
id
- id to apply to new label.
-
Label
public Label(LabelId id)
Creates newLabelsPlugin.ID
plugin label, using the id passed as argument as label id.- Parameters:
id
- id to apply to new label.
-
-
Method Detail
-
getId
public LabelId getId()
Returns the id of label.- Returns:
- the id of label
-
getFont
public Font getFont()
Returns the font object.- Returns:
- the font object.
-
setColor
public void setColor(IsColor color)
Sets the font color.- Parameters:
color
- font color.
-
setColor
public void setColor(String color)
Sets the font color.- Parameters:
color
- font color.
-
getColorAsString
public String getColorAsString()
Returns the font color as string.- Returns:
- font color as string
-
getColor
public IsColor getColor()
Returns the font color.- Returns:
- font color
-
setRender
public void setRender(Render render)
Sets what data must be showed.- Parameters:
render
- what data must be showed.
-
getRender
public Render getRender()
Returns what data must be showed.- Returns:
- what data must be showed.
-
setPrecision
public void setPrecision(int precision)
Sets the precision for percentage.- Parameters:
precision
- the precision for percentage
-
getPrecision
public int getPrecision()
Returns the precision for percentage.- Returns:
- the precision for percentage.
-
setShowZero
public void setShowZero(boolean showZero)
Sets whether or not labels of value 0 are displayed.- Parameters:
showZero
- whether or not labels of value 0 are displayed.
-
isShowZero
public boolean isShowZero()
Returns whether or not labels of value 0 are displayed.- Returns:
- whether or not labels of value 0 are displayed.
-
setTextShadow
public void setTextShadow(boolean textShadow)
Sets if draws text shadows under labels.- Parameters:
textShadow
-true
if draws text shadows under labels.
-
isTextShadow
public boolean isTextShadow()
Returns if draws text shadows under labels.- Returns:
true
if draws text shadows under labels.
-
setShadowBlur
public void setShadowBlur(int shadowBlur)
Sets the text shadow intensity.- Parameters:
shadowBlur
- the text shadow intensity.
-
getShadowBlur
public int getShadowBlur()
Returns the text shadow intensity.- Returns:
- the text shadow intensity.
-
setShadowOffsetX
public void setShadowOffsetX(int shadowOffsetX)
Sets the text shadow X offset.- Parameters:
shadowOffsetX
- the text shadow X offset.
-
getShadowOffsetX
public int getShadowOffsetX()
Returns the text shadow X offset.- Returns:
- the text shadow X offset.
-
setShadowOffsetY
public void setShadowOffsetY(int shadowOffsetY)
Sets the text shadow Y offset.- Parameters:
shadowOffsetY
- the text shadow Y offset.
-
getShadowOffsetY
public int getShadowOffsetY()
Returns the text shadow Y offset.- Returns:
- the text shadow Y offset.
-
setShadowColor
public void setShadowColor(IsColor shadowColor)
Sets the text shadow color as color.- Parameters:
shadowColor
- the text shadow color as color.
-
setShadowColor
public void setShadowColor(String shadowColor)
Sets the text shadow color as string.- Parameters:
shadowColor
- the text shadow color as string.
-
getShadowColorAsString
public String getShadowColorAsString()
Returns the text shadow color as string.- Returns:
- the text shadow color as string.
-
getShadowColor
public IsColor getShadowColor()
Returns the text shadow color as color.- Returns:
- the text shadow color as color.
-
setArc
public void setArc(boolean arc)
Sets if draws label in arc. For bar chart this is ignored.- Parameters:
arc
- if draws label in arc.
-
isArc
public boolean isArc()
Returns if draws label in arc.- Returns:
true
if draws label in arc.
-
setPosition
public void setPosition(Position position)
+ Sets the position to draw label. For bar chart this is ignored.- Parameters:
position
- the position to draw label.
-
getPosition
public Position getPosition()
Returns the position to draw label.- Returns:
- the position to draw label.
-
setOverlap
public void setOverlap(boolean overlap)
Sets if draws label even it's overlap. For bar chart this is ignored.- Parameters:
overlap
- if draws label even it's overlap.
-
isOverlap
public boolean isOverlap()
Returns if draws label even it's overlap.- Returns:
true
if draws label even it's overlap.
-
setShowActualPercentages
public void setShowActualPercentages(boolean showActualPercentages)
Sets if shows the real calculated percentages from the values and don't apply the additional logic to fit the percentages to 100 in total.- Parameters:
showActualPercentages
- if shows the real calculated percentages from the values and don't apply the additional logic to fit the percentages to 100 in total.
-
isShowActualPercentages
public boolean isShowActualPercentages()
Returns if shows the real calculated percentages from the values and don't apply the additional logic to fit the percentages to 100 in total.- Returns:
true
if shows the real calculated percentages from the values and don't apply the additional logic to fit the percentages to 100 in total.
-
setOutsidePadding
public void setOutsidePadding(int outsidePadding)
Sets the padding when position isPosition.OUTSIDE
.- Parameters:
outsidePadding
- the padding when position isPosition.OUTSIDE
.
-
getOutsidePadding
public int getOutsidePadding()
Returns the padding when position isPosition.OUTSIDE
.- Returns:
- the padding when position is
Position.OUTSIDE
.
-
setTextMargin
public void setTextMargin(int textMargin)
Sets the margin of text when position isPosition.OUTSIDE
orPosition.BORDER
.- Parameters:
textMargin
- the margin of text when position isPosition.OUTSIDE
orPosition.BORDER
.
-
getTextMargin
public int getTextMargin()
Returns the margin of text when position isPosition.OUTSIDE
orPosition.BORDER
.- Returns:
- the margin of text when position is
Position.OUTSIDE
orPosition.BORDER
.
-
setImages
public void setImages(Img... images)
Sets the images whenRender
isRender.IMAGE
.- Parameters:
images
- images whenRender
isRender.IMAGE
.
-
getImages
public List<Img> getImages()
Returns the images whenRender
isRender.IMAGE
.- Returns:
- the images when
Render
isRender.IMAGE
or an empty list.
-
getRenderCallback
public RenderCallback getRenderCallback()
Returns the render callback, if set, otherwisenull
.- Returns:
- the render callback, if set, otherwise
null
-
setRender
public void setRender(RenderCallback renderCallback)
Sets the render callback.- Parameters:
renderCallback
- the render callback to set
-
setRender
public void setRender(NativeCallback renderCallback)
Sets the render callback.- Parameters:
renderCallback
- the render callback to set
-
getFontCallback
public FontCallback<LabelsContext> getFontCallback()
Returns the font callback, if set, otherwisenull
.- Specified by:
getFontCallback
in interfaceIsScriptableFontProvider<LabelsContext>
- Returns:
- the font callback, if set, otherwise
null
-
setFont
public void setFont(FontCallback<LabelsContext> fontCallback)
Sets the font callback.- Specified by:
setFont
in interfaceIsScriptableFontProvider<LabelsContext>
- Parameters:
fontCallback
- the font callback.
-
setFont
public void setFont(NativeCallback fontCallback)
Sets the font callback.- Specified by:
setFont
in interfaceIsScriptableFontProvider<LabelsContext>
- Parameters:
fontCallback
- the font callback.
-
getColorCallback
public ColorCallback<LabelsContext> getColorCallback()
Returns the font color callback, if set, otherwisenull
.- Returns:
- the font color callback, if set, otherwise
null
-
setColor
public void setColor(ColorCallback<LabelsContext> colorCallback)
Sets the font color callback.- Parameters:
colorCallback
- the font color callback.
-
setColor
public void setColor(NativeCallback colorCallback)
Sets the font color callback.- Parameters:
colorCallback
- the font color callback.
-
-