ach.image
Class PrintImage2

java.lang.Object
  extended byach.image.PrintImage2
All Implemented Interfaces:
java.lang.Runnable

public class PrintImage2
extends java.lang.Object
implements java.lang.Runnable

PrintImage2.java
Copyright (c) 1998-2001 Helge Hackbarth, All Rights Reserved.
Enhancement to class PrintImage for printing in Java 2 environments.

THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.


Constructor Summary
PrintImage2(java.awt.Frame parent, EMemImageSource imgSrc, java.util.Hashtable props, BatchPrinter batchPrinter)
          Constructor.
PrintImage2(java.awt.Frame parent, EMemImageSource imgSrc, java.awt.Rectangle printArea, java.awt.print.PrinterJob printerJob)
          Constructor.
 
Method Summary
static java.awt.Dimension getPageDimension(java.lang.Object printerJob)
          Retrieve the dimension of the default paper setting in a JDK 1.1 compatible manner.
static void printBook(java.lang.Object printerJob, java.lang.Object book)
          Print a pageable object (e.g. an instance of Book) through a Java 2 PrinterJob.
static java.lang.Object printImage(java.lang.Object printerJob, java.lang.Object book, java.awt.Image img, int iWidth, int iHeight, java.awt.Dimension printDimension, double pX, double pY, double pWidth, double pHeight, java.util.Hashtable props)
          Add an image to a "Book" (instance of class Book) to be printed in a specified location and size.
 void run()
          Run Java 2 (JDK 1.2) compatible printing (automatically called as separate thread by start()).
 void start()
          Start printing as a seperate thread (calls run() automatically).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintImage2

public PrintImage2(java.awt.Frame parent,
                   EMemImageSource imgSrc,
                   java.util.Hashtable props,
                   BatchPrinter batchPrinter)
Constructor. Used to specify all printing relevant parameters with dialog boxes.

Parameters:
parent - the parent frame
imgSrc - image producer derived from EMemImageSource
props - Hashtable with properties (values for "PAGESIZE", "ORIENTATION", "LEFTMARGIN", "RIGHTMARGIN", "TOPMARGIN", "BOTTOMMARGIN"); "PAGESIZE"="Executive", "Letter", "Legal", "A4", "A3", "Tabloid", "A2", "A1", "A0"; "ORIENTATION"=true for portrait, false for landscape; "AUTOROTATEALLOWED"=true or false; margins specified in 1/1000 cm = 1/2540 inch
batchPrinter - allows to hand over a callback method for printing a sequence of slides (see interface BatchPrinter)

PrintImage2

public PrintImage2(java.awt.Frame parent,
                   EMemImageSource imgSrc,
                   java.awt.Rectangle printArea,
                   java.awt.print.PrinterJob printerJob)
Constructor. Allows to print an image without further print dialogs using a given (JDK 1.2 type) PrinterJob.

Parameters:
parent - the parent frame
imgSrc - image producer derived from EMemImageSource
printArea - Rectangle to be used for printing (JDK >= 1.1.6 uses points (1/72 inch), other VMs relate to screen resolution)
printerJob - print job (must be created once before and can be reused for all printouts)
Method Detail

start

public void start()
Start printing as a seperate thread (calls run() automatically). If you want to print without separate thread, please call run() method immediately.


run

public void run()
Run Java 2 (JDK 1.2) compatible printing (automatically called as separate thread by start()).

Specified by:
run in interface java.lang.Runnable

printBook

public static void printBook(java.lang.Object printerJob,
                             java.lang.Object book)
Print a pageable object (e.g. an instance of Book) through a Java 2 PrinterJob. Use generic object parameters instead of classes in order to be able to be compiled into applications that may not make use of Java 2 classes.

Parameters:
printerJob - an instance of PrinterJob
book - an object implementing the Pageable interface (e.g. a Book)

getPageDimension

public static java.awt.Dimension getPageDimension(java.lang.Object printerJob)
Retrieve the dimension of the default paper setting in a JDK 1.1 compatible manner. Use generic object parameters instead of classes in order to be able to be compiled into applications that may not make use of Java 2 classes.

Parameters:
printerJob - an instance of PrinterJob

printImage

public static java.lang.Object printImage(java.lang.Object printerJob,
                                          java.lang.Object book,
                                          java.awt.Image img,
                                          int iWidth,
                                          int iHeight,
                                          java.awt.Dimension printDimension,
                                          double pX,
                                          double pY,
                                          double pWidth,
                                          double pHeight,
                                          java.util.Hashtable props)
Add an image to a "Book" (instance of class Book) to be printed in a specified location and size. If the the book object is not yet instantiated, it will be instantiated with class Book. Use generic object parameters instead of classes in order to be able to be compiled into applications that may not make use of Java 2 classes.

Parameters:
printerJob - an instance of PrinterJob
book - an object implementing the Pageable interface (e.g. a Book)
img - specifying the image to be printed
iWidth - specifying the width of the image in pixels
iHeight - specifying the height of the image in pixels
printDimension - width and height of image in print units (72 dpi)
pX - the horizontal location on the page where image should be printed (in print units (72 dpi))
pY - the vertical location on the page where image should be printed (in print units (72 dpi))
pWidth - the width of the image on the page (in print units (72 dpi))
pHeight - the height of the image on the page (in print units (72 dpi))
props - a hashtable containing additional properties, e.g. annotations
Returns:
book Object (instantiated if null before)