コード例 #1
0
  private static JRCompiler getCompiler(JasperDesign jasperDesign) throws JRException {
    JRCompiler compiler = null;

    String compilerClassName = JRProperties.getProperty(JRProperties.COMPILER_CLASS);
    if (compilerClassName == null || compilerClassName.trim().length() == 0) {
      String language = jasperDesign.getLanguage();
      compilerClassName = JRProperties.getProperty(JRCompiler.COMPILER_PREFIX + language);
      if (compilerClassName == null || compilerClassName.trim().length() == 0) {
        if (JRReport.LANGUAGE_JAVA.equals(language)) {
          return getJavaCompiler();
        } else {
          throw new JRException("No report compiler set for language : " + language);
        }
      }
    }

    try {
      Class clazz = JRClassLoader.loadClassForName(compilerClassName);
      compiler = (JRCompiler) clazz.newInstance();
    } catch (Exception e) {
      throw new JRException("Could not instantiate report compiler : " + compilerClassName, e);
    }

    return compiler;
  }
コード例 #2
0
  private String getValueClassRealName() {
    if (valueClassRealName == null) {
      valueClassRealName = JRClassLoader.getClassRealName(valueClassName);
    }

    return valueClassRealName;
  }
コード例 #3
0
  public Class<?> getNestedType() {
    if (nestedTypeName != null && nestedType == null) {
      try {
        nestedType = JRClassLoader.loadClassForName(nestedTypeName);
      } catch (ClassNotFoundException e) {
        throw new JRRuntimeException(e);
      }
    }

    return nestedType;
  }
コード例 #4
0
  private static JRCompiler getJavaCompiler() {
    JRCompiler compiler = null;

    try {
      JRClassLoader.loadClassForRealName("org.eclipse.jdt.internal.compiler.Compiler");
      compiler = new JRJdtCompiler();
    } catch (Exception e) {
    }

    if (compiler == null) {
      try {
        JRClassLoader.loadClassForRealName("com.sun.tools.javac.Main");
        compiler = new JRJdk13Compiler();
      } catch (Exception e) {
      }
    }

    if (compiler == null) {
      compiler = new JRJavacCompiler();
    }

    return compiler;
  }
コード例 #5
0
  public Class<?> getValueClass() {
    if (valueClass == null) {
      String className = getValueClassRealName();
      if (className != null) {
        try {
          valueClass = JRClassLoader.loadClassForName(className);
        } catch (ClassNotFoundException e) {
          throw new JRRuntimeException(e);
        }
      }
    }

    return valueClass;
  }
コード例 #6
0
  /**
   * Creates the scriptlet.
   *
   * @return the scriptlet
   * @throws JRException
   */
  protected JRAbstractScriptlet createScriptlet() throws JRException {
    JRAbstractScriptlet tmpScriptlet = null;

    if (scriptletClassName != null) {
      try {
        Class scriptletClass = JRClassLoader.loadClassForName(scriptletClassName);
        tmpScriptlet = (JRAbstractScriptlet) scriptletClass.newInstance();
      } catch (ClassNotFoundException e) {
        throw new JRException("Error loading scriptlet class : " + scriptletClassName, e);
      } catch (Exception e) {
        throw new JRException("Error creating scriptlet class instance : " + scriptletClassName, e);
      }
    } else {
      tmpScriptlet = new JRDefaultScriptlet();
    }

    return tmpScriptlet;
  }
コード例 #7
0
  protected void evaluateRenderer(byte evaluation) throws JRException {
    maxValue = (Double) fillContext.evaluate(getPlot().getMaxValueExpression(), evaluation);
    titleText =
        JRStringUtil.getString(
            fillContext.evaluate(getChartSettings().getTitleExpression(), evaluation));
    subtitleText =
        JRStringUtil.getString(
            fillContext.evaluate(getChartSettings().getSubtitleExpression(), evaluation));
    anchorName =
        JRStringUtil.getString(
            fillContext.evaluate(getChartSettings().getAnchorNameExpression(), evaluation));
    hyperlinkReference =
        JRStringUtil.getString(
            fillContext.evaluate(getChartSettings().getHyperlinkReferenceExpression(), evaluation));
    hyperlinkAnchor =
        JRStringUtil.getString(
            fillContext.evaluate(getChartSettings().getHyperlinkAnchorExpression(), evaluation));
    hyperlinkPage =
        (Integer) fillContext.evaluate(getChartSettings().getHyperlinkPageExpression(), evaluation);
    hyperlinkTooltip =
        JRStringUtil.getString(
            fillContext.evaluate(getChartSettings().getHyperlinkTooltipExpression(), evaluation));
    hyperlinkParameters =
        JRFillHyperlinkHelper.evaluateHyperlinkParameters(
            getChartSettings(), expressionEvaluator, evaluation);

    dataset.evaluateDatasetRun(evaluation);
    dataset.finishDataset();

    chartHyperlinkProvider = new CategoryChartHyperlinkProvider(dataset.getItemHyperlinks());
    bookmarkLevel = getChartSettings().getBookmarkLevel();

    JRComponentElement element = fillContext.getComponentElement();

    SpiderChartSharedBean spiderChartSharedBean =
        new SpiderChartSharedBean(
            getChartSettings().getRenderType(),
            maxValue,
            titleText,
            subtitleText,
            chartHyperlinkProvider,
            dataset);

    customizerClass = chartSettings.getCustomizerClass();
    if (customizerClass != null && customizerClass.length() > 0) {
      try {
        Class<?> myClass = JRClassLoader.loadClassForName(customizerClass);
        chartCustomizer = (ChartCustomizer) myClass.newInstance();
      } catch (Exception e) {
        throw new JRRuntimeException("Could not create chart customizer instance.", e);
      }

      if (chartCustomizer instanceof AbstractChartCustomizer) {
        ((AbstractChartCustomizer) chartCustomizer).init(fillContext.getFiller(), getDataset());
      }
    }

    renderer =
        SpiderChartRendererEvaluator.evaluateRenderable(
            fillContext.getFiller().getJasperReportsContext(),
            element,
            spiderChartSharedBean,
            chartCustomizer,
            JRChart.RENDER_TYPE_DRAW,
            SpiderChartRendererEvaluator.FILL_DATASET);
  }