You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by wo...@apache.org on 2004/06/08 04:43:18 UTC

cvs commit: jakarta-jmeter/src/components/org/apache/jmeter/visualizers DistributionGraphVisualizer.java

woolfel     2004/06/07 19:43:18

  Modified:    src/components/org/apache/jmeter/visualizers
                        DistributionGraphVisualizer.java
  Log:
  this is a quick implementation using a button to save the distribution
  graph. Since I can't decide what is the best way to handle saving
  graphics, this will allow others to play with it. I like mike's idea of using
  actions to do it.
  
  peter
  
  Revision  Changes    Path
  1.4       +24 -2     jakarta-jmeter/src/components/org/apache/jmeter/visualizers/DistributionGraphVisualizer.java
  
  Index: DistributionGraphVisualizer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/visualizers/DistributionGraphVisualizer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DistributionGraphVisualizer.java	6 Jun 2004 22:07:41 -0000	1.3
  +++ DistributionGraphVisualizer.java	8 Jun 2004 02:43:18 -0000	1.4
  @@ -24,11 +24,14 @@
   import java.awt.Component;
   import java.awt.Dimension;
   import java.awt.Image;
  +import java.awt.event.ActionEvent;
  +import java.awt.event.ActionListener;
   import java.awt.event.ItemEvent;
   import java.awt.event.ItemListener;
   
   import javax.swing.BorderFactory;
   import javax.swing.Box;
  +import javax.swing.JButton;
   import javax.swing.JCheckBox;
   import javax.swing.JLabel;
   import javax.swing.JPanel;
  @@ -39,6 +42,7 @@
   
   import org.apache.jmeter.samplers.Clearable;
   import org.apache.jmeter.samplers.SampleResult;
  +import org.apache.jmeter.save.SaveGraphicsService;
   import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
   
  @@ -53,7 +57,7 @@
    * @version   $Revision: 
    */
   public class DistributionGraphVisualizer extends AbstractVisualizer
  -        implements ImageVisualizer, ItemListener, GraphListener, Clearable
  +        implements ImageVisualizer, ItemListener, GraphListener, ActionListener, Clearable
   {
       SamplingStatCalculator model;
       private JPanel graphPanel = null;
  @@ -62,6 +66,7 @@
   
       private DistributionGraph graph;
       private JTextField noteField;
  +    private JButton saveButton;
       private int delay = 10;
       private int counter = 0;
       //NOTREAD private int cwidth = 0;
  @@ -269,6 +274,23 @@
   		graphInfoPanel.add(
   			this.createInfoLabel("distribution_note1",this.noteField)
   		);
  +		graphInfoPanel.add(createSaveButton());
   		return graphInfoPanel;
  +    }
  +    
  +    private JButton createSaveButton(){
  +		saveButton = new JButton("Save Graph");
  +		saveButton.addActionListener(this);
  +    	return saveButton;
  +    }
  +    
  +    public void actionPerformed(ActionEvent event){
  +    	Object src = event.getSource();
  +    	// only save if the source was the save button
  +    	if (src == saveButton){
  +    		SaveGraphicsService service = new SaveGraphicsService();
  +			//service.saveJComponent("distributionGraph.jpg",this.graphPanel);
  +			service.saveJComponentWithJAI("distributionGraph.png",this.graphPanel);
  +    	}
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org