From 2b6bd89a4d36a72110d85675e93a1e7d85db4f8f Mon Sep 17 00:00:00 2001
From: dblouin <dominique.blouin@telecom-paristech.fr>
Date: Mon, 8 Apr 2019 19:25:19 +0200
Subject: [PATCH] Issue #31 for communication patterns and sequence diagrams

---
 src/main/java/ui/tmlcp/TGConnectorTMLCP.java  |   3 +-
 src/main/java/ui/tmlcp/TMLCPForLoop.java      |  20 ++-
 src/main/java/ui/tmlcp/TMLCPFork.java         |  18 ++-
 src/main/java/ui/tmlcp/TMLCPJoin.java         |  16 +-
 src/main/java/ui/tmlcp/TMLCPPanel.java        |   9 +-
 src/main/java/ui/tmlcp/TMLCPRefAD.java        |  62 +++++---
 src/main/java/ui/tmlcp/TMLCPRefSD.java        |  57 ++++---
 src/main/java/ui/tmlcp/TMLCPStartState.java   |   2 +-
 src/main/java/ui/tmlsd/TMLSDActionState.java  |  44 ++---
 .../ui/tmlsd/TMLSDControllerInstance.java     |  28 ++--
 src/main/java/ui/tmlsd/TMLSDInstance.java     | 150 +++++++++++-------
 src/main/java/ui/tmlsd/TMLSDPanel.java        |   4 +-
 .../java/ui/tmlsd/TMLSDStorageInstance.java   |  29 ++--
 .../java/ui/tmlsd/TMLSDTransferInstance.java  |  29 ++--
 14 files changed, 266 insertions(+), 205 deletions(-)

diff --git a/src/main/java/ui/tmlcp/TGConnectorTMLCP.java b/src/main/java/ui/tmlcp/TGConnectorTMLCP.java
index 2ed2f6dd86..65b3673ee3 100755
--- a/src/main/java/ui/tmlcp/TGConnectorTMLCP.java
+++ b/src/main/java/ui/tmlcp/TGConnectorTMLCP.java
@@ -56,7 +56,8 @@ import java.util.Vector;
  */
 public class TGConnectorTMLCP extends TADConnector /* Issue #69 TGConnector*/ {
     
-	protected int arrowLength = 10;
+	// Issue #31
+	//protected int arrowLength = 10;
 	
 	protected String guard = "";
     
diff --git a/src/main/java/ui/tmlcp/TMLCPForLoop.java b/src/main/java/ui/tmlcp/TMLCPForLoop.java
index 53a89272c2..8fc396c12b 100755
--- a/src/main/java/ui/tmlcp/TMLCPForLoop.java
+++ b/src/main/java/ui/tmlcp/TMLCPForLoop.java
@@ -116,13 +116,15 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp
 
     @Override
     protected void internalDrawing(Graphics g) {
-        final int textWidth = g.getFontMetrics().stringWidth(value);
-        int w1 = Math.max(minWidth, textWidth + 2 * textX);
-        if ((w1 != width) & (!tdp.isScaled())) {
-            setCd(x + width / 2 - w1 / 2, y);
-            width = w1;
-            //updateConnectingPoints();
-        }
+    	
+    	// Issue #31
+        final int textWidth = checkWidth( g );//g.getFontMetrics().stringWidth(value);
+//        int w1 = Math.max(minWidth, textWidth + 2 * textX);
+//        if ((w1 != width) & (!tdp.isScaled())) {
+//            setCd(x + width / 2 - w1 / 2, y);
+//            width = w1;
+//            //updateConnectingPoints();
+//        }
 
         if (stateOfError > 0) {
             Color c = g.getColor();
@@ -140,7 +142,9 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp
         g.drawRoundRect(x, y, width, height, arc, arc);
         g.drawLine(x + (width / 2), y, x + (width / 2), y - lineLength);
         g.drawLine(x + (width / 2), y + height, x + (width / 2), y + lineLength + height);
-        g.drawLine(x + width, y + height / 2, x + width + lineLength, y + height / 2);
+        
+        // Issue #31 Useless line
+        //g.drawLine(x + width, y + height / 2, x + width + lineLength, y + height / 2);
 
         g.drawString(value, x + (width - textWidth) / 2, y + textY);
     }
diff --git a/src/main/java/ui/tmlcp/TMLCPFork.java b/src/main/java/ui/tmlcp/TMLCPFork.java
index 1d8f840e0e..e51de14c97 100755
--- a/src/main/java/ui/tmlcp/TMLCPFork.java
+++ b/src/main/java/ui/tmlcp/TMLCPFork.java
@@ -59,7 +59,7 @@ import ui.util.IconManager;
  */
 public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGCWithoutInternalComponent*/ {
 	
-	private int lineLength = 0;
+	//private int lineLength = 0;
 	private static int instanceCounter = 0;
 	private int counter = 0;
 	//private int textX, textY;
@@ -67,12 +67,7 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC
 	public TMLCPFork(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
 		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
 			
-		width = 150;
-		height = 5;
-		
-		//textX = width - 10;
-		//textY = height - 8;
-
+		// Issue #31
 		nbConnectingPoint = 6;
 		connectingPoint = new TGConnectingPoint[6];
 		connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.167, 1.0);
@@ -81,6 +76,13 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC
 		connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.667, 1.0);
 		connectingPoint[4] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.833, 1.0);
 		connectingPoint[5] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0);
