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.IDplugin options, both at chart and global level.- Author:
- Andrea "Stock" Stocchero
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_ARCDefault to enable drawing label in arc, false.static intDEFAULT_OUTSIDE_PADDINGDefault padding when position isPosition.OUTSIDE, 2.static booleanDEFAULT_OVERLAPDefault to enable drawing label even it's overlap, true.static PositionDEFAULT_POSITIONDefault position to draw label,Position.DEFAULT.static intDEFAULT_PRECISIONDefault the precision for percentage, 0.static RenderDEFAULT_RENDERDefault rendering (what data must be showed),Render.VALUE.static intDEFAULT_SHADOW_BLURDefault text shadow intensity, 6.static StringDEFAULT_SHADOW_COLORDefault text shadow color, "rgba(0,0,0,0.3)".static intDEFAULT_SHADOW_OFFSET_XDefault text shadow X offset, 3.static intDEFAULT_SHADOW_OFFSET_YDefault text shadow Y offset, 3.static booleanDEFAULT_SHOW_ACTUAL_PERCENTAGESDefault to enable showing the real calculated percentages from the values, false.static booleanDEFAULT_SHOW_ZERODefault to enable whether or not labels of value 0 are displayed, false.static intDEFAULT_TEXT_MARGINDefault the margin of text when position isPosition.OUTSIDEorPosition.BORDER, 2.static booleanDEFAULT_TEXT_SHADOWDefault to enable if draws text shadows under labels, false.
-
Constructor Summary
Constructors Constructor Description Label()Creates newLabelsPlugin.IDplugin label, using an incremental id.Label(String id)Creates newLabelsPlugin.IDplugin label, using the id passed as argument as label id.Label(LabelId id)Creates newLabelsPlugin.IDplugin label, using the id passed as argument as label id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IsColorgetColor()Returns the font color.StringgetColorAsString()Returns the font color as string.ColorCallback<LabelsContext>getColorCallback()Returns the font color callback, if set, otherwisenull.FontgetFont()Returns the font object.FontCallback<LabelsContext>getFontCallback()Returns the font callback, if set, otherwisenull.LabelIdgetId()Returns the id of label.List<Img>getImages()Returns the images whenRenderisRender.IMAGE.intgetOutsidePadding()Returns the padding when position isPosition.OUTSIDE.PositiongetPosition()Returns the position to draw label.intgetPrecision()Returns the precision for percentage.RendergetRender()Returns what data must be showed.RenderCallbackgetRenderCallback()Returns the render callback, if set, otherwisenull.intgetShadowBlur()Returns the text shadow intensity.IsColorgetShadowColor()Returns the text shadow color as color.StringgetShadowColorAsString()Returns the text shadow color as string.intgetShadowOffsetX()Returns the text shadow X offset.intgetShadowOffsetY()Returns the text shadow Y offset.intgetTextMargin()Returns the margin of text when position isPosition.OUTSIDEorPosition.BORDER.booleanisArc()Returns if draws label in arc.booleanisOverlap()Returns if draws label even it's overlap.booleanisShowActualPercentages()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.booleanisShowZero()Returns whether or not labels of value 0 are displayed.booleanisTextShadow()Returns if draws text shadows under labels.voidsetArc(boolean arc)Sets if draws label in arc.voidsetColor(String color)Sets the font color.voidsetColor(ColorCallback<LabelsContext> colorCallback)Sets the font color callback.voidsetColor(NativeCallback colorCallback)Sets the font color callback.voidsetColor(IsColor color)Sets the font color.voidsetFont(FontCallback<LabelsContext> fontCallback)Sets the font callback.voidsetFont(NativeCallback fontCallback)Sets the font callback.voidsetImages(Img... images)Sets the images whenRenderisRender.IMAGE.voidsetOutsidePadding(int outsidePadding)Sets the padding when position isPosition.OUTSIDE.voidsetOverlap(boolean overlap)Sets if draws label even it's overlap.voidsetPosition(Position position)+ Sets the position to draw label.voidsetPrecision(int precision)Sets the precision for percentage.voidsetRender(NativeCallback renderCallback)Sets the render callback.voidsetRender(RenderCallback renderCallback)Sets the render callback.voidsetRender(Render render)Sets what data must be showed.voidsetShadowBlur(int shadowBlur)Sets the text shadow intensity.voidsetShadowColor(String shadowColor)Sets the text shadow color as string.voidsetShadowColor(IsColor shadowColor)Sets the text shadow color as color.voidsetShadowOffsetX(int shadowOffsetX)Sets the text shadow X offset.voidsetShadowOffsetY(int shadowOffsetY)Sets the text shadow Y offset.voidsetShowActualPercentages(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.voidsetShowZero(boolean showZero)Sets whether or not labels of value 0 are displayed.voidsetTextMargin(int textMargin)Sets the margin of text when position isPosition.OUTSIDEorPosition.BORDER.voidsetTextShadow(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, 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, 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.OUTSIDEorPosition.BORDER, 2.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Label
public Label()
Creates newLabelsPlugin.IDplugin label, using an incremental id.
-
Label
public Label(String id)
Creates newLabelsPlugin.IDplugin 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.IDplugin 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-trueif draws text shadows under labels.
-
isTextShadow
public boolean isTextShadow()
Returns if draws text shadows under labels.- Returns:
trueif 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:
trueif 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:
trueif 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:
trueif 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.OUTSIDEorPosition.BORDER.- Parameters:
textMargin- the margin of text when position isPosition.OUTSIDEorPosition.BORDER.
-
getTextMargin
public int getTextMargin()
Returns the margin of text when position isPosition.OUTSIDEorPosition.BORDER.- Returns:
- the margin of text when position is
Position.OUTSIDEorPosition.BORDER.
-
setImages
public void setImages(Img... images)
Sets the images whenRenderisRender.IMAGE.- Parameters:
images- images whenRenderisRender.IMAGE.
-
getImages
public List<Img> getImages()
Returns the images whenRenderisRender.IMAGE.- Returns:
- the images when
RenderisRender.IMAGEor 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:
getFontCallbackin interfaceIsScriptableFontProvider<LabelsContext>- Returns:
- the font callback, if set, otherwise
null
-
setFont
public void setFont(FontCallback<LabelsContext> fontCallback)
Sets the font callback.- Specified by:
setFontin interfaceIsScriptableFontProvider<LabelsContext>- Parameters:
fontCallback- the font callback.
-
setFont
public void setFont(NativeCallback fontCallback)
Sets the font callback.- Specified by:
setFontin 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.
-
-