neth        01/08/29 04:48:29

  Added:       src/org/apache/jmeter/visualizers GraphAccumVisualizer.java
  Log:
  Visualizer to display the response time of the sample and all its components
  in a line graph.
  
  Revision  Changes    Path
  1.1                  
jakarta-jmeter/src/org/apache/jmeter/visualizers/GraphAccumVisualizer.java
  
  Index: GraphAccumVisualizer.java
  ===================================================================
  /*
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   * notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   * notice, this list of conditions and the following disclaimer in
   * the documentation and/or other materials provided with the
   * distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   * if any, must include the following acknowledgment:
   * "This product includes software developed by the
   * Apache Software Foundation (http://www.apache.org/)."
   * Alternately, this acknowledgment may appear in the software itself,
   * if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   * "Apache JMeter" must not be used to endorse or promote products
   * derived from this software without prior written permission. For
   * written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   * "Apache JMeter", nor may "Apache" appear in their name, without
   * prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jmeter.visualizers;
  
  import java.awt.*;
  import java.util.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  import org.apache.jmeter.samplers.SampleResult;
  import org.apache.jmeter.gui.*;
  
  import org.apache.log4j.*;
  /**
   * This class implements a statistical analyser that plots the accumulated time
   * taken to load each set of pages.  The number of plots is equivalent to the
   * number of times the set of pages is configured to load.
   *
   * @author     Khor Soon Hin
   * @created    2001/08/11
   * @version    $Revision: 1.1 $ $Date: 2001/08/29 11:48:29 $
   */
  public class GraphAccumVisualizer extends JPanel
    implements ImageVisualizer, ModelSupported,
    GraphAccumListener, GenericGraphListener
  {
    private static Category catClass = 
      Category.getInstance(GraphAccumVisualizer.class.getName());
  
    protected GraphAccumModel model;
    protected NamePanel namePanel;
    protected GraphAccum graph;
  
    protected JPanel legendPanel;
    /**
     *  Constructor
     */
    public GraphAccumVisualizer()
    {
      super();
      catClass.debug("Start : GraphAccumVisualizer1");
      catClass.debug("End : GraphAccumVisualizer1");
    }
  
    /**
     * Sets the model which this visualizer will represent
     * 
     * @param model     the model tied to this visualizer
     */
    public void setModel(Object model)
    {
      catClass.debug("Start : setModel1");
      this.model = (GraphAccumModel)model;
      this.model.addModelListener(this);
      init();
      catClass.debug("End : setModel1");
    }
  
    /**
     * Updates the gui to reflect changes
     */
    public void updateGui()
    {
      catClass.debug("Start : updateGui1");
      namePanel.updateGui();
      graph.updateGui();
      catClass.debug("End : updateGui1");
    }
  
    /**
     * Updates gui to reflect small changes
     *
     * @param s sample to be added to plot
     */
    public void updateGui(SampleResult s)
    {
      catClass.debug("Start : updateGui2");
      catClass.debug("End : updateGui2");
    }
  
    /**
     * Returns the panel where labels can be added
     *
     * @returns a panel where labels can be added
     */
    public Object getWhiteCanvas()
    {
      return legendPanel;
    };
  
    /**
     * Setup all the swing components
     */
    private void init()
    {
      catClass.debug("Start : init1");
      graph = new GraphAccum(model);
      graph.setVisualizer(this);
  
      JScrollPane graphScrollPanel = new 
        JScrollPane(graph,JScrollPane.VERTICAL_SCROLLBAR_NEVER,
        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      graphScrollPanel.setViewportBorder(
        BorderFactory.createEmptyBorder(2, 2, 2, 2));
      legendPanel = new JPanel();
      JScrollPane legendScrollPanel = new
        JScrollPane(legendPanel);
      JSplitPane graphSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
        graphScrollPanel, legendScrollPanel);
  
      setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
      setLayout(new BorderLayout());
      namePanel = new NamePanel(model);
      this.add(namePanel,BorderLayout.NORTH);
      add(graphSplitPane, BorderLayout.CENTER);
      catClass.debug("End : init1");
    }
  
    /**
     * Gets the Image attribute of the GraphVisualizer object
     *
     * @return The Image value
     */
    public Image getImage()
    {
      catClass.debug("Start : getImage1");
      Image result = graph.createImage(graph.getWidth(), graph.getHeight());
      graph.paintComponent(result.getGraphics());
      catClass.debug("End : getImage1");
      return result;
    }
  
    /**
     *  Clear this visualizer data
     */
    public synchronized void clear()
    {
      catClass.debug("Start : clear1");
      repaint();
      catClass.debug("End : clear1");
    }
  
    /**
     * Returns a description of this instance
     *
     * @return    description of this instance
     */
    public String toString()
    {
      String toString = "Show the samples analysys as dot plots";
      catClass.debug("toString1 : Returning - " + toString);
      return toString;
    }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to