You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/12/28 20:16:55 UTC

svn commit: r1776323 - in /jmeter/trunk/src/components/org/apache/jmeter/visualizers: RespTimeGraphVisualizer.java StatGraphProperties.java StatGraphVisualizer.java StatVisualizer.java

Author: pmouawad
Date: Wed Dec 28 20:16:55 2016
New Revision: 1776323

URL: http://svn.apache.org/viewvc?rev=1776323&view=rev
Log:
sonar: fix errors 

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphProperties.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatVisualizer.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java?rev=1776323&r1=1776322&r2=1776323&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java Wed Dec 28 20:16:55 2016
@@ -213,13 +213,13 @@ public class RespTimeGraphVisualizer ext
 
     private final JComboBox<String> titleFontNameList = new JComboBox<>(StatGraphProperties.getFontNameMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
-    private final JComboBox<String> titleFontSizeList = new JComboBox<>(StatGraphProperties.FONT_SIZE);
+    private final JComboBox<String> titleFontSizeList = new JComboBox<>(StatGraphProperties.getFontSize());
 
     private final JComboBox<String> titleFontStyleList = new JComboBox<>(StatGraphProperties.getFontStyleMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
     private final JComboBox<String> fontNameList = new JComboBox<>(StatGraphProperties.getFontNameMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
-    private final JComboBox<String> fontSizeList = new JComboBox<>(StatGraphProperties.FONT_SIZE);
+    private final JComboBox<String> fontSizeList = new JComboBox<>(StatGraphProperties.getFontSize());
 
     private final JComboBox<String> fontStyleList = new JComboBox<>(StatGraphProperties.getFontStyleMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
@@ -227,7 +227,7 @@ public class RespTimeGraphVisualizer ext
     
     private final JComboBox<String> pointShapeLine = new JComboBox<>(StatGraphProperties.getPointShapeMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
-    private final JComboBox<String> strokeWidthList = new JComboBox<>(StatGraphProperties.STROKE_WIDTH);
+    private final JComboBox<String> strokeWidthList = new JComboBox<>(StatGraphProperties.getStrokeWidth());
 
     private final JCheckBox numberShowGrouping = new JCheckBox(JMeterUtils.getResString("aggregate_graph_number_grouping"), // $NON-NLS-1$
             DEFAULT_NUMBER_SHOW_GROUPING); // Default checked
@@ -819,7 +819,7 @@ public class RespTimeGraphVisualizer ext
         titleFontNameList.setSelectedIndex(DEFAULT_TITLE_FONT_NAME);
         titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$
                 titleFontSizeList));
-        titleFontSizeList.setSelectedItem(StatGraphProperties.FONT_SIZE[DEFAULT_TITLE_FONT_SIZE]);
+        titleFontSizeList.setSelectedItem(StatGraphProperties.getFontSize()[DEFAULT_TITLE_FONT_SIZE]);
         titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$
                 titleFontStyleList));
         titleFontStyleList.setSelectedIndex(DEFAULT_TITLE_FONT_STYLE);
@@ -840,7 +840,7 @@ public class RespTimeGraphVisualizer ext
                 JMeterUtils.getResString("graph_resp_time_settings_line"))); // $NON-NLS-1$
         lineStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("graph_resp_time_stroke_width"), //$NON-NLS-1$
                 strokeWidthList));
-        strokeWidthList.setSelectedItem(StatGraphProperties.STROKE_WIDTH[DEFAULT_STROKE_WIDTH_LIST]);
+        strokeWidthList.setSelectedItem(StatGraphProperties.getStrokeWidth()[DEFAULT_STROKE_WIDTH_LIST]);
         lineStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("graph_resp_time_shape_label"), //$NON-NLS-1$
                 pointShapeLine));
         pointShapeLine.setSelectedIndex(DEFAULT_LINE_SHAPE_POINT);
@@ -916,7 +916,7 @@ public class RespTimeGraphVisualizer ext
         fontNameList.setSelectedIndex(DEFAULT_LEGEND_FONT);
         legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$
                 fontSizeList));
