1 27 package org.objectweb.clif.console.lib.gui; 28 29 import java.awt.event.ActionEvent ; 30 import javax.swing.AbstractAction ; 31 import org.objectweb.clif.supervisor.api.TestControl; 32 33 38 final class ActionTestReport extends AbstractAction { 39 40 private Object [] injectors; 41 private GraphTableModel tModel = null; 42 private TestControl suis; 43 private Graph graph; 44 private int time; 45 private int totalTime = 0; 46 private long lastEvent = 0; 47 private long diff; 48 49 54 public ActionTestReport( 55 TestControl suis, 56 Graph graph, 57 GraphTableModel tModel) { 58 this.suis = suis; 59 this.graph = graph; 60 this.tModel = tModel; 61 } 62 63 64 68 public void setTime(int time) { 69 this.time = time; 70 } 71 72 public void reset() { 73 totalTime = 0; 74 lastEvent = 0; 75 } 76 77 80 public void actionPerformed(ActionEvent e) 81 { 82 if (lastEvent != 0) { 83 diff = 84 new Long ((System.currentTimeMillis() - lastEvent) / 1000) 85 .longValue(); 86 if (diff > time) { 87 totalTime += (diff - time); 90 } 91 } 92 93 totalTime += time; 94 graph.updateXAxis(totalTime); 96 97 injectors = tModel.getInjectorsToCollect(); 99 100 for (int i = 0; i < injectors.length; i++) 101 { 102 long[] stats = suis.getStats((String ) injectors[i]); 103 if (stats != null) 104 { 105 for (int j = 0 ; j < stats.length ; ++j) 106 { 107 graph.addPoint( 108 (String ) injectors[i], 109 j, 110 totalTime, 111 stats[j]); 112 } 113 } 114 } 115 lastEvent = System.currentTimeMillis(); 116 117 injectors = tModel.getAllInjectors(); 119 for (int i = 0; i < injectors.length; i++) { 120 graph.removePointsFromDisplay((String ) injectors[i]); 121 } 122 123 injectors = tModel.getInjectorsToDisplay(); 124 for (int i = 0; i < injectors.length; i++) { 125 graph.addPointsOnDisplay((String ) injectors[i]); 126 } 127 128 graph.updateGraph(); 129 } 130 } | Popular Tags |