Class TLabelElement
java.lang.Object
com.thecsdev.common.scene.Node<TElement>
com.thecsdev.commonmc.api.client.gui.TElement
com.thecsdev.commonmc.api.client.gui.label.TLabelElement
- All Implemented Interfaces:
INode<TElement>, INodeBounded<TElement,Bounds2i>, INodeRenderable<TElement, TGuiGraphics>, Iterable<TElement>, Collection<TElement>
-
Field Summary
Fields inherited from class TElement
eInitialized -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal BooleanPropertyABooleanPropertyfor whether the text should have a 'shadow' when rendered.final NotNullProperty<net.minecraft.client.gui.Font> final @NotNull net.minecraft.network.chat.ComponentgetText()Convenience method for getting the value oftextProperty().final intReturns the height thisTLabelElementwould need, to fit all lines of text it has.final intReturns the width thisTLabelElementwould need, to fit all lines of text it has.protected final voidCallback method that is invoked when thisTElementis initializing.final IntegerPropertyAnIntegerPropertyfor the spacing between lines of text.voidpostRenderCallback(@NotNull TGuiGraphics pencil) Callback method that is invoked after thisNodeand all of their children have been rendered.final voidrefresh()Refreshes thisTLabelElement.final voidrenderCallback(@NotNull TGuiGraphics pencil) Callback method that is invoked when thisNodeis being rendered.final voidsetBoundsToFitText(int maxWidth) Sets thisTLabelElement's bounds to fit its text, given a maximum width.final voidsetBoundsToFitText(int x, int y, int maxWidth) Sets thisTLabelElement's bounds to fit its text, given a maximum width.final voidsetText(@NotNull net.minecraft.network.chat.Component text) Convenience method for setting the value oftextProperty().final NotNullProperty<CompassDirection> ANotNullPropertyfor the horizontal and vertical alignment of text.final IntegerPropertyAnIntegerPropertyfor the color of the text that will be rendered.final NotNullProperty<net.minecraft.network.chat.Component> ANotNullPropertyfor thisTLabelElement's text.final DoublePropertyADoublePropertyfor the visual scale of the text.final BooleanPropertyABooleanPropertyfor whether the text should be wrapped.Methods inherited from class TElement
addRel, boundsProperty, clearAndInit, clipsDescendantsProperty, contextMenuProperty, dragEndCallback, dragStartCallback, findElementAt, focusableProperty, focusGainedCallback, focusLostCallback, forEachVisible, getBaseType, getBounds, getClient, getContentBounds, getCursor, getSelf, getTooltip, hoverableProperty, hoverGainedCallback, hoverLostCallback, inputCallback, invalidateTooltipCache, isFocusable, isFocused, isHoverable, isHovered, isHoveredOrFocused, isVisible, move, moveChildren, moveTo, removeRel, screenProperty, setBounds, setBounds, setBounds, showContextMenu, tickCallback, tooltipProperty, toString, visiblePropertyMethods inherited from class Node
add, addAll, childAddedCallback, childRemovedCallback, clear, contains, containsAll, equals, findChild, findParent, findSibling, forEach, get, getFirst, getLast, getParent, hashCode, indexOf, isEmpty, iterator, parentProperty, remove, remove, remove, removeAll, retainAll, rootProperty, size, toArray, toArray
-
Constructor Details
-
TLabelElement
public TLabelElement(@NotNull @NotNull net.minecraft.network.chat.Component text) -
TLabelElement
public TLabelElement()
-
-
Method Details
-
textProperty
ANotNullPropertyfor thisTLabelElement's text. -
fontProperty
-
lineSpacingProperty
AnIntegerPropertyfor the spacing between lines of text. -
textColorProperty
AnIntegerPropertyfor the color of the text that will be rendered. -
wrapTextProperty
ABooleanPropertyfor whether the text should be wrapped.- API Note:
- Wikipedia article
-
textAlignmentProperty
ANotNullPropertyfor the horizontal and vertical alignment of text. -
textScaleProperty
ADoublePropertyfor the visual scale of the text. -
dropShadowProperty
ABooleanPropertyfor whether the text should have a 'shadow' when rendered.- Since:
- 5.3.0
-
initCallback
protected final void initCallback()Description copied from class:TElementCallback method that is invoked when thisTElementis initializing. You may override this method to create and add childTElements.- Overrides:
initCallbackin classTElement- See Also:
-
renderCallback
Description copied from interface:INodeRenderableCallback method that is invoked when thisNodeis being rendered.- Specified by:
renderCallbackin interfaceINodeRenderable<TElement, TGuiGraphics>- Overrides:
renderCallbackin classTElement- Parameters:
pencil- The rendering context.
-
postRenderCallback
Description copied from interface:INodeRenderableCallback method that is invoked after thisNodeand all of their children have been rendered.- Specified by:
postRenderCallbackin interfaceINodeRenderable<TElement, TGuiGraphics>- Overrides:
postRenderCallbackin classTElement- Parameters:
pencil- The rendering context.
-
refresh
public final void refresh()Refreshes thisTLabelElement. This may be called in the event a property was updated without triggering change listeners. -
getText
@NotNull public final @NotNull net.minecraft.network.chat.Component getText()Convenience method for getting the value oftextProperty().- Returns:
- The current
textProperty()value.
-
setText
public final void setText(@NotNull @NotNull net.minecraft.network.chat.Component text) Convenience method for setting the value oftextProperty().- Parameters:
text- The newtextProperty()value.
-
setBoundsToFitText
public final void setBoundsToFitText(int maxWidth) Sets thisTLabelElement's bounds to fit its text, given a maximum width.- Parameters:
maxWidth- The maximum width the bounds can have.
-
setBoundsToFitText
public final void setBoundsToFitText(int x, int y, int maxWidth) Sets thisTLabelElement's bounds to fit its text, given a maximum width.- Parameters:
x- The x position to set the bounds to.y- The y position to set the bounds to.maxWidth- The maximum width the bounds can have.
-
getTextWidth
public final int getTextWidth()Returns the width thisTLabelElementwould need, to fit all lines of text it has. This accounts fortextScaleProperty()value as well.Note: If you have
wrapTextProperty()enabled, this will likely return a value that's around the width of thisTLabelElement.- See Also:
- API Note:
- Relies on this
TLabelElement's bounding box.
-
getTextHeight
public final int getTextHeight()Returns the height thisTLabelElementwould need, to fit all lines of text it has. This accounts fortextScaleProperty()value as well.- See Also:
- API Note:
- Relies on this
TLabelElement's bounding box.
-