protected void setTextRenderer() {
    boolean isMinimizePrinterJobSize = true;
    Boolean isMinimizePrinterJobSizeParam =
        (Boolean) parameters.get(JRGraphics2DExporterParameter.MINIMIZE_PRINTER_JOB_SIZE);
    if (isMinimizePrinterJobSizeParam == null) {
      isMinimizePrinterJobSize =
          JRProperties.getBooleanProperty(
              MINIMIZE_PRINTER_JOB_SIZE); // FIXMENOW check other potential report properties
    } else {
      isMinimizePrinterJobSize = isMinimizePrinterJobSizeParam.booleanValue();
    }

    textRenderer =
        new TextRenderer(
            isMinimizePrinterJobSize,
            JRProperties.getBooleanProperty(
                jasperPrint, JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false));
  }
コード例 #2
0
  protected void configureDigester(Digester digester)
      throws SAXException, ParserConfigurationException {
    boolean validating = JRProperties.getBooleanProperty(JRProperties.COMPILER_XML_VALIDATION);

    digester.setErrorHandler(this);
    digester.setValidating(validating);
    digester.setFeature("http://xml.org/sax/features/validation", validating);

    digester.addRuleSet(rules);
  }
  public void exportReport() throws JRException {
    progressMonitor =
        (JRExportProgressMonitor) parameters.get(JRExporterParameter.PROGRESS_MONITOR);

    /*   */
    setOffset(false);

    try {
      /*   */
      setExportContext();

      /*   */
      setInput();

      if (!parameters.containsKey(JRExporterParameter.FILTER)) {
        filter = createFilter(GRAPHICS2D_EXPORTER_PROPERTIES_PREFIX);
      }

      /*   */
      setPageRange();

      /*   */
      setTextRenderer();

      grx = (Graphics2D) parameters.get(JRGraphics2DExporterParameter.GRAPHICS_2D);
      if (grx == null) {
        throw new JRException(
            "No output specified for the exporter. java.awt.Graphics2D object expected.");
      }

      BorderOffset.setLegacy(
          JRProperties.getBooleanProperty(
              jasperPrint, BorderOffset.PROPERTY_LEGACY_BORDER_OFFSET, false));

      /*   */
      setDrawers();

      Float zoomRatio = (Float) parameters.get(JRGraphics2DExporterParameter.ZOOM_RATIO);
      if (zoomRatio != null) {
        zoom = zoomRatio.floatValue();
        if (zoom <= 0) {
          throw new JRException("Invalid zoom ratio : " + zoom);
        }
      } else {
        zoom = DEFAULT_ZOOM;
      }

      exportReportToGraphics2D();
    } finally {
      resetExportContext();
    }
  }
  /**
   * Creates a data source out of the query result.
   *
   * @return the data source
   */
  protected JRDataSource createResultDatasource() {
    JRDataSource resDatasource;

    String runType =
        JRProperties.getProperty(
            dataset, JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_RUN_TYPE);
    boolean useFieldDescriptions =
        JRProperties.getBooleanProperty(
            dataset,
            JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_FIELD_MAPPING_DESCRIPTIONS,
            true);

    if (runType == null
        || runType.equals(JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_LIST)) {
      try {
        int pageSize =
            JRProperties.getIntegerProperty(
                dataset,
                JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE,
                0);

        resDatasource = new JRHibernateListDataSource(this, useFieldDescriptions, pageSize);
      } catch (NumberFormatException e) {
        throw new JRRuntimeException(
            "The "
                + JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE
                + " property must be numerical.",
            e);
      }
    } else if (runType.equals(
        JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_ITERATE)) {
      resDatasource = new JRHibernateIterateDataSource(this, useFieldDescriptions);
    } else if (runType.equals(
        JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_SCROLL)) {
      resDatasource = new JRHibernateScrollDataSource(this, useFieldDescriptions);
    } else {
      throw new JRRuntimeException(
          "Unknown value for the "
              + JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_RUN_TYPE
              + " property.  Possible values are "
              + JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_LIST
              + ", "
              + JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_ITERATE
              + " and "
              + JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_SCROLL
              + ".");
    }

    return resDatasource;
  }
  public JRHibernateQueryExecuter(JRDataset dataset, Map parameters) {
    super(dataset, parameters);

    session =
        (Session) getParameterValue(JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION);
    reportMaxCount = (Integer) getParameterValue(JRParameter.REPORT_MAX_COUNT);
    isClearCache =
        JRProperties.getBooleanProperty(
            dataset, JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_CLEAR_CACHE, false);

    if (session == null) {
      log.warn("The supplied org.hibernate.Session object is null.");
    }

    parseQuery();
  }
コード例 #6
0
  protected void setPrintText(JRPrintText printText) {
    int startIndex = getTextStart();
    int endIndex = getTextEnd();
    JRStyledText fullStyledText = getStyledText();
    String fullText = fullStyledText.getText();

    boolean keepAllText =
        !canOverflow()
            && JRProperties.getBooleanProperty(
                this, JRTextElement.PROPERTY_PRINT_KEEP_FULL_TEXT, false);
    if (keepAllText) {
      // assert getTextStart() == 0
      if (startIndex != 0) {
        throw new JRRuntimeException("Text start index != 0 on keep all text.");
      }

      if (!JRCommonText.MARKUP_NONE.equals(getMarkup())) {
        // rewrite as styled text
        String styledText = filler.getStyledTextParser().write(fullStyledText);
        printText.setText(styledText);
      } else {
        printText.setText(fullText);
      }

      if (endIndex < fullText.length()) {
        printText.setTextTruncateIndex(new Integer(endIndex));
      }
    } else {
      String printedText;
      if (!JRCommonText.MARKUP_NONE.equals(getMarkup())) {
        printedText = filler.getStyledTextParser().write(fullStyledText, startIndex, endIndex);
      } else {
        printedText = fullText.substring(startIndex, endIndex);
      }
      printText.setText(printedText);
    }

    printText.setTextTruncateSuffix(getTextTruncateSuffix());
    printText.setLineBreakOffsets(getLineBreakOffsets());
  }