Class AsciiArtBuilder

    • Constructor Detail

      • AsciiArtBuilder

        public AsciiArtBuilder()
    • Method Detail

      • getPixmapRatioMode

        public PixmapRatioMode getPixmapRatioMode()
        Retrieves the Pixmap ratio mode from the Pixmap ratio mode property.
        Returns:
        The Pixmap ratio mode stored by the Pixmap ratio mode property.
      • setPixmapRatioMode

        public void setPixmapRatioMode​(PixmapRatioMode aPixmapRatioMode)
        Sets the Pixmap ratio mode for the Pixmap ratio mode property.
        Parameters:
        aPixmapRatioMode - The Pixmap ratio mode to be stored by the text strip mode property.
      • getRgbPixmap

        public org.refcodes.graphical.RgbPixmap getRgbPixmap()
        Retrieves the Pixmap from the Pixmap property.
        Returns:
        The Pixmap stored by the Pixmap property.
      • withColumnWidth

        public AsciiArtBuilder withColumnWidth​(int aColumnWidth)
        Specified by:
        withColumnWidth in interface org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<AsciiArtBuilder>
      • setColumnWidth

        public void setColumnWidth​(int aColumnWidth)
        Specified by:
        setColumnWidth in interface org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
      • getColumnWidth

        public int getColumnWidth()
        Specified by:
        getColumnWidth in interface org.refcodes.mixin.ColumnWidthAccessor
      • getFont

        public Font getFont()
        Retrieves the font from the font property.
        Specified by:
        getFont in interface FontAccessor
        Returns:
        The font stored by the font property.
      • setFont

        public void setFont​(Font aFont)
        Sets the font for the font property.
        Specified by:
        setFont in interface FontAccessor.FontMutator
        Parameters:
        aFont - The font to be stored by the font property.
      • getAsciiArtMode

        public AsciiArtMode getAsciiArtMode()
        Retrieves the ASCII-Art mode from the ASCII-Art mode property.
        Returns:
        The ASCII-Art mode stored by the ASCII-Art mode property.
      • setAsciiArtMode

        public void setAsciiArtMode​(AsciiArtMode aAsciiArtMode)
        Sets the ASCII-Art mode for the ASCII_HEADER_ASCII_BODY art mode property.
        Parameters:
        aAsciiArtMode - The ASCII-Art mode to be stored by the text strip mode property.
      • getAsciiColors

        public char[] getAsciiColors()
        Retrieves the ASCII_HEADER_ASCII_BODY colors from the ASCII_HEADER_ASCII_BODY colors property.
        Returns:
        The ASCII_HEADER_ASCII_BODY colors stored by the ASCII_HEADER_ASCII_BODY colors property.
      • setAsciiColors

        public void setAsciiColors​(char... aAsciiColors)
        Sets the ASCII_HEADER_ASCII_BODY colors for the ASCII_HEADER_ASCII_BODY colors property.
        Parameters:
        aAsciiColors - The ASCII_HEADER_ASCII_BODY colors to be stored by the ASCII_HEADER_ASCII_BODY colors property.
      • getAsciiColorPalette

        public org.refcodes.data.AsciiColorPalette getAsciiColorPalette()
        Retrieves the ASCII_HEADER_ASCII_BODY color palette from the ASCII_HEADER_ASCII_BODY color palette property.
        Returns:
        The ASCII_HEADER_ASCII_BODY color palette stored by the ASCII_HEADER_ASCII_BODY color palette property.
      • setAsciiColorPalette

        public void setAsciiColorPalette​(org.refcodes.data.AsciiColorPalette aAsciiColorPalette)
        Sets the ASCII_HEADER_ASCII_BODY color palette for the ASCII_HEADER_ASCII_BODY color palette property.
        Parameters:
        aAsciiColorPalette - The ASCII_HEADER_ASCII_BODY color palette to be stored by the ASCII_HEADER_ASCII_BODY color palette property.
      • getFontFamily

        public FontFamily getFontFamily()
        Retrieves the font family from the font family property.
        Specified by:
        getFontFamily in interface FontFamilyAccessor
        Returns:
        The font family stored by the font family property.
      • getFontStyle

        public FontStyle getFontStyle()
        Retrieves the font style from the font style property.
        Specified by:
        getFontStyle in interface FontStyleAccessor
        Returns:
        The font style stored by the font style property.
      • getFontSize

        public int getFontSize()
        Retrieves the font style from the font style property.
        Specified by:
        getFontSize in interface FontSizeAccessor
        Returns:
        The font style stored by the font style property.
      • setFontSize

        public void setFontSize​(int aFontSize)
        Sets the font style for the font style property.
        Specified by:
        setFontSize in interface FontSizeAccessor.FontSizeMutator
        Parameters:
        aFontSize - The font style to be stored by the font style property.
      • getFontName

        public String getFontName()
        Retrieves the font name from the font name property.
        Specified by:
        getFontName in interface FontNameAccessor
        Returns:
        The font name stored by the font name property.
      • setFontName

        public void setFontName​(String aFontName)
        Sets the font name for the font name property.
        Specified by:
        setFontName in interface FontNameAccessor.FontNameMutator
        Parameters:
        aFontName - The font name to be stored by the font name property.
      • setRgbPixmap

        public void setRgbPixmap​(org.refcodes.graphical.RgbPixmap aPixmap)
        Sets the Pixmap for the Pixmap property.
        Parameters:
        aPixmap - The Pixmap to be stored by the Pixmap property.
      • toStrings

        public String[] toStrings​(org.refcodes.graphical.RgbPixmap aPixmap)
        Race condition safe shortcut for using withRgbPixmap(RgbPixmap) followed by toStrings(). Implementation requirements: This method must not(!) be implemented by calling withRgbPixmap(RgbPixmap) followed by toStrings() (do not change the Pixmap property) as this would not be thread safe!
        Parameters:
        aPixmap - The Pixmap to be converted to ASCII-Art.
        Returns:
        The according resulting String array
      • withAsciiArtMode

        public AsciiArtBuilder withAsciiArtMode​(AsciiArtMode aAsciiArtMode)
        Sets the ASCII-Art mode for the ASCII_HEADER_ASCII_BODY art mode property.
        Parameters:
        aAsciiArtMode - The ASCII-Art mode to be stored by the text strip mode property.
        Returns:
        The builder for applying multiple build operations.
      • withPixmapRatioMode

        public AsciiArtBuilder withPixmapRatioMode​(PixmapRatioMode aPixmapRatioMode)
        Sets the Pixmap ratio mode for the Pixmap ratio mode property.
        Parameters:
        aPixmapRatioMode - The Pixmap ratio mode to be stored by the text strip mode property.
        Returns:
        The builder for applying multiple build operations.
      • withAsciiColors

        public AsciiArtBuilder withAsciiColors​(char... aAsciiColors)
        Sets the ASCII_HEADER_ASCII_BODY colors for the ASCII_HEADER_ASCII_BODY colors property.
        Parameters:
        aAsciiColors - The ASCII_HEADER_ASCII_BODY colors to be stored by the ASCII_HEADER_ASCII_BODY colors property.
        Returns:
        The builder for applying multiple build operations.
      • setAsciiColors

        public void setAsciiColors​(String aAsciiColors)
        Sets the ASCII_HEADER_ASCII_BODY colors for the ASCII_HEADER_ASCII_BODY colors property.
        Parameters:
        aAsciiColors - The ASCII_HEADER_ASCII_BODY colors to be stored by the ASCII_HEADER_ASCII_BODY colors property.
      • withAsciiColors

        public AsciiArtBuilder withAsciiColors​(String aAsciiColors)
        Sets the ASCII_HEADER_ASCII_BODY colors for the ASCII_HEADER_ASCII_BODY colors property.
        Parameters:
        aAsciiColors - The ASCII_HEADER_ASCII_BODY colors to be stored by the ASCII_HEADER_ASCII_BODY colors property.
        Returns:
        The builder for applying multiple build operations.
      • withAsciiColorPalette

        public AsciiArtBuilder withAsciiColorPalette​(org.refcodes.data.AsciiColorPalette aAsciiColorPalette)
        Sets the ASCII_HEADER_ASCII_BODY color palette for the ASCII_HEADER_ASCII_BODY color palette property.
        Parameters:
        aAsciiColorPalette - The ASCII_HEADER_ASCII_BODY color palette to be stored by the ASCII_HEADER_ASCII_BODY color palette property.
        Returns:
        The builder for applying multiple build operations.
      • withRgbPixmap

        public AsciiArtBuilder withRgbPixmap​(org.refcodes.graphical.RgbPixmap aPixmap)
        Sets the Pixmap for the Pixmap property.
        Parameters:
        aPixmap - The Pixmap to be stored by the Pixmap property.
        Returns:
        The builder for applying multiple build operations.
      • setImageFile

        public void setImageFile​(File aImageFile)
                          throws IOException
        Sets the image file for the Pixmap property.
        Parameters:
        aImageFile - The file from which to retrieve the Pixmap which is to be stored by the Pixmap property.
        Throws:
        IOException - in case the file was not found.
      • withImageFile

        public AsciiArtBuilder withImageFile​(File aImageFile)
                                      throws IOException
        Sets the image file for the Pixmap property.
        Parameters:
        aImageFile - The image file for the Pixmap to be stored by the Pixmap property.
        Returns:
        The builder for applying multiple build operations.
        Throws:
        IOException - in case the file was not found.
      • toStrings

        public String[] toStrings​(File aImageFile)
                           throws IOException
        Race condition safe shortcut for using withImageFile(File) followed by toStrings(). Implementation requirements: This method must not(!) be implemented by calling withImageFile(File) followed by toStrings() (do not change the Pixmap property) as this would not be thread safe!
        Parameters:
        aImageFile - The image file to be converted to ASCII-Art.
        Returns:
        The according resulting String array
        Throws:
        IOException - in case the file was not found or the like.
      • asAsciiArt

        public static String[] asAsciiArt​(int aWidth,
                                          Font aFont,
                                          AsciiArtMode aAsciiArtMode,
                                          String[] aLines,
                                          char... aPalette)
        Produces ASCII-Art from the provided arguments.
        Parameters:
        aWidth - The width for the resulting ASCII-Art.
        aFont - The Font to use for printing ASCII-Art.
        aAsciiArtMode - The AsciiArtMode specifies whether to invert the resulting ASCII-Art or not.
        aLines - The text lines to convert to ASCII-Art.
        aPalette - The Character set used as ASCII-Art color palette.
        Returns:
        The resulting ASCII-Art.
      • asAsciiArt

        public static String[] asAsciiArt​(int aWidth,
                                          Font aFont,
                                          AsciiArtMode aAsciiArtMode,
                                          char[] aPalette,
                                          String... aLines)
        Produces ASCII-Art from the provided arguments.
        Parameters:
        aWidth - The width for the resulting ASCII-Art.
        aFont - The Font to use for printing ASCII-Art.
        aAsciiArtMode - The AsciiArtMode specifies whether to invert the resulting ASCII-Art or not.
        aPalette - The Character set used as ASCII-Art color palette.
        aLines - The text lines to convert to ASCII-Art.
        Returns:
        The resulting ASCII-Art.
      • asAsciiArt

        public static String[] asAsciiArt​(String aText,
                                          int aWidth,
                                          Font aFont,
                                          AsciiArtMode aAsciiArtMode,
                                          char... aPalette)
        Produces ASCII-Art from the provided arguments.
        Parameters:
        aText - The text to convert to ASCII-Art.
        aWidth - The width for the resulting ASCII-Art.
        aFont - The Font to use for printing ASCII-Art.
        aAsciiArtMode - The AsciiArtMode specifies whether to invert the resulting ASCII-Art or not.
        aPalette - The Character set used as ASCII-Art color palette.
        Returns:
        The resulting ASCII-Art.
      • asSimpleBanner

        public static String[] asSimpleBanner​(String aText,
                                              int aWidth,
                                              AsciiArtMode aAsciiArtMode,
                                              char... aPalette)
        Fallback in case creating the ASCII-Art banner failed (can happen in the GraalVM with poor AWT support for rendering fonts.
        Parameters:
        aText - The text to convert to ASCII-Art.
        aWidth - The width for the resulting ASCII-Art.
        aAsciiArtMode - The AsciiArtMode specifies whether to invert the resulting ASCII-Art or not.
        aPalette - The Character set used as ASCII-Art color palette.
        Returns:
        The resulting simple banner.
      • asAsciiArt

        public static String[] asAsciiArt​(File aImageFile,
                                          int aWidth,
                                          AsciiArtMode aAsciiArtMode,
                                          PixmapRatioMode aPixmapRatioMode,
                                          char... aPalette)
                                   throws IOException
        Produces ASCII-Art from the provided arguments.
        Parameters:
        aImageFile - The image file to be converted to ASCII-Art.
        aWidth - The width for the resulting ASCII-Art.
        aAsciiArtMode - The AsciiArtMode specifies whether to invert the resulting ASCII-Art or not.
        aPixmapRatioMode - The PixmapRatioMode describes how to scale the Pixmap ratio for ASCII-Art as a Character on the screen does not have a ratio of 1:1 (in comparison to a pixel which usually has a ration of 1:1).
        aPalette - The Character set used as ASCII-Art color palette.
        Returns:
        The resulting ASCII-Art.
        Throws:
        IOException - in case the file was not found or the like.
      • asAsciiArt

        public static String[] asAsciiArt​(org.refcodes.graphical.RgbPixmap aPixmap,
                                          int aWidth,
                                          AsciiArtMode aAsciiArtMode,
                                          PixmapRatioMode aPixmapRatioMode,
                                          char... aPalette)
        Produces ASCII-Art from the provided arguments.
        Parameters:
        aPixmap - The Pixmap which to convert to ASCII-Art.
        aWidth - The width for the resulting ASCII-Art.
        aAsciiArtMode - The AsciiArtMode specifies whether to invert the resulting ASCII-Art or not.
        aPixmapRatioMode - The PixmapRatioMode describes how to scale the Pixmap ratio for ASCII-Art as a Character on the screen does not have a ratio of 1:1 (in comparison to a pixel which usually has a ration of 1:1).
        aPalette - The Character set used as ASCII-Art color palette.
        Returns:
        The resulting ASCII-Art.
      • toAsciiArt

        protected static String[] toAsciiArt​(org.refcodes.graphical.RgbPixmap aPixmap,
                                             char[] aPalette)
        To ascii art.
        Parameters:
        aPixmap - the pixmap
        aPalette - the palette
        Returns:
        the string[]
      • toInverseAsciiArt

        protected static String[] toInverseAsciiArt​(org.refcodes.graphical.RgbPixmap aPixmap,
                                                    char[] aPalette)
        To inverse ascii art.
        Parameters:
        aPixmap - the pixmap
        aPalette - the palette
        Returns:
        the string[]
      • toAsciiArt

        protected static String[] toAsciiArt​(String aText,
                                             int aWidth,
                                             String aFontName,
                                             int aFontStyle,
                                             char[] aPalette)
        This method creates an array of String instances containing the given text as so called ASCII-Art rendered with the given Font name and Font Style to fit into the given width.
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aWidth - the width
        aFontName - The Font name to be used when rendering to ASCII-Art.
        aFontStyle - The Font style to be used when rendering to ASCII-Art.
        aPalette - The character palate to use when converting an RGB value to an ASCII_HEADER_ASCII_BODY character. The first character represents white, the last character represents black, the characters in between are gradients from white to black.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toAsciiArt

        protected static String[] toAsciiArt​(String aText,
                                             int aWidth,
                                             Font aFont,
                                             char[] aPalette)
        This method creates an array of String instances containing the given text as so called ASCII-Art rendered with the given Font name and Font Style to fit into the given width.
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aWidth - the width
        aFont - the font
        aPalette - The character palate to use when converting an RGB value to an ASCII_HEADER_ASCII_BODY character. The first character represents white, the last character represents black, the characters in between are gradients from white to black.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toInverseAsciiArt

        protected static String[] toInverseAsciiArt​(String aText,
                                                    int aWidth,
                                                    String aFontName,
                                                    int aFontStyle,
                                                    char[] aPalette)
        Same as toAsciiArt(org.refcodes.graphical.RgbPixmap,char[]) with inverted colors (black = white, dark = bright, bright = dark, white = black).
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aWidth - the width
        aFontName - The Font name to be used when rendering to ASCII-Art.
        aFontStyle - The Font style to be used when rendering to ASCII-Art.
        aPalette - The character palate to use when converting an RGB value to an ASCII_HEADER_ASCII_BODY character. The first character represents white, the last character represents black, the characters in between are gradients from white to black.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toInverseAsciiArt

        protected static String[] toInverseAsciiArt​(String aText,
                                                    int aWidth,
                                                    Font aFont,
                                                    char[] aPalette)
        Same as toAsciiArt(org.refcodes.graphical.RgbPixmap,char[]) with inverted colors (black = white, dark = bright, bright = dark, white = black).
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aWidth - the width
        aFont - The Font to be used when rendering to ASCII-Art.
        aPalette - The character palate to use when converting an RGB value to an ASCII_HEADER_ASCII_BODY character. The first character represents white, the last character represents black, the characters in between are gradients from white to black.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toAsciiArt

        protected static String[] toAsciiArt​(String aText,
                                             int aWidth,
                                             String aFontName,
                                             int aFontStyle)
        This method creates an array of String instances containing the given text as so called ASCII-Art rendered with the given Font name and Font Style to fit into the given width.
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aWidth - the width
        aFontName - The Font name to be used when rendering to ASCII-Art.
        aFontStyle - The Font style to be used when rendering to ASCII-Art.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toInverseAsciiArt

        protected static String[] toInverseAsciiArt​(String aText,
                                                    int aWidth,
                                                    String aFontName,
                                                    int aFontStyle)
        Same as toAsciiArt(org.refcodes.graphical.RgbPixmap,char[]) with inverted colors (black = white, dark = bright, bright = dark, white = black).
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aWidth - the width
        aFontName - The Font name to be used when rendering to ASCII-Art.
        aFontStyle - The Font style to be used when rendering to ASCII-Art.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toAsciiArt

        protected static String[] toAsciiArt​(String aText,
                                             Font aFont)
        This method creates an array of String instances containing the given text rendered with the given Font as so called ASCII-Art.
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aFont - The Font to render the ASCII-Art.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toInverseAsciiArt

        protected static String[] toInverseAsciiArt​(String aText,
                                                    Font aFont)
        Same as toAsciiArt(org.refcodes.graphical.RgbPixmap,char[]) with inverted colors (black = white, dark = bright, bright = dark, white = black).
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aFont - The Font to render the ASCII-Art.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toAsciiArt

        protected static String[] toAsciiArt​(String aText,
                                             Font aFont,
                                             char[] aPalette)
        This method creates an array of String instances containing the given text rendered with the given Font as so called ASCII-Art.
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aFont - The Font to render the ASCII-Art.
        aPalette - The character palate to use when converting an RGB value to an ASCII_HEADER_ASCII_BODY character. The first character represents white, the last character represents black, the characters in between are gradients from white to black.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toInverseAsciiArt

        protected static String[] toInverseAsciiArt​(String aText,
                                                    Font aFont,
                                                    char[] aPalette)
        Same as toAsciiArt(org.refcodes.graphical.RgbPixmap,char[]) with inverted colors (black = white, dark = bright, bright = dark, white = black).
        Parameters:
        aText - The text to be rendered as ASCII-Art.
        aFont - The Font to render the ASCII-Art.
        aPalette - The character palate to use when converting an RGB value to an ASCII_HEADER_ASCII_BODY character. The first character represents white, the last character represents black, the characters in between are gradients from white to black.
        Returns:
        An array of String instances, when printed out in the order as returned, visualize the provided text in the given Font as ASCII-Art.
      • toAscii

        protected static char toAscii​(int aRgbValue,
                                      char[] aPalette)
        Converts an RGB value to an ASCII_HEADER_ASCII_BODY character from a palette if characters as provided.
        Parameters:
        aRgbValue - The RGB value to be converted to an ASCII_HEADER_ASCII_BODY character.
        aPalette - The character palate to use when converting an RGB value to an ASCII_HEADER_ASCII_BODY character. The first character represents white, the last character represents black, the characters in between are gradients from white to black.
        Returns:
        the char
      • toAscii

        protected static char toAscii​(int aRgbValue)
        Converts an RGB value to an ASCII_HEADER_ASCII_BODY character from a palette if characters as provided.
        Parameters:
        aRgbValue - The RGB value to be converted to an ASCII_HEADER_ASCII_BODY character.
        Returns:
        the char
      • getText

        public String[] getText()
        Retrieves the text from the text property.
        Specified by:
        getText in interface TextAccessor
        Returns:
        The text stored by the text property.
      • setText

        public void setText​(String... aText)
        Sets the text for the text property.
        Specified by:
        setText in interface TextAccessor.TextMutator
        Parameters:
        aText - The text to be stored by the text property.
      • toString

        public String toString()
        The String being build by the builder upon the settings of the attributes. In case more then one line has been set as input and the functionality of the builder is applied to each line in separate, then this method returns all of them lines concatenated with a line break between each of them (implementation depended).
        Specified by:
        toString in interface TextAccessor.TextProvider
        Overrides:
        toString in class Object
        Returns:
        The according resulting String