Class DotMapper


  • public class DotMapper
    extends Object

    Provides a utility to map unicode braille patterns to a braille graphics mode. This can be useful when embossing 8-dot files on an embosser using a 6-dot table, or when converting 6-dot graphics into 8-dot graphics.

    Data is added via write(String), newLine(int) and flush(). The patterns are then mapped internally using a mapping configuration. The result is extracted using readLine() and readLine(boolean). To check if there is more data use hasMoreFullLines() and hasMoreLines().

    Note that in order to create the same appearance as the the original patterns, the resulting patterns should be embossed without any row spacing.

    • Constructor Detail

      • DotMapper

        public DotMapper​(int width)
        Creates a new dot mapper with the specified line length and default configuration. The default configuration maps 8-dot unicode patterns to 6-dot unicode patterns: Dots 7 and 8 of the first cell are shifted to dots 1 and 4 of the first cell of the following line. Dots 1 and 4 of the first cell of the second line are subsequently shifted to dots 2 and 5 of the first cell of the second line and so on.
        Parameters:
        width - the length of the lines, in characters
      • DotMapper

        public DotMapper​(int width,
                         DotMapperConfiguration config)
        Creates a new dot mapper with the specified line length and configuration.
        Parameters:
        width - the width
        config - the configuration
    • Method Detail

      • write

        public void write​(String braille)
        Writes a string of braille. Values must be between 0x2800 and 0x28FF.
        Parameters:
        braille - characters in the range 0x2800 to 0x28FF
        Throws:
        IllegalArgumentException - if the number of characters exceeds the line width
      • newLine

        public void newLine​(int rowgap)
        Starts a new line.
        Parameters:
        rowgap - the row gap following the line currently in the buffer
      • flush

        public void flush()
        Flushes the last line of characters. This will empty the input buffer and add them to the output buffer that can be read with readLine() or readLine(boolean). This is equal to calling newLine(0).
      • hasMoreFullLines

        public boolean hasMoreFullLines()
        Returns true if there are at least one full height line to extract with readLine() or readLine(boolean).
        Returns:
        true if there are at least one full height line, false otherwise
      • hasMoreLines

        public boolean hasMoreLines()
        Returns true if there is more data to extract with readLine() or readLine(boolean).
        Returns:
        returns true if there is more data, false otherwise
      • readLine

        public String readLine()
        Reads a line from the output buffer. When the last line is read, the grid alignment resets (the characters are padded to their full cell height).
        Returns:
        returns the line or null if the buffer is empty
      • readLine

        public String readLine​(boolean trimTrailing)
        Reads a line from the output buffer. When the last line is read, the grid alignment resets (the characters are padded to their full cell height).
        Parameters:
        trimTrailing - when true, trailing base characters are trimmed
        Returns:
        returns the line or null if the buffer is empty