com.sap.ip.me.api.pios.printer
Class GraphicPrinter

java.lang.Object
  extended bycom.sap.ip.me.api.pios.connection.Connection
      extended bycom.sap.ip.me.api.pios.printer.PrinterConnection
          extended bycom.sap.ip.me.api.pios.printer.GraphicPrinter

public abstract class GraphicPrinter
extends PrinterConnection

A graphic printer refers to a printer that supports X, Y coordinates to locate text, barcodes, images, or graphics to be printed. The coordinates are specified in points (1/72th of an inch). Fields may also be rotated, if the printer supports rotation.

Example: Draw text rotated 90 degrees
 
 
	Connector connector = Connector.getInstance();
 
	DriverInfo[] printers = connector.listDrivers(ConnectionType.PRINTER);
	PrinterParameters parameters = new PrinterParameters(printers[0]);
	parameters.setPrinterMode(PrinterParameters.GRAPHIC_MODE);
	GraphicPrinter printer = (GraphicPrinter)connector.open(parameters);

	ScalableFont font1 = (ScalableFont) printer.getFont("Scalable");
	font1.setFontSize(12);
		
	printer.drawText(font1, 100, 100, "I like rotation", 
		GraphicPrinter.ROTATE_90_DEGREES);
		
	printer.doPrint(1);
	printer.close();
   
 
 

Since:
MI 2.5
Author:
Abaco
See Also:
Connection, PrinterBarcode, PrinterFont

Nested Class Summary
 
Nested classes inherited from class com.sap.ip.me.api.pios.printer.PrinterConnection
PrinterConnection.Attributes
 
Field Summary
static int NO_ROTATION
          Constant to indicate no rotation.
static int ROTATE_180_DEGREES
          Constant to indicate a rotation of 180 degrees.
static int ROTATE_270_DEGREES
          Constant to indicate a rotation of 270 degrees.
static int ROTATE_90_DEGREES
          Constant to indicate a rotation of 90 degrees.
 
Fields inherited from class com.sap.ip.me.api.pios.printer.PrinterConnection
STATUS_BUSY, STATUS_DATA_ERROR, STATUS_FONT_NOT_AVAILABLE_ERROR, STATUS_IDLE, STATUS_INVALID_COORDINATE_ERROR, STATUS_OUT_OF_MEMORY_ERROR, STATUS_OUT_OF_PAPER, STATUS_UNKNOWN_ERROR
 
Fields inherited from class com.sap.ip.me.api.pios.connection.Connection
attributesFileName, cfgFile, opened, parameters
 
Constructor Summary
protected GraphicPrinter()
          Constructs a new graphic printer connection.
 
Method Summary
abstract  void drawBarcode(PrinterBarcode barcode, float x, float y, byte[] data, int rotate)
          Draws a barcode at the specified coordinates.
abstract  void drawImage(java.lang.String name, float x, float y, int rotate)
          Draws an image at the specified coordinates.
abstract  void drawLine(float x0, float y0, float x1, float y1, float thickness)
          Draws a line using the specified coordinates.
abstract  void drawRectangle(float x, float y, float width, float height, float thickness)
          Draws a rectangle using the specified point coordinate for the left most top corner of the rectangle and the width and height.
abstract  void drawText(PrinterFont font, float x, float y, java.lang.String text, int rotate)
          Draws a text field using the particular font at the specified coordinates.
abstract  void drawTransientImage(java.awt.Image img, float x, float y, int rotate)
          Draws a transient image at the specified coordinates.
abstract  Metrics getPageMetrics()
          Returns the printer page metrics.
 
Methods inherited from class com.sap.ip.me.api.pios.printer.PrinterConnection
advance, clearError, createBarcode, createImage, deleteImage, dispose, doPrint, getFont, getFontConfigurationManager, getPrinterDPI, getPrintHeadWidth, getStatus, listFonts, loadImage, sendRawBytes
 
Methods inherited from class com.sap.ip.me.api.pios.connection.Connection
close, getParameters, isOpen, open
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ROTATION

public static final int NO_ROTATION
Constant to indicate no rotation.

See Also:
Constant Field Values

ROTATE_90_DEGREES

public static final int ROTATE_90_DEGREES
Constant to indicate a rotation of 90 degrees.

See Also:
Constant Field Values

ROTATE_180_DEGREES

public static final int ROTATE_180_DEGREES
Constant to indicate a rotation of 180 degrees.

See Also:
Constant Field Values

