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

java.lang.Object
  |
  +--com.jrefinery.report.targets.pageable.output.PrinterCommandSet
        |
        +--com.jrefinery.report.targets.pageable.output.IBMPrinterCommandSet

public class IBMPrinterCommandSet
extends PrinterCommandSet

Implements the printer command set for IBM compatible printers.

This implementation is untested. If you have access to an IBM 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
IBMPrinterCommandSet(java.io.OutputStream out, java.awt.print.PageFormat format, int defaultCPI, int defaultLPI)
          Creates a new IBMPrinterCommandSet.
 
Method Summary
 void endPage()
          This implementation send the form feed command, IBM printers handle the bottom border automaticly.
 boolean isEncodingSupported(java.lang.String encoding)
          Checks, whether the given encoding string is supported by this printer command set.
 void setAutoLF(boolean autoLF)
          Defines whether to print in AutoLF mode.
 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 setVerticalBorder(int top, int bottom)
          Defines the horizontal borders for the current paper.
 void startLine()
          This implementation is empty, as IBM printers handle the left border automaticly.
 void startPage()
          This implementation is empty, as IBM printers handle the top borders automaticly.
 
Methods inherited from class com.jrefinery.report.targets.pageable.output.PrinterCommandSet
endLine, flush, getBorderBottom, getBorderLeft, getBorderRight, getBorderTop, getCharacterWidth, getCodepage, getDefaultCPI, getDefaultLPI, getFont, getLineSpacing, getOut, getPageFormat, getPaperSize, isAutoLf, isBold, isItalic, isLetterQuality, isStrikethrough, isUnderline, printChunk, printEmptyChunk, resetPrinter, setPrintQuality
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IBMPrinterCommandSet

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

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. The IBM-CommandSet does not support strike-through.

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.

setVerticalBorder

public void setVerticalBorder(int top,
                              int bottom)
                       throws java.io.IOException
Defines the horizontal borders for the current paper. The borders are given in characters.

Overrides:
setVerticalBorder in class PrinterCommandSet
Parameters:
top - the number of blank lines printed on the start of a page.
bottom - the number of blank lines printed at the end of a page
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
Defines whether to print in AutoLF mode. If AutoLF is enabled, then a linefeed character is automaticly printed after every <CR> character.

Overrides:
setAutoLF in class PrinterCommandSet
Parameters:
autoLF - the new autoLF state
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 IBM printers handle the left border automaticly.

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

startPage

public void startPage()
               throws java.io.IOException
This implementation is empty, as IBM printers handle the top borders automaticly.

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

endPage

public void endPage()
             throws java.io.IOException
This implementation send the form feed command, IBM printers handle the bottom border automaticly.

Overrides:
endPage 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.