Assing default angle value when the rotation value is not present
Clément DAVID [Mon, 11 Jan 2010 15:03:54 +0000 (16:03 +0100)]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/BasicBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/codec/BasicPortCodec.java

index f0dbf6b..8d18e85 100644 (file)
@@ -911,7 +911,12 @@ public class BasicBlock extends XcosUIDObject {
        public void updateFieldsFromStyle() {
                StyleMap map = new StyleMap(getStyle());
 
-               angle = Integer.parseInt(map.get(XcosConstants.STYLE_ROTATION));
+               if (map.get(XcosConstants.STYLE_ROTATION) != null) {
+                       angle = Integer.parseInt(map.get(XcosConstants.STYLE_ROTATION));
+               } else {
+                       angle = 0;
+               }
+               
                isFlipped = Boolean.parseBoolean(map.get(XcosConstants.STYLE_FLIP));
                isMirrored = Boolean.parseBoolean(map.get(XcosConstants.STYLE_MIRROR));
        }
index e88bf17..44aa345 100644 (file)
@@ -94,7 +94,12 @@ public class BasicPortCodec extends XcosObjectCodec {
 
                StyleMap map = new StyleMap(style);
                
-               rotation = Integer.parseInt(map.get(XcosConstants.STYLE_ROTATION));
+               if (map.get(XcosConstants.STYLE_ROTATION) != null) {
+                       rotation = Integer.parseInt(map.get(XcosConstants.STYLE_ROTATION));
+               } else {
+                       rotation = 0;
+               }
+               
                flipped = Boolean.parseBoolean(map.get(XcosConstants.STYLE_FLIP));
                mirrored = Boolean.parseBoolean(map.get(XcosConstants.STYLE_MIRROR));