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: * StyleKeyReferenceGenerator.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.misc.referencedoc;
030:
031: import java.net.URL;
032: import javax.swing.table.TableModel;
033:
034: import org.jfree.report.JFreeReport;
035: import org.jfree.report.JFreeReportBoot;
036: import org.jfree.report.TableDataFactory;
037: import org.jfree.report.modules.output.pageable.pdf.PdfReportUtil;
038: import org.jfree.report.modules.output.table.html.HtmlReportUtil;
039: import org.jfree.report.modules.parser.base.ReportGenerator;
040: import org.jfree.report.modules.parser.ext.factory.stylekey.DefaultStyleKeyFactory;
041: import org.jfree.report.modules.parser.ext.factory.stylekey.PageableLayoutStyleKeyFactory;
042: import org.jfree.report.modules.parser.ext.factory.stylekey.StyleKeyFactoryCollector;
043: import org.jfree.util.ObjectUtilities;
044:
045: /**
046: * An application that generates a report that provides style key reference information.
047: *
048: * @author Thomas Morgner.
049: */
050: public final class StyleKeyReferenceGenerator {
051: /**
052: * The report definition file.
053: */
054: private static final String REFERENCE_REPORT = "StyleKeyReferenceReport.xml"; //$NON-NLS-1$
055:
056: /**
057: * DefaultConstructor.
058: */
059: private StyleKeyReferenceGenerator() {
060: }
061:
062: /**
063: * Creates the default tablemodel for the stylekey reference generator.
064: *
065: * @return the tablemodel for the stylekey reference generator.
066: */
067: public static TableModel createData() {
068: final StyleKeyFactoryCollector cc = new StyleKeyFactoryCollector();
069: cc.addFactory(new DefaultStyleKeyFactory());
070: cc.addFactory(new PageableLayoutStyleKeyFactory());
071:
072: return new StyleKeyReferenceTableModel(cc);
073: }
074:
075: /**
076: * The starting point for the application.
077: *
078: * @param args ignored.
079: */
080: public static void main(final String[] args) {
081: JFreeReportBoot.getInstance().start();
082: final ReportGenerator gen = ReportGenerator.getInstance();
083: final URL reportURL = ObjectUtilities.getResourceRelative(
084: REFERENCE_REPORT, StyleKeyReferenceGenerator.class);
085: if (reportURL == null) {
086: System.err
087: .println("The report was not found in the classpath"); //$NON-NLS-1$
088: System.err.println("File: " + REFERENCE_REPORT); //$NON-NLS-1$
089: System.exit(1);
090: return;
091: }
092:
093: final JFreeReport report;
094: try {
095: report = gen.parseReport(reportURL);
096: } catch (Exception e) {
097: System.err.println("The report could not be parsed."); //$NON-NLS-1$
098: System.err.println("File: " + REFERENCE_REPORT); //$NON-NLS-1$
099: e.printStackTrace(System.err);
100: System.exit(1);
101: return;
102: }
103: report.setDataFactory(new TableDataFactory(
104: "default", createData())); //$NON-NLS-1$
105: try {
106: HtmlReportUtil.createStreamHTML(report, System
107: .getProperty("user.home") //$NON-NLS-1$
108: + "/stylekey-reference.html"); //$NON-NLS-1$
109: PdfReportUtil.createPDF(report, System
110: .getProperty("user.home") //$NON-NLS-1$
111: + "/stylekey-reference.pdf"); //$NON-NLS-1$
112: } catch (Exception e) {
113: System.err.println("The report processing failed."); //$NON-NLS-1$
114: System.err.println("File: " + REFERENCE_REPORT); //$NON-NLS-1$
115: e.printStackTrace(System.err);
116: System.exit(1);
117: }
118: }
119:
120: }
|