Example #1
0
 private XYDataset filterData(List<double[]> ds) {
   this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
   double[] correlation = null;
   double[] dblData1 = applyWindow(ds.get(0), (String) getTaperCB().getSelectedItem());
   try {
     if (ds.size() == 1) {
       correlation = IstiUtilsMath.correlate(dblData1, dblData1);
     } else {
       double[] dblData2 = applyWindow(ds.get(1), (String) taperCB.getSelectedItem());
       correlation = IstiUtilsMath.correlate(dblData1, dblData2);
     }
   } catch (IllegalArgumentException e) {
     logger.error("IllegalArgumentException:", e);
   }
   logger.debug("correlation computed, size = " + correlation.length);
   XYSeriesCollection dataset = new XYSeriesCollection();
   XYSeries series = new XYSeries(seriesName);
   double ampMax = 0;
   int ampMaxPoint = -1;
   for (int i = 0; i < correlation.length; i++) {
     series.add(sampleRate * (i - correlation.length / 2) / 1000, correlation[i]);
     if (Math.abs(correlation[i]) > ampMax) {
       ampMax = Math.abs(correlation[i]);
       ampMaxPoint = i;
     }
   }
   dataset.addSeries(series);
   getAmpMaxL().setText("Max Amplitude: " + dFormat.format(ampMax));
   getLagTimeL()
       .setText("Lag time: " + sampleRate * (ampMaxPoint - correlation.length / 2) / 1000 + " s");
   this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
   return dataset;
 }
