⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 report.java

📁 iReport-0.4.1-src是iReport的源代码,iReport是一个开源的报表项目,可以生成PDF等格式报表
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * Report.java
 *
 *  iReport  --  Visual designer for generating JasperReports Documents
 *  Copyright (C) 2002  Giulio Toffoli gt@businesslogic.it
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Giulio Toffoli
 *  Via T.Aspetti, 233
 *  35100 Padova ITALY
 *  gt@businesslogic.it
 *
 * Created on 10 febbraio 2003, 19.32
 * 
 * Updated by Robert Lamping:
 * dtd updated with the new package path net/sf/  etc...
 * Added Try catch to catch a missing dtd.
 * Changed Mainframe.openFile to catch this exception and stop opening a file in case of an exception.
 */

package it.businesslogic.ireport;

//import java.util.*;
import java.util.Vector;
import java.util.Iterator;
import java.util.Properties;
import java.util.Enumeration;

import java.awt.Point;

import it.businesslogic.ireport.JRField;

//import it.businesslogic.ireport.util.*;
import it.businesslogic.ireport.util.Misc;
import it.businesslogic.ireport.util.PageSize;
import it.businesslogic.ireport.gui.JReportFrame;

//import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.JRReport;
import net.sf.jasperreports.engine.JasperManager;

import org.apache.xerces.parsers.DOMParser;

//import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import org.xml.sax.SAXException;

import java.io.IOException;
import java.io.File;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;


//import org.syntax.jedit.*;
import org.syntax.jedit.IReportKeywordLookup;
import org.syntax.jedit.KeywordLookupIF;

/**
 *
 * @author  Administrator
 */
public class Report {
    
    public static int SCRIPTLET_IREPORT_INTERNAL_HANDLING = 1;
    public static int SCRIPTLET_NOT_USED = 0;
    public static int SCRIPTLET_CLASSIC_HANDLING = 2;
    
    private IReportFont defaultFont = new IReportFont();
    
    private boolean modified = true;
    
    private boolean readOnly = false;
    
    private int height = 0;
    
    private int width = 0;
    
    private String name = "";
    
    private Vector elements = new Vector();
    
    private Vector bands = new Vector();
    
    private Vector groups = new Vector();
    
    private Vector imports = new Vector();
    
    private String filename = "";
    
    private String query = "";
    
    private String encoding = "UTF-8";
    
    private int columnCount = 1;
    
    private String printOrder = "Vertical";
    
    private String orientation = "Portrait";
    
    private String whenNoDataType = "NoPages";
    
    private int columnWidth = 535;
    
    private int columnSpacing = 0 ;
    
    private int leftMargin = 20;
    
    private int rightMargin = 20;
    
    private int topMargin = 30;
    
    private int bottomMargin = 30;
    
    private boolean isTitleNewPage = false;
    
    private boolean isSummaryNewPage = false;
    
    private String scriptletClass = "";
    
    private long loadTime = 0;
    
    private Vector fields = new Vector();
    
    private Vector parameters = new Vector();
    
    private Vector variables = new Vector();
    
    private Vector fonts = new Vector();
    
    private JReportFrame reportFrame;
    
    private String reportFormat;
    
    static int untitledId = 1;
    
    private int dirty = 1;
    
    private String ResourceBundleBaseName = "";
    
    private IReportKeywordLookup keywordLookup = new IReportKeywordLookup();
    
    private boolean floatColumnFooter = false;
    
    
    /** used to tell the report when outputting to XML that it needs to set isCode="true" in expressions */
    protected boolean usingMultiLineExpressions = false;
    
    private java.util.Vector JRproperties = new Vector();
    
    private ScriptletCode scripletCode;
    
    private int scriptletHandling = 2;
    
    /** Creates a new instance of Report */
    
    public Report() {
        name = "Untitled_report_" + untitledId;
        untitledId++;
        
        // Add basic variables...
        addVariable(new JRVariable("PAGE_NUMBER","java.lang.Integer", true ));
        addVariable(new JRVariable("COLUMN_NUMBER","java.lang.Integer", true));
        addVariable(new JRVariable("REPORT_COUNT","java.lang.Integer", true));
        addVariable(new JRVariable("PAGE_COUNT","java.lang.Integer", true));
        addVariable(new JRVariable("COLUMN_COUNT","java.lang.Integer", true));
        
        keywordLookup.addKeyword("$R{*}");
        
        //addParameter(new JRParameter("COLUMN_COUNT", "", ));
        
        bands.addElement( new Band(this,"background",0) );
        bands.addElement( new Band(this,"title", 50));
        bands.addElement( new Band(this,"pageHeader", 50) );
        bands.addElement( new Band(this,"columnHeader",30) );
        bands.addElement( new Band(this,"detail",100));
        bands.addElement( new Band(this,"columnFooter",30) );
        bands.addElement( new Band(this,"pageFooter",50));
        bands.addElement( new Band(this,"lastPageFooter",50));
        bands.addElement( new Band(this,"summary",50) );
        
        //addImport("it.businesslogic.ireport.IReportScriptlet");
        addImport("java.util.*");
        addImport("net.sf.jasperreports.engine.*");
        addImport("net.sf.jasperreports.engine.data.*");
        
        try {
            scripletCode = new ScriptletCode(ScriptletCode.class.getClassLoader().getResourceAsStream("scriptlet_template.jav"));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    
    /** Creates a new instance of Report reading it by a file...*/
    public Report(String xmlFile) throws Exception {
        
        this();
        untitledId--;
        
        //reset bands, prevents page height overflow for unused bands
        for(int i = 0; i < bands.size(); i++) {
            ((Band)bands.elementAt(i)).setHeight(0);
        }
        
        //  Create a Xerces DOM Parser
        //  Parse the Document
        //  and traverse the DOM
        
        this.setFilename(xmlFile);
        checkReadOnlyFlag();
        
        // set load time...
        this.setLoadTime( Misc.getLastWriteTime( xmlFile ));
        
        try {
            
            if (xmlFile.toLowerCase().endsWith(".jasper")) {
                JRReport report = JasperManager.loadReport(xmlFile);
                this.setWidth(report.getPageWidth());
                this.setHeight(report.getPageHeight());
                this.setTopMargin(report.getTopMargin());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -