From 8ee5b8acc2f07b53f70b3f428ea9d8f0486c4e3d Mon Sep 17 00:00:00 2001
From: Moemoea Fierin <moemoea.fierin@epita.fr>
Date: Mon, 30 Sep 2019 18:29:55 +0200
Subject: [PATCH] [ZOOM] On Diplodocus TML task Diagram: Issue #31 Fixed Title
 zoom

- on my way to fix zooms on attributes: just need an element to follow
the last attribute position. If none, need to use the cpt previously
used
---
 .../ui/tmlcompd/TMLCPrimitiveComponent.java   | 64 +++++++++++++++++--
 1 file changed, 59 insertions(+), 5 deletions(-)

diff --git a/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java b/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java
index 431dc68934..8d180a305d 100755
--- a/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java
+++ b/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java
@@ -62,10 +62,11 @@ import java.util.Vector;
  * @version 1.0 12/03/2008
  */
 public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, WithAttributes {
-    private int maxFontSize = 14;
+    // #FIXME Debugging
+	private int maxFontSize = 14;
     private int minFontSize = 4;
-    
     private int currentFontSize = -1;
+	
     //private boolean displayText = true;
     //    private int spacePt = 3;
     private Color myColor;
@@ -93,8 +94,10 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp
         super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
 
         // Issue #31
-        minWidth = 1;
-        minHeight = 1;
+        //minWidth = 1;
+        //minHeight = 1;
+        minWidth = 150;
+        minHeight = 100;
         initScaling(200, 150);
 
         // Issue #31
@@ -125,7 +128,58 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp
 
         actionOnAdd();
     }
+    /*
+    private Color choosingColor()
+    {
+        if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) 
+            return Color.white;
+        else 
+            return new Color(201, 243, 188 - (getMyDepth() * 10), 200);
+    }*/
 
+    @Override
+    public void internalDrawing(Graphics g)
+    {
+    	//rectangle + Filling color
+    	Color c = g.getColor();
+    	if (myColor == null) {
+            if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white)
+                myColor = Color.white;
+            else 
+                myColor = new Color(201, 243, 188 - (getMyDepth() * 10), 200);
+        }
+    	g.drawRect(x, y, width, height);
+    	g.setColor(myColor);
+    	g.fill3DRect(x, y, width, height, true);
+    	g.setColor(c);
+    	
+    	//String
+    	int stringWidth = g.getFontMetrics().stringWidth(value);
+    	int centerOfBox = (width - stringWidth) / 2;
+    	g.drawString(value, x + centerOfBox, y + currentFontSize + textY);
+    	
+    	// Icon
+    	g.drawImage(scale(IconManager.imgic1200.getImage()), x + width - scale(iconSize) - textX, y + textX, null);
+        if (isAttacker)
+            g.drawImage(scale(IconManager.imgic7008.getImage()), x + width - scale(2 * iconSize) - textX, y + 2 * textX, null);
+        
+        // Attributes
+        if (tdp.areAttributesVisible())
+        {
+        	TAttribute attribute;
+        	String attributeStr;
+        	for (int i = 0; i < myAttributes.size(); i++)
+        	{
+                attribute = myAttributes.get(i);
+                attributeStr = attribute.toString();
+                g.drawString(attributeStr, x + textX, y + currentFontSize + textY);
+                //g.drawString(attributeStr, x + textX, y + currentFontSize);
+                drawVerification(g, x + textX, y + currentFontSize, attribute.getConfidentialityVerification());
+            }
+        }
+    	
+    }
+/*
     @Override
     public void internalDrawing(Graphics g) {
         int w;
@@ -251,7 +305,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp
         }
 
         g.setFont(fold);
-    }
+    }*/
 
     public void drawVerification(Graphics g, int x, int y, int checkConfStatus) {
         Color c = g.getColor();
-- 
GitLab