TextElement
final class TextElement
Package: dev.joid.lib.draw.text · Module: core · Source: TextElement.java
One styled part of a Text, with its value, its TextInfo and its own modifier.
Description
Section titled “Description”Put several elements in one Text to mix styles in one run, such as a bold word in a sentence.
The value can be any object, converted to a string by TextConverter, or a Supplier read each time the text is measured or drawn.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
TextElement | create(Object text, TextInfo info) factory | Creates an element showing text, styled by info. |
TextElement | create(Supplier<?> text, TextInfo info) factory | Creates an element showing the value of text, styled by info. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| text signal | Object | set at creation, by TextElement.create(text, info) | The value of the element: getText() returns it as a string after the modifier; text(Object) and text(Supplier) set it. |
| info | TextInfo | set at creation, by TextElement.create(text, info) | The TextInfo that styles the element: font, size, color, weight and spacing. |
| modifier | TextModifier | null | The TextModifier applied to the text of this element, or null for none. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
TextElement | copy() | Returns an element with the same value, style and modifier. |
TextElement | copyWithText(Object text) | Returns an element with the style and the modifier of this one and the value text. |
TextElement | copyWithText(Supplier<?> text) | Returns an element with the style and the modifier of this one, showing the value of text. |
String | getRawText() | Returns the value converted to a string, before the modifier, markup tags included. |
Creation details
Section titled “Creation details”create
Section titled “create”TextElement create(Object text, TextInfo info) factory
Creates an element showing text, styled by info.
TextElement create(Supplier<?> text, TextInfo info) factory
Creates an element showing the value of text, styled by info.
Property details
Section titled “Property details”this text(Object text)fluentthis text(Supplier<?> text)fluent signalString getText()
Default: set at creation, by TextElement.create(text, info)
The value of the element: getText() returns it as a string after the modifier; text(Object) and text(Supplier) set it.
this info(TextInfo info)fluentTextInfo getInfo()
Default: set at creation, by TextElement.create(text, info)
The TextInfo that styles the element: font, size, color, weight and spacing.
modifier
Section titled “modifier”this modifier(TextModifier modifier)fluentTextModifier getModifier()
Default: null
The TextModifier applied to the text of this element, or null for none.
Method details
Section titled “Method details”TextElement copy()
Returns an element with the same value, style and modifier.
copyWithText
Section titled “copyWithText”TextElement copyWithText(Object text)
Returns an element with the style and the modifier of this one and the value text.
TextElement copyWithText(Supplier<?> text)
Returns an element with the style and the modifier of this one, showing the value of text.
getRawText
Section titled “getRawText”String getRawText()
Returns the value converted to a string, before the modifier, markup tags included.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