Example #2
0
  public static void drawPic(String url, String file) throws FileNotFoundException, IOException {
    //		XYSeries xyseries = getXY(url);
    XYSeries xyseries = getXYseries(url);
    XYSeriesCollection xyseriescollection =
        new XYSeriesCollection(); // 再用XYSeriesCollection添加入XYSeries
    // 对象
    xyseriescollection.addSeries(xyseries);

    // 创建主题样式
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    // 设置标题字体
    standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
    // 设置图例的字体
    standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
    // 设置轴向的字体
    standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
    // 应用主题样式
    ChartFactory.setChartTheme(standardChartTheme);
    // JFreeChart chart=ChartFactory.createXYAreaChart("xyPoit", "点的标号",
    // "出现次数", xyseriescollection, PlotOrientation.VERTICAL, true, false,
    // false);
    JFreeChart chart =
        ChartFactory.createScatterPlot(
            "决策图", "点密度", "点距离", xyseriescollection, PlotOrientation.VERTICAL, true, false, false);
    //		String file="d:/decision_chart.png";
    try {
      ChartUtilities.saveChartAsPNG(new File(file), chart, 470, 470);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    System.out.println(new java.util.Date() + ": finished drawing the pic in " + file);
  }
Example #3
0
  protected void updateXYSerieses() throws MicroarrayException {

    Iterable<Float> xValues = data.queryFeatures(xVar.getExpression()).asFloats();
    Iterable<Float> yValues = data.queryFeatures(yVar.getExpression()).asFloats();

    XYSeries series = new XYSeries("");
    XYSeries selectionSeries = new XYSeries("");

    Iterator<Float> xIterator = xValues != null ? xValues.iterator() : null;
    int i = 0;

    for (Float y : yValues) {
      if (selectedIndexes.contains(i)) {
        if (xIterator != null) {
          selectionSeries.add(xIterator.next(), y);
        } else {
          selectionSeries.add(i, y);
        }
      } else {

        if (xIterator != null) {
          series.add(xIterator.next(), y);
        } else {
          series.add(i, y);
        }
      }
      i++;
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    dataset.addSeries(selectionSeries);

    plot.setDataset(dataset);
  }
 private XYPlot createScalabilityPlot(
     List<XYSeries> seriesList,
     String xAxisLabel,
     NumberFormat xAxisNumberFormat,
     String yAxisLabel,
     NumberFormat yAxisNumberFormat) {
   NumberAxis xAxis;
   if (useLogarithmicProblemScale(seriesList)) {
     LogarithmicAxis logarithmicAxis = new LogarithmicAxis(xAxisLabel + " (logarithmic)");
     logarithmicAxis.setAllowNegativesFlag(true);
     xAxis = logarithmicAxis;
   } else {
     xAxis = new NumberAxis(xAxisLabel);
   }
   xAxis.setNumberFormatOverride(xAxisNumberFormat);
   NumberAxis yAxis = new NumberAxis(yAxisLabel);
   yAxis.setNumberFormatOverride(yAxisNumberFormat);
   XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
   int seriesIndex = 0;
   for (XYSeries series : seriesList) {
     XYSeriesCollection seriesCollection = new XYSeriesCollection();
     seriesCollection.addSeries(series);
     plot.setDataset(seriesIndex, seriesCollection);
     XYItemRenderer renderer = createScalabilityPlotRenderer(yAxisNumberFormat);
     plot.setRenderer(seriesIndex, renderer);
     seriesIndex++;
   }
   plot.setOrientation(PlotOrientation.VERTICAL);
   return plot;
 }
Example #5
0
  private XYDataset createDataset(String metricName) {

    series = new XYSeriesCollection();

    // For each collection of evaluations
    for (int i = 0; i < evaluationsCollection.size(); i++) {

      if (!set.contains(i)) {

        List<AbstractEvaluation> evaluations = evaluationsCollection.get(i);
        XYSeries newXYSerie = new XYSeries(queryNames.get(i));

        int evalIndex = 0;

        for (AbstractEvaluation eval : evaluations) {
          if (evalIndex % reportFrecuency == 0) {
            newXYSerie.add(eval.getLabeledSetSize(), eval.getMetricValue(metricName));
          }
          ++evalIndex;
        }
        series.addSeries(newXYSerie);
      }
    }
    // The series that belongs to passive learning is the last
    if (passiveEvaluation != null) {

      series.addSeries(createPassiveLearningSerie(metricName, evaluationsCollection.get(0)));
    }
    return series;
  }
  public PlotterXY(String chartTitle) {
    setLayout(new BorderLayout());
    mIdeal = new XYSeries("Ideal  Position");
    mReal = new XYSeries("Ideal  Velocity");

    mCollection = new XYSeriesCollection();
    mCollection.addSeries(mIdeal);
    mCollection.addSeries(mReal);

    final JFreeChart chart =
        ChartFactory.createXYLineChart(
            chartTitle,
            "X (Inches)",
            "Y (Inches)",
            mCollection,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);
    chart.setBackgroundPaint(Color.white);

    m_chartPanel = new ChartPanel(chart);
    m_chartPanel.setPreferredSize(new Dimension(400, 300));
    m_chartPanel.setBackground(getBackground());

    add(m_chartPanel, BorderLayout.CENTER);
  }
Example #7
0
 private static XYDataset createDataset() {
   XYSeries xyseries = new XYSeries("First");
   xyseries.add(1.0D, 1.0D);
   xyseries.add(2D, 4D);
   xyseries.add(3D, 3D);
   xyseries.add(4D, 5D);
   xyseries.add(5D, 5D);
   xyseries.add(6D, 7D);
   xyseries.add(7D, 7D);
   xyseries.add(8D, 8D);
   XYSeries xyseries1 = new XYSeries("Second");
   xyseries1.add(1.0D, 5D);
   xyseries1.add(2D, 7D);
   xyseries1.add(3D, 6D);
   xyseries1.add(4D, 8D);
   xyseries1.add(5D, 4D);
   xyseries1.add(6D, 4D);
   xyseries1.add(7D, 2D);
   xyseries1.add(8D, 1.0D);
   XYSeries xyseries2 = new XYSeries("Third");
   xyseries2.add(3D, 4D);
   xyseries2.add(4D, 3D);
   xyseries2.add(5D, 2D);
   xyseries2.add(6D, 3D);
   xyseries2.add(7D, 6D);
   xyseries2.add(8D, 3D);
   xyseries2.add(9D, 4D);
   xyseries2.add(10D, 3D);
   XYSeriesCollection xyseriescollection = new XYSeriesCollection();
   xyseriescollection.addSeries(xyseries);
   xyseriescollection.addSeries(xyseries1);
   xyseriescollection.addSeries(xyseries2);
   return xyseriescollection;
 }
  private void crearImagen() {

    XYSeries serie = new XYSeries("Serie");
    Iterator<Double> iterator = ejercicio.getHistoricoSolucion().iterator();
    for (int i = 0; i < ejercicio.getHistoricoSolucion().size(); i++) {
      serie.add(i, iterator.next());
    }

    XYSeriesCollection coleccionSeries = new XYSeriesCollection();
    coleccionSeries.addSeries(serie);

    JFreeChart chart =
        ChartFactory.createXYLineChart(
            "Comportamiento Simulated Annealing",
            "Ciclo",
            "Solucion",
            coleccionSeries,
            PlotOrientation.VERTICAL,
            false,
            false,
            true);

    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseZoomable(true);
    this.add(panel);
  }
  public void displayWithOtherSignals(
      ArrayList<GeneralSignal> otherSignals, String title, boolean shapeVisible) {
    JFreeChart chart;

    XYSeriesCollection xyDataSet = new XYSeriesCollection(this.data);
    for (int i = 0; i < otherSignals.size(); i++) {
      xyDataSet.addSeries(otherSignals.get(i).getData());
    }

    chart =
        ChartFactory.createXYLineChart(
            title, // Title
            "Abscissa", // X axis label
            "Ordinate", // Y axis label
            xyDataSet, // dataset
            PlotOrientation.VERTICAL, // orientation
            true, // legends
            true, // tool tips
            true); // urls

    if (shapeVisible) {
      XYPlot plot = (XYPlot) chart.getPlot();
      XYItemRenderer r = plot.getRenderer();
      if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setSeriesShapesVisible(0, true);
        renderer.setSeriesShapesFilled(0, true);
      }
    }

    ChartFrame frame = new ChartFrame("Frame Title", chart);
    frame.setVisible(true);
    frame.setSize(512, 512);
  }
  public void execute() {
    // TODO Auto-generated method stub

    // simply get the environment datamodel
    dmodel = (StaticEnvDataModel) sim.getEnvDataModel();

    double infected = getPercentInfected(dmodel);

    synchronized (this) {
      XYSeries series;
      try {
        series = data.getSeries("infected");
        series.add(dmodel.time, infected);
      } catch (org.jfree.data.UnknownKeyException e) {
        series = new XYSeries("infected");
        data.addSeries(series);
        series.add(dmodel.time, infected);
      }

      if (dmodel.time % 100 == 0) {
        // this will cause the gui to update?
        updateChart();
      }
    }
  }
Example #11
0
  private boolean plotCorrectionData() {
    plot3d.removeAllPlots();
    XYSeries series;
    XYPlot plot = chartPanel.getChart().getXYPlot();
    XYSeriesCollection lineDataset = (XYSeriesCollection) plot.getDataset(0);
    DecimalFormat df = new DecimalFormat(".00");
    String val;
    int i = 0;
    int j = 0;
    if (!Utils.isTableEmpty(corrTable)) {
      try {
        for (i = 1; i < corrTable.getColumnCount(); ++i) {
          val = corrTable.getValueAt(0, i).toString();
          series = new XYSeries(df.format(Double.valueOf(val)));
          for (j = 1; j < corrTable.getRowCount(); ++j) {
            if (corrTable.getValueAt(j, i) != null) {
              val = corrTable.getValueAt(j, i).toString();
              if (!val.isEmpty())
                series.add(
                    Double.valueOf(corrTable.getValueAt(j, 0).toString()), Double.valueOf(val));
            }
          }
          if (series.getItemCount() > 0) {
            corrData.add(series);
            series.setDescription(series.getKey().toString());
            lineDataset.addSeries(series);
          }
        }
        plot.getDomainAxis(0).setAutoRange(true);
        plot.getRangeAxis(0).setAutoRange(true);
        plot.getDomainAxis(0).setLabel(xAxisName);
        plot.getRangeAxis(0).setLabel(yAxisName);
        plot.getRenderer(0).setSeriesVisible(0, false);

        double[] x = new double[xAxisArray.size()];
        for (i = 0; i < xAxisArray.size(); ++i) x[i] = xAxisArray.get(i);
        double[] y = new double[yAxisArray.size()];
        for (i = 0; i < yAxisArray.size(); ++i) y[i] = yAxisArray.get(i);
        double[][] z = Utils.doubleZArray(corrTable, x, y);
        Color[][] colors = Utils.generateTableColorMatrix(corrTable, 1, 1);
        plot3d.addGridPlot("Average Error % Plot", colors, x, y, z);
      } catch (NumberFormatException e) {
        logger.error(e);
        JOptionPane.showMessageDialog(
            null,
            "Error parsing number from "
                + corrTableName
                + " table, cell("
                + i
                + " : "
                + j
                + "): "
                + e,
            "Error",
            JOptionPane.ERROR_MESSAGE);
        return false;
      }
    }
    return true;
  }
  /**
   * A check for the datasetIndex and seriesIndex fields in the LegendItem returned by the
   * getLegendItem() method.
   */
  public void testGetLegendItemSeriesIndex() {
    XYSeriesCollection d1 = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, 1.1);
    XYSeries s2 = new XYSeries("S2");
    s2.add(1.0, 1.1);
    d1.addSeries(s1);
    d1.addSeries(s2);

    XYSeriesCollection d2 = new XYSeriesCollection();
    XYSeries s3 = new XYSeries("S3");
    s3.add(1.0, 1.1);
    XYSeries s4 = new XYSeries("S4");
    s4.add(1.0, 1.1);
    XYSeries s5 = new XYSeries("S5");
    s5.add(1.0, 1.1);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    XYDotRenderer r = new XYDotRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
  }
 /**
  * Creates and returns a sample dataset. The data was randomly generated.
  *
  * @return a sample dataset.
  */
 private XYDataset createSampleData() {
   XYSeries series = new XYSeries("Series 1");
   series.add(2.0, 56.27);
   series.add(3.0, 41.32);
   series.add(4.0, 31.45);
   series.add(5.0, 30.05);
   series.add(6.0, 24.69);
   series.add(7.0, 19.78);
   series.add(8.0, 20.94);
   series.add(9.0, 16.73);
   series.add(10.0, 14.21);
   series.add(11.0, 12.44);
   XYSeriesCollection result = new XYSeriesCollection(series);
   XYSeries series2 = new XYSeries("Series 2");
   series2.add(11.0, 56.27);
   series2.add(10.0, 41.32);
   series2.add(9.0, 31.45);
   series2.add(8.0, 30.05);
   series2.add(7.0, 24.69);
   series2.add(6.0, 19.78);
   series2.add(5.0, 20.94);
   series2.add(4.0, 16.73);
   series2.add(3.0, 14.21);
   series2.add(2.0, 12.44);
   result.addSeries(series2);
   return result;
 }
  public static ChartPanel getAvgRewardsChart(BotStatistic stats) {
    XYSeriesCollection ds = new XYSeriesCollection();

    LinkedList<BotSeries> series = new LinkedList<BotSeries>();

    for (String botName : stats.getAllRewardedBotNames()) {
      series.add(new BotSeries(new XYSeries(botName), 0, 0, botName));
    }

    String allName = "all RL";
    int botsNum = stats.getAllRewardedBotNames().size();
    series.add(new BotSeries(new XYSeries(allName), 0, 0, allName));

    int segmentSize = stats.rewards.size() / avgRewardsChartSegments;
    if (segmentSize < 1) {
      segmentSize = 1;
    }

    int i = 0;

    for (Reward k : stats.rewards) {
      for (BotSeries s : series) {
        if (k.botName.equals(s.botName)) {
          s.d1 += k.reward;
        }
      }

      i++;

      if (i % segmentSize == 0) {
        BotSeries as = series.getLast();
        for (BotSeries s : series) {
          if (s.botName.equals(as.botName)) continue;
          s.series.add(k.time - segmentSize / 2 / 10, s.d1 / segmentSize);
          as.d1 += s.d1;
          s.d1 = 0;
        }
        as.series.add(k.time - segmentSize / 2 / 10, as.d1 / (botsNum * segmentSize));
        as.d1 = 0;
      }
    }

    for (BotSeries s : series) {
      ds.addSeries(s.series);
    }

    JFreeChart c =
        ChartFactory.createXYLineChart(
            "avg reward gaining speed",
            "time [s]",
            "avg reward gaining speed",
            ds,
            PlotOrientation.VERTICAL,
            true,
            true,
            true);

    ChartPanel cp = new ChartPanel(c);
    return cp;
  }