-        fontSizeList.setSelectedItem(StatGraphProperties.FONT_SIZE[DEFAULT_LEGEND_SIZE]);
+        fontSizeList.setSelectedItem(StatGraphProperties.getFontSize()[DEFAULT_LEGEND_SIZE]);
         legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$
                 fontStyleList));
         fontStyleList.setSelectedIndex(DEFAULT_LEGEND_STYLE);

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphProperties.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphProperties.java?rev=1776323&r1=1776322&r2=1776323&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphProperties.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphProperties.java Wed Dec 28 20:16:55 2016
@@ -30,9 +30,9 @@ import org.jCharts.properties.PointChart
 
 public class StatGraphProperties {
 
-    static final String[] FONT_SIZE = { "8", "9", "10", "11", "12", "14", "16", "18", "20", "24", "28", "32"};
+    private static final String[] FONT_SIZE = { "8", "9", "10", "11", "12", "14", "16", "18", "20", "24", "28", "32"};
 
-    static final String[] STROKE_WIDTH = { "1.0f", "1.5f", "2.0f", "2.5f", "3.0f", "3.5f", "4.0f", "4.5f", "5.0f", "5.5f", "6.0f", "6.5f"};
+    private static final String[] STROKE_WIDTH = { "1.0f", "1.5f", "2.0f", "2.5f", "3.0f", "3.5f", "4.0f", "4.5f", "5.0f", "5.5f", "6.0f", "6.5f"};
 
     public static Map<String, String> getFontNameMap() {
         Map<String, String> fontNameMap = new LinkedHashMap<>(2);
@@ -40,6 +40,24 @@ public class StatGraphProperties {
         fontNameMap.put(JMeterUtils.getResString("font.serif"), "Serif"); //$NON-NLS-1$
         return fontNameMap;
     }
+    
+    /**
+     * @return array of String containing font sizes
+     */
+    public static final String[] getFontSize() {
+        String[] fontSize = new String[FONT_SIZE.length];
+        System.arraycopy(FONT_SIZE, 0, fontSize, 0, FONT_SIZE.length);
+        return fontSize;
+    }
+
+    /**
+     * @return array of String containing stroke widths
+     */
+    public static final String[] getStrokeWidth() {
+        String[] strokeWidth = new String[STROKE_WIDTH.length];
+        System.arraycopy(STROKE_WIDTH, 0, strokeWidth, 0, STROKE_WIDTH.length);
+        return strokeWidth;
+    }
 
     @SuppressWarnings("boxing")
     public static Map<String, Integer> getFontStyleMap() {

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java?rev=1776323&r1=1776322&r2=1776323&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java Wed Dec 28 20:16:55 2016
@@ -238,19 +238,19 @@ public class StatGraphVisualizer extends
 
     private JComboBox<String> titleFontNameList = new JComboBox<>(StatGraphProperties.getFontNameMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
-    private JComboBox<String> titleFontSizeList = new JComboBox<>(StatGraphProperties.FONT_SIZE);
+    private JComboBox<String> titleFontSizeList = new JComboBox<>(StatGraphProperties.getFontSize());
 
     private JComboBox<String> titleFontStyleList = new JComboBox<>(StatGraphProperties.getFontStyleMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
     private JComboBox<String> valueFontNameList = new JComboBox<>(StatGraphProperties.getFontNameMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
-    private JComboBox<String> valueFontSizeList = new JComboBox<>(StatGraphProperties.FONT_SIZE);
+    private JComboBox<String> valueFontSizeList = new JComboBox<>(StatGraphProperties.getFontSize());
 
     private JComboBox<String> valueFontStyleList = new JComboBox<>(StatGraphProperties.getFontStyleMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
     private JComboBox<String> fontNameList = new JComboBox<>(StatGraphProperties.getFontNameMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
-    private JComboBox<String> fontSizeList = new JComboBox<>(StatGraphProperties.FONT_SIZE);
+    private JComboBox<String> fontSizeList = new JComboBox<>(StatGraphProperties.getFontSize());
 
     private JComboBox<String> fontStyleList = new JComboBox<>(StatGraphProperties.getFontStyleMap().keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
 
@@ -285,6 +285,15 @@ public class StatGraphVisualizer extends
         clearData();
         init();
     }
+    
+    /**
+     * @return array of String containing column names
+     */
+    public static final String[] getColumns() {
+        String[] columns = new String[COLUMNS.length];
+        System.arraycopy(COLUMNS, 0, columns, 0, COLUMNS.length);
+        return columns;
+    }
 
     /**
      * Creates that Table model 
@@ -867,7 +876,7 @@ public class StatGraphVisualizer extends
         titleFontNameList.setSelectedIndex(0); // default: sans serif
         titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$
                 titleFontSizeList));
-        titleFontSizeList.setSelectedItem(StatGraphProperties.FONT_SIZE[6]); // default: 16
+        titleFontSizeList.setSelectedItem(StatGraphProperties.getFontSize()[6]); // default: 16
         titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$
                 titleFontStyleList));
         titleFontStyleList.setSelectedItem(JMeterUtils.getResString("fontstyle.bold"));  // $NON-NLS-1$ // default: bold
@@ -888,7 +897,7 @@ public class StatGraphVisualizer extends
         valueFontNameList.setSelectedIndex(0); // default: sans serif
         fontValueStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$
                 valueFontSizeList));
-        valueFontSizeList.setSelectedItem(StatGraphProperties.FONT_SIZE[2]); // default: 10
+        valueFontSizeList.setSelectedItem(StatGraphProperties.getFontSize()[2]); // default: 10
         fontValueStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$
                 valueFontStyleList));
         valueFontStyleList.setSelectedItem(JMeterUtils.getResString("fontstyle.normal")); // default: normal //$NON-NLS-1$
@@ -962,7 +971,7 @@ public class StatGraphVisualizer extends
         fontNameList.setSelectedIndex(0); // default: sans serif
         legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$
                 fontSizeList));
-        fontSizeList.setSelectedItem(StatGraphProperties.FONT_SIZE[2]); // default: 10
+        fontSizeList.setSelectedItem(StatGraphProperties.getFontSize()[2]); // default: 10
         legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$
                 fontStyleList));
         fontStyleList.setSelectedItem(JMeterUtils.getResString("fontstyle.normal"));  // $NON-NLS-1$ // default: normal

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatVisualizer.java?rev=1776323&r1=1776322&r2=1776323&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatVisualizer.java Wed Dec 28 20:16:55 2016
@@ -47,7 +47,6 @@ import org.apache.jmeter.util.JMeterUtil
 import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
 import org.apache.jorphan.gui.ObjectTableModel;
 import org.apache.jorphan.gui.RendererUtils;
-import org.apache.jorphan.util.JOrphanUtils;
 
 /**
  * Aggregrate Table-Based Reporting Visualizer for JMeter. Props to the people
@@ -209,15 +208,12 @@ public class StatVisualizer extends Abst
             if (chooser == null) {
                 return;
             }
-            FileWriter writer = null;
-            try {
-                writer = new FileWriter(chooser.getSelectedFile()); // TODO Charset ?
-                CSVSaveService.saveCSVStats(StatGraphVisualizer.getAllTableData(model, StatGraphVisualizer.FORMATS),writer,
-                        saveHeaders.isSelected() ? StatGraphVisualizer.getLabels(StatGraphVisualizer.COLUMNS) : null);
+            try (FileWriter writer = new FileWriter(chooser.getSelectedFile());){  // TODO Charset ?
+                CSVSaveService.saveCSVStats(StatGraphVisualizer.getAllTableData(model, StatGraphVisualizer.FORMATS),
+                        writer,
+                        saveHeaders.isSelected() ? StatGraphVisualizer.getLabels(StatGraphVisualizer.getColumns()) : null);
             } catch (IOException e) {
                 JMeterUtils.reportErrorToUser(e.getMessage(), "Error saving data");
-            } finally {
-                JOrphanUtils.closeQuietly(writer);
             }
         }
     }