/** 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()));
  }
  /**
   * 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);
    }
  }