The baseclass for all PageLayouter. A page layouter is the layoutmanager of
an logical page. This layoutmanager is responsible for handling and detecting
page breaks, for placing the various Root-Bands (bands that are contained
directly in an report) on the page and for the global appeareance of an page
(columns, band placement policy etc.)
All PageLayouter may define a set of LayoutConstraints for use in the Root-Bands.
These constraints can be used to configure the layouting process. It is up to
the layoutmanager implementation, which constraints are recognized and how these
constraints are used.
All layoutmanagers should document their known constraints.
| Method from org.jfree.report.modules.output.pageable.base.pagelayout.PageLayouter Detail: |
protected void clearCurrentEvent() {
if (currentEvent == null)
{
Log.error ("Failed to clear current event; we don't have an event set!",
new IllegalStateException("stacktrace generated:"));
}
this.currentEvent = null;
}
Clears the current event. |
public void clearLogicalPage() {
this.logicalPage = null;
}
Clears the logical page reference. This method must be called after
the page has been processed. |
protected void clearSaveState() {
layoutManagerState = null;
}
Clear the beginTransaction. This should be called after the beginTransaction has been
restored. |
public Object clone() throws CloneNotSupportedException {
final PageLayouter l = (PageLayouter) super.clone();
l.currentEvent = null;
return l;
}
Returns a clone of the PageLayouter.
Be aware, this does not create a deep copy. If you have complex
structures contained in objects, you have to overwrite this function. |
protected void endPage() throws ReportProcessingException {
// this can be dangerous if a band spans multiple pages.
// rethink that.
if (isRestartingPage())
{
throw new ReportProcessingException("Report does not proceed (PageEnd during RestartPage)");
}
// cannot finish
if (isFinishingPage())
{
throw new IllegalStateException("Page is currently finishing");
}
setFinishingPage(true);
final ReportEvent cEvent = getCurrentEvent();
clearCurrentEvent();
cEvent.getState().firePageFinishedEvent();
cEvent.getState().nextPage();
setCurrentEvent(cEvent);
setFinishingPage(false);
// save the state after the PageFinished event is fired to
// gather as many information as possible
// log // no cloning save the orignal state
layoutManagerState = saveCurrentState();
setGeneratedPageEmpty(getLogicalPage().isEmpty());
getLogicalPage().close();
}
Ends a page. During the process, an PageFinished event is generated and
the state advances to the next page. The Layoutmanager-State is saved and
the logical page is closed.
While this method is executed, the FinishingPage flag is set to true.
You are not able to print on the logical page after the page is finished. |
protected ReportEvent getCurrentEvent() {
return currentEvent;
}
Returns the current report event. |
public int getDependencyLevel() {
return depLevel;
}
The dependency level defines the level of execution for this function. Higher dependency
functions are executed before lower dependency functions. For ordinary functions and
expressions, the range for dependencies is defined to start from 0 (lowest dependency
possible) to 2^31 (upper limit of int).
PageLayouter functions override the default behaviour an place them self at depency level -1,
an so before any userdefined function. |
public PageLayouter.LayoutManagerState getLayoutManagerState() {
return layoutManagerState;
}
Return the last stored LayoutManager state or null if there is no state
stored. |
public LogicalPage getLogicalPage() {
return logicalPage;
}
Returns the logical page. |
public ReportDefinition getReport() {
if (getCurrentEvent() == null)
{
throw new IllegalStateException("No Current Event available.");
}
return getCurrentEvent().getReport();
}
Returns the report that should be printed. This is the report contained
in the last ReportEvent received, or null, if no event occurred here. |
public Object getValue() {
return this;
}
Return a self-reference. This backdoor is used to extract the current
PageLayoutManager instance from the DataRow. Please don't use it in your functions,
it is required for the PageableReportProcessor. |
public boolean isFinishingPage() {
return finishingPage;
}
Returns the 'finishing page' flag.
When set to true, indicates that the current page is shut down.
The page footer should be printed and the state stored. Trying to end the
page again while the finishing process is not complete will result in an
IllegalState.
If the page should be finished while the page is restarted, will throw an
ReportProcessing exception, as this would result in an infinite loop. |
public boolean isGeneratedPageEmpty() {
return generatedPageEmpty;
}
Maintains a flag, whether the generated page was completly empty. |
abstract public boolean isNewPageStarted()
Returns true, if the PageLayouter has successfully started a new page. The
start of the new page is delayed, until the first content is printed. |
public boolean isPageEnded() {
return getLogicalPage().isOpen() == false;
}
Checks whether this page has ended. If this method returns true, no
printing to the logical page is allowed. |
public boolean isPageRestartDone() {
return pageRestartDone;
}
Returns whether the restarting of the page is completed. Restarting the
page is separated into two processes. The first step restores the save state,
and the second step starts to print the page header and opens the logical page.
The second step is not executed, if no more content is printed. |
public boolean isRestartingPage() {
return restartingPage;
}
Returns the 'restarting page' flag.
Is set to true, while the page is started.
The last saved state is restored and the page header gets prepared.
Trying the start the page again while the restarting process is not complete
or while the page is currently being finished, will result in an IllegalState. |
public void pageCanceled(ReportEvent event) {
// does nothing, we dont care about canceled pages by default..
}
Receives notification that a page was canceled by the ReportProcessor.
This method is called, when a page was removed from the report after
it was generated. |
public void restoreSaveState(ReportState ancestor) throws ReportProcessingException {
final Object state = getLayoutManagerState();
// reset the report finished flag...
//setStartNewPage(false);
setGeneratedPageEmpty(true);
setPageRestartDone(false);
if (state == null)
{
if (ancestor.getCurrentPage() != ReportState.BEFORE_FIRST_PAGE)
{
throw new IllegalStateException("State is null, but this is not the first page."
+ ancestor.getCurrentPage());
}
}
// open the logical page ...
getLogicalPage().open();
}
|
abstract protected PageLayouter.LayoutManagerState saveCurrentState()
Save the current state into the LayoutManagerState object. The concrete
implementation is responsible to save all required information so that the
printing can be continued after the pagebreak is done. |
protected void setCurrentEvent(ReportEvent currentEvent) {
if (currentEvent == null)
{
throw new NullPointerException("Current Event is null");
}
this.currentEvent = currentEvent;
}
Sets the current event (also updates the report reference). |
public void setDependencyLevel(int deplevel) {
this.depLevel = deplevel;
}
Overrides the depency level. Should be lower than any other function depency. |
public void setFinishingPage(boolean finishingPage) {
this.finishingPage = finishingPage;
}
Sets the 'finishing page' flag. |
protected void setGeneratedPageEmpty(boolean generatedPageEmpty) {
this.generatedPageEmpty = generatedPageEmpty;
}
Defines a flag, whether the generated page was completly empty. |
public void setLogicalPage(LogicalPage logicalPage) {
if (logicalPage == null)
{
throw new NullPointerException("PageLayouter.setLogicalPage: logicalPage is null.");
}
this.logicalPage = logicalPage;
}
Sets the logical page for the layouter. |
public void setPageRestartDone(boolean pageRestartDone) {
this.pageRestartDone = pageRestartDone;
}
Defines whether the restarting of the page is completed. Restarting the
page is separated into two processes. The first step restores the save state,
and the second step starts to print the page header and opens the logical page.
The second step is not executed, if no more content is printed. |
public void setRestartingPage(boolean restartingPage) {
this.restartingPage = restartingPage;
}
Sets the 'restarting page' flag. |
protected void startPage() {
if (isPageRestartDone() == true)
{
throw new IllegalStateException("Page already started");
}
final ReportEvent event = getCurrentEvent();
if (event == null)
{
throw new NullPointerException("PageLayouter.startPage(...): state is null.");
}
// remove the old event binding ....
clearCurrentEvent();
setRestartingPage(true);
event.getState().firePageStartedEvent(event.getType());
// restore the saved original event ...
setCurrentEvent(event);
setRestartingPage(false);
setPageRestartDone(true);
}
Restarts the current page. The logical page is opened again and the
PageStartedEvent is fired. While this method is executed, the RestartingPage
flag is set to true. |