com.jrefinery.report.targets.pageable.output
Class EpsonPrinterCommandSet

java.lang.Object
  extended bycom.jrefinery.report.targets.pageable.output.PrinterCommandSet
      extended bycom.jrefinery.report.targets.pageable.output.EpsonPrinterCommandSet

public class EpsonPrinterCommandSet
extends PrinterCommandSet

Implements the printer command set for Epson ESC/P compatible printers. This implementation assumes that AutoLF is disabled.

This implementation is untested. If you have access to an ESC/P compatible printer, you could try this command set to improve printing quality.

Author:
Thomas Morgner
See Also:
PrinterCommandSet, PlainTextOutputTarget

Field Summary
 
Fields inherited from class com.jrefinery.report.targets.pageable.output.PrinterCommandSet
CARRIAGE_RETURN, FORM_FEED, LINE_FEED, SELECT_FONT_COURIER, SELECT_FONT_FROM_MENU, SELECT_FONT_GOTHIC, SELECT_FONT_OCR_A, SELECT_FONT_OCR_B, SELECT_FONT_ORATOR, SELECT_FONT_PRESTIGE, SELECT_FONT_ROMAN, SELECT_FONT_SWISS, SELECT_FONT_SWISS_BOLD, SPACE
 
Constructor Summary
EpsonPrinterCommandSet(java.io.OutputStream out, java.awt.print.PageFormat format, int defaultCPI, int defaultLPI)
          Creates a new EpsonPrinterCommandSet.
 
Method Summary
 boolean isAutoLf()
          Always returns false, as ESC/P has we assume AutoLF to be disabled for all Epson-Printers.
 boolean isEncodingSupported(java.lang.String encoding)
          Checks, whether the given encoding string is supported by this printer command set.
 void resetPrinter()
          Resets the printer to the default values.
 void setAutoLF(boolean autoLF)
          This implementation is empty, the Epson Printer Language defines no command to alter the AutoLF feature from within a programm, we assume no AutoLF.
 void setCharacterWidth(byte charWidth)
          Defines the character width for the current font.
 void setCodePage(java.lang.String codepage)
          Defines the code page for the text to be printed.
 void setFont(byte fontSelection)
          Defines the new font for the printer.
 void setFontStyle(boolean bold, boolean italic, boolean underline, boolean strike)
          Defines the font style for the printed text.
 void setHorizontalBorder(int left, int right)
          Defines the horizontal borders for the current paper.
 void setLineSpacing(int spaceInInch)
          Defines the line spacing for the printer, the spacing is given in 1/1440 inches.
 void setPaperSize(int lines)
          Defines the papersize in lines.
 void setPrintQuality(boolean letterQuality)
          Defines the printing quality for the printed text.
 void startLine()
          This implementation is empty, as epson printers handle the left border automaticly.
 
Methods inherited from class com.jrefinery.report.targets.pageable.output.PrinterCommandSet
endLine, endPage, flush, getBorderBottom, getBorderLeft, getBorderRight, getBorderTop, getCharacterWidth, getCodepage, getDefaultCPI, getDefaultLPI, getFont, getLineSpacing, getOut, getPageFormat, getPaperSize, isBold, isItalic, isLetterQuality, isStrikethrough, isUnderline, printChunk, printEmptyChunk, setVerticalBorder, startPage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EpsonPrinterCommandSet

public EpsonPrinterCommandSet(java.io.OutputStream out,
                              java.awt.print.PageFormat format,
                              int defaultCPI,
                              int defaultLPI)
Creates a new EpsonPrinterCommandSet.

Parameters:
out - the target output stream
format - the pageformat of the used report
defaultCPI - the characters-per-inch for the output.
defaultLPI - the lines-per-inch for the output.
Method Detail

setFont

public void setFont(byte fontSelection)
             throws java.io.IOException
Defines the new font for the printer. The font must be one of the supported fonts, the available fonts are defined in PrinterCommandSet. You may use additional fonts, if your printer supports them.

To use these fonts, specify the font parameter for the escape sequence 0x1b, 0x6b, [font-selection] as defined in your printers reference manual.

Overrides:
setFont in class PrinterCommandSet
Parameters:
fontSelection - the printers font selection token.
Throws:
java.io.IOException - if there was an IOError while writing the command.

setCharacterWidth

public void setCharacterWidth(byte charWidth)
                       throws java.io.IOException
Defines the character width for the current font. The width is specified in Characters-per-inch. Valid values are 10, 12, 15, 17 and 20 cpi.

Overrides:
setCharacterWidth in class PrinterCommandSet
Parameters:
charWidth - the character width in CPI.
Throws:
java.io.IOException - if there was an IOError while writing the command or if the character width is not supported by the printer.

setFontStyle

public void setFontStyle(boolean bold,
                         boolean italic,
                         boolean underline,
                         boolean strike)
                  throws java.io.IOException
Defines the font style for the printed text. This implementation does not support strike-through, due to a missing reference manual for epson printers.

Overrides:
setFontStyle in class PrinterCommandSet
Parameters:
bold - true, if the text should be printed in bold mode.
italic - true, if the text should be italic, false otherwise
underline - true, if the text should be underlined, false otherwise
strike - true, if the text should be strikethrough, false otherwise
Throws:
java.io.IOException - if there was an IOError while writing the command

setPaperSize

public void setPaperSize(int lines)
                  throws java.io.IOException
Defines the papersize in lines.

Overrides:
setPaperSize in class PrinterCommandSet
Parameters:
lines - the number of lines that could be printed on a single page.
Throws:
java.io.IOException - if there was an IOError while writing the command

setHorizontalBorder

public void setHorizontalBorder(int left,
                                int right)
                         throws java.io.IOException
Defines the horizontal borders for the current paper. The borders are given in characters.

Overrides:
setHorizontalBorder in class PrinterCommandSet
Parameters:
left - the number of spaces printed on the start of a line.
right - the number of spaces left free on the right paper border.
Throws:
java.io.IOException - if an IOException occured while updating the printer state.

setLineSpacing

public void setLineSpacing(int spaceInInch)
                    throws java.io.IOException
Defines the line spacing for the printer, the spacing is given in 1/1440 inches.

Overrides:
setLineSpacing in class PrinterCommandSet
Parameters:
spaceInInch - the linespacing in 1/1440 inches.
Throws:
java.io.IOException - if an IOException occured while updating the printer state.

setCodePage

public void setCodePage(java.lang.String codepage)
                 throws java.io.IOException
Defines the code page for the text to be printed. The codepage is an 8-Bit encoding scheme to print non-ascii-characters.

Overrides:
setCodePage in class PrinterCommandSet
Parameters:
codepage - the new codepage that should be used.
Throws:
java.io.IOException - if there was an IOError while writing the command

setAutoLF

public void setAutoLF(boolean autoLF)
               throws java.io.IOException
This implementation is empty, the Epson Printer Language defines no command to alter the AutoLF feature from within a programm, we assume no AutoLF.

Overrides:
setAutoLF in class PrinterCommandSet
Parameters:
autoLF - this parameter is ignored.
Throws:
java.io.IOException - if there was an IOError while writing the command

isAutoLf

public boolean isAutoLf()
Always returns false, as ESC/P has we assume AutoLF to be disabled for all Epson-Printers.

Overrides:
isAutoLf in class PrinterCommandSet
Returns:
always false, as we have to assume that AutoLF is disabled.

setPrintQuality

public void setPrintQuality(boolean letterQuality)
                     throws java.io.IOException
Defines the printing quality for the printed text. Set to true, to enable LetterQuality printing, false enables Draft-Quality.

Overrides:
setPrintQuality in class PrinterCommandSet
Parameters:
letterQuality - true, if letter quality should be used, false for draft-quality
Throws:
java.io.IOException - if there was an IOError while writing the command

startLine

public void startLine()
               throws java.io.IOException
This implementation is empty, as epson printers handle the left border automaticly.

Overrides:
startLine in class PrinterCommandSet
Throws:
java.io.IOException - if there was an IOError while writing the command

resetPrinter

public void resetPrinter()
                  throws java.io.IOException
Resets the printer to the default values. This performs a reset and then sets the values defined for this CommandSet.

Overrides:
resetPrinter in class PrinterCommandSet
Throws:
java.io.IOException - if there was an IOError while writing the command

isEncodingSupported

public boolean isEncodingSupported(java.lang.String encoding)
Checks, whether the given encoding string is supported by this printer command set.

Overrides:
isEncodingSupported in class PrinterCommandSet
Parameters:
encoding - the encoding that should be tested.
Returns:
true, if the encoding is valid, false otherwise.