001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * PageableHtmlOutputProcessor.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.output.table.html;
030:
031: import java.util.ArrayList;
032: import java.util.Collections;
033: import java.util.List;
034:
035: import org.jfree.report.layout.model.LogicalPageBox;
036: import org.jfree.report.layout.output.ContentProcessingException;
037: import org.jfree.report.layout.output.DisplayAllFlowSelector;
038: import org.jfree.report.layout.output.FlowSelector;
039: import org.jfree.report.layout.output.LogicalPageKey;
040: import org.jfree.report.layout.output.OutputProcessorMetaData;
041: import org.jfree.report.layout.output.PhysicalPageKey;
042: import org.jfree.report.modules.output.pageable.base.PageableOutputProcessor;
043: import org.jfree.report.modules.output.table.base.AbstractTableOutputProcessor;
044: import org.jfree.report.modules.output.table.base.TableContentProducer;
045: import org.jfree.report.modules.output.table.html.helper.HtmlOutputProcessorMetaData;
046: import org.jfree.util.Configuration;
047:
048: /**
049: * Creation-Date: 04.05.2007, 16:36:48
050: *
051: * @author Thomas Morgner
052: */
053: public class PageableHtmlOutputProcessor extends
054: AbstractTableOutputProcessor implements
055: PageableOutputProcessor, HtmlOutputProcessor {
056: private List physicalPages;
057: private HtmlOutputProcessorMetaData metaData;
058: private HtmlPrinter printer;
059: private FlowSelector flowSelector;
060:
061: public PageableHtmlOutputProcessor(final Configuration configuration) {
062: this .physicalPages = new ArrayList();
063: this .flowSelector = new DisplayAllFlowSelector();
064: this .metaData = new HtmlOutputProcessorMetaData(configuration,
065: HtmlOutputProcessorMetaData.PAGINATION_FULL);
066: }
067:
068: protected void processingPagesFinished() {
069: super .processingPagesFinished();
070: physicalPages = Collections.unmodifiableList(physicalPages);
071: }
072:
073: public int getPhysicalPageCount() {
074: return physicalPages.size();
075: }
076:
077: public PhysicalPageKey getPhysicalPage(final int page) {
078: if (isPaginationFinished() == false) {
079: throw new IllegalStateException();
080: }
081:
082: return (PhysicalPageKey) physicalPages.get(page);
083: }
084:
085: protected LogicalPageKey createLogicalPage(final int width,
086: final int height) {
087: final LogicalPageKey key = super .createLogicalPage(width,
088: height);
089: for (int h = 0; h < key.getHeight(); h++) {
090: for (int w = 0; w < key.getWidth(); w++) {
091: physicalPages.add(key.getPage(w, h));
092: }
093: }
094: return key;
095: }
096:
097: public OutputProcessorMetaData getMetaData() {
098: return metaData;
099: }
100:
101: public HtmlPrinter getPrinter() {
102: return printer;
103: }
104:
105: public void setPrinter(final HtmlPrinter printer) {
106: this .printer = printer;
107: }
108:
109: public FlowSelector getFlowSelector() {
110: return flowSelector;
111: }
112:
113: public void setFlowSelector(final FlowSelector flowSelector) {
114: this .flowSelector = flowSelector;
115: }
116:
117: protected void processTableContent(
118: final LogicalPageKey logicalPageKey,
119: final LogicalPageBox logicalPage,
120: final TableContentProducer contentProducer)
121: throws ContentProcessingException {
122: if (printer == null) {
123: return;
124: }
125:
126: printer.print(logicalPageKey, logicalPage, contentProducer,
127: metaData, false);
128: }
129: }
|