Package org.daisy.braille.embosser
Class BufferedEmbosserWriter
java.lang.Object
org.daisy.braille.embosser.BufferedEmbosserWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,EmbosserProperties
,EmbosserWriter
,EmbosserWriterProperties
Provides an easy way to add a communications contract to an EmbosserWriter.
All events sent to the BufferedEmbosserWriter are kept in memory while the
contract information is collected. When the BufferedEmbosserWriter
is closed, the underlying EmbosserWriter is opened with a contract
matching the events in the communication. The events are then sent
to the underlying EmbosserWriter as they would have been if used directly.
- Author:
- Joel HÃ¥kansson
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.daisy.braille.embosser.EmbosserProperties
EmbosserProperties.PrintMode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
int
Gets the maximum page height in the current configurationint
Gets the maximum row width in the current configurationint
Gets the current row gap, measured as an integer multiple of the dot-to-dot height.boolean
isClosed()
Tests if embosser has been closedboolean
isOpen()
Returns true if embosser is openvoid
newLine()
Starts a new linevoid
newPage()
Starts a new pagevoid
newSectionAndPage
(boolean duplex) Starts a new page on a blank sheet of paper with the specified duplex settings.void
newVolumeSectionAndPage
(boolean duplex) Starts a new page on a blank sheet of paper in a new volume with the specified duplex settings.void
open
(boolean duplex) Opens for writing using the default contractvoid
Opens for writingvoid
setRowGap
(int value) Sets the row gap for following calls to newLine to the specified value, measured as an integer multiple of the dot-to-dot height.boolean
Returns true if this embosser supports 8 dot brailleboolean
Returns true if this embosser supports aligning.boolean
Returns true if this embosser supports duplex printingboolean
Returns true if this embosser supports magazine layout.boolean
Returns true if this embosser has some method for volume handlingboolean
Returns true if this embosser supports z-folding.void
Writes a string of braille to the embosser.
-
Constructor Details
-
BufferedEmbosserWriter
-
-
Method Details
-
getMaxWidth
public int getMaxWidth()Description copied from interface:EmbosserWriterProperties
Gets the maximum row width in the current configuration- Specified by:
getMaxWidth
in interfaceEmbosserWriterProperties
- Returns:
- returns the maximum row width, in characters
-
getMaxHeight
public int getMaxHeight()Description copied from interface:EmbosserWriterProperties
Gets the maximum page height in the current configuration- Specified by:
getMaxHeight
in interfaceEmbosserWriterProperties
- Returns:
- returns the maximum page height, in rows
-
supportsVolumes
public boolean supportsVolumes()Description copied from interface:EmbosserProperties
Returns true if this embosser has some method for volume handling- Specified by:
supportsVolumes
in interfaceEmbosserProperties
- Returns:
- returns true if this embosser supports volumes
-
supports8dot
public boolean supports8dot()Description copied from interface:EmbosserProperties
Returns true if this embosser supports 8 dot braille- Specified by:
supports8dot
in interfaceEmbosserProperties
- Returns:
- returns true if this embosser supports 8 dot braille
-
supportsDuplex
public boolean supportsDuplex()Description copied from interface:EmbosserProperties
Returns true if this embosser supports duplex printing- Specified by:
supportsDuplex
in interfaceEmbosserProperties
- Returns:
- returns true if this embosser supports duplex printing
-
supportsAligning
public boolean supportsAligning()Description copied from interface:EmbosserProperties
Returns true if this embosser supports aligning. This indicates that rows can be padded with whitespace to move the text block horizontally using the value returned bygetMaxWidth
. Should return true for all physical embossers, since they all have a finite row length.- Specified by:
supportsAligning
in interfaceEmbosserProperties
- Returns:
- returns true if this embosser supports aligning, false otherwise.
-
supportsZFolding
public boolean supportsZFolding()Description copied from interface:EmbosserProperties
Returns true if this embosser supports z-folding. This indicates that, if tractor paper is used, the embosser can emboss every other paper upside down with the rear side up so that pages are ordered face up as they fold naturally in the output stack.- Specified by:
supportsZFolding
in interfaceEmbosserProperties
- Returns:
- returns true if this embosser supports z-folding, false otherwise.
-
supportsPrintMode
Description copied from interface:EmbosserProperties
Returns true if this embosser supports magazine layout. This indicates that the embosser can reorder pages and emboss two pages side-by-side on the same side of the paper (and two more on the other side), so that a readable document is created by stapling and folding the output stack in the middle.- Specified by:
supportsPrintMode
in interfaceEmbosserProperties
- Returns:
- returns true if this embosser supports magazine layout, false otherwise.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
write
Description copied from interface:EmbosserWriter
Writes a string of braille to the embosser. Values must be between 0x2800 and 0x28FF. An implementation may supply a complete row of braille in a single chunk. However, an implementation may also call this method repeatedly without any other calls in between.- Specified by:
write
in interfaceEmbosserWriter
- Parameters:
braille
- characters in the range 0x2800 to 0x28FF- Throws:
IOException
-
newLine
Description copied from interface:EmbosserWriter
Starts a new line- Specified by:
newLine
in interfaceEmbosserWriter
- Throws:
IOException
-
newPage
Description copied from interface:EmbosserWriter
Starts a new page- Specified by:
newPage
in interfaceEmbosserWriter
- Throws:
IOException
-
newSectionAndPage
Description copied from interface:EmbosserWriter
Starts a new page on a blank sheet of paper with the specified duplex settings.- Specified by:
newSectionAndPage
in interfaceEmbosserWriter
- Throws:
IOException
-
newVolumeSectionAndPage
Description copied from interface:EmbosserWriter
Starts a new page on a blank sheet of paper in a new volume with the specified duplex settings.- Specified by:
newVolumeSectionAndPage
in interfaceEmbosserWriter
- Throws:
IOException
-
open
Description copied from interface:EmbosserWriter
Opens for writing using the default contract- Specified by:
open
in interfaceEmbosserWriter
- Throws:
IOException
- if an I/O exception of some sort has occurred
-
open
public void open(boolean duplex, Contract contract) throws IOException, ContractNotSupportedException Description copied from interface:EmbosserWriter
Opens for writing- Specified by:
open
in interfaceEmbosserWriter
- Throws:
IOException
- if an I/O exception of some sort has occurredContractNotSupportedException
- if the supplied contract is not supported, that is to say if the contract does not contain information required by the implementation
-
isOpen
public boolean isOpen()Description copied from interface:EmbosserWriter
Returns true if embosser is open- Specified by:
isOpen
in interfaceEmbosserWriter
- Returns:
- returns true if embosser is open, false otherwise
-
isClosed
public boolean isClosed()Description copied from interface:EmbosserWriter
Tests if embosser has been closed- Specified by:
isClosed
in interfaceEmbosserWriter
- Returns:
- returns true if the embosser has been open, but is now closed, false otherwise
-
setRowGap
public void setRowGap(int value) Description copied from interface:EmbosserWriter
Sets the row gap for following calls to newLine to the specified value, measured as an integer multiple of the dot-to-dot height.- Specified by:
setRowGap
in interfaceEmbosserWriter
-
getRowGap
public int getRowGap()Description copied from interface:EmbosserWriter
Gets the current row gap, measured as an integer multiple of the dot-to-dot height.- Specified by:
getRowGap
in interfaceEmbosserWriter
- Returns:
- returns the current row gap
-