com.jrefinery.report.targets.pageable
Class PageableReportProcessor

java.lang.Object
  extended bycom.jrefinery.report.targets.pageable.PageableReportProcessor

public class PageableReportProcessor
extends java.lang.Object

A report processor for Pageable OutputTargets. The processor coordinates and initializes the output process for all page- and print-oriented output formats.

Author:
Thomas Morgner

Field Summary
static java.lang.String LAYOUTMANAGER_NAME
          The page layout manager name.
 
Constructor Summary
PageableReportProcessor(JFreeReport report)
          Creates a new ReportProcessor.
 
Method Summary
 void addRepaginationListener(RepaginationListener l)
          Adds a listener.
protected  void fireStateUpdate(RepaginationState state)
          Sends a repagination update to all registered listeners.
 OutputTarget getOutputTarget()
          Returns the output target.
 JFreeReport getReport()
          Returns the report.
protected  boolean isEmptyPageGenerated(ReportState state)
          Checks the state of the logical page, to see whether some content has been printed on the page.
 boolean isHandleInterruptedState()
          Returns whether the processor should check the threads interrupted state.
 ReportState processPage(ReportState currPage, OutputTarget out)
          Draws a single page of the report to the specified graphics device, and returns state information.
 ReportState processPage(ReportState currPage, OutputTarget out, boolean failOnError)
          Draws a single page of the report to the specified graphics device, and returns state information.
 void processReport()
          Processes the report in two passes, the first pass calculates page boundaries and function values, the second pass sends each page to the output target.
 void removeRepaginationListener(RepaginationListener l)
          Removes a listener.
 ReportStateList repaginate()
          Processes the entire report and records the state at the end of every page.
 void setHandleInterruptedState(boolean handleInterruptedState)
          Defines, whether the processor should check the threads interrupted state.
 void setOutputTarget(OutputTarget outputTarget)
          Sets the output target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUTMANAGER_NAME

public static final java.lang.String LAYOUTMANAGER_NAME
The page layout manager name.

See Also:
Constant Field Values
Constructor Detail

PageableReportProcessor

public PageableReportProcessor(JFreeReport report)
                        throws ReportProcessingException,
                               FunctionInitializeException
Creates a new ReportProcessor.

Parameters:
report - the report.
Throws:
ReportProcessingException - if the report cannot be cloned.
FunctionInitializeException - if a function cannot be initialised.
Method Detail

addRepaginationListener

public void addRepaginationListener(RepaginationListener l)
Adds a listener.

Parameters:
l - the listener.

removeRepaginationListener

public void removeRepaginationListener(RepaginationListener l)
Removes a listener.

Parameters:
l - the listener.

fireStateUpdate

protected void fireStateUpdate(RepaginationState state)
Sends a repagination update to all registered listeners.

Parameters:
state - the state.

isHandleInterruptedState

public boolean isHandleInterruptedState()
Returns whether the processor should check the threads interrupted state. If this is set to true and the thread was interrupted, then the report processing is aborted.

Returns:
true, if the processor should check the current thread state, false otherwise.

setHandleInterruptedState

public void setHandleInterruptedState(boolean handleInterruptedState)
Defines, whether the processor should check the threads interrupted state. If this is set to true and the thread was interrupted, then the report processing is aborted.

Parameters:
handleInterruptedState - true, if the processor should check the current thread state, false otherwise.

getOutputTarget

public OutputTarget getOutputTarget()
Returns the output target.

Returns:
the output target.

setOutputTarget

public void setOutputTarget(OutputTarget outputTarget)
Sets the output target.

Parameters:
outputTarget - the output target.

getReport

public JFreeReport getReport()
Returns the report.

Returns:
the report.

processReport

public void processReport()
                   throws ReportProcessingException,
                          EmptyReportException
Processes the report in two passes, the first pass calculates page boundaries and function values, the second pass sends each page to the output target.

It is possible for the report processing to fail. A base cause is that the report is designed for a certain page size, but ends up being sent to an output target with a much smaller page size. If the headers and footers don't leave enough room on the page for at least one row of data to be printed, then no progress is made. An exception will be thrown if this happens.

Throws:
ReportProcessingException - if the report did not proceed and got stuck.
EmptyReportException - if the repagination returned no pages.

repaginate

public ReportStateList repaginate()
                           throws ReportProcessingException
Processes the entire report and records the state at the end of every page.

Returns:
a list of report states (one for the beginning of each page in the report).
Throws:
ReportProcessingException - if there was a problem processing the report.

processPage

public ReportState processPage(ReportState currPage,
                               OutputTarget out)
                        throws ReportProcessingException
Draws a single page of the report to the specified graphics device, and returns state information. The caller should check the returned state to ensure that some progress has been made, because on some small paper sizes the report may get stuck (particularly if the header and footer are large).

To check the progress, use ReportState.isProceeding(oldstate).

Parameters:
out - The output target.
currPage - The report state at the beginning of the current page.
Returns:
The report state suitable for the next page or ReportState.FinishState.
Throws:
java.lang.IllegalArgumentException - if the given state is a start or a finish state.
ReportProcessingException - if there is a problem processing the report or the current thread has been interrupted.

processPage

public ReportState processPage(ReportState currPage,
                               OutputTarget out,
                               boolean failOnError)
                        throws ReportProcessingException
Draws a single page of the report to the specified graphics device, and returns state information. The caller should check the returned state to ensure that some progress has been made, because on some small paper sizes the report may get stuck (particularly if the header and footer are large).

To check the progress, use ReportState.isProceeding(oldstate).

Parameters:
out - The output target.
currPage - The report state at the beginning of the current page.
failOnError - if set to true, then errors in the report event handling will cause the reporting to fail.
Returns:
The report state suitable for the next page or ReportState.FinishState.
Throws:
java.lang.IllegalArgumentException - if the given state is a start or a finish state.
ReportProcessingException - if there is a problem processing the report or the current thread has been interrupted.

isEmptyPageGenerated

protected boolean isEmptyPageGenerated(ReportState state)
Checks the state of the logical page, to see whether some content has been printed on the page.

Parameters:
state - the state which should be checked
Returns:
true, if the page is empty, false otherwise.