Xcos block: fix the displaying of port labels in the decoding of mlist scilab. 30/12930/2
Clément DAVID [Wed, 16 Oct 2013 09:28:36 +0000 (11:28 +0200)]
Change-Id: If540f96776e58038a1b618ce264d0e2de4a3e3ba

scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/InputPortElement.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/OutputPortElement.java

index 6fcefc9..975e36c 100644 (file)
@@ -223,39 +223,35 @@ public final class InputPortElement extends AbstractElement<InputPort> {
      */
     private void decodeGraphics(InputPort port) {
         // protection against previously stored blocks
-        if (graphics.size() <= GRAPHICS_INSTYLE_INDEX || isEmptyField(graphics.get(GRAPHICS_INSTYLE_INDEX))) {
-            return;
-        }
-
-        final ScilabString styles = (ScilabString) graphics.get(GRAPHICS_INSTYLE_INDEX);
+        if (graphics.size() > GRAPHICS_INSTYLE_INDEX && !isEmptyField(graphics.get(GRAPHICS_INSTYLE_INDEX))) {
+            final ScilabString styles = (ScilabString) graphics.get(GRAPHICS_INSTYLE_INDEX);
 
-        boolean isColumnDominant = styles.getHeight() >= styles.getWidth();
-        int[] indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
+            boolean isColumnDominant = styles.getHeight() >= styles.getWidth();
+            int[] indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
 
-        if (canGet(styles, indexes)) {
-            final String style;
+            if (canGet(styles, indexes)) {
+                final String style;
 
-            style = styles.getData()[indexes[0]][indexes[1]];
-            port.setStyle(new StyleMap(port.getStyle()).putAll(style).toString());
+                style = styles.getData()[indexes[0]][indexes[1]];
+                port.setStyle(new StyleMap(port.getStyle()).putAll(style).toString());
+            }
         }
 
         // protection against previously stored blocks
-        if (graphics.size() <= GRAPHICS_INLABEL_INDEX || isEmptyField(graphics.get(GRAPHICS_INLABEL_INDEX))) {
-            return;
-        }
-
-        final ScilabString labels = (ScilabString) graphics.get(GRAPHICS_INLABEL_INDEX);
+        if (graphics.size() > GRAPHICS_INLABEL_INDEX && !isEmptyField(graphics.get(GRAPHICS_INLABEL_INDEX))) {
+            final ScilabString labels = (ScilabString) graphics.get(GRAPHICS_INLABEL_INDEX);
 
-        isColumnDominant = labels.getHeight() >= labels.getWidth();
-        indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
+            boolean isColumnDominant = labels.getHeight() >= labels.getWidth();
+            int[] indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
 
-        if (canGet(labels, indexes)) {
-            final String label = labels.getData()[indexes[0]][indexes[1]];
+            if (canGet(labels, indexes)) {
+                final String label = labels.getData()[indexes[0]][indexes[1]];
 
-            if (label != null) {
-                port.setValue(label);
-            } else {
-                port.setValue("");
+                if (label != null) {
+                    port.setValue(label);
+                } else {
+                    port.setValue("");
+                }
             }
         }
     }
index e9d3442..a6ba906 100644 (file)
@@ -223,39 +223,35 @@ public final class OutputPortElement extends AbstractElement<OutputPort> {
      */
     private void decodeGraphics(OutputPort port) {
         // protection against previously stored blocks
-        if (graphics.size() <= GRAPHICS_OUTSTYLE_INDEX || isEmptyField(graphics.get(GRAPHICS_OUTSTYLE_INDEX))) {
-            return;
-        }
-
-        final ScilabString styles = (ScilabString) graphics.get(GRAPHICS_OUTSTYLE_INDEX);
+        if (graphics.size() > GRAPHICS_OUTSTYLE_INDEX && !isEmptyField(graphics.get(GRAPHICS_OUTSTYLE_INDEX))) {
+            final ScilabString styles = (ScilabString) graphics.get(GRAPHICS_OUTSTYLE_INDEX);
 
-        boolean isColumnDominant = styles.getHeight() >= styles.getWidth();
-        int[] indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
+            boolean isColumnDominant = styles.getHeight() >= styles.getWidth();
+            int[] indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
 
-        if (canGet(styles, indexes)) {
-            final String style;
+            if (canGet(styles, indexes)) {
+                final String style;
 
-            style = styles.getData()[indexes[0]][indexes[1]];
-            port.setStyle(new StyleMap(port.getStyle()).putAll(style).toString());
+                style = styles.getData()[indexes[0]][indexes[1]];
+                port.setStyle(new StyleMap(port.getStyle()).putAll(style).toString());
+            }
         }
 
         // protection against previously stored blocks
-        if (graphics.size() <= GRAPHICS_OUTLABEL_INDEX || isEmptyField(graphics.get(GRAPHICS_OUTLABEL_INDEX))) {
-            return;
-        }
-
-        final ScilabString labels = (ScilabString) graphics.get(GRAPHICS_OUTLABEL_INDEX);
+        if (graphics.size() > GRAPHICS_OUTLABEL_INDEX && !isEmptyField(graphics.get(GRAPHICS_OUTLABEL_INDEX))) {
+            final ScilabString labels = (ScilabString) graphics.get(GRAPHICS_OUTLABEL_INDEX);
 
-        isColumnDominant = labels.getHeight() >= labels.getWidth();
-        indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
+            boolean isColumnDominant = labels.getHeight() >= labels.getWidth();
+            int[] indexes = getIndexes(alreadyDecodedCount, isColumnDominant);
 
-        if (canGet(styles, indexes)) {
-            final String label = labels.getData()[indexes[0]][indexes[1]];
+            if (canGet(labels, indexes)) {
+                final String label = labels.getData()[indexes[0]][indexes[1]];
 
-            if (label != null) {
-                port.setValue(label);
-            } else {
-                port.setValue("");
+                if (label != null) {
+                    port.setValue(label);
+                } else {
+                    port.setValue("");
+                }
             }
         }
     }