Exemplo 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);
  }
Exemplo n.º 2
0
  /** Displayd a dataset in the data table. */
  public void updateDataTable(SignalDataSet dataSet) {
    // Creates a line within table to store
    // datasource info.
    createDataRow(dataSet);
    SignalSource source = dataSet.getSource();

    // Sets row data.
    AndroidUtil.getTextViewByTag(this, dataSet.getId() + "-signalTypeText")
        .setText(source.getSignalType());
    AndroidUtil.getTextViewByTag(this, dataSet.getId() + "-sourceIdText").setText(source.getId());
    AndroidUtil.getTextViewByTag(this, dataSet.getId() + "-samplesCountText")
        .setText(dataSet.size() + "");

    SimpleDateFormat dt = new SimpleDateFormat("MM-dd hh:mm:ss");
    AndroidUtil.getTextViewByTag(this, dataSet.getId() + "-dateText")
        .setText(dt.format(dataSet.getDate()));

    DoubleSignalDataSet doubleSignalDataSet = (DoubleSignalDataSet) dataSet;
    AndroidUtil.getTextViewByTag(this, dataSet.getId() + "-minText")
        .setText(String.format("%.2f", doubleSignalDataSet.getMinValue()));
    AndroidUtil.getTextViewByTag(this, dataSet.getId() + "-maxText")
        .setText(String.format("%.2f", doubleSignalDataSet.getMaxValue()));
    AndroidUtil.getTextViewByTag(this, dataSet.getId() + "-avgText")
        .setText(String.format("%.2f", doubleSignalDataSet.getAverage()));
  }
Exemplo n.º 3
0
  /**
   * Creates a row in the data table to store a signal source data (source, date, count, min, max
   * and avg).
   */
  public void createDataRow(SignalDataSet dataSet) {
    SignalSource source = dataSet.getSource();
    ArrayList<View> containers = AndroidUtil.getViewsByTag(this, dataSet.getId() + "-dataRow");
    if (containers.size() == 0) { // There is NO row

      TableRow row = new TableRow(this);
      TableRow.LayoutParams lp =
          new TableRow.LayoutParams(
              TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
      row.setLayoutParams(lp);
      row.setTag(dataSet.getId() + "-dataRow");

      // Signal type.
      TextView signalType =
          createDataRowText(dataSet.getId() + "-signalTypeText", source.getSignalType(), 20f);

      // Source id.
      TextView sourceId = createDataRowText(dataSet.getId() + "-sourceIdText", source.getId(), 35f);

      // Record date.
      TextView date = createDataRowText(dataSet.getId() + "-dateText", "", 20f);

      // Samples recorded.
      TextView samplesCount = createDataRowText(dataSet.getId() + "-samplesCountText", "0", 15f);

      // Min, max and avg.
      TextView min = createDataRowText(dataSet.getId() + "-minText", "---", 15f);
      TextView max = createDataRowText(dataSet.getId() + "-maxText", "---", 15f);
      TextView avg = createDataRowText(dataSet.getId() + "-avgText", "---", 15f);

      row.addView(signalType);
      row.addView(sourceId);
      row.addView(date);
      row.addView(samplesCount);
      row.addView(min);
      row.addView(max);
      row.addView(avg);

      TableLayout table = (TableLayout) findViewById(R.id.dataTable);
      table.addView(row);
    }
  }