+		
+		initSize( 150, 5 );
+//		width = 150;
+//		height = 5;
+		
+		//textX = width - 10;
+		//textY = height - 8;
                 
         addTGConnectingPointsComment();
 
@@ -98,7 +100,7 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC
 	}
 
 	@Override
-	public void internalDrawing(Graphics g) {
+	protected void internalDrawing(Graphics g) {
 		g.drawRect(x, y, width, height);
 		g.fillRect(x, y, width, height);
 	}
diff --git a/src/main/java/ui/tmlcp/TMLCPJoin.java b/src/main/java/ui/tmlcp/TMLCPJoin.java
index 341f896cde..26b6d04297 100755
--- a/src/main/java/ui/tmlcp/TMLCPJoin.java
+++ b/src/main/java/ui/tmlcp/TMLCPJoin.java
@@ -57,20 +57,16 @@ import ui.util.IconManager;
  */
 public class TMLCPJoin extends TGCWithoutInternalComponent{
 
-	private int lineLength = 0;
+	// Issue #31
+//	private int lineLength = 0;
 	private static int instanceCounter = 0;
 	private int counter = 0;
 	//private int textX, textY;
 
 	public TMLCPJoin(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
 		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
-			
-		width = 150;
-		height = 5;
-		
-		//textX = width - 10;
-		//textY = height - 8;
 
+		// Issue #31
 		nbConnectingPoint = 6;
 		connectingPoint = new TGConnectingPoint[6];
 		connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.167, 0.0);
@@ -79,6 +75,10 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{
 		connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.667, 0.0);
 		connectingPoint[4] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.833, 0.0);
 		connectingPoint[5] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0);
+			
+		initSize( 150, 5 );
+//		width = 150;
+//		height = 5;
 
 		addTGConnectingPointsComment();
 
@@ -96,7 +96,7 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{
 	}
 
 	@Override
-	public void internalDrawing(Graphics g) {
+	protected void internalDrawing(Graphics g) {
 		g.drawRect(x, y, width, height);
 		g.fillRect(x, y, width, height);
 	}
diff --git a/src/main/java/ui/tmlcp/TMLCPPanel.java b/src/main/java/ui/tmlcp/TMLCPPanel.java
index cb458388dd..c7fe4fcc02 100755
--- a/src/main/java/ui/tmlcp/TMLCPPanel.java
+++ b/src/main/java/ui/tmlcp/TMLCPPanel.java
@@ -54,7 +54,6 @@ public class TMLCPPanel extends TDiagramPanel {
     
     public  TMLCPPanel(MainGUI mgui, TToolBar _ttb) {
         super(mgui, _ttb);
-
     }
     
     @Override
@@ -108,8 +107,8 @@ public class TMLCPPanel extends TDiagramPanel {
     }
     
     @Override
-    public String getXMLHead() {
-        return "<CommunicationPatternDiagramPanel name=\"" + name + "\"" + sizeParam() + " >";
+    public String getXMLHead() {												// Issue #31
+        return "<CommunicationPatternDiagramPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; // Issue #31
     }
     
     @Override
@@ -189,7 +188,7 @@ public class TMLCPPanel extends TDiagramPanel {
         return null;
     }*/
     
-    public void makePostLoadingProcessing() throws MalformedModelingException {
+    //public void makePostLoadingProcessing() throws MalformedModelingException {
        // TGComponent tgc;
         
         /*for(int i=0; i<componentList.size(); i++) {
@@ -198,7 +197,7 @@ public class TMLCPPanel extends TDiagramPanel {
                 ((TCDTObject)tgc).postLoadingProcessing();
             }
         }*/
-    }
+    //}
     
     public boolean isTMLCPSDCreated(String name) {
         return mgui.isTMLCPSDCreated(tp, name);
diff --git a/src/main/java/ui/tmlcp/TMLCPRefAD.java b/src/main/java/ui/tmlcp/TMLCPRefAD.java
index 5e07d71601..9832d2193b 100755
--- a/src/main/java/ui/tmlcp/TMLCPRefAD.java
+++ b/src/main/java/ui/tmlcp/TMLCPRefAD.java
@@ -58,23 +58,28 @@ import java.awt.geom.Line2D;
  * @author Ludovic APVRILLE, Andrea ENRICI
  */
 public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
-    protected int lineLength = 5;
-    protected int textX =  5;
-    protected int textY =  15;
-    protected int arc = 5;
+	
+	// Issue #31
+//    protected int lineLength = 5;
+//    protected int textX =  5;
+//    protected int textY =  15;
+//    protected int arc = 5;
 
     public TMLCPRefAD(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
         super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
 
-        width = 30;
-        height = 35;
-        minWidth = 70;
-
+        // Issue #31
         nbConnectingPoint = 2;
         connectingPoint = new TGConnectingPoint[2];
         connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0);
         connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0);
 
+        initSize( 30, 35 );
+//        width = 30;
+//        height = 35;
+        minWidth = scale( 70 );
+        textX = scale( 5 );
+
         addTGConnectingPointsComment();
 
         moveable = true;
@@ -88,15 +93,16 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
     }
 
     @Override
-    public void internalDrawing(Graphics g) {
-        //int w2 = g.getFontMetrics().stringWidth("ref");
-        int w  = g.getFontMetrics().stringWidth(value) /*+ w2*/;
-        int w1 = Math.max(minWidth, w + 2 * textX);
-        if ((w1 != width) & (!tdp.isScaled())) {
-            setCd(x + width/2 - w1/2, y);
-            width = w1;
-            //updateConnectingPoints();
-        }
+    protected void internalDrawing(Graphics g) {
+    	
+    	// Issue #31
+        final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value);
+//        int w1 = Math.max(minWidth, w + 2 * textX);
+//        if ((w1 != width) & (!tdp.isScaled())) {
+//            setCd(x + width/2 - w1/2, y);
+//            width = w1;
+//            //updateConnectingPoints();
+//        }
 
         Color c = g.getColor();
         g.setColor(ColorManager.IOD_REFERENCE);
@@ -105,17 +111,22 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
 
         g.drawRect(x, y, width, height);
 
-
         g.drawLine(x+(width/2), y, x+(width/2), y - lineLength);
         g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height);
 
-        g.drawString(name, x + (width - w) / 2, y + textY + 15);
-        g.drawString("ad", x+3, y+12);
-        g.drawLine(x, y+15, x+15, y+15);
-        g.drawLine(x+25, y, x+25, y+8);
-        g.drawLine(x+15, y+15, x+25, y+8);
-
-
+        final int offset = scale( 15 );
+        g.drawString(name, x + (width - w) / 2, y + textY + offset /* 15 Issue #31 */ );
+        
+        // Issue #31
+        final int adOffsetX = scale( 3 );
+        final int adOffsetY = scale( 12 );
+        g.drawString("ad", x + adOffsetX /*3*/, y + adOffsetY );
+        g.drawLine(x, y + offset /*15*/, x + offset /* 15 */, y+ offset /*15 Issue #31 */);
+       
+        final int adBoxOffsetX = scale( 25 );
+        final int adBoxOffsetY = scale( 8 );
+        g.drawLine(x + adBoxOffsetX /*25*/, y, x + adBoxOffsetX /*25*/, y + adBoxOffsetY /*8*/);
+        g.drawLine(x+ offset /*15*/, y+ offset /*15*/, x + adBoxOffsetX /*25*/, y + adBoxOffsetY /*8*/ );
     }
 
     @Override
@@ -135,7 +146,6 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
         return value;
     }
 
-
     @Override
     public int getType() {
         return TGComponentManager.TMLCP_REF_CP;
diff --git a/src/main/java/ui/tmlcp/TMLCPRefSD.java b/src/main/java/ui/tmlcp/TMLCPRefSD.java
index 413b831c3a..b93784a3d5 100755
--- a/src/main/java/ui/tmlcp/TMLCPRefSD.java
+++ b/src/main/java/ui/tmlcp/TMLCPRefSD.java
@@ -66,10 +66,12 @@ import ui.util.IconManager;
  * @author Ludovic APVRILLE
  */
 public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
-    protected int lineLength = 5;
-    protected int textX =  5;
-    protected int textY =  15;
-    protected int arc = 5;
+	
+	// Issue #31
+//    protected int lineLength = 5;
+//    protected int textX =  5;
+//    protected int textY =  15;
+//    protected int arc = 5;
 	//	private TMLSDPanel refToSD;
 //		private TGConnectorTMLCP[] connectors = new TGConnectorTMLCP[2];
 		//private int index = 0;
@@ -77,14 +79,17 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
     public TMLCPRefSD(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
         super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
         
-        width = 30;
-        height = 35;
-        minWidth = 70;
-        
+        // Issue #31
         nbConnectingPoint = 2;
         connectingPoint = new TGConnectingPoint[2];
         connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0);
         connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0);
+
+        textX = 5;
+//        width = 30;
+//        height = 35;
+        initSize( 30, 35 );
+        minWidth = 70;
         
         addTGConnectingPointsComment();
         
@@ -99,15 +104,16 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
     }
     
     @Override
