JHotDraw 7.4.1

org.jhotdraw.draw.print
Class DrawingPageable

java.lang.Object
  extended by org.jhotdraw.draw.print.DrawingPageable
All Implemented Interfaces:
java.awt.print.Pageable

public class DrawingPageable
extends java.lang.Object
implements java.awt.print.Pageable

DrawingPageable can be used to print a Drawing using the java.awt.print API.

Usage:

 Pageable pageable = new DrawingPageable(aDrawing);
 PrinterJob job = PrinterJob.getPrinterJob();
 job.setPageable(pageable);
 if (job.printDialog()) {
     try {
         job.print();
      } catch (PrinterException e) {
          ...inform the user that we couldn't print...
      }
 }
 

Version:
$Id: DrawingPageable.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer
See Also:
PrintFileAction

Field Summary
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Constructor Summary
DrawingPageable(Drawing drawing)
          Creates a new instance.
 
Method Summary
 int getNumberOfPages()
           
 java.awt.print.PageFormat getPageFormat(int pageIndex)
           
 java.awt.print.Printable getPrintable(int pageIndex)
           
 int printPage(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
           
protected  void setRenderingHints(java.awt.Graphics2D g)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrawingPageable

public DrawingPageable(Drawing drawing)
Creates a new instance.

Method Detail

getNumberOfPages

public int getNumberOfPages()
Specified by:
getNumberOfPages in interface java.awt.print.Pageable

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
                                        throws java.lang.IndexOutOfBoundsException
Specified by:
getPageFormat in interface java.awt.print.Pageable
Throws:
java.lang.IndexOutOfBoundsException

getPrintable

public java.awt.print.Printable getPrintable(int pageIndex)
                                      throws java.lang.IndexOutOfBoundsException
Specified by:
getPrintable in interface java.awt.print.Pageable
Throws:
java.lang.IndexOutOfBoundsException

printPage

public int printPage(java.awt.Graphics graphics,
                     java.awt.print.PageFormat pageFormat,
                     int pageIndex)
              throws java.awt.print.PrinterException
Throws:
java.awt.print.PrinterException

setRenderingHints

protected void setRenderingHints(java.awt.Graphics2D g)

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.