1 6 7 package analyzer.charts; 8 9 import analyzer.listeners.WindowData; 10 import java.util.Hashtable ; 11 import java.util.Enumeration ; 12 import java.util.TreeSet ; 13 import java.util.Iterator ; 14 15 19 public class DataManager { 20 21 Hashtable editor,all,show; 22 long start,end; 23 24 25 public DataManager(Hashtable allWindows,Hashtable editorWindows) { 26 start=end=-1; 27 editor=editorWindows; 28 all=allWindows; 29 show=(Hashtable )all.clone(); 30 } 31 32 public void setStartTime(long time){ 33 start=time; 34 } 35 36 public void setEndTime(long duration){ 37 end=start+duration; 38 } 39 40 public void hideAllEditorWindows(){ 41 Enumeration e=editor.keys(); 42 Object key; 43 while(e.hasMoreElements()){ 44 key=e.nextElement(); 45 if(show.containsKey(key)) show.remove(key); 46 } 47 } 48 49 public void showAllEditorWindows(){ 50 Enumeration e=editor.keys(); 51 Object key; 52 while(e.hasMoreElements()){ 53 key=e.nextElement(); 54 if(!show.containsKey(key)) show.put(key,editor.get(key)); 55 } 56 } 57 58 public void display(){ 59 if(start==-1){ 60 System.err.println("start time not fixed"); 61 return; 62 } 63 if(start>=end){ 64 System.err.println("start >= end"); 65 return; 66 } 67 ChartManager chart=new ChartManager(start,end); 68 Iterator it=sort(); 69 WindowData w; 70 while(it.hasNext()){ 71 w=(WindowData)it.next(); 72 chart.addChart(w); 73 } 74 chart.displayCharts(); 75 } 76 77 private Iterator sort(){ 78 TreeSet tree=new TreeSet (); 79 Enumeration e=show.elements(); 80 WindowData w; 81 while(e.hasMoreElements()){ 82 w=(WindowData)e.nextElement(); 83 tree.add(w); 84 } 85 return tree.iterator(); 86 } 87 88 public void showThisWindow(String name){ 89 WindowData w=(WindowData)all.get(name); 90 if(w==null){ 91 System.err.println("no such window:"+name); 92 return; 93 } 94 show.put(name,w); 95 } 96 97 public void hideThisWindow(String name){ 98 show.remove(name); 99 } 100 } 101 | Popular Tags |