-    public void internalDrawing(Graphics g) {
-        //int w2 = g.getFontMetrics().stringWidth("ref");
-        int w  = g.getFontMetrics().stringWidth(value) /*+ w2*/;
-        int w1 = Math.max(minWidth, w + 2 * textX);
-        if ((w1 != width) & (!tdp.isScaled())) {
-            setCd(x + width/2 - w1/2, y);
-            width = w1;
-            //updateConnectingPoints();
-        }
+    protected void internalDrawing(Graphics g) {
+    	
+    	// Issue #31
+        final int w = checkWidth( g );// g.getFontMetrics().stringWidth(value) /*+ w2*/;
+//        int w1 = Math.max(minWidth, w + 2 * textX);
+//        if ((w1 != width) & (!tdp.isScaled())) {
+//            setCd(x + width/2 - w1/2, y);
+//            width = w1;
+//            //updateConnectingPoints();
+//        }
 		
 		Color c = g.getColor();
 		g.setColor(ColorManager.SD_REFERENCE);
@@ -118,11 +124,18 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ {
         g.drawLine(x+(width/2), y, x+(width/2), y - lineLength);
         g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height);
         
-        g.drawString(name, x + (width - w) / 2, y + textY + 15);
-        g.drawString("sd", x+3, y+12);
-        g.drawLine(x, y+15, x+15, y+15);
-        g.drawLine(x+25, y, x+25, y+8);
-        g.drawLine(x+15, y+15, x+25, y+8);
+        final int offsetDefault = scale( 15 );
+        g.drawString(name, x + (width - w) / 2, y + textY + offsetDefault /*15*/);
+
+        final int sdOffsetX = scale( 3 );
+        final int sdOffsetY = scale( 12 );
+        g.drawString("sd", x + sdOffsetX /*3*/, y + sdOffsetY /*12*/);
+        g.drawLine(x, y + offsetDefault /*15*/, x + offsetDefault /*15*/, y + offsetDefault /*15*/);
+
+        final int sdBoxOffsetX = scale( 25 );
+        final int sdBoxOffsetY = scale( 8 );
+        g.drawLine(x + sdBoxOffsetX /*25*/, y, x + sdBoxOffsetX /*25*/, y + sdBoxOffsetY /*8*/);
+        g.drawLine(x + offsetDefault /*15*/, y + offsetDefault /*15*/, x + sdBoxOffsetX /*25*/, y + sdBoxOffsetY /*8*/);
     }
     
     @Override
diff --git a/src/main/java/ui/tmlcp/TMLCPStartState.java b/src/main/java/ui/tmlcp/TMLCPStartState.java
index 03816840c1..14b1e024fd 100755
--- a/src/main/java/ui/tmlcp/TMLCPStartState.java
+++ b/src/main/java/ui/tmlcp/TMLCPStartState.java
@@ -52,7 +52,7 @@ import ui.ad.TADStartState;
  * @author Ludovic APVRILLE
  */
 public class TMLCPStartState extends TADStartState /* Issue #69 TGCWithoutInternalComponent*/{
-	private int lineLength = 5;
+	//private int lineLength = 5;
 
 	public TMLCPStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
 		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
diff --git a/src/main/java/ui/tmlsd/TMLSDActionState.java b/src/main/java/ui/tmlsd/TMLSDActionState.java
index bb0cc83b8b..2a2b62d063 100755
--- a/src/main/java/ui/tmlsd/TMLSDActionState.java
+++ b/src/main/java/ui/tmlsd/TMLSDActionState.java
@@ -36,9 +36,6 @@
  * knowledge of the CeCILL license and that you accept its terms.
  */
 
-
-
-
 package ui.tmlsd;
 
 import myutil.GraphicLib;
@@ -55,18 +52,22 @@ import java.awt.*;
  * @author Ludovic APVRILLE
  */
 public class TMLSDActionState extends TGCOneLineText implements SwallowedTGComponent {
-    protected int lineLength = 5;
-    protected int textX =  5;
-    protected int textY =  15;
-    protected int arc = 5;
-    protected int w; //w1;
+
+	// Issue #31
+	//    protected int lineLength = 5;
+//    protected int textX =  5;
+//    protected int textY =  15;
+//    protected int arc = 5;
+    //protected int w; //w1;
     
     public TMLSDActionState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
         super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
         
-        width = 30;
-        height = 20;
-        minWidth = 30;
+        // Issue #31
+        initSize( 30, 20 );
+//        width = 30;
+//        height = 20;
+        minWidth = scale( 30 );
         
         nbConnectingPoint = 0;
         addTGConnectingPointsCommentMiddle();
@@ -81,17 +82,21 @@ public class TMLSDActionState extends TGCOneLineText implements SwallowedTGCompo
         myImageIcon = IconManager.imgic512;
     }
     
-    public void internalDrawing(Graphics g) {
-        w  = g.getFontMetrics().stringWidth(value);
-        int w1 = Math.max(minWidth, w + 2 * textX);
-        if ((w1 != width) && (!tdp.isScaled())) {
-            width = w1;
-        }
+    @Override
+    protected void internalDrawing(Graphics g) {
+
+    	// Issue #31
+        final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value);
+//        int w1 = Math.max(minWidth, w + 2 * textX);
+//        if ((w1 != width) && (!tdp.isScaled())) {
+//            width = w1;
+//        }
         g.drawRoundRect(x - width/2, y, width, height, arc, arc);
         
         g.drawString(value, x - w / 2 , y + textY);
     }
     
+    @Override
     public TGComponent isOnMe(int _x, int _y) {
         if (GraphicLib.isInRectangle(_x, _y, x - width/2, y, width, height)) {
             return this;
@@ -99,7 +104,6 @@ public class TMLSDActionState extends TGCOneLineText implements SwallowedTGCompo
         return null;
     }
     
- 
     public String getAction() {
         return value;
     }
@@ -129,8 +133,8 @@ public class TMLSDActionState extends TGCOneLineText implements SwallowedTGCompo
         return ret;
     }
     
+    @Override
     public int getType() {
         return TGComponentManager.TMLSD_ACTION_STATE;
     }
-  
-}
\ No newline at end of file
+}
diff --git a/src/main/java/ui/tmlsd/TMLSDControllerInstance.java b/src/main/java/ui/tmlsd/TMLSDControllerInstance.java
index 3af95fd7db..6e86ac74ee 100755
--- a/src/main/java/ui/tmlsd/TMLSDControllerInstance.java
+++ b/src/main/java/ui/tmlsd/TMLSDControllerInstance.java
@@ -37,9 +37,6 @@
  * knowledge of the CeCILL license and that you accept its terms.
  */
 
