From aac54f1071413813822fab4de1bde036aede10b0 Mon Sep 17 00:00:00 2001
From: apvrille <ludovic.apvrille@eurecom.fr>
Date: Wed, 19 Sep 2018 18:00:38 +0200
Subject: [PATCH] Resolving bug on color for blocks

---
 src/main/java/ui/avatarbd/AvatarBDBlock.java | 17 +++++++++++++++--
 ttool/launch_configurations/config.xml       |  4 ----
 ttool/runtime/config.xml                     |  6 ------
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/main/java/ui/avatarbd/AvatarBDBlock.java b/src/main/java/ui/avatarbd/AvatarBDBlock.java
index 5edc8eddbf..ed99011fdd 100644
--- a/src/main/java/ui/avatarbd/AvatarBDBlock.java
+++ b/src/main/java/ui/avatarbd/AvatarBDBlock.java
@@ -208,6 +208,9 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
 
         // Draw inner rectangle
         //graph.setColor(ColorManager.AVATAR_BLOCK);
+
+        //TraceManager.addDev("type stereotype=" + typeStereotype);
+
         graph.setColor(BLOCK_TYPE_COLOR.get(typeStereotype));
         graph.fillRect(this.x + 1, this.y + 1, this.width - 1, this.height - 1);
         graph.setColor(c);
@@ -235,6 +238,8 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
 
         String ster = BLOCK_TYPE_STR.get(typeStereotype);
 
+        //TraceManager.addDev("My ster=" + ster);
+
         if (this.rescaled && !this.tdp.isScaled()) {
             this.rescaled = false;
             // Must set the font size...
@@ -700,19 +705,23 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
 
                 int rgb = dialog.getColor();
 
-                TraceManager.addDev("RGBColor:" + rgb + " vs default color:" + ColorManager.AVATAR_BLOCK.getRGB());
+                //TraceManager.addDev("RGBColor:" + rgb + " vs default color:" + ColorManager.AVATAR_BLOCK.getRGB());
 
                 addStereotype(s, rgb);
 
-                TraceManager.addDev("My stereotype=" + BLOCK_TYPE_STR.get(typeStereotype) + " color=" + BLOCK_TYPE_COLOR.get(typeStereotype).getRGB());
+                //TraceManager.addDev("My stereotype=" + BLOCK_TYPE_STR.get(typeStereotype) + " color=" + BLOCK_TYPE_COLOR.get(typeStereotype).getRGB());
+
 
 
                 if (isCryptoBlock()) {
                     addCryptoElements();
                 } else {
+                    int tmpSter = typeStereotype;
                     removeCryptoElements();
+                    typeStereotype = tmpSter;
                 }
 
+
                 return true;
 
             }
@@ -1146,17 +1155,21 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
 
         // Found stereotype
         if (index != -1) {
+            TraceManager.addDev("Found stereotype");
             typeStereotype = index;
             if (index > 0) {
+                TraceManager.addDev("Setting new color");
                 BLOCK_TYPE_COLOR.set(index, new Color(rgb));
             }
             return false;
 
             // Must add a new stereotype
         } else {
+            TraceManager.addDev("No stereotype found: adding" + s + " with color " + rgb);
             BLOCK_TYPE_STR.add(s);
             BLOCK_TYPE_COLOR.add(new Color(rgb));
             typeStereotype = BLOCK_TYPE_STR.size()-1;
+            TraceManager.addDev("Stereotype =" + BLOCK_TYPE_STR.get(typeStereotype) + " typestereotype=" + typeStereotype);
             return true;
         }
     }
diff --git a/ttool/launch_configurations/config.xml b/ttool/launch_configurations/config.xml
index de5ba95d29..94c26000ea 100644
--- a/ttool/launch_configurations/config.xml
+++ b/ttool/launch_configurations/config.xml
@@ -67,10 +67,6 @@
 
 <PLUGIN_JAVA_CODE_GENERATOR data="../plugins/CustomizerAvatarCodeGeneration.jar" />
 
-<LastOpenFile data="/home/satan/TTool/modeling/DIPLODOCUS/ZigBeeTutorial.ttool"/>
-
-<LastWindowAttributes x="65" y="24" width="1301" height="744" max="true" />
-
 
 <ProVerifHash data="1427594573"/>
 </TURTLECONFIGURATION>
diff --git a/ttool/runtime/config.xml b/ttool/runtime/config.xml
index a6629fa26f..b036e28828 100755
--- a/ttool/runtime/config.xml
+++ b/ttool/runtime/config.xml
@@ -65,12 +65,6 @@
 <ExternalCommand2 data="/packages/uppaal4.0.11/uppaal ../uppaal/spec.xml"/>
 
 
-<LastOpenFile data="/home/satan/TTool/modeling/DIPLODOCUS/ZigBeeTutorial.ttool"/>
-
-
-
-<LastWindowAttributes x="65" y="-4" width="1301" height="772" max="true" />
-
 
 <ProVerifHash data="1427594573"/>
 </TURTLECONFIGURATION>
-- 
GitLab