Class DotMapper
- java.lang.Object
-
- org.daisy.braille.utils.impl.tools.embosser.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)
andflush()
. The patterns are then mapped internally using a mapping configuration. The result is extracted usingreadLine()
andreadLine(boolean)
. To check if there is more data usehasMoreFullLines()
andhasMoreLines()
.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 Summary
Constructors Constructor Description DotMapper(int width)
Creates a new dot mapper with the specified line length and default configuration.DotMapper(int width, DotMapperConfiguration config)
Creates a new dot mapper with the specified line length and configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
Flushes the last line of characters.boolean
hasMoreFullLines()
Returns true if there are at least one full height line to extract withreadLine()
orreadLine(boolean)
.boolean
hasMoreLines()
Returns true if there is more data to extract withreadLine()
orreadLine(boolean)
.void
newLine(int rowgap)
Starts a new line.String
readLine()
Reads a line from the output buffer.String
readLine(boolean trimTrailing)
Reads a line from the output buffer.void
write(String braille)
Writes a string of braille.
-
-
-
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 widthconfig
- 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 withreadLine()
orreadLine(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 withreadLine()
orreadLine(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 withreadLine()
orreadLine(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
-
-