-
-
-
 package ui.tmlsd;
 
 import myutil.GraphicLib;
@@ -62,17 +59,18 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC
 																	TGComponent _father, TDiagramPanel _tdp)  {
         super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
         
-        width = 10;
-        height = 500;
-        //textX = 0;
-        //textY = 2;
-        minWidth = 10;
-        maxWidth = 10;
-        minHeight = 250;
-        maxHeight = 1500;
+        // Issue #31
+        initSize( 10, 500 );
+//        width = 10;
+//        height = 500;
+        minWidth = scale( 10 );
+        maxWidth = scale( 10 );
+        minHeight = scale( 250 );
+        maxHeight = scale( 1500 );
         
         
-        makeTGConnectingPoints();
+        // Issue #31 Already called in superclass
+//        makeTGConnectingPoints();
         //addTGConnectingPointsComment();
         
         nbInternalTGComponent = 0;
@@ -84,7 +82,7 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC
         
         value = "Controller instance name";
         name = "ControllerInstance";
-				isActor = false;
+		isActor = false;
         
         myImageIcon = IconManager.imgic500;
 	}
@@ -106,7 +104,6 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC
 	}
 	
 	protected void setJDialogOptions( JDialogTMLCPControllerInstance jda ) {
-		
 		jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC));
 		jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE));
 		jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true);
@@ -124,7 +121,8 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC
 		//jda.enableTMLKeyword(false);
 	}
 
