Xcos: fix port labeling on invalid rpar 11/18411/2
Clément DAVID [Thu, 4 Aug 2016 16:11:41 +0000 (18:11 +0200)]
Change-Id: I0c00735a3db948fbda25786e665bb50f326cb4db

scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/custom/ProdPortLabeler.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/custom/SumPortLabeler.java

index 46bb339..41c0c22 100644 (file)
@@ -76,16 +76,16 @@ public class ProdPortLabeler {
          * Set the ports labels
          */
         JavaController controller = new JavaController();
-        VectorOfInt ipar = new VectorOfInt(ports.size());
+        VectorOfInt ipar = new VectorOfInt();
         controller.getObjectProperty(source.getUID(), Kind.BLOCK, ObjectProperties.IPAR, ipar);
 
         for (int i = 0; i < ports.size(); i++) {
             final int gain;
 
-            if (ipar.size() < i) {
-                gain = 1;
-            } else {
+            if (i < rpar.size()) {
                 gain = ipar.get(i);
+            } else {
+                gain = 1;
             }
 
             ports.get(i).setValue(getLabel(gain));
index 560bf8d..845feac 100644 (file)
@@ -77,16 +77,16 @@ public class SumPortLabeler {
          * Set the ports labels
          */
         JavaController controller = new JavaController();
-        VectorOfDouble rpar = new VectorOfDouble(ports.size());
+        VectorOfDouble rpar = new VectorOfDouble();
         controller.getObjectProperty(source.getUID(), Kind.BLOCK, ObjectProperties.RPAR, rpar);
 
         for (int i = 0; i < ports.size(); i++) {
             final double gain;
 
-            if (rpar.size() < i) {
-                gain = 1;
-            } else {
+            if (i < rpar.size()) {
                 gain = rpar.get(i);
+            } else {
+                gain = 1;
             }
 
             ports.get(i).setValue(getLabel(gain));