private static OrderedMap<Long, Double[]> _MergeDataSets(boolean F, TemperatureSet TSList[]) { /* merge temperature data sets */ OrderedMap<Long, Double[]> rowMap = new OrderedMap<Long, Double[]>(); if (!ListTools.isEmpty(TSList)) { for (int d = 0; d < TSList.length; d++) { TemperatureSet TS = TSList[d]; if (TS != null) { Collection<Temperature> TList = TS.getTemperatures(); for (Temperature T : TList) { Long ts = new Long(T.getTimestamp()); Double tmp = new Double(T.getTemperature(F)); Double row[] = rowMap.get(ts); if (row == null) { row = new Double[TSList.length]; rowMap.put(ts, row); } row[d] = tmp; } } } } /* sort by timestamp */ rowMap.sortKeys(new ListTools.NumberComparator<Long>()); /* return */ return rowMap; }
/** ** Update min/max temperatures */ private void _updateMinMaxTemperature() { this.minTempC = 9999.0; this.maxTempC = -9999.0; for (Temperature T : this.tempList) { double tempC = T.getTemperatureC(); // temperature guaranteed valid if (tempC < this.minTempC) { this.minTempC = tempC; } if (tempC > this.maxTempC) { this.maxTempC = tempC; } } }
/** ** Adds the specified temperature to this data set */ public boolean addTemperature(Temperature T) { if (Temperature.isValid(T)) { // valid timestamp and temperature this.tempList.add(T); double tempC = T.getTemperatureC(); if (tempC < this.minTempC) { this.minTempC = tempC; } if (tempC > this.maxTempC) { this.maxTempC = tempC; } return true; } else { return false; } }