Skip to content

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.

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.

ReturnsSignatureSummary
TextElementcreate(Object text, TextInfo info) factoryCreates an element showing text, styled by info.
TextElementcreate(Supplier<?> text, TextInfo info) factoryCreates an element showing the value of text, styled by info.

PropertyTypeDefaultSummary
text signalObjectset 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.
infoTextInfoset at creation, by TextElement.create(text, info)The TextInfo that styles the element: font, size, color, weight and spacing.
modifierTextModifiernullThe TextModifier applied to the text of this element, or null for none.

ReturnsSignatureSummary
TextElementcopy()Returns an element with the same value, style and modifier.
TextElementcopyWithText(Object text)Returns an element with the style and the modifier of this one and the value text.
TextElementcopyWithText(Supplier<?> text)Returns an element with the style and the modifier of this one, showing the value of text.
StringgetRawText()Returns the value converted to a string, before the modifier, markup tags included.

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.

  • this text(Object text) fluent
  • this text(Supplier<?> text) fluent signal
  • String 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) fluent
  • TextInfo getInfo()

Default: set at creation, by TextElement.create(text, info)

The TextInfo that styles the element: font, size, color, weight and spacing.

  • this modifier(TextModifier modifier) fluent
  • TextModifier getModifier()

Default: null

The TextModifier applied to the text of this element, or null for none.

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.


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

Report a problem with this page