1 18 19 package org.apache.jmeter.visualizers; 20 21 22 import java.awt.BorderLayout ; 23 import java.awt.Font ; 24 import java.awt.Image ; 25 26 import javax.swing.BorderFactory ; 27 import javax.swing.BoxLayout ; 28 import javax.swing.JLabel ; 29 import javax.swing.JPanel ; 30 import javax.swing.JScrollPane ; 31 import javax.swing.JSplitPane ; 32 import javax.swing.border.Border ; 33 import javax.swing.border.EmptyBorder ; 34 35 import org.apache.jmeter.samplers.Clearable; 36 import org.apache.jmeter.samplers.SampleResult; 37 import org.apache.jmeter.util.JMeterUtils; 38 import org.apache.jmeter.visualizers.gui.AbstractVisualizer; 39 import org.apache.jorphan.logging.LoggingManager; 40 import org.apache.log.Logger; 41 42 43 52 public class GraphAccumVisualizer extends AbstractVisualizer 53 implements ImageVisualizer, GraphAccumListener, Clearable 54 { 55 transient private static Logger log = LoggingManager.getLoggerForClass(); 56 57 protected transient GraphAccumModel model; 58 protected transient GraphAccum graph; 59 transient protected JPanel legendPanel; 60 61 64 public GraphAccumVisualizer() 65 { 66 super(); 67 model = new GraphAccumModel(); 68 model.addGraphAccumListener(this); 69 init(); 70 log.debug("Start : GraphAccumVisualizer1"); 71 log.debug("End : GraphAccumVisualizer1"); 72 } 73 74 public String getLabelResource() 75 { 76 return "graph_full_results_title"; 77 } 78 79 public void add(SampleResult res) 80 { 81 model.addNewSample(res); 82 } 83 84 89 public Object getWhiteCanvas() 90 { 91 return legendPanel; 92 } 93 94 99 public Image getImage() 100 { 101 log.debug("Start : getImage1"); 102 Image result = graph.createImage(graph.getWidth(), graph.getHeight()); 103 104 graph.paintComponent(result.getGraphics()); 105 log.debug("End : getImage1"); 106 return result; 107 } 108 109 112 public void updateGui() 113 { 114 log.debug("Start : updateGui1"); 115 graph.updateGui(); 116 log.debug("End : updateGui1"); 117 } 118 119 124 public void updateGui(SampleResult s) 125 { 126 log.debug("Start : updateGui2"); 127 log.debug("End : updateGui2"); 128 } 129 130 133 public synchronized void clear() 134 { 135 model.clear(); 136 graph.clear(); 137 log.debug("Start : clear1"); 138 repaint(); 139 log.debug("End : clear1"); 140 } 141 142 147 public String toString() 148 { 149 String toString = "Show the samples analysys as dot plots"; 150 151 log.debug("toString1 : Returning - " + toString); 152 return toString; 153 } 154 155 158 private void init() 159 { 160 log.debug("Start : init1"); 161 graph = new GraphAccum(model); 162 graph.setVisualizer(this); 163 164 this.setLayout(new BorderLayout ()); 165 166 JPanel mainPanel = new JPanel (); 168 Border margin = new EmptyBorder (10, 10, 5, 10); 169 170 mainPanel.setBorder(margin); 171 mainPanel.setLayout(new BoxLayout (mainPanel, BoxLayout.Y_AXIS)); 172 173 JLabel panelTitleLabel = 175 new JLabel (JMeterUtils.getResString("graph_full_results_title")); 176 Font curFont = panelTitleLabel.getFont(); 177 int curFontSize = curFont.getSize(); 178 179 curFontSize += 4; 180 panelTitleLabel.setFont( 181 new Font (curFont.getFontName(), curFont.getStyle(), curFontSize)); 182 mainPanel.add(panelTitleLabel); 183 184 mainPanel.add(getNamePanel()); 185 mainPanel.add(getFilePanel()); 186 187 JScrollPane graphScrollPanel = new 188 JScrollPane (graph, JScrollPane.VERTICAL_SCROLLBAR_NEVER, 189 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 190 191 graphScrollPanel.setViewportBorder( 192 BorderFactory.createEmptyBorder(2, 2, 2, 2)); 193 legendPanel = new JPanel (); 194 195 JScrollPane legendScrollPanel = new JScrollPane (legendPanel); 196 JSplitPane graphSplitPane = new JSplitPane (JSplitPane.VERTICAL_SPLIT, 197 graphScrollPanel, legendScrollPanel); 198 199 this.add(mainPanel, BorderLayout.NORTH); 200 this.add(graphSplitPane, BorderLayout.CENTER); 201 log.debug("End : init1"); 202 } 203 } 204 | Popular Tags |