Ejemplo n.º 1
0
  /** Add the data of a specific signal type of a specific point to chart. */
  public void refreshChartOfSignal(MapPoint p, String signalTypeId) {
    LineChart chart = getChart(signalTypeId);
    ArrayList<LineDataSet> currentChartDataSets = new ArrayList<LineDataSet>();

    for (SignalDataSet ds : p.getDataSetsOfSignal(signalTypeId)) {
      // Log.i("NewPointActivity", "addToGraph ("+p+"): "+signalTypeId+",
      // "+ds.getSignalSourceId()+", "+ds.getDate()+", "+ds.size());

      LineDataSet chartDataSet = createChartDataSet(ds.getSignalSourceId(), ds.getDate());

      for (SignalSample s : ds.getSamples()) {
        if (s == null) {
          // @todo Each dataset must have its own null value.
          // Here the null value is fixed -150f.
          chartDataSet.addEntry(new Entry(-150f, chartDataSet.getEntryCount()));
        } else {
          // Add the sample to chart line.
          DoubleSignalSample doubleSignalSample = (DoubleSignalSample) s;
          chartDataSet.addEntry(
              new Entry(doubleSignalSample.getValue().floatValue(), chartDataSet.getEntryCount()));
        }
      }

      // Add the line to chart.
      currentChartDataSets.add(chartDataSet);

      // Updates table.
      updateDataTable(ds);
    }

    refreshChart(chart, currentChartDataSets);
  }