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