Class StyleResolver

  • Direct Known Subclasses:
    StyleResolver

    public class StyleResolver
    extends java.lang.Object
    Resolves named (or source-referenced) AttributedStyle.
    Since:
    3.6
    • Field Detail

      • log

        private static final java.util.logging.Logger log
      • source

        private final java.util.function.Function<java.lang.String,​java.lang.String> source
    • Constructor Detail

      • StyleResolver

        public StyleResolver​(java.util.function.Function<java.lang.String,​java.lang.String> source)
    • Method Detail

      • colorRgb

        private static java.lang.Integer colorRgb​(java.lang.String name)
        Returns the RGB color for the given name.

        Bright color can be specified with: !<color> or bright-<color>.

        Full xterm256 color can be specified with: ~<color>. RGB colors can be specified with: x<rgb> or #<rgb> where rgb is a 24 bits hexadecimal color.

        Parameters:
        name - the name of the color
        Returns:
        color code, or null if unable to determine.
      • color

        private static java.lang.Integer color​(java.lang.String name)
        Returns the color identifier for the given name.

        Bright color can be specified with: !<color> or bright-<color>.

        Full xterm256 color can be specified with: ~<color>.

        Parameters:
        name - the name of the color
        Returns:
        color code, or null if unable to determine.
      • resolve

        public AttributedStyle resolve​(java.lang.String spec)
        Resolve the given style specification.

        If for some reason the specification is invalid, then AttributedStyle.DEFAULT will be used.

        Parameters:
        spec - the specification
        Returns:
        the style
      • resolve

        public AttributedStyle resolve​(java.lang.String spec,
                                       java.lang.String defaultSpec)
        Resolve the given style specification.

        If this resolves to AttributedStyle.DEFAULT then given default specification is used if non-null.

        Parameters:
        spec - the specification
        defaultSpec - the default specifiaction
        Returns:
        the style
      • apply

        private AttributedStyle apply​(AttributedStyle style,
                                      java.lang.String spec)
        Apply style specification.
        Parameters:
        style - the style to apply to
        spec - the specification
        Returns:
        the new style
      • applyReference

        private AttributedStyle applyReference​(AttributedStyle style,
                                               java.lang.String spec)
        Apply source-referenced named style.
        Parameters:
        style - the style to apply to
        spec - the specification
        Returns:
        the new style
      • applyNamed

        private AttributedStyle applyNamed​(AttributedStyle style,
                                           java.lang.String name)
        Apply default named styles.
        Parameters:
        style - the style to apply to
        name - the named style
        Returns:
        the new style
      • applyColor

        private AttributedStyle applyColor​(AttributedStyle style,
                                           java.lang.String spec)
        Apply color styles specification.
        Parameters:
        style - The style to apply to
        spec - Color specification: <color-mode>:<color-name>
        Returns:
        The new style