Example #15
0
  /** Creates a dataset of type XYSeries */
  public XYDataset convertDataSet() {
    int size = 0; // Initialises a value for size
    int sum = 0; // initialises a value for sum
    int pos = 0; // initialises a value for position
    int j = 0; // initialises a increment for the for loop

    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries(super.GetTitle());

    DataCell preVal = super.GetDataSet().GetCell(0, 0);
    // Creates a new list for the found elements
    super.m_foundElements = new ArrayList<String>();

    for (int i = 0; i < super.GetDataSet().GetNumOfRows() - 1; i++) {

      if (!super.isUnique(super.GetDataSet().GetCell(super.GetXColumnPosition(), i).toString())) {
        for (j = pos; j < super.GetDataSet().GetNumOfRows() - 1; j++) {
          if (preVal
              .toString()
              .equals(super.GetDataSet().GetCell(super.GetXColumnPosition(), j).toString())) {

            // Check if datatype is a number
            if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
                == DataType.INTEGER) {
              sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetInteger();
            } else if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
                == DataType.DOUBLE) {
              sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetDouble();
            }
          }
        }
        super.m_foundElements.add(
            super.GetDataSet().GetCell(super.GetXColumnPosition(), i).toString());

        // Add to chart dataSet
        series.add(sum, preVal.GetInteger());

        preVal = super.GetDataSet().GetCell(super.GetXColumnPosition(), i++);
        sum = 0; //
        pos++;
      }
    }

    for (j = pos; j < super.GetDataSet().GetNumOfRows() - 1; j++) {
      if (super.m_foundElements
          .get(super.m_foundElements.size() - 1)
          .equals(super.GetDataSet().GetCell(super.GetXColumnPosition(), j).toString())) {
        if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
            == DataType.INTEGER) {
          sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetInteger();
        } else if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
            == DataType.DOUBLE) {
          sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetDouble();
        }
      }
    }
    series.add(sum, preVal.GetInteger());
    dataset.addSeries(series);
    return dataset;
  }
  @Override
  protected void setChart() {
    SeriesManager<Double, Double> sf = new SeriesManager<Double, Double>(intermediateData);
    List<DataSeries<Double, Double>> seriesList = sf.getSeries();

    DataSeries<Double, Double> series = seriesList.get(0);
    List<SeriesPair<Double, Double>> values = series.getSeriesValues(Double.class, Double.class);

    XYSeries deltaMassSeries = new XYSeries(series.getIdentifier());
    for (SeriesPair<Double, Double> value : values) {
      deltaMassSeries.add(value.getX(), value.getY());
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(deltaMassSeries);

    chart =
        ChartFactory.createXYLineChart(
            getChartTitle(), // chart title
            "Experimental m/z - Theoretical m/z", // x axis label
            "Relative Frequency", // y axis label
            dataset, // chartData
            PlotOrientation.VERTICAL,
            false, // include legend
            true, // tooltips
            false // urls
            );
    chart.addSubtitle(new TextTitle(getChartSubTitle()));

    XYPlot plot = chart.getXYPlot();
    plot.setDomainZeroBaselineVisible(true);
    plot.setBackgroundAlpha(0f);
    plot.setDomainGridlinePaint(Color.red);
    plot.setRangeGridlinePaint(Color.blue);
  }
Example #17
0
 private XYDataset createDataset(XYSeries data[]) {
   XYSeriesCollection collection = new XYSeriesCollection();
   for (XYSeries line : data) {
     collection.addSeries(line);
   }
   return collection;
 }
  /**
   * precondition : 'attribute' MUST contain number values only
   *
   * @param cases
   * @param attribute
   * @return DefaultXYDataset with all values of 'attribute' against event numbers or timestamps.
   */
  private XYSeriesCollection getDataAttributes(
      String[] attributes, boolean byTime, double timesize) {
    XYSeriesCollection result = new XYSeriesCollection();
    for (int index = 0; index < attributes.length; index++) {
      String attribute = attributes[index];
      Integer i = 0;
      XYSeries row = new XYSeries(attribute);
      for (ProcessInstance pi : mylog.getInstances()) {
        Integer x = 0; // count event number
        Date begin = pi.getAuditTrailEntries().first().getTimestamp(); // starting
        // time
        // of
        // process
        // instance

        for (AuditTrailEntry ate : pi.getListOfATEs()) {
          if (ate.getAttributes().containsKey(attribute)) {
            Double val;
            val = Double.valueOf(ate.getAttributes().get(attribute));
            if (byTime) {
              row.add(timediff(begin, ate.getTimestamp()) / timesize, val.doubleValue());
            } else {
              row.add(x.doubleValue(), val.doubleValue());
            }
          }
          x++; // event number in case
        }
        i++; // case number
      }
      result.addSeries(row);
    }
    return result;
  }
 /**
  * Creates a sample dataset.
  *
  * @param index the dataset index.
  * @return A dataset.
  */
 private XYDataset createDataset(int index) {
   XYSeries series1 = new XYSeries("Series " + (index + 1));
   series1.add(-10.0, -5.0);
   series1.add(10.0, 5.0);
   XYSeriesCollection dataset = new XYSeriesCollection();
   dataset.addSeries(series1);
   return dataset;
 }
  /** Sets the chart dataset */
  private void refreshChartData() {
    // Get all payoff history (put into readable format for series)
    XYSeries payoffHistory = getUserPayoffData();

    if (payoffHistory == null) return;

    // Reupdate series
    xySeriesCollection.removeAllSeries();
    xySeriesCollection.addSeries(payoffHistory);
  }
Example #21
0
 /**
  * Creates a dataset.
  *
  * @return the dataset.
  */
 public XYDataset createDataset(DataSequence ds, String label) {
   XYSeries observations = new XYSeries(label);
   int n = ds.size();
   for (int i = 0; i < n; i++) {
     observations.add(i, ds.get(i).value);
   }
   XYSeriesCollection collection = new XYSeriesCollection();
   collection.addSeries(observations);
   return collection;
 }
Example #22
0
 /** Creates a float[] time-series */
 public XYDataset createDataset(Float[] ds, String label) {
   XYSeries observations = new XYSeries(label);
   int n = ds.length;
   for (int i = 0; i < n; i++) {
     observations.add(i, ds[i]);
   }
   XYSeriesCollection collection = new XYSeriesCollection();
   collection.addSeries(observations);
   return collection;
 }
  public double highestPeak() {

    double max = data.getSeries(0).getDataItem(0).getY().doubleValue();
    for (int i = 0; i < data.getSeriesCount(); i++)
      for (int j = 0; j < data.getSeries(i).getItemCount(); j++) {
        if (data.getSeries(i).getDataItem(j).getY().doubleValue() > max) {
          max = data.getSeries(i).getDataItem(j).getY().doubleValue();
        }
      }
    return max;
  }
 @Override
 public void writeGraphFiles(BenchmarkReport benchmarkReport) {
   List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList =
       new ArrayList<Map<String, XYSeries>>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
   for (ConstraintMatchTotalStepScoreStatisticPoint point : getPointList()) {
     int scoreLevel = point.getScoreLevel();
     if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) {
       continue;
     }
     while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) {
       constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>());
     }
     Map<String, XYSeries> constraintIdToWeightSeriesMap =
         constraintIdToWeightSeriesMapList.get(scoreLevel);
     if (constraintIdToWeightSeriesMap == null) {
       constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>();
       constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap);
     }
     String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName();
     XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId);
     if (weightSeries == null) {
       weightSeries = new XYSeries(point.getConstraintName() + " weight");
       constraintIdToWeightSeriesMap.put(constraintId, weightSeries);
     }
     long timeMillisSpent = point.getTimeMillisSpent();
     weightSeries.add(timeMillisSpent, point.getWeightTotal());
   }
   graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size());
   for (int scoreLevelIndex = 0;
       scoreLevelIndex < constraintIdToWeightSeriesMapList.size();
       scoreLevelIndex++) {
     XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex);
     // No direct ascending lines between 2 points, but a stepping line instead
     XYItemRenderer renderer = new XYStepRenderer();
     plot.setRenderer(renderer);
     XYSeriesCollection seriesCollection = new XYSeriesCollection();
     for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) {
       seriesCollection.addSeries(series);
     }
     plot.setDataset(seriesCollection);
     JFreeChart chart =
         new JFreeChart(
             singleBenchmarkResult.getName()
                 + " constraint match total step score diff level "
                 + scoreLevelIndex
                 + " statistic",
             JFreeChart.DEFAULT_TITLE_FONT,
             plot,
             true);
     graphFileList.add(
         writeChartToImageFile(
             chart, "ConstraintMatchTotalStepScoreStatisticLevel" + scoreLevelIndex));
   }
 }
