Package net.risingworld.api.ui
Class UILabel
java.lang.Object
net.risingworld.api.ui.UIElement
net.risingworld.api.ui.UILabel
Represents a label.
Example: Create a label in the upper center of the screen
-
Field Summary
Fields inherited from class net.risingworld.api.ui.UIElement
hoverStyle, style
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetText()
Gets the currently set text of the label.boolean
Gets whether or not rich text is enabled and should be parsed.void
Sets a new font for this label.void
setFontColor
(float r, float g, float b, float a) Sets a font color for the label.void
setFontColor
(int rgba) Sets a font color for the label.void
setFontSize
(float size) Sets a font size for the label.void
setFontSize
(float size, Unit unit) Sets a font size for the label.void
Changes the origin of this element.void
setRichTextEnabled
(boolean set) Determines whether or not rich text tags should be supported (e.g tags like "<color>" etc).void
Sets the text for the label.void
setTextAlign
(TextAnchor anchor) Sets the alignment for the text.void
setTextWrap
(boolean wrap) Sets automatic text wrap for the label.Methods inherited from class net.risingworld.api.ui.UIElement
addChild, addStyleSheet, addToClassList, getChildCount, getChilds, getID, getParent, getPluginID, isClickable, onClick, removeAllChilds, removeChild, removeFromClassList, removeFromParent, removeStyleSheet, resetPivot, resetPosition, setBackgroundColor, setBackgroundColor, setBorder, setBorderColor, setBorderColor, setBorderEdgeRadius, setClickable, setOpacity, setPickable, setPosition, setSize, setVisible, updateStyle
-
Constructor Details
-
UILabel
public UILabel()Creates a new, empty label. -
UILabel
Creates a label containing the provided text.- Parameters:
text
- the text you want to set for the label.
-
-
Method Details
-
setText
Sets the text for the label.- Parameters:
text
- the new text you want to set.
-
getText
Gets the currently set text of the label.- Returns:
- the text of the label.
-
setRichTextEnabled
public void setRichTextEnabled(boolean set) Determines whether or not rich text tags should be supported (e.g tags like "<color>" etc).- Parameters:
set
- true to enable rich text tags (so they get parsed), false to disable them (so they will just be displayed like regular text). By default, rich text tags are enabled.
-
isRichTextEnabled
public boolean isRichTextEnabled()Gets whether or not rich text is enabled and should be parsed.- Returns:
- true if rich text should be parsed, false if not.
-
setFont
Sets a new font for this label.
Note: This is just a helper method. Internally it changes the style font property!- Parameters:
font
- the new font you want to set for this label.
-
setFontSize
public void setFontSize(float size) Sets a font size for the label.
Note: This is just a helper method. Internally it changes the style fontSize property!- Parameters:
size
- the new font size (pixels) you want to set for this label.
-
setFontSize
Sets a font size for the label.
Note: This is just a helper method. Internally it changes the style fontSize property!- Parameters:
size
- the new font size you want to set for this label.unit
- determines if the size is in pixels (absolute) or percent (relative).
-
setFontColor
public void setFontColor(float r, float g, float b, float a) Sets a font color for the label.
Note: This is just a helper method. Internally it changes the style color property!- Parameters:
r
- the new red component for the font color (0-1).g
- the new green component for the font color (0-1).b
- the new blue component for the font color (0-1).a
- the new alpha component (opacity) for the font color (0-1).
-
setFontColor
public void setFontColor(int rgba) Sets a font color for the label.
Note: This is just a helper method. Internally it changes the style color property!- Parameters:
rgba
- an int RGBA value describing the new color (e.g 0xFF0000FF for fully opaque red etc).
-
setTextAlign
Sets the alignment for the text.
Note: This is just a helper method. Internally it changes the style textAlign property!- Parameters:
anchor
- the anchor.- Example: Set centered text
-
setTextWrap
public void setTextWrap(boolean wrap) Sets automatic text wrap for the label.
Note: This is just a helper method. Internally it changes the style whiteSpace property!- Parameters:
wrap
- true to enable automatic text wrapping, false to disable it.
-
setPivot
Description copied from class:UIElement
Changes the origin of this element.
Note: This is just a helper method. Internally it only changes the style transformOrigin and translate values!
-