-	@Override public int getType() {
+	@Override
+	public int getType() {
 		return TGComponentManager.TMLSD_CONTROLLER_INSTANCE;
 	}
 
diff --git a/src/main/java/ui/tmlsd/TMLSDInstance.java b/src/main/java/ui/tmlsd/TMLSDInstance.java
index bdd4524068..48b9087934 100755
--- a/src/main/java/ui/tmlsd/TMLSDInstance.java
+++ b/src/main/java/ui/tmlsd/TMLSDInstance.java
@@ -37,9 +37,6 @@
  * knowledge of the CeCILL license and that you accept its terms.
  */
 
-
-
-
 package ui.tmlsd;
 
 import myutil.GraphicLib;
@@ -50,10 +47,12 @@ import ui.*;
 import ui.util.IconManager;
 
 import javax.swing.*;
-import java.awt.*;
+
+import java.awt.Graphics;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.LinkedList;
+import java.util.List;
 
 //Abstract class, getType() and editOndoubleClick( JFrame ) are abstract
 /**
@@ -65,31 +64,43 @@ import java.util.LinkedList;
  */
 public abstract class TMLSDInstance extends TGCWithInternalComponent implements SwallowTGComponent {
 
+	// Issue #31
 	//protected int lineLength = 5;
 	//protected int textX, textY;
-	protected int spacePt = 10;
-	protected int wText = 10, hText = 15;
-	protected int increaseSlice = 250;
+	private static final int POINT_MARGIN = 10;
+//	protected int spacePt = 10;
+//	protected int wText = 10, hText = 15;
+	private static final int SLICE_INCREMENT = 250;
+//	protected int increaseSlice = 250;
+	private static final int ACTOR_HEIGHT = 30;
+//	protected static int heightActor = 30;
+	private static final int ACTOR_WIDTH = 16;
+//	protected static int widthActor = 16;
+
+	private int wText;
+	private int hText;
 	protected boolean isActor;
-	protected static int heightActor = 30;
-	protected static int widthActor = 16;
-	protected LinkedList<TAttribute> myAttributes;
+	protected List<TAttribute> myAttributes;
 	protected String mappedUnit = "";	//The arch unit where the instance is mapped to
 
 
 	public TMLSDInstance(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
 		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
-
-		width = 10;
-		height = 500;
-		//textX = 0;
-		//textY = 2;
-		minWidth = 10;
-		maxWidth = 10;
-		minHeight = 250;
-		maxHeight = 1500;
+		
+		initSize( 10, 500 );
+//		width = 10;
+//		height = 500;
+		minWidth = scale( 10 );
+		maxWidth = scale( 10 );
+		minHeight = scale( 250 );
+		maxHeight = scale( 1500 );
+		wText = 10;
+		hText = 15;
+
+		// Issue #31
 		makeTGConnectingPoints();
 		//addTGConnectingPointsComment();
+
 		nbInternalTGComponent = 0;
 		moveable = true;
 		editable = true;
@@ -97,22 +108,39 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 		userResizable = true;
 		value = "Instance name";
 		name = "instance";
-		myAttributes = new LinkedList<TAttribute> ();
+		myAttributes = new LinkedList<TAttribute>();
 		myImageIcon = IconManager.imgic500;
 	}
 
-	public void internalDrawing(Graphics g) {
-		if (!tdp.isScaled()) {
+	@Override
+	protected void internalDrawing(Graphics g) {
+    	
+		// Issue #31
+        final int scaledWText;
+        final int scaledHText;
+
+        if (!tdp.isScaled()) {
 			wText  = g.getFontMetrics().stringWidth(name);
-			hText = g.getFontMetrics().getHeight();
+        	scaledWText = wText;
+        	hText = g.getFontMetrics().getHeight();
+        	scaledHText = hText;
 		}
-		g.drawString(name, x - (wText / 2) + width/2, y - 3);
-		g.drawLine(x - (wText / 2) + width/2, y-2, x + (wText / 2) + width/2, y-2);
-		g.drawLine(x+(width/2), y, x+(width/2), y +height);
+        else {
+        	scaledWText = scale( wText );
+        	scaledHText = scale( hText );
+        }
 
+		g.drawString(name, x - (scaledWText / 2) + width/2, y - 3); // Issue #31
+		g.drawLine(x - (scaledWText / 2) + width/2, y-2, x + (scaledWText / 2) + width/2, y-2); // Issue #31
+		g.drawLine(x+(width/2), y, x+(width/2), y +height);
+		
 		if (isActor) {
+			final int widthActor = scale( ACTOR_WIDTH );
+			final int heightActor = scale( ACTOR_HEIGHT );
+			
 			int xtmp = x + (width-widthActor) / 2;
-			int ytmp = y-hText;
+			int ytmp = y - scaledHText; // Issue #31
+			
 			// Head
 			g.drawOval(xtmp+(widthActor/4)-1, ytmp-heightActor, 2+widthActor/2, 2+widthActor/2);
 			//Body
@@ -126,103 +154,107 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 		}
 	}
 
+	@Override
 	public TGComponent isOnOnlyMe(int _x, int _y) {
 		if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
 			return this;
 		}
 
-		if (GraphicLib.isInRectangle(_x, _y, x + (width/2) - (wText/2) , y-hText, wText, hText)) {
+		final int scaledHText = scale( hText );
+		final int scaledWText = scale( wText );
+				
+		if (GraphicLib.isInRectangle(_x, _y, x + (width/2) - (scaledWText/2) , y-scaledHText, scaledWText, scaledHText)) { // Issue #31
 			return this;
 		}
 
 		if (isActor) {
-			if (GraphicLib.isInRectangle(_x, _y, x + (width-widthActor) / 2, y-heightActor-hText, widthActor, heightActor)) {
+			final int widthActor = scale( ACTOR_WIDTH );
+			final int heightActor = scale( ACTOR_HEIGHT );
+
+			if (GraphicLib.isInRectangle(_x, _y, x + (width-widthActor) / 2, y-heightActor-scaledHText, widthActor, heightActor)) { // Issue #31
 				return this;
 			}
 		}
 		return null;
 	}
 
+	@Override
 	public int getMyCurrentMinX() {
-		return Math.min(x + (width/2) - (wText/2), x);
-
+		return Math.min(x + (width/2) - ( scale( wText ) / 2 ), x);
 	}
 
+	@Override
 	public int getMyCurrentMaxX() {
-		return Math.max(x + (width/2) + (wText/2), x + width);
+		return Math.max(x + (width/2) + ( scale( wText ) / 2 ), x + width);
 	}
 
+	@Override
 	public int getMyCurrentMinY() {
-		return Math.min(y-hText-heightActor, y);
+		return Math.min( y - scale( hText ) - scale( ACTOR_HEIGHT ), y); // Issue #31
 	}
 
 	public String getInstanceName() {
 		return getName();
 	}
 
-	public abstract int getType();
+//	public abstract int getType();
 
 	protected void makeTGConnectingPoints() {
-
+		// Issue #31
+		final int spacePt = scale( POINT_MARGIN );
 		nbConnectingPoint = ( (height - (2 * spacePt) ) / spacePt ) + 1;
 		connectingPoint = new TGConnectingPoint[ nbConnectingPoint ];
 
 		int yh = spacePt;
 
 		for(int i = 0; i < nbConnectingPoint; i++, yh += spacePt ) {
-			connectingPoint[i] = new TGConnectingPointTMLSD(this, ( width/2), yh, true, true );
+			connectingPoint[i] = new TGConnectingPointTMLSD(this, ( width / 2 ), yh, true, true );
 		}
-
 	}
 
-	public abstract boolean editOndoubleClick( JFrame frame );
+//	public abstract boolean editOndoubleClick( JFrame frame );
 
+	@Override
 	public boolean acceptSwallowedTGComponent(TGComponent tgc) {
         return (tgc instanceof TMLSDActionState);
     }
 
+	@Override
 	public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
 		if (!acceptSwallowedTGComponent(tgc)) {
 			return false;
 		}
 
-
-		//
 		// Choose its position
+		final int spacePt = scale( POINT_MARGIN );
 		int realY = Math.max(y, getY() + spacePt);
 		realY = Math.min(realY, getY() + height + spacePt);
 		int realX = tgc.getX();
 
-
 		// Make it an internal component
 		// It's one of my son
 		tgc.setFather(this);
 		tgc.setDrawingZone(true);
 
-
-
 		if ((tgc instanceof TMLSDActionState)) {
 			realX = getX()+(width/2);
 			//tgc.setCdRectangle((width/2), (width/2), spacePt, height-spacePt-tgc.getHeight());
 			tgc.setCd(realX, realY);
 		}
 
-
 		setCDRectangleOfSwallowed(tgc);
 
-
 		//add it
 		addInternalComponent(tgc, 0);
 
 		return true;
 	}
 
+	@Override
 	public void removeSwallowedTGComponent(TGComponent tgc) {
 		removeInternalComponent(tgc);
 	}
 
-
-
 	// previous in the sense of with y the closer and before
 	public TGComponent getPreviousTGComponent(TGComponent tgcToAnalyse) {
 		int close = Integer.MAX_VALUE;
@@ -253,9 +285,9 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 		/* now: only message! */
 
 		return ((TMLSDPanel)tdp).messageActionCloserTo(tgc, this);
-
 	}
 
+	@Override
 	public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) {
 		componentMenu.addSeparator();
 
@@ -268,15 +300,18 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 		componentMenu.add(increase);
 	}
 
+	@Override
 	public boolean eventOnPopup(ActionEvent e) {
 		if ((e.getActionCommand().compareTo("Decrease size")) == 0) {
 			decreaseSize();
 		} else {
 			increaseSize();
 		}
+		
 		return true;
 	}
 
+	@Override
 	public void updateMinMaxSize() {
 		minHeight = 250;
 		int i;
@@ -293,10 +328,13 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 	}
 
 	public boolean canDecreaseSize() {
+		final int increaseSlice = scale( SLICE_INCREMENT ); // Issue #31
+		
 		if (height <= increaseSlice) {
 			return false;
 		}
 
+		final int spacePt = scale( POINT_MARGIN );
 		int newNbConnectingPoint = (((height-increaseSlice) - (2 * spacePt)) / spacePt) + 1;
 		int i;
 
@@ -328,16 +366,17 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 		// new nb of connectingPoints
 
 		// If ok, do the modification
-		height = height - increaseSlice;
+		height = height - scale( SLICE_INCREMENT ); // Issue #31
 		hasBeenResized();
 	}
 
 	public void increaseSize() {
 		//
-		height = height + increaseSlice;
+		height = height + scale( SLICE_INCREMENT ); // Issue #31
 		hasBeenResized();
 	}
 
+	@Override
 	public void hasBeenResized(){
 		int i;
 
@@ -356,15 +395,13 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 	}
 
 	protected void setCDRectangleOfSwallowed(TGComponent tgc) {
-
-
 		if ((tgc instanceof TMLSDActionState)) {
+			final int spacePt =  scale( POINT_MARGIN );
 			tgc.setCdRectangle((width/2), (width/2), spacePt, height-spacePt-tgc.getHeight());
 		}
-
-
 	}
 
+	@Override
 	protected String translateExtraParam() {
 		StringBuffer sb = new StringBuffer( "<extraparam>\n" );
 		sb.append( "<Mapping mappedOn=\"" );
@@ -387,6 +424,7 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 			sb.append( "\" />\n" );
 		}
 		sb.append( "</extraparam>\n" );
+		
 		return new String(sb);
 	}
 
@@ -449,7 +487,7 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 			}
 		}
 		catch ( Exception e ) {
-			throw new MalformedModelingException();
+			throw new MalformedModelingException( e );
 		}
 	}
 
