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 of CharacterWidthFunctions and a context CX.

    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 using ComponentFlattener.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 float width​(char character, @NotNull net.kyori.adventure.text.format.Style style)
      Calculates the pixel width of a character without any context.
      float width​(char character, @NotNull net.kyori.adventure.text.format.Style style, CX context)
      Calculates the pixel width of a character, given a context.
      default float width​(int codepoint, @NotNull net.kyori.adventure.text.format.Style style)
      Calculates the pixel width of a character represented by a codepoint without any context.
      float width​(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 float width​(@NotNull String string, @NotNull net.kyori.adventure.text.format.Style style)
      Calculates the pixel width of a string without any context.
      float width​(@NotNull String string, @NotNull net.kyori.adventure.text.format.Style style, CX context)
      Calculates the pixel width of a string, given a context.
      default float width​(@NotNull net.kyori.adventure.text.Component component)
      Calculates the pixel width of a component without any context.
      float width​(@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 text
        function - 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 using ComponentFlattener.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 component
        context - 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: PixelWidthSource
        Calculates the pixel width of a component without any context.
        Specified by:
        width in interface PixelWidthSource
        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 string
        style - the style of the string
        context - 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: PixelWidthSource
        Calculates the pixel width of a string without any context.
        Specified by:
        width in interface PixelWidthSource
        Parameters:
        string - a string
        style - 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 character
        style - the style of the character
        context - 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: PixelWidthSource
        Calculates the pixel width of a character without any context.
        Specified by:
        width in interface PixelWidthSource
        Parameters:
        character - a character
        style - 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 character
        style - the style of the character
        context - 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: PixelWidthSource
        Calculates the pixel width of a character represented by a codepoint without any context.
        Specified by:
        width in interface PixelWidthSource
        Parameters:
        codepoint - a codepoint representing a character
        style - the style of the character
        Returns:
        the pixel width of the character