Example #25
0
  private XYDataset createDataset(Review[] reviews) {
    XYSeries series = new XYSeries("Ratings");

    for (int i = 0; i < reviews.length; i++) {
      series.add(new XYDataItem(i, reviews[i].getRating()));
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    return dataset;
  }
Example #26
0
  public static JPanel createDemoPanel(int[] arvud) {

    XYSeries xyseries = new XYSeries("Täidetud mälublokid");
    for (int i = 0; i < arvud.length; i++) {
      xyseries.add(i, arvud[i]);
    }

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    JFreeChart jfreechart = createChart(xyseriescollection);
    return new ChartPanel(jfreechart);
  }
Example #27
0
  public static XYSeriesCollection getCustomXYSeriesCollection(String xAxisName, String yAxisName) {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    runner.eval(
        "[Xdata Ydata] = plotter.plotCustom('"
            + DBSeerPlotControlPanel.axisMap.get(xAxisName)
            + "', '"
            + DBSeerPlotControlPanel.axisMap.get(yAxisName)
            + "');");

    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");

    XYSeriesCollection dataSet = new XYSeriesCollection();

    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;

    if (numXCellArray != numYCellArray) {
      JOptionPane.showMessageDialog(
          null,
          "The number of X dataset and Y dataset does not match.",
          "The number of X dataset and Y dataset does not match.",
          JOptionPane.ERROR_MESSAGE);
      System.out.println(numXCellArray + " : " + numYCellArray);
      return null;
    }

    for (int i = 0; i < numYCellArray; ++i) {
      double[] xArray = (double[]) xCellArray[i];

      runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
      runner.eval("yArray = Ydata{" + (i + 1) + "};");
      double[] yArraySize = runner.getVariableDouble("yArraySize");
      double[] yArray = runner.getVariableDouble("yArray");

      int xLength = xArray.length;
      int row = (int) yArraySize[0];
      int col = (int) yArraySize[1];

      for (int c = 0; c < col; ++c) {
        XYSeries series = new XYSeries(yAxisName);

        for (int r = 0; r < row; ++r) {
          int xRow = (r >= xLength) ? xLength - 1 : r;
          series.add(xArray[xRow], yArray[r + c * row]);
        }
        dataSet.addSeries(series);
      }
    }

    return dataSet;
  }
  public static ChartPanel getKillsPerEachDeathByBotType(BotStatistic stats) {
    XYSeriesCollection ds = new XYSeriesCollection();

    LinkedList<BotSeries> series = new LinkedList<BotSeries>();

    for (String botName : stats.getAllBotFamilies()) {
      series.add(new BotSeries(new XYSeries(botName), 0, 0, botName));
    }

    for (BotSeries s : series) {
      s.series.add(0, 0);
      s.d1 = StatsTools.countBotsOfGivenFamilly(s.botName, stats);
    }

    for (Kill k : stats.kills) {
      for (BotSeries s : series) {
        if (k.killer.startsWith(s.botName) || k.victim.startsWith(s.botName)) {
          if (k.killer.startsWith(s.botName)) {
            s.int1++;
          }
          if (k.victim.startsWith(s.botName)) {
            s.int2++;
          }
          float val = 0;
          if (s.int2 != 0) {
            val = (float) s.int1 / (float) s.int2;
          }
          s.series.add(k.time / 10, val / s.d1);
        }
      }
    }

    for (BotSeries s : series) {
      ds.addSeries(s.series);
    }

    JFreeChart c =
        ChartFactory.createXYLineChart(
            "Kills per each death by bot type in time",
            "time [s]",
            "kills / deaths",
            ds,
            PlotOrientation.VERTICAL,
            true,
            true,
            true);

    ChartPanel cp = new ChartPanel(c);
    return cp;
  }
Example #29
0
  /**
   * Creates a sample dataset.
   *
   * @return A sample dataset.
   */
  private IntervalXYDataset createDataset(double[][] dataMatrix, String[] names) {
    final XYSeriesCollection dataset = new XYSeriesCollection();
    for (int fitResultPos = 0; fitResultPos < dataMatrix.length; fitResultPos++) {
      final XYSeries series = new XYSeries(names[fitResultPos]);

      for (int fitPos = 0; fitPos < dataMatrix[fitResultPos].length; fitPos++) {
        series.add((double) fitPos, dataMatrix[fitResultPos][fitPos]);
      }

      dataset.addSeries(series);
    }

    return dataset;
  }
Example #30
0
  private XYDataset createDataset(final List<Coordinates>... lists) {
    final XYSeriesCollection dataset = new XYSeriesCollection();
    int i = 0;
    for (final List<Coordinates> list : lists) {
      final XYSeries xySeries = new XYSeries(i);
      for (final Coordinates coordinates : list) {
        xySeries.add(coordinates.getFirst(), coordinates.getSecond());
      }
      dataset.addSeries(xySeries);
      i++;
    }

    return dataset;
  }