Class WDynamicLabel
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WDynamicLabel
Dynamic labels are labels that pull their text from a 
Supplier<String>.
 They can be used for automatically getting data from a block entity or another data source.
 Translating strings in dynamic labels should be done using
 I18n.translate(String, Object...).
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intprotected intstatic final intThe default text color for dark mode labels.static final intThe default text color for light mode labels.protected booleanprotected HorizontalAlignmentprotected VerticalAlignment
- 
Constructor SummaryConstructorsConstructorDescriptionWDynamicLabel(Supplier<String> text) Constructs a new dynamic label with the default text color.WDynamicLabel(Supplier<String> text, int color) Constructs a new dynamic label.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanChecks whether this widget can be resized usingWWidget.setSize(int, int).Disables separate dark mode coloring by copying the dark color to be the light color.booleanChecks whether shadows should be drawn for this label.Gets the horizontal text alignment of this label.Gets the vertical text alignment of this label.voidpaint(DrawContext context, int x, int y, int mouseX, int mouseY) Paints this widget.setColor(int color, int darkmodeColor) Sets the light and dark mode colors of this label.setDarkmodeColor(int color) Sets the dark mode color of this label.setDrawShadows(boolean drawShadows) Sets whether shadows should be drawn for this label.Sets the horizontal text alignment of this label.voidsetSize(int x, int y) Sets the size of this widget.Sets the text of this label.Sets the vertical text alignment of this label.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WWidgetaddNarrations, addPainters, addTooltip, canFocus, canHover, getAbsoluteX, getAbsoluteY, getFocusModel, getHeight, getHost, getParent, getWidth, getX, getY, hit, hoveredProperty, isActivationKey, isFocused, isHovered, isNarratable, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onHidden, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, onShown, releaseFocus, renderTooltip, requestFocus, setHost, setHovered, setLocation, setParent, shouldRenderInDarkMode, tick, validate
- 
Field Details- 
text
- 
horizontalAlignment
- 
verticalAlignment
- 
colorprotected int color
- 
darkmodeColorprotected int darkmodeColor
- 
drawShadowsprotected boolean drawShadows
- 
DEFAULT_TEXT_COLORpublic static final int DEFAULT_TEXT_COLORThe default text color for light mode labels.- See Also:
 
- 
DEFAULT_DARKMODE_TEXT_COLORpublic static final int DEFAULT_DARKMODE_TEXT_COLORThe default text color for dark mode labels.- See Also:
 
 
- 
- 
Constructor Details- 
WDynamicLabelConstructs a new dynamic label.- Parameters:
- text- the text of the label
- color- the color of the label
 
- 
WDynamicLabelConstructs a new dynamic label with the default text color.- Parameters:
- text- the text of the label
 
 
- 
- 
Method Details- 
paintDescription copied from class:WWidgetPaints this widget.
- 
canResizepublic boolean canResize()Description copied from class:WWidgetChecks whether this widget can be resized usingWWidget.setSize(int, int).
- 
setSizepublic void setSize(int x, int y) Description copied from class:WWidgetSets the size of this widget.Overriding methods may restrict one of the dimensions to be a constant value, for example super.setSize(x, 20).
- 
setDarkmodeColorSets the dark mode color of this label.- Parameters:
- color- the new color
- Returns:
- this label
 
- 
disableDarkmodeDisables separate dark mode coloring by copying the dark color to be the light color.- Returns:
- this label
 
- 
setColorSets the light and dark mode colors of this label.- Parameters:
- color- the new light color
- darkmodeColor- the new dark color
- Returns:
- this label
 
- 
getDrawShadowspublic boolean getDrawShadows()Checks whether shadows should be drawn for this label.- Returns:
- trueshadows should be drawn,- falseotherwise
- Since:
- 11.1.0
 
- 
setDrawShadowsSets whether shadows should be drawn for this label.- Parameters:
- drawShadows-- trueif shadows should be drawn,- falseotherwise
- Returns:
- this label
- Since:
- 11.1.0
 
- 
setTextSets the text of this label.- Parameters:
- text- the new text
- Returns:
- this label
 
- 
getHorizontalAlignmentGets the horizontal text alignment of this label.- Returns:
- the alignment
 
- 
setHorizontalAlignmentSets the horizontal text alignment of this label.- Parameters:
- align- the new text alignment
- Returns:
- this label
 
- 
getVerticalAlignmentGets the vertical text alignment of this label.- Returns:
- the alignment
- Since:
- 11.1.0
 
- 
setVerticalAlignmentSets the vertical text alignment of this label.- Parameters:
- align- the new text alignment
- Returns:
- this label
- Since:
- 11.1.0
 
 
-