com.levigo.jadice.printer
Class AbstractPrinter

java.lang.Object
  extended by com.levigo.jadice.printer.AbstractPrinter
Direct Known Subclasses:
Printer

public abstract class AbstractPrinter
extends Object

Abstract superclass of all printer implementations


Nested Class Summary
protected  class AbstractPrinter.BasicPageable
           
 
Field Summary
protected  PrintJobConfiguration cfg
           
protected  int currentPageIndex
          Current printed page index for pageSelection array.
protected  PrintErrorHandler errorHandler
          The PrintErrorHandler to be applied when a print error occurred.
protected  int lastPage
          Last page processed saved here to indicate a page change to set new page index from page selection array.
 Pageable myPageable
           
protected  List<PrinterException> printerExceptionList
          A list of printer exceptions, which may have occurred using this printer
 
Constructor Summary
AbstractPrinter(PrintJobConfiguration cfg)
           
 
Method Summary
 void addException(PrinterException e)
           
 boolean doPrint()
          Performs synchronous printing.
 void firePrintEvent(PrintEvent printEvent)
          Fires a print page print event for a page contained in the book to print.
 List<Class<? extends Annotation>> getAnnotationsToDisable()
          Return current annotation classes disabled for printing.
 PrintErrorHandler getErrorHandler()
           
 List<PrinterException> getPrinterExceptions()
           
 PrinterJob getPrinterJob()
          Gets the job.
 PrintJobConfiguration getPrintJobConfiguration()
           
 PrintRequestAttributeSet getPrintRequestAttributeSet()
          Returns the PrintRequestAttributeSet to apply while printing.
 void initializePrintCache()
          Creates a fresh instance of the cache.
 boolean isPrintAllAnnotationsUsed()
          Return current flag.
static boolean isPrinting()
          Determines whether this method is called from within a print process.
 void reset()
          Resets this printer.
A fresh PrintJobConfiguration with default settings will be set and a new PrinterJob is assigned.
 void resetPrintCache()
          Clears the cache instance and frees the resources.
 void resetPrinterExceptions()
           
 void setAnnotationsToDisable(List<Class<? extends Annotation>> allAnnotationsToDisable)
          Sets a list containing annotation class (e.g.
 void setErrorHandler(PrintErrorHandler errorHandler)
           
 void setPrintAllAnnotations(boolean doForcePrintAllAnnotations)
          Sets a flag to print all annotation types.
 void setPrinterJob(PrinterJob aPrinterJob)
          Associates a printer job.
protected static void setPrinting(boolean value)
           
 void setPrintRequestAttributeSet(PrintRequestAttributeSet attributes)
          Sets the attributes to be applied by the printer job for printing.
protected  PageFormat validatePageFormat(PageFormat aPageFormat)
          Validates given pageformat, logs an error message, if given pageformat is not valid and returns a correct pageformat.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myPageable

public final Pageable myPageable

cfg

protected PrintJobConfiguration cfg

errorHandler

protected PrintErrorHandler errorHandler
The PrintErrorHandler to be applied when a print error occurred.


printerExceptionList

protected List<PrinterException> printerExceptionList
A list of printer exceptions, which may have occurred using this printer


currentPageIndex

protected int currentPageIndex
Current printed page index for pageSelection array. Points to current page to print.


lastPage

protected int lastPage
Last page processed saved here to indicate a page change to set new page index from page selection array. -1 must be initial value.

Constructor Detail

AbstractPrinter

public AbstractPrinter(PrintJobConfiguration cfg)
                throws JadiceException
Parameters:
cfg - basic print job configuration
Throws:
JadiceException - especially if permissions prohibit export or print.
Method Detail

isPrinting

public static boolean isPrinting()
Determines whether this method is called from within a print process.
It is used by page segments, renderers etc. which need to determine, whether they are called from within a print process.

Returns:
true if this method is called from within a print process,
false if not.

setPrinting

protected static void setPrinting(boolean value)
Parameters:
value - true if printer is in a print process, false if not.

initializePrintCache

public void initializePrintCache()
Creates a fresh instance of the cache. Only done if cache is null.


resetPrintCache

public void resetPrintCache()
Clears the cache instance and frees the resources.


firePrintEvent

public void firePrintEvent(PrintEvent printEvent)
Fires a print page print event for a page contained in the book to print.

Parameters:
printEvent - the print event to fire, if given print event is null no print event will be fired.

doPrint

public boolean doPrint()
Performs synchronous printing.

Returns:
true if print succeeded
false if not.

getPrinterJob

public PrinterJob getPrinterJob()
Gets the job.

Returns:
Returns a PrinterJob

setPrinterJob

public void setPrinterJob(PrinterJob aPrinterJob)
Associates a printer job.

Parameters:
aPrinterJob - The job to set

getPrintRequestAttributeSet

public PrintRequestAttributeSet getPrintRequestAttributeSet()
Returns the PrintRequestAttributeSet to apply while printing.

Returns:
PrintRequestAttributeSet

setPrintRequestAttributeSet

public void setPrintRequestAttributeSet(PrintRequestAttributeSet attributes)
Sets the attributes to be applied by the printer job for printing.

This method will be called when a AbstractPrintDialog was committed by the user, to set the actually choosen print request attributes.

Predefined attributes, set with this method, before opening a AbstractPrintDialog will be ignored and overriden, when the dialog is closed and acknowledged by the user.

Parameters:
attributes - a set of attributes for the job

validatePageFormat

protected PageFormat validatePageFormat(PageFormat aPageFormat)
Validates given pageformat, logs an error message, if given pageformat is not valid and returns a correct pageformat.

Parameters:
aPageFormat - pageformat to validate
Returns:
PageFormat valid pageformat

setAnnotationsToDisable

public void setAnnotationsToDisable(List<Class<? extends Annotation>> allAnnotationsToDisable)
Sets a list containing annotation class (e.g. TextAnnotation.class) which should not be printed. Default value is null -> all annotation types defined in the given render context will be printed. To clear selection set null.

Parameters:
allAnnotationsToDisable - a list containing annotation classes.

getAnnotationsToDisable

public List<Class<? extends Annotation>> getAnnotationsToDisable()
Return current annotation classes disabled for printing.

Returns:
Disabled annotation classes.

setPrintAllAnnotations

public void setPrintAllAnnotations(boolean doForcePrintAllAnnotations)
Sets a flag to print all annotation types. If this flag is set to true all render context settings depending to annotations will be ignored !!! Default value is false.

Parameters:
doForcePrintAllAnnotations - Flag

isPrintAllAnnotationsUsed

public boolean isPrintAllAnnotationsUsed()
Return current flag.

Returns:
Flag

getErrorHandler

public PrintErrorHandler getErrorHandler()

setErrorHandler

public void setErrorHandler(PrintErrorHandler errorHandler)

addException

public void addException(PrinterException e)

getPrinterExceptions

public List<PrinterException> getPrinterExceptions()

resetPrinterExceptions

public void resetPrinterExceptions()

getPrintJobConfiguration

public PrintJobConfiguration getPrintJobConfiguration()

reset

public void reset()
Resets this printer.
A fresh PrintJobConfiguration with default settings will be set and a new PrinterJob is assigned.



Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.