📄 pagelayouter.java
字号:
/**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://www.jfree.org/jfreereport/index.html
* Project Lead: Thomas Morgner;
*
* (C) Copyright 2000-2003, by Simba Management Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* -----------------
* PageLayouter.java
* -----------------
* (C)opyright 2002, 2003, by Thomas Morgner and Contributors.
*
* Original Author: Thomas Morgner;
* Contributor(s): David Gilbert (for Simba Management Limited);
*
* $Id: PageLayouter.java,v 1.9.2.1 2003/12/21 23:28:45 taqua Exp $
*
* Changes
* -------
* 04-Dec-2002 : Added Javadocs (DG);
*
*/
package org.jfree.report.modules.output.pageable.base.pagelayout;
import org.jfree.report.ReportDefinition;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.util.Log;
import org.jfree.report.event.PageEventListener;
import org.jfree.report.event.ReportEvent;
import org.jfree.report.function.AbstractFunction;
import org.jfree.report.modules.output.pageable.base.LogicalPage;
import org.jfree.report.states.ReportState;
/**
* 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.)
* <p>
* A PageLayouter for an Report is defined by the ReportProperty
* <code>pageable.layoutManager</code> by setting the classname of the page layouter.
* The specified class must contain an DefaultConstructor and must be an instance of
* PageLayouter.
* <p>
* 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.
* <p>
* All layoutmanagers should document their known constraints.
*
* @author Thomas Morgner
*/
public abstract strictfp class PageLayouter extends AbstractFunction
implements PageEventListener
{
/**
* Represents the state of the page layouter. Subclasses must override this
* class to create an internal state which can be saved and restored when
* a page-break occurs.
* <p>
* The state is required to be cloneable and must support deep-cloning so that
* the state can be restored multiple times whenever the page printing continues.
*/
protected abstract static class LayoutManagerState implements Cloneable
{
/**
* Creates a new state.
*/
public LayoutManagerState()
{
}
}
/**
* The current layoutmanager state. This is used to reconstruct the state of
* the last print operation whenever an pagebreak occured. The contents depend
* on the specific implementation of the PageLayouter.
*/
private LayoutManagerState layoutManagerState;
/** The logical page used to output the generated content. */
private LogicalPage logicalPage;
/** The latest report event. */
private ReportEvent currentEvent;
/**
* The depency level. Should be set to -1 or lower to ensure that this function
* has the highest priority in the function collection.
*/
private int depLevel;
/**
* The 'finishing page' flag. 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.
* <p>
* If the page should be finished while the page is restarted, will throw an
* ReportProcessing exception, as this would result in an infinite loop.
*/
private boolean finishingPage;
/**
* 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.
*/
private boolean restartingPage;
/** A flag indicating whether some content was created. */
private boolean generatedPageEmpty;
/** A flag indicating whether the process of restarting the page is completed. */
private boolean pageRestartDone;
/**
* Creates a new page layouter. The function depency level is set to -1 (highest
* priority).
*/
public PageLayouter()
{
setDependencyLevel(-1);
}
/**
* 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.
*
* @return true, if the restart process for this page is completed, false otherwise.
*/
public boolean isPageRestartDone()
{
return 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.
*
* @param pageRestartDone set to true, if the restart process for this page is completed,
* false otherwise.
*/
public void setPageRestartDone(final boolean pageRestartDone)
{
this.pageRestartDone = pageRestartDone;
}
/**
* Maintains a flag, whether the generated page was completly empty.
*
* @return true, if the page was empty when the logical page was closed,
* false otherwise.
*/
public boolean isGeneratedPageEmpty()
{
return generatedPageEmpty;
}
/**
* Defines a flag, whether the generated page was completly empty.
*
* @param generatedPageEmpty true, if the page was empty when the logical page was closed,
* false otherwise.
*/
protected void setGeneratedPageEmpty(final boolean generatedPageEmpty)
{
this.generatedPageEmpty = generatedPageEmpty;
}
/**
* Sets the logical page for the layouter.
*
* @param logicalPage the logical page (null not permitted).
* @throws NullPointerException it the logical page is null
*/
public void setLogicalPage(final LogicalPage logicalPage)
{
if (logicalPage == null)
{
throw new NullPointerException("PageLayouter.setLogicalPage: logicalPage is null.");
}
this.logicalPage = logicalPage;
}
/**
* Clears the logical page reference. This method must be called after
* the page has been processed.
*/
public void clearLogicalPage()
{
this.logicalPage = null;
}
/**
* Returns the logical page.
*
* @return the logical page.
*/
public LogicalPage getLogicalPage()
{
return logicalPage;
}
/**
* Returns the 'finishing page' flag.
* <p>
* 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.
* <p>
* If the page should be finished while the page is restarted, will throw an
* ReportProcessing exception, as this would result in an infinite loop.
*
* @return true if the current page is currently shut down, false otherwise.
*/
public boolean isFinishingPage()
{
return finishingPage;
}
/**
* Sets the 'finishing page' flag.
*
* @see PageLayouter#isFinishingPage
* @param finishingPage the new flag value.
*/
public void setFinishingPage(final boolean finishingPage)
{
this.finishingPage = finishingPage;
}
/**
* Returns the 'restarting page' flag.
* <p>
* 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.
*
* @return true if the current page is currently restarting, false otherwise
*/
public boolean isRestartingPage()
{
return restartingPage;
}
/**
* Sets the 'restarting page' flag.
*
* @see PageLayouter#isRestartingPage
* @param restartingPage sets the restarting page flag.
*/
public void setRestartingPage(final boolean restartingPage)
{
this.restartingPage = restartingPage;
}
/**
* Returns the report that should be printed. This is the report contained
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -