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 se...@apache.org on 2006/05/24 20:25:59 UTC

svn commit: r409222 - in /jakarta/jmeter/branches/rel-2-1: src/components/org/apache/jmeter/visualizers/ src/core/org/apache/jmeter/resources/ xdocs/

Author: sebb
Date: Wed May 24 11:25:56 2006
New Revision: 409222

URL: http://svn.apache.org/viewvc?rev=409222&view=rev
Log:
Bug 39652 - Allow truncation of labels on AxisGraph

Modified:
    jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java
    jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
    jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml

Modified: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java?rev=409222&r1=409221&r2=409222&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java Wed May 24 11:25:56 2006
@@ -49,10 +49,14 @@
  */
 public class AxisGraph extends JPanel {
 
-    private static final Logger log = LoggingManager.getLoggerForClass();
+	private static final Logger log = LoggingManager.getLoggerForClass();
+
+    private static final String ELLIPSIS = "..."; //$NON-NLS-1$
+	private static final int ELLIPSIS_LEN = ELLIPSIS.length();
     
     protected double[][] data = null;
     protected String title, xAxisTitle, yAxisTitle, yAxisLabel;
+    protected int maxLength;
     protected String[] xAxisLabels;
     protected int width, height;
     
@@ -85,6 +89,10 @@
     public void setTitle(String title) {
         this.title = title;
     }
+
+    public void setMaxLength(int maxLength) {
+        this.maxLength = maxLength;
+    }    
     
     public void setXAxisTitle(String title) {
         this.xAxisTitle = title;
@@ -114,8 +122,8 @@
         if (data != null && this.title != null && this.xAxisLabels != null &&
                 this.xAxisTitle != null && this.yAxisLabel != null &&
                 this.yAxisTitle != null) {
-            drawSample(this.title,this.xAxisLabels,this.xAxisTitle,
-                    this.yAxisTitle,this.data,this.width,this.height,g);
+            drawSample(this.title,this.maxLength,this.xAxisLabels,this.xAxisTitle,
+                this.yAxisTitle,this.data,this.width,this.height,g);
         }
     }
 
@@ -132,15 +140,37 @@
         return max;
     }
     
-    private void drawSample(String _title, String[] _xAxisLabels, String _xAxisTitle,
+    private String squeeze (String input, int _maxLength){
+        if (input.length()>_maxLength){
+            String output=input.substring(0,_maxLength-ELLIPSIS_LEN)+ELLIPSIS;
+            return output;
+        }
+        return input;
+    }
+    
+    private void drawSample(String _title, int _maxLength, String[] _xAxisLabels, String _xAxisTitle,
             String _yAxisTitle, double[][] _data, int _width, int _height, Graphics g) {
         double max = findMax(_data);
         try {
+            /** These controls are already done in StatGraphVisualizer
             if (_width == 0) {
                 _width = 450;
             }
             if (_height == 0) {
                 _height = 250;
+            }
+			**/
+            if (_maxLength < 3) {
+                _maxLength = 3;
+            }
+            // if the "Title of Graph" is empty, we can assume some default
+            if (_title.length() == 0 ) {
+                _title = "Graph";
+            }
+            // if the labels are too long, they'll be "squeezed" to make the chart viewable.
+            for (int i = 0; i < _xAxisLabels.length; i++) {
+                String label = _xAxisLabels[i];
+                _xAxisLabels[i]=squeeze(label, _maxLength);
             }
             this.setPreferredSize(new Dimension(_width,_height));
             DataSeries dataSeries = new DataSeries( _xAxisLabels, _xAxisTitle, _yAxisTitle, _title );

Modified: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java?rev=409222&r1=409221&r2=409222&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java Wed May 24 11:25:56 2006
@@ -73,20 +73,25 @@
 ActionListener {
     private static final Logger log = LoggingManager.getLoggerForClass();
     
-	private final String[] COLUMNS = { JMeterUtils.getResString("URL"),
-			JMeterUtils.getResString("aggregate_report_count"), JMeterUtils.getResString("average"),
-			JMeterUtils.getResString("aggregate_report_median"), JMeterUtils.getResString("aggregate_report_90%_line"),
-			JMeterUtils.getResString("aggregate_report_min"), JMeterUtils.getResString("aggregate_report_max"),
-			JMeterUtils.getResString("aggregate_report_error%"), JMeterUtils.getResString("aggregate_report_rate"),
-			JMeterUtils.getResString("aggregate_report_bandwidth") };
-    
-    private final String[] GRAPH_COLUMNS = {JMeterUtils.getResString("average"),
-            JMeterUtils.getResString("aggregate_report_median"),
-            JMeterUtils.getResString("aggregate_report_90%_line"),
-            JMeterUtils.getResString("aggregate_report_min"),
-            JMeterUtils.getResString("aggregate_report_max")};
+	private final String[] COLUMNS = { JMeterUtils.getResString("URL"), //$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_count"),			//$NON-NLS-1$
+			JMeterUtils.getResString("average"),						//$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_median"),		//$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_90%_line"),		//$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_min"),			//$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_max"),			//$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_error%"),		//$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_rate"),			//$NON-NLS-1$
+			JMeterUtils.getResString("aggregate_report_bandwidth") };	//$NON-NLS-1$
+    
+    private final String[] GRAPH_COLUMNS = {JMeterUtils.getResString("average"),//$NON-NLS-1$
+            JMeterUtils.getResString("aggregate_report_median"),		//$NON-NLS-1$
+            JMeterUtils.getResString("aggregate_report_90%_line"),		//$NON-NLS-1$
+            JMeterUtils.getResString("aggregate_report_min"),			//$NON-NLS-1$
+            JMeterUtils.getResString("aggregate_report_max")};			//$NON-NLS-1$
 
-	private final String TOTAL_ROW_LABEL = JMeterUtils.getResString("aggregate_report_total_label");
+	private final String TOTAL_ROW_LABEL =
+		JMeterUtils.getResString("aggregate_report_total_label");		//$NON-NLS-1$
 
 	protected JTable myJTable;
 
@@ -105,29 +110,33 @@
     protected JSplitPane spane = null;
     
     protected JLabeledChoice columns = 
-        new JLabeledChoice(JMeterUtils.getResString("aggregate_graph_column"),GRAPH_COLUMNS);
+        new JLabeledChoice(JMeterUtils.getResString("aggregate_graph_column"),GRAPH_COLUMNS);//$NON-NLS-1$
     
     //NOT USED protected double[][] data = null;
     
     protected JButton displayButton = 
-        new JButton(JMeterUtils.getResString("aggregate_graph_display"));
+        new JButton(JMeterUtils.getResString("aggregate_graph_display"));				//$NON-NLS-1$
     
     protected JButton saveGraph = 
-        new JButton(JMeterUtils.getResString("aggregate_graph_save"));
+        new JButton(JMeterUtils.getResString("aggregate_graph_save"));					//$NON-NLS-1$
     
     protected JButton saveTable = 
-        new JButton(JMeterUtils.getResString("aggregate_graph_save_table"));
+        new JButton(JMeterUtils.getResString("aggregate_graph_save_table"));			//$NON-NLS-1$
     
     JLabeledTextField graphTitle = 
-        new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_user_title"));
+        new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_user_title"));	//$NON-NLS-1$
+    
+    JLabeledTextField maxLengthXAxisLabel = 
+        new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_max_length_xaxis_label"));//$NON-NLS-1$
+    
     JLabeledTextField graphWidth = 
-        new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_width"));
+        new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_width"));		//$NON-NLS-1$
     JLabeledTextField graphHeight = 
-        new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_height"));
+        new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_height"));		//$NON-NLS-1$
     
-    protected String yAxisLabel = JMeterUtils.getResString("aggregate_graph_response_time");
+    protected String yAxisLabel = JMeterUtils.getResString("aggregate_graph_response_time");//$NON-NLS-1$
     
-    protected String yAxisTitle = JMeterUtils.getResString("aggregate_graph_ms");
+    protected String yAxisTitle = JMeterUtils.getResString("aggregate_graph_ms");		//$NON-NLS-1$
     
     protected boolean saveGraphToFile = false;
     
@@ -137,19 +146,27 @@
 
 	public StatGraphVisualizer() {
 		super();
-		model = new ObjectTableModel(COLUMNS, new Functor[] { new Functor("getLabel"), new Functor("getCount"),
-				new Functor("getMeanAsNumber"), new Functor("getMedian"),
-				new Functor("getPercentPoint", new Object[] { new Float(.900) }), new Functor("getMin"),
-				new Functor("getMax"), new Functor("getErrorPercentageString"), new Functor("getRateString"),
-				new Functor("getPageSizeString") }, new Functor[] { null, null, null, null, null, null, null, null,
-				null, null }, new Class[] { String.class, Long.class, Long.class, Long.class, Long.class, Long.class,
+		model = new ObjectTableModel(COLUMNS, new Functor[] {
+				new Functor("getLabel"),					//$NON-NLS-1$
+				new Functor("getCount"),					//$NON-NLS-1$
+				new Functor("getMeanAsNumber"),				//$NON-NLS-1$
+				new Functor("getMedian"),					//$NON-NLS-1$
+				new Functor("getPercentPoint",				//$NON-NLS-1$
+				new Object[] { new Float(.900) }),
+				new Functor("getMin"),						//$NON-NLS-1$
+				new Functor("getMax"), 						//$NON-NLS-1$
+				new Functor("getErrorPercentageString"),	//$NON-NLS-1$
+				new Functor("getRateString"),				//$NON-NLS-1$
+				new Functor("getPageSizeString") },			//$NON-NLS-1$
+				new Functor[] { null, null, null, null, null, null, null, null,	null, null }, 
+				new Class[] { String.class, Long.class, Long.class, Long.class, Long.class, Long.class,
 				Long.class, String.class, String.class, String.class });
 		clear();
 		init();
 	}
 
 	public String getLabelResource() {
-		return "aggregate_graph_title";
+		return "aggregate_graph_title";						//$NON-NLS-1$
 	}
 
 	public void add(SampleResult res) {
@@ -209,7 +226,7 @@
         graph.setBorder(margin2);
 
 
-        JLabel graphLabel = new JLabel(JMeterUtils.getResString("aggregate_graph"));
+        JLabel graphLabel = new JLabel(JMeterUtils.getResString("aggregate_graph")); //$NON-NLS-1$
         graphPanel = new AxisGraph();
         graphPanel.setPreferredSize(new Dimension(defaultWidth,defaultHeight));
 
@@ -222,6 +239,7 @@
         
         graph.add(graphLabel);
         graph.add(graphTitle);
+        graph.add(maxLengthXAxisLabel);
         graph.add(graphWidth);
         graph.add(graphHeight);
         graph.add(buttonpanel);
@@ -246,19 +264,25 @@
     public void makeGraph() {
         String wstr = graphWidth.getText();
         String hstr = graphHeight.getText();
+        String lstr = maxLengthXAxisLabel.getText();
         if (wstr.length() == 0) {
-            wstr = "450";
+            wstr = "450";//$NON-NLS-1$
         }
         if (hstr.length() == 0) {
-            hstr = "250";
+            hstr = "250";//$NON-NLS-1$
+        }
+        if (lstr.length() == 0) {
+            lstr = "20";//$NON-NLS-1$
         }
         int width = Integer.parseInt(wstr);
         int height = Integer.parseInt(hstr);
+        int maxLength = Integer.parseInt(lstr);
 
         graphPanel.setData(this.getData());
         graphPanel.setHeight(height);
         graphPanel.setWidth(width);
         graphPanel.setTitle(graphTitle.getText());
+        graphPanel.setMaxLength(maxLength);
         graphPanel.setXAxisLabels(getAxisLabels());
         graphPanel.setXAxisTitle(columns.getText());
         graphPanel.setYAxisLabels(this.yAxisLabel);
@@ -330,7 +354,7 @@
             }
         } else if (event.getSource() == saveTable) {
             JFileChooser chooser = FileDialoger.promptToSaveFile(
-                    "statistics.csv");
+                    "statistics.csv");		//$NON-NLS-1$
             File output = chooser.getSelectedFile();
             FileWriter writer = null;
             try {

Modified: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties?rev=409222&r1=409221&r2=409222&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties Wed May 24 11:25:56 2006
@@ -21,6 +21,7 @@
 aggregate_graph_save_table=Save Table Data
 aggregate_graph_title=Aggregate Graph
 aggregate_graph_user_title=Title for Graph
+aggregate_graph_max_length_xaxis_label=Max length of x-axis label
 aggregate_graph_width=Width
 aggregate_report=Aggregate Report
 aggregate_report_90%_line=90% Line

Modified: jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml?rev=409222&r1=409221&r2=409222&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml Wed May 24 11:25:56 2006
@@ -103,6 +103,7 @@
 <li>Bug 39580 - recycle option for CSV Dataset</li>
 <li>Bug 37652 - support for Ajp Tomcat protocol</li>
 <li>Bug 39626 - Loading SOAP/XML-RPC requests from file</li>
+<li>Bug 39652 - Allow truncation of labels on AxisGraph</li>
 </ul>
 
 <h4>Bug fixes:</h4>



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