@@ -469,7 +507,7 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements
 		return connectingPoint;
 	}
 
-	public LinkedList<TAttribute> getAttributes()	{
+	public List<TAttribute> getAttributes()	{
 		return myAttributes;
 	}
 }
diff --git a/src/main/java/ui/tmlsd/TMLSDPanel.java b/src/main/java/ui/tmlsd/TMLSDPanel.java
index 7f6344261a..79fd33f1aa 100755
--- a/src/main/java/ui/tmlsd/TMLSDPanel.java
+++ b/src/main/java/ui/tmlsd/TMLSDPanel.java
@@ -109,8 +109,8 @@ public class TMLSDPanel extends TDiagramPanel {
         return false;
     }
     
-    public String getXMLHead() {
-        return "<TMLSDPanel name=\"" + name + "\"" + sizeParam() + " >";
+    public String getXMLHead() {							// Issue #31
+        return "<TMLSDPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >";
     }
     
     public String getXMLTail() {
diff --git a/src/main/java/ui/tmlsd/TMLSDStorageInstance.java b/src/main/java/ui/tmlsd/TMLSDStorageInstance.java
index f639d69cb4..40fe0b29db 100755
--- a/src/main/java/ui/tmlsd/TMLSDStorageInstance.java
+++ b/src/main/java/ui/tmlsd/TMLSDStorageInstance.java
@@ -59,19 +59,17 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp
 																	TGComponent _father, TDiagramPanel _tdp )  {
         super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
         
-        width = 10;
-        height = 500;
-        //textX = 0;
-        //textY = 2;
-        minWidth = 10;
-        maxWidth = 10;
-        minHeight = 250;
-        maxHeight = 1500;
-        
-        
-        makeTGConnectingPoints();
-        //addTGConnectingPointsComment();
+        initSize( 10, 500 );
+//        width = 10;
+//        height = 500;
+        minWidth = scale( 10 );
+        maxWidth = scale( 10 );
+        minHeight = scale( 250 );
+        maxHeight = scale( 1500 );
         
+        // Issue #31 Already called in superclass
+      //  makeTGConnectingPoints();
+
         nbInternalTGComponent = 0;
         
         moveable = true;
@@ -103,22 +101,15 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp
 	}
 	
 	protected void setJDialogOptions( JDialogTMLCPStorageInstance jda ) {
-		
 		jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC));
 		jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE));
 		jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true);
 		jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true);
 		jda.addType(TAttribute.getStringType(TAttribute.ADDRESS), true);
 		
