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: * HtmlOutputProcessorMetaData.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.output.table.html.helper;
030:
031: import org.jfree.fonts.awt.AWTFontRegistry;
032: import org.jfree.fonts.registry.DefaultFontStorage;
033: import org.jfree.fonts.registry.FontStorage;
034: import org.jfree.report.layout.output.AbstractOutputProcessorMetaData;
035: import org.jfree.report.layout.output.OutputProcessorFeature;
036: import org.jfree.report.modules.output.table.base.AbstractTableOutputProcessor;
037: import org.jfree.util.Configuration;
038: import org.jfree.util.ExtendedConfiguration;
039: import org.jfree.util.ExtendedConfigurationWrapper;
040:
041: /**
042: * Creation-Date: 04.05.2007, 18:04:58
043: *
044: * @author Thomas Morgner
045: */
046: public class HtmlOutputProcessorMetaData extends
047: AbstractOutputProcessorMetaData {
048: public static final int PAGINATION_NONE = 0;
049: public static final int PAGINATION_MANUAL = 1;
050: public static final int PAGINATION_FULL = 2;
051:
052: private int paginationMode;
053:
054: public HtmlOutputProcessorMetaData(
055: final Configuration configuration, final int paginationMode) {
056: this (configuration, createFontStorage(), paginationMode);
057: }
058:
059: private static FontStorage createFontStorage() {
060: return new DefaultFontStorage(new AWTFontRegistry());
061: }
062:
063: public HtmlOutputProcessorMetaData(
064: final Configuration configuration,
065: final FontStorage fontStorage, final int paginationMode) {
066: super (configuration, fontStorage);
067: addFeature(OutputProcessorFeature.SPACING_SUPPORTED);
068:
069: this .paginationMode = paginationMode;
070: final String localStrict = configuration
071: .getConfigProperty("org.jfree.report.modules.output.table.html.StrictLayout");
072: if (localStrict != null) {
073: if ("true".equals(localStrict)) {
074: addFeature(AbstractTableOutputProcessor.STRICT_LAYOUT);
075: }
076: } else {
077: final String globalStrict = configuration
078: .getConfigProperty("org.jfree.report.modules.output.table.base.StrictLayout");
079: if ("true".equals(globalStrict)) {
080: addFeature(AbstractTableOutputProcessor.STRICT_LAYOUT);
081: }
082: }
083: if ("true"
084: .equals(configuration
085: .getConfigProperty("org.jfree.report.modules.output.table.base.UsePageBands"))) {
086: addFeature(OutputProcessorFeature.PAGE_SECTIONS);
087: }
088: if ("true"
089: .equals(configuration
090: .getConfigProperty("org.jfree.report.modules.output.table.html.UsePageBands"))) {
091: addFeature(OutputProcessorFeature.PAGE_SECTIONS);
092: }
093: if ("true"
094: .equals(configuration
095: .getConfigProperty("org.jfree.report.modules.output.table.base.TreatEllipseAsRectangle"))) {
096: addFeature(AbstractTableOutputProcessor.TREAT_ELLIPSE_AS_RECTANGLE);
097: }
098: if ("true"
099: .equals(configuration
100: .getConfigProperty("org.jfree.report.modules.output.table.html.TreatEllipseAsRectangle"))) {
101: addFeature(AbstractTableOutputProcessor.TREAT_ELLIPSE_AS_RECTANGLE);
102: }
103:
104: final ExtendedConfiguration extendedConfig = new ExtendedConfigurationWrapper(
105: configuration);
106: final double deviceResolution = extendedConfig
107: .getIntProperty(
108: "org.jfree.report.modules.output.table.html.DeviceResolution",
109: 0);
110: if (deviceResolution > 0) {
111: setNumericFeatureValue(
112: OutputProcessorFeature.DEVICE_RESOLUTION,
113: deviceResolution);
114: }
115:
116: if (paginationMode == PAGINATION_FULL) {
117: addFeature(OutputProcessorFeature.PAGEBREAKS);
118: } else if (paginationMode == PAGINATION_MANUAL) {
119: addFeature(OutputProcessorFeature.PAGEBREAKS);
120: addFeature(OutputProcessorFeature.ITERATIVE_RENDERING);
121: addFeature(OutputProcessorFeature.UNALIGNED_PAGEBANDS);
122: } else {
123: addFeature(OutputProcessorFeature.ITERATIVE_RENDERING);
124: addFeature(OutputProcessorFeature.UNALIGNED_PAGEBANDS);
125: }
126: }
127:
128: public int getPaginationMode() {
129: return paginationMode;
130: }
131:
132: public String getExportDescriptor() {
133: switch (paginationMode) {
134: case PAGINATION_FULL:
135: return "table/html+pagination";
136: case PAGINATION_MANUAL:
137: return "table/html+flow";
138: default:
139: return "table/html+stream";
140: }
141: }
142: }
|