From c68096affa305bac82f98d36835afd13874b0fc8 Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paris.fr> Date: Fri, 13 Aug 2021 17:57:34 +0200 Subject: [PATCH] Adding connecting points to block in avatarcd and avatarbd --- src/main/java/ui/avatarbd/AvatarBDBlock.java | 41 +++---- src/main/java/ui/avatarcd/AvatarCDBlock.java | 113 +++++++++---------- 2 files changed, 76 insertions(+), 78 deletions(-) diff --git a/src/main/java/ui/avatarbd/AvatarBDBlock.java b/src/main/java/ui/avatarbd/AvatarBDBlock.java index 4f38dc86b9..149dcc36be 100644 --- a/src/main/java/ui/avatarbd/AvatarBDBlock.java +++ b/src/main/java/ui/avatarbd/AvatarBDBlock.java @@ -116,26 +116,27 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S initScaling(250, 200); - nbConnectingPoint = 16; - connectingPoint = new TGConnectingPoint[16]; - - connectingPoint[0] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.0); - connectingPoint[1] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); - connectingPoint[2] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.0); - connectingPoint[3] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.5); - connectingPoint[4] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.5); - connectingPoint[5] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 1.0); - connectingPoint[6] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); - connectingPoint[7] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 1.0); - - connectingPoint[8] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.25, 0.0); - connectingPoint[9] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.75, 0.0); - connectingPoint[10] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.25); - connectingPoint[11] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.25); - connectingPoint[12] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.75); - connectingPoint[13] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.75); - connectingPoint[14] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.25, 1.0); - connectingPoint[15] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.75, 1.0); + nbConnectingPoint = 32; + connectingPoint = new TGConnectingPoint[32]; + for(int i=0; i<32; i = i + 16) { + connectingPoint[0+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.0); + connectingPoint[1+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); + connectingPoint[2+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.0); + connectingPoint[3+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.5); + connectingPoint[4+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.5); + connectingPoint[5+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 1.0); + connectingPoint[6+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); + connectingPoint[7+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 1.0); + + connectingPoint[8+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.25, 0.0); + connectingPoint[9+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.75, 0.0); + connectingPoint[10+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.25); + connectingPoint[11+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.25); + connectingPoint[12+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.0, 0.75); + connectingPoint[13+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 1.0, 0.75); + connectingPoint[14+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.25, 1.0); + connectingPoint[15+i] = new AvatarBDConnectingPoint(this, 0, 0, true, true, 0.75, 1.0); + } addTGConnectingPointsComment(); diff --git a/src/main/java/ui/avatarcd/AvatarCDBlock.java b/src/main/java/ui/avatarcd/AvatarCDBlock.java index b1593461bf..844c551779 100644 --- a/src/main/java/ui/avatarcd/AvatarCDBlock.java +++ b/src/main/java/ui/avatarcd/AvatarCDBlock.java @@ -1,26 +1,26 @@ /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille - * + * * ludovic.apvrille AT enst.fr - * + * * This software is a computer program whose purpose is to allow the * edition of TURTLE analysis, design and deployment diagrams, to * allow the generation of RT-LOTOS or Java code from this diagram, * and at last to allow the analysis of formal validation traces * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP * from INRIA Rhone-Alpes. - * + * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, * modify and/ or redistribute the software under the terms of the CeCILL * license as circulated by CEA, CNRS and INRIA at the following URL * "http://www.cecill.info". - * + * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited * liability. - * + * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the * software by the user in light of its specific status of free software, @@ -31,7 +31,7 @@ * requirements in conditions enabling the security of their systems and/or * data to be ensured and, more generally, to use and operate it in the * same conditions as regards security. - * + * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ @@ -46,16 +46,11 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; import ui.util.IconManager; -import ui.window.JDialogAttribute; -import ui.window.JDialogGeneralAttribute; import ui.window.JDialogTitleAndNote; import javax.swing.*; import java.awt.*; -import java.util.HashMap; import java.util.LinkedList; -import java.util.List; -import java.util.Map; /** @@ -67,7 +62,7 @@ import java.util.Map; * @version 1.2 03/07/2019 */ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, ColorCustomizable { -// private int textY1 = 3; + // private int textY1 = 3; // private int textX = 7; private String stereotype = "block"; @@ -75,15 +70,13 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S // private int minFontSize = 4; // private int currentFontSize = -1; // private boolean displayText = true; - + // private int limitName = -1; // private int limitAttr = -1; // private int limitMethod = -1; - - protected String text; protected String[] texts = {""}; @@ -103,28 +96,32 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S height = 200; minWidth = 5; minHeight = 2; - initScaling(250,200); - - nbConnectingPoint = 16; - connectingPoint = new TGConnectingPoint[16]; - - connectingPoint[0] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.0); - connectingPoint[1] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); - connectingPoint[2] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.0); - connectingPoint[3] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.5); - connectingPoint[4] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.5); - connectingPoint[5] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 1.0); - connectingPoint[6] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); - connectingPoint[7] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 1.0); - - connectingPoint[8] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.25, 0.0); - connectingPoint[9] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.75, 0.0); - connectingPoint[10] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.25); - connectingPoint[11] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.25); - connectingPoint[12] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.75); - connectingPoint[13] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.75); - connectingPoint[14] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.25, 1.0); - connectingPoint[15] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.75, 1.0); + initScaling(250, 200); + + nbConnectingPoint = 32; + connectingPoint = new TGConnectingPoint[32]; + for(int i=0; i<32; i = i + 16) { + connectingPoint[0+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.0); + connectingPoint[1+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); + connectingPoint[2+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.0); + connectingPoint[3+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.5); + connectingPoint[4+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.5); + connectingPoint[5+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 1.0); + connectingPoint[6+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); + connectingPoint[7+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 1.0); + + connectingPoint[8+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.25, 0.0); + connectingPoint[9+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.75, 0.0); + connectingPoint[10+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.25); + connectingPoint[11+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.25); + connectingPoint[12+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.0, 0.75); + connectingPoint[13+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 1.0, 0.75); + connectingPoint[14+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.25, 1.0); + connectingPoint[15+i] = new AvatarCDConnectingPoint(this, 0, 0, true, true, 0.75, 1.0); + } + + + addTGConnectingPointsComment(); @@ -155,15 +152,15 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S public void makeValue() { texts = Conversion.wrapText(text); } - + /** * Internal Drawing function of AvatarCDBlock * draws the rectangle, fills it with color and writes the texts where it needs to be + * * @param g */ - public void internalDrawing(Graphics g) - { - //Rectangle + public void internalDrawing(Graphics g) { + //Rectangle Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); @@ -174,7 +171,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); g.fill3DRect(x + 1, y + 1, width - 1, Math.min(currentHeight, height), true); g.setColor(c); - + //Strings if (stereotype.length() > 0) { String ster = "<<" + stereotype + ">>"; @@ -182,23 +179,23 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S currentHeight = f.getSize(); drawSingleString(g, ster, getCenter(g, ster), y + currentHeight); } - - + + g.setFont(f); // strWidth = g.getFontMetrics().stringWidth(value); if (stereotype.length() == 0) { - currentHeight = (int)(1.5 * f.getSize()); + currentHeight = (int) (1.5 * f.getSize()); } else { currentHeight = 2 * f.getSize(); } drawSingleString(g, value, getCenter(g, value), y + currentHeight); currentHeight += 4; - + if (currentHeight < height) { //g.drawLine(x, y+h, x+width, y+h); g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); - g.fill3DRect(x + 1, y + currentHeight+1, width - 1, height - 1 - currentHeight, true); + g.fill3DRect(x + 1, y + currentHeight + 1, width - 1, height - 1 - currentHeight, true); g.setColor(c); } @@ -208,7 +205,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S internalDrawingAux(g, size, currentHeight); } - private void internalDrawingAux(Graphics g, int size, int currentHeight) { + private void internalDrawingAux(Graphics g, int size, int currentHeight) { String texti = "Text"; String s; int i; @@ -233,7 +230,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S } - + @Override public TGComponent isOnOnlyMe(int x1, int y1) { @@ -279,7 +276,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S } String ster = s.substring(0, index); - String blo = s.substring(index+1, s.length()); + String blo = s.substring(index + 1, s.length()); /*if (ster.length() == 0 ) { JOptionPane.showMessageDialog(frame, "Invalid stereotype", @@ -337,18 +334,18 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return true; } - + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof AvatarCDBlock; } - + @Override public int getType() { return TGComponentManager.ACD_BLOCK; } - + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { boolean swallowed = false; @@ -395,7 +392,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return true; } - + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeMyInternalComponent(tgc, false); @@ -442,7 +439,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return value; } - + @Override public void hasBeenResized() { for (int i = 0; i < nbInternalTGComponent; i++) { @@ -456,7 +453,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S } } - + @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarCDBlock)) { @@ -500,12 +497,12 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return false; } - + @Override public int getDefaultConnector() { return TGComponentManager.ACD_COMPOSITION_CONNECTOR; } - + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); -- GitLab