-/*		Vector<String> records = ( (TMLComponentTaskDiagramPanel )(tdp)).getAllRecords(this);
-		for( String s: records ) {
-			jda.addType(s, false);
-		}*/
-		
 		jda.enableInitialValue(true);
 		jda.enableRTLOTOSKeyword(true);
 		jda.enableJavaKeyword(false);
-		//jda.enableTMLKeyword(false);
 	}
 
 	@Override
diff --git a/src/main/java/ui/tmlsd/TMLSDTransferInstance.java b/src/main/java/ui/tmlsd/TMLSDTransferInstance.java
index fc47516378..5eabb7d8ad 100755
--- a/src/main/java/ui/tmlsd/TMLSDTransferInstance.java
+++ b/src/main/java/ui/tmlsd/TMLSDTransferInstance.java
@@ -58,20 +58,21 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom
     public TMLSDTransferInstance( int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos,
 																	TGComponent _father, TDiagramPanel _tdp )  {
         super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        // Issue #31
+//        width = 10;
+//        height = 500;
+
+        initSize( 10, 500 );
+        minWidth = scale( 10 );
+        maxWidth = scale( 10 );
+        minHeight = scale( 250 );
+        maxHeight = scale( 1500 );
         
-        width = 10;
-        height = 500;
-        //textX = 0;
-        //textY = 2;
-        minWidth = 10;
-        maxWidth = 10;
-        minHeight = 250;
-        maxHeight = 1500;
-        
-        
-        makeTGConnectingPoints();
+        // Issue #31 Already called in superclass
+        // makeTGConnectingPoints();
         //addTGConnectingPointsComment();
-        
+
         nbInternalTGComponent = 0;
         
         moveable = true;
@@ -103,7 +104,6 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom
 	}
 
 	protected void setJDialogOptions( JDialogTMLCPTransferInstance jda ) {
-		
 		jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC));
 		jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE));
 		jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true);
@@ -121,7 +121,8 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom
 		//jda.enableTMLKeyword(false);
 	}
 
-	@Override public int getType() {
+	@Override
+	public int getType() {
 		return TGComponentManager.TMLSD_TRANSFER_INSTANCE;
 	}
 
-- 
GitLab