1 23 24 package info.monitorenter.reflection; 25 26 import info.monitorenter.gui.chart.ITrace2D; 27 import info.monitorenter.util.TimeStampedValue; 28 29 import javax.swing.event.ChangeEvent ; 30 import javax.swing.event.ChangeListener ; 31 32 33 43 public class ObjRecorder2Trace2DAdapter implements ChangeListener { 44 45 46 private String m_fieldname; 47 48 49 private ObjectRecorder m_inspector; 50 51 55 private long m_start = System.currentTimeMillis(); 56 57 58 private ITrace2D m_view; 59 60 77 public ObjRecorder2Trace2DAdapter(final ITrace2D view, final Object toinspect, 78 final String fieldname, final long interval) { 79 this.m_view = view; 80 this.m_fieldname = fieldname; 81 this.m_inspector = new ObjectRecorder(toinspect, interval); 82 this.m_inspector.addChangeListener(this); 83 } 84 85 92 public void setInterval(final long interval) { 93 this.m_inspector.setInterval(interval); 94 } 95 96 99 public void stateChanged(final ChangeEvent e) { 100 TimeStampedValue last; 101 try { 102 last = this.m_inspector.getLastValue(this.m_fieldname); 103 } catch (Exception f) { 104 f.printStackTrace(); 105 return; 106 } 107 if (last != null) { 108 double tmpx, tmpy; 109 tmpx = last.getTime() - this.m_start; 110 tmpy = Double.parseDouble(last.getValue().toString()); 111 this.m_view.addPoint(tmpx, tmpy); 112 } 113 } 114 } 115 | Popular Tags |