1 24 package info.monitorenter.gui.chart.io; 25 26 import info.monitorenter.gui.chart.ITrace2D; 27 import info.monitorenter.gui.chart.TracePoint2D; 28 29 import java.io.FileNotFoundException ; 30 import java.io.IOException ; 31 import java.io.InputStream ; 32 import java.util.Collections ; 33 import java.util.Iterator ; 34 import java.util.LinkedList ; 35 import java.util.List ; 36 import java.util.Map ; 37 import java.util.Properties ; 38 39 47 public class PropertyFileStaticDataCollector extends AStaticDataCollector { 48 49 54 private InputStream m_source; 55 56 68 public PropertyFileStaticDataCollector(final ITrace2D trace, final InputStream propertyFileStream) { 69 super(trace); 70 this.m_source = propertyFileStream; 71 } 72 73 76 public void collectData() throws FileNotFoundException , IOException { 77 Properties props = new Properties (); 78 props.load(this.m_source); 79 Map.Entry entry; 80 Iterator it = props.entrySet().iterator(); 81 List sortList = new LinkedList (); 82 while (it.hasNext()) { 83 entry = (Map.Entry ) it.next(); 84 sortList.add(new TracePoint2D(Double.parseDouble((String ) entry.getKey()), Double 85 .parseDouble((String ) entry.getValue()))); 86 } 87 Collections.sort(sortList); 88 it = sortList.iterator(); 89 while (it.hasNext()) { 90 m_trace.addPoint((TracePoint2D) it.next()); 91 } 92 } 93 } 94 | Popular Tags |