superwaba.ext.xplat.io.print
Class PrintManager

java.lang.Object
  |
  +--superwaba.ext.xplat.io.print.PrintManager

public abstract class PrintManager
extends Object

This class represents a print manager, which is extended by the drivers to provide a common way to handle the printer. Please be careful when using these methods; any error may freeze the device.


Field Summary
protected  Graphics g
          The Graphics instance that may be assigned to this print manager
protected  Settings set
          The Settings instance that may be assigned to this print manager
protected  TypeWriter tw
          The TypeWriter instance that may be assigned to this print manager
 
Constructor Summary
protected PrintManager()
          This class cannot be instantiated by its constructor
 
Method Summary
abstract  void close()
          Closes this print manager.
abstract  void finishPage()
          Ends a page, flushing the contents.
abstract  void formFeed()
          Do a form feed.
abstract  String getDetailedErrorMessage(PrinterException e)
          Given the PrinterException, returns a detailed error message for the problem.
abstract  FontMetrics getFontMetrics(Font f)
          Gets a FontMetrics object for the given font
 Graphics getGraphics()
          May return the Graphics instance if this print manager was opened using textMode = true.
 Settings getSettings()
          Will return the Settings instance assigned to this print manager
 TypeWriter getTypeWriter()
          May return the TypeWritter instance if this print manager was opened using textMode = false.
abstract  void open(String printerName, String portName, int baudRate, boolean textMode)
          This method must be extended and must set the fields Graphics, TypeWriter and Settings accordingly.
abstract  void startPage()
          Start a new page.
abstract  int writeBytes(byte[] buf, int start, int len)
          Send bytes to the printer, usualy scape codes and contents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, toString, wait, wait
 

Field Detail

g

protected Graphics g
The Graphics instance that may be assigned to this print manager

tw

protected TypeWriter tw
The TypeWriter instance that may be assigned to this print manager

set

protected Settings set
The Settings instance that may be assigned to this print manager
Constructor Detail

PrintManager

protected PrintManager()
This class cannot be instantiated by its constructor
Method Detail

open

public abstract void open(String printerName,
                          String portName,
                          int baudRate,
                          boolean textMode)
                   throws PrinterException
This method must be extended and must set the fields Graphics, TypeWriter and Settings accordingly. Not all fields are required to be used.

getGraphics

public Graphics getGraphics()
                     throws NotSupportedException
May return the Graphics instance if this print manager was opened using textMode = true. Will throw NotSupportedException otherwise.

getTypeWriter

public TypeWriter getTypeWriter()
                         throws NotSupportedException
May return the TypeWritter instance if this print manager was opened using textMode = false. Will throw NotSupportedException otherwise.

getSettings

public Settings getSettings()
Will return the Settings instance assigned to this print manager

getFontMetrics

public abstract FontMetrics getFontMetrics(Font f)
Gets a FontMetrics object for the given font

close

public abstract void close()
                    throws PrinterException
Closes this print manager.

formFeed

public abstract void formFeed()
                       throws PrinterException,
                              NotSupportedException
Do a form feed. You must always call formFeed before calling finishPage.

startPage

public abstract void startPage()
                        throws PrinterException
Start a new page. You must always start a new page before writting to the printer.

finishPage

public abstract void finishPage()
                         throws PrinterException
Ends a page, flushing the contents. You must always call formFeed before calling finishPage.

writeBytes

public abstract int writeBytes(byte[] buf,
                               int start,
                               int len)
                        throws PrinterException,
                               ArrayIndexOutOfBoundsException,
                               NotSupportedException
Send bytes to the printer, usualy scape codes and contents

getDetailedErrorMessage

public abstract String getDetailedErrorMessage(PrinterException e)
Given the PrinterException, returns a detailed error message for the problem.