Java 类net.sf.jasperreports.engine.export.JRTextExporterParameter 实例源码

项目:ireport-fork    文件:TextExportParametersPanel.java   
public void load() {
    setInit(true);
    Preferences pref = IReportManager.getPreferences();

    SpinnerNumberModel model = (SpinnerNumberModel)jSpinnerCharacterHeight.getModel();
    model.setValue( pref.getFloat(JRTextExporterParameter.PROPERTY_CHARACTER_HEIGHT, 0));

    model = (SpinnerNumberModel)jSpinnerCharacterWidth.getModel();
    model.setValue( pref.getFloat(JRTextExporterParameter.PROPERTY_CHARACTER_WIDTH, 0));

    model = (SpinnerNumberModel)jSpinnerPageHeight.getModel();
    model.setValue( pref.getInt(JRTextExporterParameter.PROPERTY_PAGE_HEIGHT, 0));

    model = (SpinnerNumberModel)jSpinnerPageWidth.getModel();
    model.setValue( pref.getInt(JRTextExporterParameter.PROPERTY_PAGE_WIDTH, 0));

    jTextAreaBetweenPagesText.setText(Misc.addSlashesString(pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.betweenPagesText", "")));
    jCheckBoxNothingBetweenPages.setSelected(pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.nothingBetweenPages", false)); // This is an iReport specific option!

    jTextFieldLineSeparator.setText( Misc.addSlashesString(pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.lineSeparator", System.getProperty("line.separator"))));
    setInit(false);
}
项目:nextreports-server    文件:JasperReportsUtil.java   
public static byte[] getTxt(JasperPrint jasperPrint)
        throws JRException {

    byte[] content = null;
    ByteArrayOutputStream baos = null;
    try {
        baos = new ByteArrayOutputStream();
        JRTextExporter exporter = new JRTextExporter();

        exporter.setParameter(JRTextExporterParameter.PAGE_WIDTH, JasperUtil.TXT_PAGE_WIDTH);
        exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT, JasperUtil.TXT_PAGE_HEIGHT);

        content = getBytes(exporter, baos, jasperPrint);
    } finally {
        if (baos != null) {
            try {
                baos.flush();
                baos.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return content;
}
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configureTextExporter(JRExporter exporter, SimpleJasperReportsContext context) {

        Preferences pref = IReportManager.getPreferences();
        JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);

        float floatVal = pref.getFloat(JRTextExporterParameter.PROPERTY_CHARACTER_HEIGHT, 0);
        if (floatVal > 0) context.setValue( JRTextExporterParameter.PROPERTY_CHARACTER_HEIGHT, floatVal+"");

        floatVal = pref.getFloat(JRTextExporterParameter.PROPERTY_CHARACTER_WIDTH, 0);
        if (floatVal > 0) context.setValue( JRTextExporterParameter.PROPERTY_CHARACTER_WIDTH, floatVal+"");

        int val = pref.getInt(JRTextExporterParameter.PROPERTY_PAGE_HEIGHT, 0);
        if (val > 0) context.setValue( JRTextExporterParameter.PROPERTY_PAGE_HEIGHT, ""+val);

        val = pref.getInt(JRTextExporterParameter.PROPERTY_PAGE_WIDTH, 0);
        if (val > 0) context.setValue( JRTextExporterParameter.PROPERTY_PAGE_WIDTH, ""+val);

        String s = null;
        if (pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.nothingBetweenPages", false))
        {
            exporter.setParameter( JRTextExporterParameter.BETWEEN_PAGES_TEXT, "");
        }
        else
        {
            s = pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.betweenPagesText", "");
            if (s.length() > 0) exporter.setParameter( JRTextExporterParameter.BETWEEN_PAGES_TEXT, s);
        }

        s = pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.lineSeparator", "");
        if (s.length() > 0) exporter.setParameter( JRTextExporterParameter.LINE_SEPARATOR, s);

    }
项目:gnvc-ims    文件:OOReportGenerator.java   
private void exportToTxt() {
    //log.debug("exporting to TXT");
    // textExporter = new JRTextExporter();
    // setExportParameter(JRTextExporterParameter.CHARACTER_WIDTH, new
    // Integer(13));
    // setExportParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new
    // Integer(20));

    textExporter = new JRTextExporter();
    if (getJasperReport().hasProperties()) {
        if (null != getJasperReport().getProperty("export.txt.page_rows")) {
            setExportParameter(JRTextExporterParameter.CHARACTER_WIDTH,
                    getJasperReport().getProperty("export.txt.character_width"));
        }
        if (null != getJasperReport().getProperty("export.txt.page_columns")) {
            setExportParameter(JRTxtExporterParameter.PAGE_COLUMNS,
                    getJasperReport().getProperty("export.txt.page_columns"));
        }
        if (null != getJasperReport().getProperty(
                "export.txt.add_form_feed")) {
            setExportParameter(JRTxtExporterParameter.ADD_FORM_FEED,
                    new Boolean(getJasperReport().getProperty(
                    "export.txt.add_form_feed")));
        }
    }
    textExporter.setParameters(getExportParameters());
    try {
        start = System.currentTimeMillis();
        textExporter.exportReport();
        //log.info("export running time (msec): "
        //        + (System.currentTimeMillis() - start));
    } catch (JRException jre) {

        jre.printStackTrace();
    }
}
项目:ireport-fork    文件:TextExportParametersPanel.java   
public void store() {

        Preferences pref = IReportManager.getPreferences();

        SpinnerNumberModel model = (SpinnerNumberModel)jSpinnerCharacterHeight.getModel();
        pref.putFloat(JRTextExporterParameter.PROPERTY_CHARACTER_HEIGHT, model.getNumber().floatValue());

        model = (SpinnerNumberModel)jSpinnerCharacterWidth.getModel();
        pref.putFloat(JRTextExporterParameter.PROPERTY_CHARACTER_WIDTH, model.getNumber().floatValue());

        model = (SpinnerNumberModel)jSpinnerPageHeight.getModel();
        pref.putInt(JRTextExporterParameter.PROPERTY_PAGE_HEIGHT, model.getNumber().intValue());

        model = (SpinnerNumberModel)jSpinnerPageWidth.getModel();
        pref.putInt(JRTextExporterParameter.PROPERTY_PAGE_WIDTH, model.getNumber().intValue());


        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.betweenPagesText", Misc.removeSlashesString(jTextAreaBetweenPagesText.getText()));
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.lineSeparator", Misc.removeSlashesString(jTextFieldLineSeparator.getText()));

        pref.putBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.nothingBetweenPages", jCheckBoxNothingBetweenPages.isSelected());

    }