コード例 #1
0
  /**
   * Create a chart given a definition and some data.
   *
   * @param definition the chart to create
   * @param dataSets the data to use for the chart
   * @return the chart
   * @see LineChartBuilder
   * @see BarChartBuilder
   * @see IntervalChartBuilder
   * @see HistogramChartBuilder
   */
  public JFreeChart createChart(
      BaseChartDefinition definition, Iterable<? extends DataSet> dataSets) {
    long startT = System.nanoTime();

    JFreeChart chart = null;

    if (definition.getClass().equals(LineChartDefinition.class)) {
      LineChartDefinition lineDefinition = (LineChartDefinition) definition;

      lineChartBuilder.initChart(lineDefinition);

      for (DataSet data : dataSets) {
        lineChartBuilder.addLine(data);
      }

      chart = lineChartBuilder.getChart();
    } else if (definition.getClass().equals(IntervalChartDefinition.class)) {
      IntervalChartDefinition lineDefinition = (IntervalChartDefinition) definition;

      intervalChartBuilder.initChart(lineDefinition);

      for (DataSet data : dataSets) {
        // TODO AnalysisRecord cache needed here?
        List<AnalysisRecord> analysis = new java.util.ArrayList<AnalysisRecord>();

        for (Interval i : app.getIntervalManager().getIntervals()) {
          AnalysisRecord record = new AnalysisRecord(data);
          record.setInterval(i);
          record.setGranularity(intervalChartBuilder.getGranularity());

          analysis.add(record);
        }

        intervalChartBuilder.addLine(lineDefinition, analysis);
      }

      chart = intervalChartBuilder.getChart();
    } else if (definition.getClass().equals(BarChartDefinition.class)) {
      BarChartDefinition barDefinition = (BarChartDefinition) definition;

      barChartBuilder.initChart(barDefinition);

      for (DataSet data : dataSets) {
        AnalysisRecord record = app.getAnalysis(data);

        // this check is really a hack for event interactions between the tree and the
        // ReportPanel when removing data with selected charts
        if (record != null) {
          barChartBuilder.addBar(record);
        }
      }

      chart = barChartBuilder.getChart();
    } else if (definition.getClass().equals(HistogramChartDefinition.class)) {
      HistogramChartDefinition histogramDefinition = (HistogramChartDefinition) definition;

      histogramChartBuilder.initChart(histogramDefinition);

      for (DataSet data : dataSets) {
        AnalysisRecord record = app.getAnalysis(data);

        // this check is really a hack for event interactions between the tree and the
        // ReportPanel when removing data with selected charts
        if (record != null) {
          histogramChartBuilder.addHistogram(record);
        }
      }

      chart = histogramChartBuilder.getChart();
    }

    if (LOGGER.isTraceEnabled()) {
      LOGGER.trace(
          "{}: {} chart created in {}ms",
          new Object[] {
            dataSets, definition.getShortName(), (System.nanoTime() - startT) / 1000000.0d
          });
    }

    return chart;
  }
コード例 #2
0
 public void setInterval(Interval interval) {
   lineChartBuilder.setInterval(interval);
   barChartBuilder.setInterval(interval);
   intervalChartBuilder.setInterval(interval);
   histogramChartBuilder.setInterval(interval);
 }
コード例 #3
0
 public void addPlugin(ChartBuilderPlugin plugin) {
   lineChartBuilder.addPlugin(plugin);
   barChartBuilder.addPlugin(plugin);
   intervalChartBuilder.addPlugin(plugin);
   histogramChartBuilder.addPlugin(plugin);
 }
コード例 #4
0
 public void setGranularity(int granularity) {
   lineChartBuilder.setGranularity(granularity);
   barChartBuilder.setGranularity(granularity);
   intervalChartBuilder.setGranularity(granularity);
   histogramChartBuilder.setGranularity(granularity);
 }