Class GUILabel
java.lang.Object
com.blackrook.gui.GUIObject
com.blackrook.gui.object.GUILabel
- Direct Known Subclasses:
GUICycler
GUI Object that holds and displays text data.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumList of font text vertical alignment types.static enumList of font text alignment/justification types.static enumList of auto-resizing methods.static classA single label character.Nested classes/interfaces inherited from class GUIObject
GUIObject.ScaleType -
Field Summary
Fields inherited from class GUIObject
absoluteBounds, EVENT_BLUR, EVENT_CHANGE_ENABLE_STATE, EVENT_CHANGE_VISIBLE_STATE, EVENT_FOCUS, EVENT_GAMEPAD_AXIS, EVENT_GAMEPAD_PRESS, EVENT_GAMEPAD_RELEASE, EVENT_GAMEPAD_TAP_PRESS, EVENT_GAMEPAD_TAP_RELEASE, EVENT_GENERIC_INPUT, EVENT_KEY_PRESS, EVENT_KEY_RELEASE, EVENT_KEY_TYPE, EVENT_MOUSE_CLICK, EVENT_MOUSE_DRAG, EVENT_MOUSE_LEAVE, EVENT_MOUSE_MOVE, EVENT_MOUSE_OVER, EVENT_MOUSE_PRESS, EVENT_MOUSE_RELEASE, EVENT_MOUSE_WHEEL, EVENT_NAMED, EVENT_UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionGUILabel()Creates a new GUI Text object with no text nor specific font.GUILabel(GUIFontType font) Creates a new GUI Text object.GUILabel(GUIFontType font, String text) Creates a new GUI Text object.GUILabel(GUIFontType font, String text, GUILabel.Justification justification) Creates a new GUI Text object.GUILabel(GUIFontType font, String text, GUILabel.Justification justification, GUILabel.Alignment alignment) Creates a new GUI Text object.Creates a new GUI Text object (with no specified font). -
Method Summary
Modifier and TypeMethodDescriptiongetFont()Gets the font for this text object.floatGets the current resize mode for this text object.floatgetSize()intGets the starting line that the mesh data will be generated for in the text field.getText()Gets the text on this text object.getTextPiece(int index) Gets a single piece of the rendered text data for rendering.intGets this object's texture, which is taken from the selected font.Returns this object's theme key.booleanChecks if word wrapping is enabled.protected voidonGUIChange(GUI gui) Called when this object is added to a GUI.setAlignment(GUILabel.Alignment alignment) Sets the current style of vertical text alignment.setBounds(float x, float y, float width, float height) Sets the object bounds.setFont(GUIFontType font) Sets the font for this text object.setJustification(GUILabel.Justification justification) Sets the text alignment/justification.setMaxWidth(float maxWidth) Sets the max width in units for the resizing capability of this object.setResizeMode(GUILabel.ResizeMode resizeMode) Sets the current resize mode for this text object.setSize(float size) Sets the size of the font in GUI units.setStartingLine(int startingLine) Sets the starting line that the mesh data will be generated for in the text field.Sets the text on this text object.Sets the theme used by this object, and its descendants if they do not have a theme set.setThemeKey(String themeKey) Sets this object's theme key.setWordWrapping(boolean wordWrap) Sets if word wrapping is enabled.stretch(float width, float height) Changes this object's width/height by an x or y-coordinate amount.Methods inherited from class GUIObject
addChild, addChild, addName, addToRenderSet, animate, animate, animate, animateAbort, animateDelay, animateFinish, bindAction, callAction, correctPosition, fireEvent, getAbsoluteBounds, getAsQuery, getBounds, getChildrenAsQuery, getColor, getColorNotInherited, getDescendantsAsQuery, getFinalOpacity, getGeneration, getGUI, getLayout, getLayoutAttrib, getNativeBounds, getOpacity, getParent, getParentAsQuery, getRenderAlpha, getRenderBlue, getRendered, getRenderGreen, getRenderHeight, getRenderPositionX, getRenderPositionY, getRenderRadius, getRenderRed, getRenderRotationZ, getRenderTextureScaleS, getRenderTextureScaleT, getRenderWidth, getScaleType, getSiblingsAsQuery, getTheme, getVisible, hasAction, hasName, hasNamePattern, isAnimating, isConstrainedToParent, isEnabled, isFocused, isInert, isVisible, moveDown, moveToBack, moveToFront, moveUp, releaseFocus, remove, removeChild, removeName, requestFocus, resizeChildren, rotate, setBounds, setBoundsByChildren, setColor, setColor, setColorNotInherited, setConstrainToParent, setDimensions, setEnabled, setInert, setLayout, setLayoutAttrib, setOpacity, setPosition, setRendered, setRotationZ, setScaleType, setTexture, setVisible, toString, translate, unbindAction, unbindAllActions, updateDirty, updateScenePosition, useRenderRadius
-
Constructor Details
-
GUILabel
public GUILabel()Creates a new GUI Text object with no text nor specific font. -
GUILabel
Creates a new GUI Text object (with no specified font).- Parameters:
text- the initial text.
-
GUILabel
Creates a new GUI Text object.- Parameters:
font- the specific font to use.
-
GUILabel
Creates a new GUI Text object.- Parameters:
font- the specific font to use.text- the initial text.
-
GUILabel
Creates a new GUI Text object.- Parameters:
font- the specific font to use.text- the initial text.justification- the text justification.
-
GUILabel
public GUILabel(GUIFontType font, String text, GUILabel.Justification justification, GUILabel.Alignment alignment) Creates a new GUI Text object.- Parameters:
font- the specific font to use.text- the initial text.justification- the text justification.alignment- the text line alignment.
-
-
Method Details
-
setBounds
-
stretch
-
getTexture
Gets this object's texture, which is taken from the selected font. If no font is set on this, this will take the one from the theme, if this also has a theme key set on it.- Overrides:
getTexturein classGUIObject- Returns:
- the most relevant texture to use, null if none suitable.
- See Also:
-
setTheme
Description copied from class:GUIObjectSets the theme used by this object, and its descendants if they do not have a theme set. Setting this to null allows this object to inherit the current theme from its parents. -
getFont
Gets the font for this text object. If no font is set on this object, it will attempt to get it from the theme, if the appropriate theme key is set.- Returns:
- the font to use for rendering text.
-
setFont
Sets the font for this text object.- Parameters:
font- the font for the label.- Returns:
- itself, to chain calls.
-
getSize
public float getSize()- Returns:
- the size of the font in GUI units.
-
setSize
Sets the size of the font in GUI units.- Parameters:
size- the new size.- Returns:
- itself, to chain calls.
-
getThemeKey
Description copied from class:GUIObjectReturns this object's theme key. This is the key that is used to look up the texture used to render this object. This may return null, indicating that this object does not have a default texture.- Specified by:
getThemeKeyin classGUIObject- Returns:
- the theme key.
-
setThemeKey
-
getText
Gets the text on this text object. Default is the empty string.- Returns:
- the text.
-
setText
-
isWordWrapping
public boolean isWordWrapping()Checks if word wrapping is enabled.- Returns:
- true if so, false if not.
-
setWordWrapping
Sets if word wrapping is enabled. True if so, false if not.- Parameters:
wordWrap-- Returns:
- itself, to chain calls.
-
getJustification
- Returns:
- the text alignment/justification.
-
setJustification
Sets the text alignment/justification.- Parameters:
justification- the justification to use.- Returns:
- itself, to chain calls.
-
getAlignment
- Returns:
- the current style of vertical text alignment.
-
setAlignment
Sets the current style of vertical text alignment.- Parameters:
alignment- the text alignment to use.- Returns:
- itself, to chain calls.
-
getResizeMode
Gets the current resize mode for this text object. If this is not null, the object will resize itself according to the max width and resize mode parameters.- Returns:
- the current resize mode.
-
setResizeMode
Sets the current resize mode for this text object. If this is not null, the object will resize itself according to the max width and resize mode parameters.- Parameters:
resizeMode- the resize mode.- Returns:
- itself, to chain calls.
-
getMaxWidth
public float getMaxWidth()- Returns:
- the max width in units for the resizing capability of this object.
-
setMaxWidth
Sets the max width in units for the resizing capability of this object.- Parameters:
maxWidth- the max width in units.- Returns:
- itself, to chain calls.
-
getStartingLine
public int getStartingLine()Gets the starting line that the mesh data will be generated for in the text field. By default, this is zero (first line).- Returns:
- the starting line index.
-
setStartingLine
Sets the starting line that the mesh data will be generated for in the text field. By default, this is zero (first line).- Parameters:
startingLine- the starting line index.- Returns:
- itself, to chain calls.
-
getTextPiece
Gets a single piece of the rendered text data for rendering.- Parameters:
index- the character index.- Returns:
- a piece of text, or null if no corresponding piece.
-
getTextPieceCount
public int getTextPieceCount()- Returns:
- get text piece count.
-
onGUIChange
Description copied from class:GUIObjectCalled when this object is added to a GUI. Does nothing, unless overridden.- Overrides:
onGUIChangein classGUIObject- Parameters:
gui- the reference to the GUI that this was added to.
-