org.gerhardb.lib.print
Class PrintableBase

java.lang.Object
  extended by org.gerhardb.lib.print.PrintableBase
All Implemented Interfaces:
java.awt.print.Pageable, java.awt.print.Printable, MediaPageable
Direct Known Subclasses:
PageableImage

public abstract class PrintableBase
extends java.lang.Object
implements java.awt.print.Printable, java.awt.print.Pageable, MediaPageable

PrintableBase


Field Summary
protected  double centerX
           
protected  double centerY
           
static java.lang.String DEFAULT_FOOTER
           
protected  float fontTheta
           
protected  double myBottomMargin
           
protected  double myBottomPictureMargin
           
protected  java.awt.Graphics2D myBuffGraphics
           
protected  java.awt.BasicStroke myDashed
           
protected  java.awt.font.FontRenderContext myFontRenderContext
           
protected  double myLeftMargin
           
protected  int myNumberOfPages
           
protected  PBO myPBO
           
protected  int myPriorPageIndex
           
protected  double myRightMargin
           
protected  java.awt.BasicStroke myStroke
           
protected  double myTopMargin
           
protected  double myTopPictureMargin
           
static java.lang.String PAGE_COUNT
           
static java.lang.String PAGE_INDEX
           
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Constructor Summary
PrintableBase(PBO pbo)
           
PrintableBase(java.lang.String header)
           
 
Method Summary
 java.lang.String convert(java.lang.String text, int pageIndex)
           
protected abstract  void drawPage(int pageIndex)
          This is what you override!
protected  void drawTestPage()
           
 javax.print.Doc getDoc(MediaFormat mediaFormat, int pageIndex)
           
protected  java.awt.Font getFont(java.lang.String fontFamily, int size, float theta)
           
protected  MediaFormat getMediaFormat()
           
 int getNumberOfPages()
          Count from 1.
 java.awt.print.PageFormat getPageFormat(int pageIndex)
           
 java.awt.print.Printable getPrintable(int pageIndex)
           
 void imprint(PrintableBase that)
           
abstract  PrintableBase makeCopy()
           
 boolean print(java.awt.Graphics2D g2, MediaFormat mediaFormat, int pageIndex, boolean buffer)
           
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
           
protected  float scaleDPI(float dpi)
           
 int scaleDPI(int dpi)
           
 void setPageFormat(java.awt.print.PageFormat pf)
           
protected  void showDebug()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAGE_INDEX

public static final java.lang.String PAGE_INDEX
See Also:
Constant Field Values

PAGE_COUNT

public static final java.lang.String PAGE_COUNT
See Also:
Constant Field Values

DEFAULT_FOOTER

public static final java.lang.String DEFAULT_FOOTER

myPBO

protected PBO myPBO

centerX

protected double centerX

centerY

protected double centerY

myLeftMargin

protected double myLeftMargin

myRightMargin

protected double myRightMargin

myTopMargin

protected double myTopMargin

myBottomMargin

protected double myBottomMargin

myTopPictureMargin

protected double myTopPictureMargin

myBottomPictureMargin

protected double myBottomPictureMargin

myPriorPageIndex

protected int myPriorPageIndex

myNumberOfPages

protected int myNumberOfPages

myStroke

protected java.awt.BasicStroke myStroke

myDashed

protected java.awt.BasicStroke myDashed

fontTheta

protected float fontTheta

myFontRenderContext

protected java.awt.font.FontRenderContext myFontRenderContext

myBuffGraphics

protected java.awt.Graphics2D myBuffGraphics
Constructor Detail

PrintableBase

public PrintableBase(PBO pbo)

PrintableBase

public PrintableBase(java.lang.String header)
Method Detail

imprint

public void imprint(PrintableBase that)

getNumberOfPages

public int getNumberOfPages()
Count from 1. So a one page document will return 1.

Specified by:
getNumberOfPages in interface java.awt.print.Pageable
Specified by:
getNumberOfPages in interface MediaPageable

getPrintable

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

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
Specified by:
getPageFormat in interface java.awt.print.Pageable
Specified by:
getPageFormat in interface MediaPageable

print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException

getDoc

public javax.print.Doc getDoc(MediaFormat mediaFormat,
                              int pageIndex)
                       throws java.io.IOException
Specified by:
getDoc in interface MediaPageable
Throws:
java.io.IOException

print

public boolean print(java.awt.Graphics2D g2,
                     MediaFormat mediaFormat,
                     int pageIndex,
                     boolean buffer)
              throws java.awt.print.PrinterException
Throws:
java.awt.print.PrinterException

setPageFormat

public void setPageFormat(java.awt.print.PageFormat pf)
Specified by:
setPageFormat in interface MediaPageable

convert

public java.lang.String convert(java.lang.String text,
                                int pageIndex)

getMediaFormat

protected MediaFormat getMediaFormat()

scaleDPI

public int scaleDPI(int dpi)

scaleDPI

protected float scaleDPI(float dpi)

makeCopy

public abstract PrintableBase makeCopy()

drawPage

protected abstract void drawPage(int pageIndex)
                          throws java.awt.print.PrinterException
This is what you override!

Parameters:
pageFormat -
Throws:
java.awt.print.PrinterException

getFont

protected java.awt.Font getFont(java.lang.String fontFamily,
                                int size,
                                float theta)

showDebug

protected void showDebug()

drawTestPage

protected void drawTestPage()


Copyright ? 2007 Gerhard Beck. All rights reserved. Subject to GPL.