ROTATE_270_DEGREES

public static final int ROTATE_270_DEGREES
Constant to indicate a rotation of 270 degrees.

See Also:
Constant Field Values
Constructor Detail

GraphicPrinter

protected GraphicPrinter()
                  throws PIOSException
Constructs a new graphic printer connection.

Throws:
PIOSException - thrown if an error is detected while creating/ opening the printer connection
Method Detail

getPageMetrics

public abstract Metrics getPageMetrics()
                                throws UnsupportedException,
                                       PrinterException
Returns the printer page metrics.

Throws:
UnsupportedException - thrown if page metrics is not supported by the printer
PrinterException - thrown if an error occurs while getting the page size information

drawText

public abstract void drawText(PrinterFont font,
                              float x,
                              float y,
                              java.lang.String text,
                              int rotate)
                       throws UnsupportedException,
                              PrinterException
Draws a text field using the particular font at the specified coordinates. Coordinates are provided in points.

Parameters:
font - the text font
x - the coordinate along horizontal axis
y - the coordinate along vertical axis
text - the text to draw
rotate - the field rotation
Throws:
UnsupportedException - thrown if rotation is not supported by the printer
PrinterException - thrown if an error occurs while drawing the text

drawBarcode

public abstract void drawBarcode(PrinterBarcode barcode,
                                 float x,
                                 float y,
                                 byte[] data,
                                 int rotate)
                          throws UnsupportedException,
                                 PrinterException
Draws a barcode at the specified coordinates. Coordinates are provided in points. Depending on the barcode used, special consideration must be made to format the data accordingly to the selected symbology. Some 2D symbologies require additional parameters specific to the symbology.

Parameters:
barcode - - the PrinterBarcode object that include information of symbology and printing options
x - the coordinate along horizontal axis
y - the coordinate along vertical axis
data - the data that will be encoded in barcode
rotate - the field rotation
Throws:
UnsupportedException - thrown if rotation is not supported by the printer
PrinterException - thrown if an error occurs while drawing the barcode
See Also:
com.sap.ip.me.api.pios.symbology

drawImage

public abstract void drawImage(java.lang.String name,
                               float x,
                               float y,
                               int rotate)
                        throws UnsupportedException,
                               PrinterException
Draws an image at the specified coordinates. Coordinates are provided in points.

Parameters:
name - the name of the image stored at the printer's memory
x - the coordinate along horizontal axis
y - the coordinate along vertical axis
rotate - the field rotation
Throws:
UnsupportedException - thrown if rotation is not supported by the printer
PrinterException - thrown if an error occurs while drawing the image

drawLine

public abstract void drawLine(float x0,
                              float y0,
                              float x1,
                              float y1,
                              float thickness)
                       throws UnsupportedException,
                              PrinterException
Draws a line using the specified coordinates. Coordinates are provided in points.

Parameters:
x0 - the coordinate along horizontal axis for first point
y0 - the coordinate along vertical axis for first point
x1 - the coordinate along horizontal axis for second point
y1 - the coordinate along vertical axis for second point
thickness - the thickness of the line in printer points
Throws:
UnsupportedException - thrown if line drawing is not supported by the printer
PrinterException - thrown when invalid parameter values are used

drawRectangle

public abstract void drawRectangle(float x,
                                   float y,
                                   float width,
                                   float height,
                                   float thickness)
                            throws UnsupportedException,
                                   PrinterException
Draws a rectangle using the specified point coordinate for the left most top corner of the rectangle and the width and height.

Parameters:
x - the coordinate along horizontal axis for left most top rectangle corner
y - the coordinate along vertical axis for left most top rectangle corner
width - the width of the rectangle in points
height - the height of the rectangle in points
thickness - the thickness of the line in points
Throws:
UnsupportedException - thrown if line drawing is not supported by the printer
PrinterException - thrown when invalid parameter values are used

drawTransientImage

public abstract void drawTransientImage(java.awt.Image img,
                                        float x,
                                        float y,
                                        int rotate)
                                 throws UnsupportedException,
                                        PrinterException
Draws a transient image at the specified coordinates. Coordinates are provided in points.

Parameters:
img - the transient image to be printed
x - the coordinate along horizontal axis
y - the coordinate along vertical axis
rotate - the field rotation
Throws:
UnsupportedException - thrown if rotation or drawing transient images is not supported by the printer
PrinterException - thrown if an error occurs while drawing the image


Copyright © 2005 SAP AG. All Rights Reserved.