kcassell    2003/02/04 13:29:15

  Modified:    src/core/org/apache/jmeter/reporters ResultCollector.java
                        FileReporter.java AbstractListenerElement.java
  Log:
  Reformatted to Turbine standards
  
  Revision  Changes    Path
  1.11      +29 -21    
jakarta-jmeter/src/core/org/apache/jmeter/reporters/ResultCollector.java
  
  Index: ResultCollector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/reporters/ResultCollector.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ResultCollector.java      27 Jan 2003 06:01:04 -0000      1.10
  +++ ResultCollector.java      4 Feb 2003 21:29:15 -0000       1.11
  @@ -54,6 +54,7 @@
    */
   package org.apache.jmeter.reporters;
   
  +
   import java.io.BufferedOutputStream;
   import java.io.ByteArrayOutputStream;
   import java.io.File;
  @@ -86,24 +87,24 @@
   import org.apache.jorphan.io.TextFile;
   import org.xml.sax.SAXException;
   
  +
   /**
    * Title: Description: Copyright: Copyright (c) 2001 Company:
    *
    * @author Michael Stover
    * @version $Id$
    */
  -public class ResultCollector
  -    extends AbstractListenerElement
  -    implements SampleListener, Clearable, Serializable, TestListener, Remoteable
  +public class ResultCollector extends AbstractListenerElement
  +        implements SampleListener, Clearable, Serializable, TestListener, Remoteable
   {
       transient private static Logger log =
  -        Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.elements");
  +            Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.elements");
       private final static String COLLECTED = "collected";
       public final static String FILENAME = "filename";
       private static boolean functionalMode = false;
       public static final String ERROR_LOGGING = "ResultCollector.error_logging";
   
  -    //protected List results = Collections.synchronizedList(new ArrayList());
  +    // protected List results = Collections.synchronizedList(new ArrayList());
       private int current;
       transient private DefaultConfigurationSerializer serializer;
       private boolean inLoading = false;
  @@ -212,6 +213,7 @@
               try
               {
                   Configuration savedSamples = getConfiguration(getFilename());
  +
                   readSamples(savedSamples);
               }
               catch (Exception e)
  @@ -241,14 +243,15 @@
           }
           PrintWriter writer = (PrintWriter) files.get(filename);
           boolean trimmed = true;
  +
           if (writer == null)
           {
               trimmed = trimLastLine(filename);
               writer =
  -                new PrintWriter(
  +                    new PrintWriter(
                       new OutputStreamWriter(
  -                        new BufferedOutputStream(new FileOutputStream(filename, 
trimmed)),
  -                        "UTF-8"));
  +                    new BufferedOutputStream(new FileOutputStream(filename, 
trimmed)),
  +                    "UTF-8"));
               files.put(filename, writer);
           }
           if (!trimmed)
  @@ -263,11 +266,13 @@
           try
           {
               TextFile text = new TextFile(filename);
  +
               if (!text.exists())
               {
                   return false;
               }
               String xml = text.getText();
  +
               xml = xml.substring(0, xml.indexOf("</testResults>"));
               text.setText(xml);
           }
  @@ -295,11 +300,13 @@
        * @return The serializedSampleResult value
        */
       private String getSerializedSampleResult(SampleResult result)
  -        throws SAXException, IOException, ConfigurationException
  +            throws SAXException, IOException, ConfigurationException
       {
           ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
  +
           serializer.serialize(tempOut, SaveService.getConfiguration(result, 
getFunctionalMode()));
           String serVer = tempOut.toString();
  +
           return 
serVer.substring(serVer.indexOf(System.getProperty("line.separator")));
       }
   
  @@ -309,12 +316,14 @@
        * @param testResults Description of the Parameter
        */
       private void readSamples(Configuration testResults)
  -        throws IOException, SAXException, ConfigurationException
  +            throws IOException, SAXException, ConfigurationException
       {
           Configuration[] samples = testResults.getChildren();
  +
           for (int i = 0; i < samples.length; i++)
           {
               SampleResult result = SaveService.getSampleResult(samples[i]);
  +
               sendToVisualizer(result);
               recordResult(result);
           }
  @@ -327,9 +336,10 @@
        * @return The configuration value
        */
       private Configuration getConfiguration(String filename)
  -        throws SAXException, IOException, ConfigurationException
  +            throws SAXException, IOException, ConfigurationException
       {
           DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +
           return builder.buildFromFile(filename);
       }
   
  @@ -344,16 +354,13 @@
       }
   
       public void setListener(Object l)
  -    {
  -    }
  +    {}
   
       public void sampleStarted(SampleEvent e)
  -    {
  -    }
  +    {}
   
       public void sampleStopped(SampleEvent e)
  -    {
  -    }
  +    {}
   
       public void sampleOccurred(SampleEvent e)
       {
  @@ -366,7 +373,7 @@
               }
               catch (Exception err)
               {
  -                log.error("", err); //should throw exception back to caller
  +                log.error("", err); // should throw exception back to caller
               }
           }
       }
  @@ -385,7 +392,7 @@
        * @param result Description of the Parameter
        */
       private void recordResult(SampleResult result)
  -        throws SAXException, IOException, ConfigurationException
  +            throws SAXException, IOException, ConfigurationException
       {
           if (out != null)
           {
  @@ -399,6 +406,7 @@
       private synchronized boolean isResultMarked(SampleResult res)
       {
           boolean marked = res.isMarked(getFilename());
  +
           if (!marked)
           {
               res.setMarked(getFilename());
  @@ -438,5 +446,5 @@
               out = null;
           }
       }
  -    
  +
   }
  
  
  
  1.5       +351 -255  
jakarta-jmeter/src/core/org/apache/jmeter/reporters/FileReporter.java
  
  Index: FileReporter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/reporters/FileReporter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileReporter.java 30 Aug 2002 14:43:20 -0000      1.4
  +++ FileReporter.java 4 Feb 2003 21:29:15 -0000       1.5
  @@ -55,6 +55,7 @@
   
   package org.apache.jmeter.reporters;
   
  +
   import java.awt.BorderLayout;
   import java.awt.Color;
   import java.awt.Graphics;
  @@ -78,6 +79,7 @@
   import org.apache.log.Hierarchy;
   import org.apache.log.Logger;
   
  +
   /**
    * This class loads data from a saved file and displays
    * statistics about it.
  @@ -85,261 +87,355 @@
    *
    * @author  Tom Schneider
    */
  -public class FileReporter extends JPanel  {
  -     transient private static Logger log = 
Hierarchy.getDefaultHierarchy().getLoggerFor(
  -                     "jmeter.elements");
  -     Hashtable data = new Hashtable();
  -     /**  initalize a file reporter from a file */
  -     public void init(String file) throws IOException {
  -             File datafile = new File(file);
  -             BufferedReader reader = null;
  -             if( datafile.canRead() ) {
  -                     reader = new BufferedReader(new FileReader(datafile));
  -             } else {
  -                     JOptionPane.showMessageDialog(
  -                             null,"The file you specified cannot be read.",
  -                             "Information",JOptionPane.INFORMATION_MESSAGE);
  -                     return;
  -             }
  -             String line;
  -             while ((line = reader.readLine()) != null) {
  -                     try {
  -                             line.trim();
  -                             if (line.startsWith("#") || line.length() == 0)
  -                                     continue;
  -                             int splitter = line.lastIndexOf(' ');
  -                             String key = line.substring(0, splitter);
  -                             int len = line.length() - 1;
  -                             Integer value = null;
  -                             if (line.charAt(len) == ',') {
  -                                     value = new Integer(
  -                                             line.substring(splitter + 1, len));
  -                             } else {
  -                                     value = new Integer(
  -                                             line.substring(splitter + 1));
  -                             }
  -                             Vector v = getData(key);
  -                             if (v == null) {
  -                                     v = new Vector();
  -                                     this.data.put(key, v);
  -                             }
  -                             v.addElement(value);
  -                     } catch (NumberFormatException nfe) {
  -                             log.error("This line could not be parsed: "
  -                                     + line,nfe);
  -                     } catch (Exception e) {
  -                             log.error("This line caused a problem: "+line,e);
  -                     }
  -             }
  -             reader.close();
  -             showPanel();
  -     }
  -     public Vector getData(String key) {
  -             return (Vector) data.get(key);
  -     }
  -     /**  show main panel with length, graph, and stats */
  -     public void showPanel() {
  -             JFrame f = new JFrame("Data File Report");
  -             setLayout(new BorderLayout());
  -             graphPanel gp = new graphPanel(data);
  -             add(gp, "Center");
  -             add(gp.getStats(), BorderLayout.EAST);
  -             add(gp.getLegend(), BorderLayout.NORTH);
  -             f.setSize(500, 300);
  -             f.getContentPane().add(this);
  -             f.show();
  -     }
  +public class FileReporter extends JPanel
  +{
  +    transient private static Logger log
  +        = Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.elements");
  +    Hashtable data = new Hashtable();
  +
  +    /** initalize a file reporter from a file */
  +    public void init(String file) throws IOException
  +    {
  +        File datafile = new File(file);
  +        BufferedReader reader = null;
  +
  +        if (datafile.canRead())
  +        {
  +            reader = new BufferedReader(new FileReader(datafile));
  +        }
  +        else
  +        {
  +            JOptionPane.showMessageDialog(
  +                    null, "The file you specified cannot be read.",
  +                    "Information", JOptionPane.INFORMATION_MESSAGE);
  +            return;
  +        }
  +        String line;
  +
  +        while ((line = reader.readLine()) != null)
  +        {
  +            try
  +            {
  +                line.trim();
  +                if (line.startsWith("#") || line.length() == 0)
  +                    continue;
  +                int splitter = line.lastIndexOf(' ');
  +                String key = line.substring(0, splitter);
  +                int len = line.length() - 1;
  +                Integer value = null;
  +
  +                if (line.charAt(len) == ',')
  +                {
  +                    value = new Integer(
  +                            line.substring(splitter + 1, len));
  +                }
  +                else
  +                {
  +                    value = new Integer(
  +                            line.substring(splitter + 1));
  +                }
  +                Vector v = getData(key);
  +
  +                if (v == null)
  +                {
  +                    v = new Vector();
  +                    this.data.put(key, v);
  +                }
  +                v.addElement(value);
  +            }
  +            catch (NumberFormatException nfe)
  +            {
  +                log.error("This line could not be parsed: " + line, nfe);
  +            }
  +            catch (Exception e)
  +            {
  +                log.error("This line caused a problem: " + line, e);
  +            }
  +        }
  +        reader.close();
  +        showPanel();
  +    }
  +
  +    public Vector getData(String key)
  +    {
  +        return (Vector) data.get(key);
  +    }
  +
  +    /** show main panel with length, graph, and stats */
  +    public void showPanel()
  +    {
  +        JFrame f = new JFrame("Data File Report");
  +
  +        setLayout(new BorderLayout());
  +        graphPanel gp = new graphPanel(data);
  +
  +        add(gp, "Center");
  +        add(gp.getStats(), BorderLayout.EAST);
  +        add(gp.getLegend(), BorderLayout.NORTH);
  +        f.setSize(500, 300);
  +        f.getContentPane().add(this);
  +        f.show();
  +    }
   }
   
  -/**  Graph panel generates all the panels for this reporter.
  -  *  Data is organized based on thread name in a hashtable.
  -  *  The data itself is a Vector of Integer objects
  -  */
  -class graphPanel extends JPanel {
  -     boolean autoScale = true;
  -     Hashtable data;
  -     Vector keys = new Vector();
  -     Vector colorList = new Vector();
  -     public graphPanel(){}
  -     public graphPanel(Hashtable data) {
  -             this.data = data;
  -             Enumeration e = data.keys();
  -             while (e.hasMoreElements()) {
  -                     String key = (String) e.nextElement();
  -                     keys.addElement(key);
  -             }
  -             for (int a = 0x33; a < 0xFF; a += 0x66) {
  -                     for (int b = 0x33; b < 0xFF; b += 0x66) {
  -                             for (int c = 0x33; c < 0xFF; c += 0x66) {
  -                                     colorList.addElement(new Color(a, b, c));
  -                             }
  -                     }
  -             }
  -     }
  -     /**  get the maximum for all the data */
  -     public float getMax() {
  -             float maxValue = 0;
  -             for (int t = 0; t < keys.size(); t++) {
  -                     String key = (String) keys.elementAt(t);
  -                     Vector temp = (Vector) data.get(key);
  -                     for (int j = 0; j < temp.size(); j++) {
  -                             float f = ((Integer) temp.elementAt(j)).intValue();
  -                             maxValue = Math.max(f, maxValue);
  -                     }
  -             }
  -             return (float) (maxValue + maxValue * 0.1);
  -     }
  -     /**  get the minimum for all the data */
  -     public float getMin() {
  -             float minValue = 9999999;
  -             for (int t = 0; t < keys.size(); t++) {
  -                     String key = (String) keys.elementAt(t);
  -                     Vector temp = (Vector) data.get(key);
  -                     for (int j = 0; j < temp.size(); j++) {
  -                             float f = ((Integer) temp.elementAt(j)).intValue();
  -                             minValue = Math.min(f, minValue);
  -                     }
  -             }
  -             return (float) (minValue - minValue * 0.1);
  -     }
  -     /**  get the legend panel */
  -     public JPanel getLegend() {
  -             JPanel main = new JPanel();
  -             GridBagLayout g = new GridBagLayout();
  -             main.setLayout(g);
  -             GridBagConstraints c = new GridBagConstraints();
  -             c.insets = new Insets(3,3,3,3);
  -             c.fill = c.BOTH;
  -             c.gridwidth = 1;
  -             c.gridheight = 1;
  -             for (int t = 0; t < keys.size(); t++) {
  -                     String key = (String) keys.elementAt(t);
  -                     JLabel colorSwatch = new JLabel("  ");
  -                     colorSwatch.setBackground((Color) colorList.elementAt(t % 
colorList.size()));
  -                     colorSwatch.setOpaque(true);
  -                     c.gridx = 1;
  -                     c.gridy = t;
  -                     g.setConstraints(colorSwatch, c);
  -                     main.add(colorSwatch);
  -                     JLabel name = new JLabel(key);
  -                     c.gridx = 2;
  -                     c.gridy = t;
  -                     g.setConstraints(name, c);
  -                     main.add(name);
  -             }
  -             return main;
  -     }
  -     /**  get the stats panel */
  -     public JPanel getStats() {
  -             int total = 0;
  -             float totalValue = 0;
  -             float maxValue = 0;
  -             float minValue = 999999;
  -             for (int t = 0; t < keys.size(); t++) {
  -                     String key = (String) keys.elementAt(t);
  -                     Vector temp = (Vector) data.get(key);
  -                     for (int j = 0; j < temp.size(); j++) {
  -                             float f = ((Integer) temp.elementAt(j)).intValue();
  -                             minValue = Math.min(f, minValue);
  -                             maxValue = Math.max(f, maxValue);
  -                             totalValue += f;
  -                             total++;
  -                     }
  -             }
  -             float averageValue = totalValue / total;
  -             JPanel main = new JPanel();
  -             GridBagLayout g = new GridBagLayout();
  -             main.setLayout(g);
  -             DecimalFormat df = new DecimalFormat("#0.0");
  -             GridBagConstraints c = new GridBagConstraints();
  -             c.insets = new Insets(3,6,3,6);
  -             c.fill = c.BOTH;
  -             c.gridwidth = 1;
  -             c.gridheight = 1;
  -             JLabel count = new JLabel("Count: " + total);
  -             c.gridx = 1;
  -             c.gridy = 1;
  -             g.setConstraints(count, c);
  -             JLabel min = new JLabel("Min: " + df.format(new Float(minValue)));
  -             c.gridx = 1;
  -             c.gridy = 2;
  -             g.setConstraints(min, c);
  -             JLabel max = new JLabel("Max: " + df.format(new Float(maxValue)));
  -             c.gridx = 1;
  -             c.gridy = 3;
  -             g.setConstraints(max, c);
  -             JLabel average = new JLabel("Average: " + df.format(new 
Float(averageValue)));
  -             c.gridx = 1;
  -             c.gridy = 4;
  -             g.setConstraints(average, c);
  -             main.add(count);
  -             main.add(min);
  -             main.add(max);
  -             main.add(average);
  -             return main;
  -     }
  -     /**  gets the size of the biggest Vector */
  -     public int getDataWidth() {
  -             int size = 0;
  -             for (int t = 0; t < keys.size(); t++) {
  -                     String key = (String) keys.elementAt(t);
  -                     Vector v = (Vector) data.get(key);
  -                     size = Math.max(size, v.size());
  -             }
  -             return size;
  -     }
  -     /**  draws the graph */
  -     public void update(Graphics g) {
  -             // setup drawing area
  -      int base = 10;
  -             g.setColor(Color.white);
  -             g.fillRect(0, 0, getSize().width, getSize().height);
  -             int width = getSize().width;
  -             int height = getSize().height;
  -             float maxValue = getMax();
  -             float minValue = getMin();
  -             // draw grid
  -             g.setColor(Color.gray);
  -             int dataWidth = getDataWidth();
  -             int increment = Math.round((width - 1) / (dataWidth - 1));
  -             /*for (int t = 0; t < dataWidth; t++) {
  -                     g.drawLine(t * increment, 0, t * increment, height);
  -             }*/
  -             int yIncrement = Math.round(((float) height - (1+base)) / (10 - 1));
  -             /*for (int t = 0; t < 10; t++) {
  -                     g.drawLine(0, height - t * yIncrement, width, height - t * 
yIncrement);
  -             }*/
  -             // draw axis
  -             for (int t = 1; t < dataWidth; t+=(dataWidth/25+1)) {
  -                     g.drawString((new Integer(t)).toString(), t * increment + 2, 
height - 2);
  -             }
  -             float incrementValue = (maxValue - minValue) / (10 - 1);
  -             for (int t = 0; t < 10; t++) {
  -                     g.drawString(new Integer(Math.round(minValue + (t * 
incrementValue))).toString(), 2,height - t * yIncrement - 2 - base);
  -             }
  -             // draw data lines
  -             int start = 0;
  -             for (int t = 0; t < keys.size(); t++) {
  -                     String key = (String) keys.elementAt(t);
  -                     Vector v = (Vector) data.get(key);
  -                     start = 0;
  -                     g.setColor((Color) colorList.elementAt(t % colorList.size()));
  -                     for (int i = 0; i < v.size() - 1; i++) {
  -                             float y1 = (float) ((Integer) 
v.elementAt(i)).intValue();
  -                             float y2 = (float) ((Integer) v.elementAt(i + 
1)).intValue();
  -                             y1 = y1 - minValue;
  -                             y2 = y2 - minValue;
  -                             int Y1 = Math.round((height * y1) / (maxValue - 
minValue));
  -                             int Y2 = Math.round((height * y2) / (maxValue - 
minValue));
  -                             Y1 = height - Y1 - base;
  -                             Y2 = height - Y2 - base;
  -                                                     g.drawLine(start, Y1, start + 
increment, Y2);
  -                             Integer value = (Integer) v.elementAt(i);
  -                             start += increment;
  -                     }
  -             }
  -     }
  -     public void paint(Graphics g) {
  -             update(g);
  -     }
  +
  +/** Graph panel generates all the panels for this reporter.
  + *  Data is organized based on thread name in a hashtable.
  + *  The data itself is a Vector of Integer objects
  + */
  +class graphPanel extends JPanel
  +{
  +    boolean autoScale = true;
  +    Hashtable data;
  +    Vector keys = new Vector();
  +    Vector colorList = new Vector();
  +    public graphPanel()
  +    {}
  +
  +    public graphPanel(Hashtable data)
  +    {
  +        this.data = data;
  +        Enumeration e = data.keys();
  +
  +        while (e.hasMoreElements())
  +        {
  +            String key = (String) e.nextElement();
  +
  +            keys.addElement(key);
  +        }
  +        for (int a = 0x33; a < 0xFF; a += 0x66)
  +        {
  +            for (int b = 0x33; b < 0xFF; b += 0x66)
  +            {
  +                for (int c = 0x33; c < 0xFF; c += 0x66)
  +                {
  +                    colorList.addElement(new Color(a, b, c));
  +                }
  +            }
  +        }
  +    }
  +
  +    /** get the maximum for all the data */
  +    public float getMax()
  +    {
  +        float maxValue = 0;
  +
  +        for (int t = 0; t < keys.size(); t++)
  +        {
  +            String key = (String) keys.elementAt(t);
  +            Vector temp = (Vector) data.get(key);
  +
  +            for (int j = 0; j < temp.size(); j++)
  +            {
  +                float f = ((Integer) temp.elementAt(j)).intValue();
  +
  +                maxValue = Math.max(f, maxValue);
  +            }
  +        }
  +        return (float) (maxValue + maxValue * 0.1);
  +    }
  +
  +    /** get the minimum for all the data */
  +    public float getMin()
  +    {
  +        float minValue = 9999999;
  +
  +        for (int t = 0; t < keys.size(); t++)
  +        {
  +            String key = (String) keys.elementAt(t);
  +            Vector temp = (Vector) data.get(key);
  +
  +            for (int j = 0; j < temp.size(); j++)
  +            {
  +                float f = ((Integer) temp.elementAt(j)).intValue();
  +
  +                minValue = Math.min(f, minValue);
  +            }
  +        }
  +        return (float) (minValue - minValue * 0.1);
  +    }
  +
  +    /** get the legend panel */
  +    public JPanel getLegend()
  +    {
  +        JPanel main = new JPanel();
  +        GridBagLayout g = new GridBagLayout();
  +
  +        main.setLayout(g);
  +        GridBagConstraints c = new GridBagConstraints();
  +
  +        c.insets = new Insets(3, 3, 3, 3);
  +        c.fill = c.BOTH;
  +        c.gridwidth = 1;
  +        c.gridheight = 1;
  +        for (int t = 0; t < keys.size(); t++)
  +        {
  +            String key = (String) keys.elementAt(t);
  +            JLabel colorSwatch = new JLabel("  ");
  +
  +            colorSwatch.setBackground((Color) colorList.elementAt(t % 
colorList.size()));
  +            colorSwatch.setOpaque(true);
  +            c.gridx = 1;
  +            c.gridy = t;
  +            g.setConstraints(colorSwatch, c);
  +            main.add(colorSwatch);
  +            JLabel name = new JLabel(key);
  +
  +            c.gridx = 2;
  +            c.gridy = t;
  +            g.setConstraints(name, c);
  +            main.add(name);
  +        }
  +        return main;
  +    }
  +
  +    /** get the stats panel */
  +    public JPanel getStats()
  +    {
  +        int total = 0;
  +        float totalValue = 0;
  +        float maxValue = 0;
  +        float minValue = 999999;
  +
  +        for (int t = 0; t < keys.size(); t++)
  +        {
  +            String key = (String) keys.elementAt(t);
  +            Vector temp = (Vector) data.get(key);
  +
  +            for (int j = 0; j < temp.size(); j++)
  +            {
  +                float f = ((Integer) temp.elementAt(j)).intValue();
  +
  +                minValue = Math.min(f, minValue);
  +                maxValue = Math.max(f, maxValue);
  +                totalValue += f;
  +                total++;
  +            }
  +        }
  +        float averageValue = totalValue / total;
  +        JPanel main = new JPanel();
  +        GridBagLayout g = new GridBagLayout();
  +
  +        main.setLayout(g);
  +        DecimalFormat df = new DecimalFormat("#0.0");
  +        GridBagConstraints c = new GridBagConstraints();
  +
  +        c.insets = new Insets(3, 6, 3, 6);
  +        c.fill = c.BOTH;
  +        c.gridwidth = 1;
  +        c.gridheight = 1;
  +        JLabel count = new JLabel("Count: " + total);
  +
  +        c.gridx = 1;
  +        c.gridy = 1;
  +        g.setConstraints(count, c);
  +        JLabel min = new JLabel("Min: " + df.format(new Float(minValue)));
  +
  +        c.gridx = 1;
  +        c.gridy = 2;
  +        g.setConstraints(min, c);
  +        JLabel max = new JLabel("Max: " + df.format(new Float(maxValue)));
  +
  +        c.gridx = 1;
  +        c.gridy = 3;
  +        g.setConstraints(max, c);
  +        JLabel average =
  +            new JLabel("Average: " + df.format(new Float(averageValue)));
  +
  +        c.gridx = 1;
  +        c.gridy = 4;
  +        g.setConstraints(average, c);
  +        main.add(count);
  +        main.add(min);
  +        main.add(max);
  +        main.add(average);
  +        return main;
  +    }
  +
  +    /** gets the size of the biggest Vector */
  +    public int getDataWidth()
  +    {
  +        int size = 0;
  +
  +        for (int t = 0; t < keys.size(); t++)
  +        {
  +            String key = (String) keys.elementAt(t);
  +            Vector v = (Vector) data.get(key);
  +
  +            size = Math.max(size, v.size());
  +        }
  +        return size;
  +    }
  +
  +    /** draws the graph */
  +    public void update(Graphics g)
  +    {
  +        // setup drawing area
  +        int base = 10;
  +
  +        g.setColor(Color.white);
  +        g.fillRect(0, 0, getSize().width, getSize().height);
  +        int width = getSize().width;
  +        int height = getSize().height;
  +        float maxValue = getMax();
  +        float minValue = getMin();
  +
  +        // draw grid
  +        g.setColor(Color.gray);
  +        int dataWidth = getDataWidth();
  +        int increment = Math.round((width - 1) / (dataWidth - 1));
  +
  +        /* for (int t = 0; t < dataWidth; t++) {
  +         g.drawLine(t * increment, 0, t * increment, height);
  +         }*/
  +        int yIncrement = Math.round(((float) height - (1 + base)) / (10 - 1));
  +
  +        /* for (int t = 0; t < 10; t++) {
  +         g.drawLine(0, height - t * yIncrement, width, height - t * yIncrement);
  +         }*/
  +        // draw axis
  +        for (int t = 1; t < dataWidth; t += (dataWidth / 25 + 1))
  +        {
  +            g.drawString((new Integer(t)).toString(), t * increment + 2, height - 
2);
  +        }
  +        float incrementValue = (maxValue - minValue) / (10 - 1);
  +
  +        for (int t = 0; t < 10; t++)
  +        {
  +            g.drawString(new Integer(Math.round(minValue + (t * 
incrementValue))).toString(), 2, height - t * yIncrement - 2 - base);
  +        }
  +        // draw data lines
  +        int start = 0;
  +
  +        for (int t = 0; t < keys.size(); t++)
  +        {
  +            String key = (String) keys.elementAt(t);
  +            Vector v = (Vector) data.get(key);
  +
  +            start = 0;
  +            g.setColor((Color) colorList.elementAt(t % colorList.size()));
  +            for (int i = 0; i < v.size() - 1; i++)
  +            {
  +                float y1 = (float) ((Integer) v.elementAt(i)).intValue();
  +                float y2 = (float) ((Integer) v.elementAt(i + 1)).intValue();
  +
  +                y1 = y1 - minValue;
  +                y2 = y2 - minValue;
  +                int Y1 = Math.round((height * y1) / (maxValue - minValue));
  +                int Y2 = Math.round((height * y2) / (maxValue - minValue));
  +
  +                Y1 = height - Y1 - base;
  +                Y2 = height - Y2 - base;
  +                g.drawLine(start, Y1, start + increment, Y2);
  +                Integer value = (Integer) v.elementAt(i);
  +
  +                start += increment;
  +            }
  +        }
  +    }
  +
  +    public void paint(Graphics g)
  +    {
  +        update(g);
  +    }
   }
  
  
  
  1.2       +25 -22    
jakarta-jmeter/src/core/org/apache/jmeter/reporters/AbstractListenerElement.java
  
  Index: AbstractListenerElement.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/reporters/AbstractListenerElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractListenerElement.java      11 Aug 2002 19:24:47 -0000      1.1
  +++ AbstractListenerElement.java      4 Feb 2003 21:29:15 -0000       1.2
  @@ -1,7 +1,10 @@
   package org.apache.jmeter.reporters;
   
  +
   import org.apache.jmeter.testelement.AbstractTestElement;
   import org.apache.jmeter.visualizers.Visualizer;
  +
  +
   /**
    * Title:        JMeter
    * Description:
  @@ -13,26 +16,26 @@
   
   public abstract class AbstractListenerElement extends AbstractTestElement
   {
  -     private Visualizer listener;
  +    private Visualizer listener;
  +
  +    public AbstractListenerElement()
  +    {}
  +
  +    protected Visualizer getVisualizer()
  +    {
  +        return listener;
  +    }
  +
  +    public void setListener(Visualizer vis)
  +    {
  +        listener = vis;
  +    }
  +
  +    public Object clone()
  +    {
  +        AbstractListenerElement clone = (AbstractListenerElement) super.clone();
   
  -     public AbstractListenerElement()
  -     {
  -     }
  -
  -     protected Visualizer getVisualizer()
  -     {
  -             return listener;
  -     }
  -
  -     public void setListener(Visualizer vis)
  -     {
  -             listener = vis;
  -     }
  -     
  -     public Object clone()
  -     {
  -             AbstractListenerElement clone = (AbstractListenerElement)super.clone();
  -             clone.setListener(getVisualizer());
  -             return clone;
  -     }
  -}
  \ No newline at end of file
  +        clone.setListener(getVisualizer());
  +        return clone;
  +    }
  +}
  
  
  

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

Reply via email to