Package solar.squares.pixelwidth
Interface ContextualPixelWidthSource<CX>
-
- Type Parameters:
CX- The context to take account for when choosing a Context to CharacterWidthFunction function
- All Superinterfaces:
PixelWidthSource
public interface ContextualPixelWidthSource<CX> extends PixelWidthSource
A source able to return the width of text with the usage ofCharacterWidthFunctions and a contextCX.If context is pointless use a generic
PixelWidthSource- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <CX> @NotNull ContextualPixelWidthSource<CX>contextualPixelWidth(@NotNull Function<@Nullable CX,@NotNull CharacterWidthFunction> function)A pixel width source calculating width usingComponentFlattener.basic()and the provided character width function.static <CX> @NotNull ContextualPixelWidthSource<CX>contextualPixelWidth(@NotNull net.kyori.adventure.text.flattener.ComponentFlattener flattener, @NotNull Function<@Nullable CX,@NotNull CharacterWidthFunction> function)A pixel width source calculating width using the provided flattener and character width function.default floatwidth(char character, @NotNull net.kyori.adventure.text.format.Style style)Calculates the pixel width of a character without any context.floatwidth(char character, @NotNull net.kyori.adventure.text.format.Style style, CX context)Calculates the pixel width of a character, given a context.default floatwidth(int codepoint, @NotNull net.kyori.adventure.text.format.Style style)Calculates the pixel width of a character represented by a codepoint without any context.floatwidth(int codepoint, @NotNull net.kyori.adventure.text.format.Style style, CX context)Calculates the pixel width of a character represented by a codepoint, given a context.default floatwidth(@NotNull String string, @NotNull net.kyori.adventure.text.format.Style style)Calculates the pixel width of a string without any context.floatwidth(@NotNull String string, @NotNull net.kyori.adventure.text.format.Style style, CX context)Calculates the pixel width of a string, given a context.default floatwidth(@NotNull net.kyori.adventure.text.Component component)Calculates the pixel width of a component without any context.floatwidth(@NotNull net.kyori.adventure.text.Component component, CX context)Calculates the pixel width of a component, given a context.
-
-
-
Method Detail
-
contextualPixelWidth
@NotNull static <CX> @NotNull ContextualPixelWidthSource<CX> contextualPixelWidth(@NotNull @NotNull net.kyori.adventure.text.flattener.ComponentFlattener flattener, @NotNull @NotNull Function<@Nullable CX,@NotNull CharacterWidthFunction> function)
A pixel width source calculating width using the provided flattener and character width function.- Type Parameters:
CX- context a context type (player, server, locale)- Parameters:
flattener- a flattener used to turn components into linear textfunction- a function that provides a character width function- Returns:
- a pixel width source
- Since:
- 1.0.0
-
contextualPixelWidth
@NotNull static <CX> @NotNull ContextualPixelWidthSource<CX> contextualPixelWidth(@NotNull @NotNull Function<@Nullable CX,@NotNull CharacterWidthFunction> function)
A pixel width source calculating width usingComponentFlattener.basic()and the provided character width function.- Type Parameters:
CX- context a context type (player, server, locale)- Parameters:
function- a function that provides a character width function- Returns:
- a pixel width source
- Since:
- 1.0.0
-
width
float width(@NotNull @NotNull net.kyori.adventure.text.Component component, @Nullable CX context)Calculates the pixel width of a component, given a context.- Parameters:
component- a componentcontext- the context of this calculation- Returns:
- the pixel width of the component
- Since:
- 1.0.0
-
width
default float width(@NotNull @NotNull net.kyori.adventure.text.Component component)Description copied from interface:PixelWidthSourceCalculates the pixel width of a component without any context.- Specified by:
widthin interfacePixelWidthSource- Parameters:
component- a component- Returns:
- the pixel width of the component
-
width
float width(@NotNull @NotNull String string, @NotNull @NotNull net.kyori.adventure.text.format.Style style, @Nullable CX context)Calculates the pixel width of a string, given a context.- Parameters:
string- a stringstyle- the style of the stringcontext- the context of this calculation- Returns:
- the pixel width of the string
- Since:
- 1.0.0
-
width
default float width(@NotNull @NotNull String string, @NotNull @NotNull net.kyori.adventure.text.format.Style style)Description copied from interface:PixelWidthSourceCalculates the pixel width of a string without any context.- Specified by:
widthin interfacePixelWidthSource- Parameters:
string- a stringstyle- the style of the string- Returns:
- the pixel width of the string
-
width
float width(char character, @NotNull @NotNull net.kyori.adventure.text.format.Style style, @Nullable CX context)Calculates the pixel width of a character, given a context.- Parameters:
character- a characterstyle- the style of the charactercontext- the context of this calculation- Returns:
- the pixel width of the character
- Since:
- 1.0.0
-
width
default float width(char character, @NotNull @NotNull net.kyori.adventure.text.format.Style style)Description copied from interface:PixelWidthSourceCalculates the pixel width of a character without any context.- Specified by:
widthin interfacePixelWidthSource- Parameters:
character- a characterstyle- the style of the character- Returns:
- the pixel width of the character
-
width
float width(int codepoint, @NotNull @NotNull net.kyori.adventure.text.format.Style style, @Nullable CX context)Calculates the pixel width of a character represented by a codepoint, given a context.- Parameters:
codepoint- a codepoint representing a characterstyle- the style of the charactercontext- the context of this calculation- Returns:
- the pixel width of the character
- Since:
- 1.0.0
-
width
default float width(int codepoint, @NotNull @NotNull net.kyori.adventure.text.format.Style style)Description copied from interface:PixelWidthSourceCalculates the pixel width of a character represented by a codepoint without any context.- Specified by:
widthin interfacePixelWidthSource- Parameters:
codepoint- a codepoint representing a characterstyle- the style of the character- Returns:
- the pixel width of the character
-
-