diff --git a/src/tmltranslator/TMLMapping.java b/src/tmltranslator/TMLMapping.java index 03293a25c5ef326f8ba11cae8898a4da5ad2ff09..2ec8f01932d0f1c644adf6556d05967345a068f9 100755 --- a/src/tmltranslator/TMLMapping.java +++ b/src/tmltranslator/TMLMapping.java @@ -37,7 +37,7 @@ knowledge of the CeCILL license and that you accept its terms. /** - * Class TMLMap + * Class TMLMapping * Creation: 05/09/2007 * @version 1.1 10/06/2014 * @author Ludovic APVRILLE, Andrea ENRICI diff --git a/src/ui/JToolBarMainTurtle.java b/src/ui/JToolBarMainTurtle.java index c65918aed053af9dfa75c933dc0fc6469b4a8d04..80cf598954f9ed426f162c59180dafe15168caeb 100755 --- a/src/ui/JToolBarMainTurtle.java +++ b/src/ui/JToolBarMainTurtle.java @@ -246,7 +246,7 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener } addSeparator(); - + if ((ConfigurationTTool.ExternalCommand1.length() > 0) && (ConfigurationTTool.ExternalCommand1Host.length() > 0)) { button = add(mgui.actions[TGUIAction.EXTERNAL_ACTION_1]); @@ -271,27 +271,27 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener search.addActionListener(this); search.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void insertUpdate(DocumentEvent documentEvent) { - if (search.getText().length()>0){ - internalSearch.setEnabled(true); - }else - internalSearch.setEnabled(false); - } - - @Override - public void removeUpdate(DocumentEvent documentEvent) { - if (search.getText().length()>0){ - internalSearch.setEnabled(true); - }else - internalSearch.setEnabled(false); - } - - @Override - public void changedUpdate(DocumentEvent documentEvent) { - - } - }); + @Override + public void insertUpdate(DocumentEvent documentEvent) { + if (search.getText().length()>0){ + internalSearch.setEnabled(true); + }else + internalSearch.setEnabled(false); + } + + @Override + public void removeUpdate(DocumentEvent documentEvent) { + if (search.getText().length()>0){ + internalSearch.setEnabled(true); + }else + internalSearch.setEnabled(false); + } + + @Override + public void changedUpdate(DocumentEvent documentEvent) { + + } + }); //@author : Huy TRUONG //add external search button into menu bar diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 65299cb66c46b5de548189a1962f381cdb67cb4b..c4c62fe825c599478c550f22d91e7171a85adeab 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -769,8 +769,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe actions[TGUIAction.ACT_AVATAR_FV_PROVERIF].setEnabled(false); actions[TGUIAction.ACT_AVATAR_FV_STATICANALYSIS].setEnabled(false); actions[TGUIAction.ACT_AVATAR_EXECUTABLE_GENERATION].setEnabled(false); + break; case MODEL_SAVED: + TraceManager.addDev("Disable save"); actions[TGUIAction.ACT_SAVE].setEnabled(false); break; case BACKWARD: diff --git a/src/ui/TGCNote.java b/src/ui/TGCNote.java index a83927240869ff7a13853490d0c68f18bd4a41dd..c51bcdf50915dc784bb1d1e56845f0a07546e483 100755 --- a/src/ui/TGCNote.java +++ b/src/ui/TGCNote.java @@ -1,48 +1,48 @@ /**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, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -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. - -/** - * Class TGCNote - * Generic text box for displaying notes - * Creation: 06/12/2003 - * @version 1.0 06/12/2003 - * @author Ludovic APVRILLE - * @see - */ + 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, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + 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. + + /** + * Class TGCNote + * Generic text box for displaying notes + * Creation: 06/12/2003 + * @version 1.0 06/12/2003 + * @author Ludovic APVRILLE + * @see + */ package ui; @@ -55,92 +55,127 @@ import org.w3c.dom.*; import myutil.*; import ui.window.*; -public class TGCNote extends TGCWithoutInternalComponent { - +public class TGCNote extends TGCScalableWithoutInternalComponent { + protected String[] values; - protected int textX = 5; - protected int textY = 20; + protected int textX = 1; + protected int textY = 2; protected int marginY = 20; protected int marginX = 20; protected int limit = 15; protected Graphics myg; - + protected Color myColor; - + + private Font myFont, myFontB; + private int maxFontSize = 30; + private int minFontSize = 4; + private int currentFontSize = -1; + + protected Graphics graphics; + public TGCNote(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 = 30; - minWidth = 50; - minHeight = 20; - + minWidth = 20; + minHeight = 10; + + oldScaleFactor = tdp.getZoom(); + nbConnectingPoint = 0; addTGConnectingPointsComment(); - + moveable = true; editable = true; removable = true; - + name = "UML Note"; value = "UML note:\nDouble-click to edit"; - + myImageIcon = IconManager.imgic320; } - - public String[] getValues() { - return values; - } - - + + public String[] getValues() { + return values; + } + + public void internalDrawing(Graphics g) { - - if ((values == null) || (myg == null)){ - myg = g; + Font f = g.getFont(); + Font fold = f; + + /*if (!tdp.isScaled()) { + graphics = g; + }*/ + + if (((rescaled) && (!tdp.isScaled())) || myFont == null) { + currentFontSize = tdp.getFontSize(); + //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); + // myFont = f.deriveFont((float)currentFontSize); + //myFontB = myFont.deriveFont(Font.BOLD); + + if (rescaled) { + rescaled = false; + } + } + + if (values == null) { makeValue(); } - - int h = g.getFontMetrics().getHeight(); + + int h = g.getFontMetrics().getHeight(); Color c = g.getColor(); - - + + int desiredWidth = minWidth; + for(int i=0; i< values.length; i++) { + desiredWidth = Math.max(desiredWidth, g.getFontMetrics().stringWidth(values[i]) + marginX); + } + + int desiredHeight = (values.length * currentFontSize) + textY + 1; + + //TraceManager.addDev("resize: " + desiredWidth + "," + desiredHeight); + + if ((desiredWidth != width) || (desiredHeight != height)) { + resize(desiredWidth, desiredHeight); + } + g.drawLine(x, y, x+width, y); g.drawLine(x, y, x, y+height); g.drawLine(x, y+height, x+width-limit, y+height); g.drawLine(x+width, y, x+width, y+height - limit); - - g.setColor(ColorManager.UML_NOTE_BG); - int [] px1 = {x+1, x+width, x + width, x + width-limit, x+1}; + + g.setColor(ColorManager.UML_NOTE_BG); + int [] px1 = {x+1, x+width, x + width, x + width-limit, x+1}; int [] py1 = {y+1, y+1, y+height-limit, y+height, y+height}; - g.fillPolygon(px1, py1, 5); - g.setColor(c); - + g.fillPolygon(px1, py1, 5); + g.setColor(c); + int [] px = {x+width, x + width - 4, x+width-10, x + width-limit}; int [] py = {y+height-limit, y + height - limit + 3, y + height - limit + 2, y +height}; g.drawPolygon(px, py, 4); - + if (g.getColor() == ColorManager.NORMAL_0) { g.setColor(ColorManager.UML_NOTE); } g.fillPolygon(px, py, 4); - - g.setColor(Color.black); + + g.setColor(Color.black); for (int i = 0; i<values.length; i++) { - g.drawString(values[i], x + textX, y + textY + i* h); + //TraceManager.addDev("x+texX=" + (x + textX) + " y+textY=" + y + textY + i* h + ": " + values[i]); + g.drawString(values[i], x + textX, y + textY + (i+1)* currentFontSize); } - g.setColor(c); - - - - + g.setColor(c); + } - + public void makeValue() { values = Conversion.wrapText(value); - checkMySize(); + //checkMySize(); } - - public void checkMySize() { + + /*public void checkMySize() { if (myg == null) { return; } @@ -148,50 +183,61 @@ public class TGCNote extends TGCWithoutInternalComponent { for(int i=0; i< values.length; i++) { desiredWidth = Math.max(desiredWidth, myg.getFontMetrics().stringWidth(values[i]) + marginX); } - + int desiredHeight = values.length * myg.getFontMetrics().getHeight() + marginY; - + if ((desiredWidth != width) || (desiredHeight != height)) { resize(desiredWidth, desiredHeight); } - } - + }*/ + public boolean editOndoubleClick(JFrame frame) { String oldValue = value; - + JDialogNote jdn = new JDialogNote(frame, "Setting the note", value); //jdn.setLocation(200, 150); GraphicLib.centerOnParent(jdn); jdn.show(); // blocked until dialog has been closed - + String s = jdn.getText(); if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { String tmp = s; /*s = GTURTLEModeling.removeForbiddenCharactersFromInput(s); - s = Conversion.replaceAllChar(s, '&', " "); - s = Conversion.replaceAllChar(s, '"', " "); - - if(s.compareTo(tmp) != 0) { - JOptionPane.showMessageDialog(frame, "Forbidden characters have been removed from the note", "Error", JOptionPane.INFORMATION_MESSAGE); - }*/ + s = Conversion.replaceAllChar(s, '&', " "); + s = Conversion.replaceAllChar(s, '"', " "); + + if(s.compareTo(tmp) != 0) { + JOptionPane.showMessageDialog(frame, "Forbidden characters have been removed from the note", "Error", JOptionPane.INFORMATION_MESSAGE); + }*/ setValue(s); makeValue(); return true; } return false; } - + public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; } return null; } - + + public void rescale(double scaleFactor){ + /*dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; + lineHeight = (int)(dlineHeight); + dlineHeight = dlineHeight - lineHeight; + minHeight = lineHeight;*/ + + values = null; + + super.rescale(scaleFactor); + } + public int getType() { return TGComponentManager.UML_NOTE; } - + protected String translateExtraParam() { if (values == null) { makeValue(); @@ -205,7 +251,7 @@ public class TGCNote extends TGCWithoutInternalComponent { sb.append("</extraparam>\n"); return new String(sb); } - + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ value = ""; values = null; @@ -214,7 +260,7 @@ public class TGCNote extends TGCWithoutInternalComponent { Node n1, n2; Element elt; String s; - + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); //System.out.println(n1); @@ -237,16 +283,9 @@ public class TGCNote extends TGCWithoutInternalComponent { } } } - + } catch (Exception e) { throw new MalformedModelingException(); } } } - - - - - - - diff --git a/src/ui/TGCScalableWithoutInternalComponent.java b/src/ui/TGCScalableWithoutInternalComponent.java index 8178d2b5172f522b401264c7394b024433b3a086..ba53d0d5161d472c4b1887245bc95ab3bac01d71 100755 --- a/src/ui/TGCScalableWithoutInternalComponent.java +++ b/src/ui/TGCScalableWithoutInternalComponent.java @@ -1,125 +1,118 @@ /**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, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -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. - -/** - * Class TGCScalableWithoutInternalComponent - * Graphical component that contains no internal components, and which is scalable - * Creation: 14/04/2014 - * @version 1.0 14/04/2014 - * @author Ludovic APVRILLE - * @see - */ + 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, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + 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. + + /** + * Class TGCScalableWithoutInternalComponent + * Graphical component that contains no internal components, and which is scalable + * Creation: 14/04/2014 + * @version 1.0 14/04/2014 + * @author Ludovic APVRILLE + * @see + */ package ui; //import java.awt.*; public abstract class TGCScalableWithoutInternalComponent extends TGCWithoutInternalComponent implements ScalableTGComponent { - protected boolean rescaled = false; - protected double oldScaleFactor; - + protected boolean rescaled = false; + protected double oldScaleFactor; + public TGCScalableWithoutInternalComponent(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); } - - public void rescale(double scaleFactor){ - rescaled = true; - - dwidth = (width + dwidth) / oldScaleFactor * scaleFactor; - dheight = (height + dheight) / oldScaleFactor * scaleFactor; - dx = (dx + x) / oldScaleFactor * scaleFactor; - dy = (dy + y) / oldScaleFactor * scaleFactor; - dMaxWidth = (maxWidth + dMaxWidth) / oldScaleFactor * scaleFactor; - dMaxHeight = (maxWidth + dMaxWidth) / oldScaleFactor * scaleFactor; - - width = (int)(dwidth); - dwidth = dwidth - width; - height = (int)(dheight); - dheight = dheight - height; - maxWidth = (int)(dMaxWidth); - maxHeight = (int)(dMaxHeight); - dMaxWidth = dMaxWidth - maxWidth; - dMaxHeight = dMaxHeight - maxHeight; - x = (int)(dx); - dx = dx - x; - y = (int)(dy); - dy = dy - y; - - oldScaleFactor = scaleFactor; - - if (father != null) { - // Must rescale my zone... - resizeWithFather(); - - } - - } - - public void initScaling(int w, int h) { - oldScaleFactor = tdp.getZoom(); - - dx = 0; - dy = 0; - - dwidth = w * oldScaleFactor; - width = (int)dwidth; - dwidth = dwidth - width; - - dheight = h * oldScaleFactor; - height = (int)(dheight); - dheight = dheight - height; - - dMaxWidth = defMaxWidth * oldScaleFactor; - dMaxHeight = defMaxHeight * oldScaleFactor; - - maxWidth = (int)defMaxWidth; - maxHeight = (int)defMaxHeight; - - dMaxWidth = dMaxWidth - maxWidth; - dMaxHeight = dMaxHeight - maxHeight; - - rescaled = true; - } - -} + public void rescale(double scaleFactor){ + rescaled = true; + + dwidth = (width + dwidth) / oldScaleFactor * scaleFactor; + dheight = (height + dheight) / oldScaleFactor * scaleFactor; + dx = (dx + x) / oldScaleFactor * scaleFactor; + dy = (dy + y) / oldScaleFactor * scaleFactor; + dMaxWidth = (maxWidth + dMaxWidth) / oldScaleFactor * scaleFactor; + dMaxHeight = (maxWidth + dMaxWidth) / oldScaleFactor * scaleFactor; + + width = (int)(dwidth); + dwidth = dwidth - width; + height = (int)(dheight); + dheight = dheight - height; + maxWidth = (int)(dMaxWidth); + maxHeight = (int)(dMaxHeight); + dMaxWidth = dMaxWidth - maxWidth; + dMaxHeight = dMaxHeight - maxHeight; + x = (int)(dx); + dx = dx - x; + y = (int)(dy); + dy = dy - y; + + oldScaleFactor = scaleFactor; + + if (father != null) { + // Must rescale my zone... + resizeWithFather(); + + } + + } + + public void initScaling(int w, int h) { + oldScaleFactor = tdp.getZoom(); + dx = 0; + dy = 0; + dwidth = w * oldScaleFactor; + width = (int)dwidth; + dwidth = dwidth - width; + dheight = h * oldScaleFactor; + height = (int)(dheight); + dheight = dheight - height; + dMaxWidth = defMaxWidth * oldScaleFactor; + dMaxHeight = defMaxHeight * oldScaleFactor; + maxWidth = (int)defMaxWidth; + maxHeight = (int)defMaxHeight; + dMaxWidth = dMaxWidth - maxWidth; + dMaxHeight = dMaxHeight - maxHeight; + + rescaled = true; + } + +} diff --git a/src/ui/avatarrd/AvatarRDProperty.java b/src/ui/avatarrd/AvatarRDProperty.java index 742629afa75980c057355062266cfbc22322cebe..a017e1f87fe6c67eb78c783f56d002e0d46b0ebb 100755 --- a/src/ui/avatarrd/AvatarRDProperty.java +++ b/src/ui/avatarrd/AvatarRDProperty.java @@ -1,48 +1,48 @@ /**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, -* that may mean that it is complicated to manipulate, and that also -* therefore means that it is reserved for developers and experienced -* professionals having in-depth computer knowledge. Users are therefore -* encouraged to load and test the software's suitability as regards their -* 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. -* -* /** -* Class AvatarRDProperty -* Avatar property: to be used in avatar requirement diagrams -* Creation: 20/04/2010 -* @version 1.0 20/04/2010 -* @author Ludovic APVRILLE -* @see -*/ + * + * 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, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * 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. + * + * /** + * Class AvatarRDProperty + * Avatar property: to be used in avatar requirement diagrams + * Creation: 20/04/2010 + * @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ package ui.avatarrd; @@ -62,38 +62,38 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement public String oldValue; protected int textX = 5; protected int textY = 22; - protected int lineHeight = 30; - private double dlineHeight = 0.0; + protected int lineHeight = 30; + private double dlineHeight = 0.0; //protected int startFontSize = 10; protected Graphics graphics; //protected int iconSize = 30; - - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - + + private Font myFont, myFontB; + private int maxFontSize = 30; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + protected final static String PROPERTY = "<<Property>>"; - - protected String diagramText; - protected String violatedAction = "noAction"; - - private int iconSize = 18; - private boolean iconIsDrawn = false; - + + protected String diagramText; + protected String violatedAction = "noAction"; + + private int iconSize = 18; + private boolean iconIsDrawn = false; + public AvatarRDProperty(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); - + initScaling(150, lineHeight); - oldScaleFactor = tdp.getZoom(); - dlineHeight = lineHeight * oldScaleFactor; - lineHeight = (int)dlineHeight; - dlineHeight = dlineHeight - lineHeight; - - minWidth = 10; + oldScaleFactor = tdp.getZoom(); + dlineHeight = lineHeight * oldScaleFactor; + lineHeight = (int)dlineHeight; + dlineHeight = dlineHeight - lineHeight; + + minWidth = 10; minHeight = lineHeight; - + nbConnectingPoint = 12; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.0, 0.25); @@ -106,272 +106,272 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement connectingPoint[7] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.5, 0.0); connectingPoint[8] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.75, 0.0); connectingPoint[9] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.25, 1.0); - connectingPoint[10] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.5, 1.0); - connectingPoint[11] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.75, 1.0); - - addTGConnectingPointsCommentTop(); - + connectingPoint[10] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[11] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsCommentTop(); + nbInternalTGComponent = 0; //tgcomponent = new TGComponent[nbInternalTGComponent]; - + int h = 1; //TAttributeRequirement tgc0; //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); //tgcomponent[0] = tgc0; - + moveable = true; editable = true; removable = true; userResizable = true; - multieditable = true; - - + multieditable = true; + + // Name of the observer name = "AvatarProperty"; value = "AvatarProperty"; - //value = tdp.findRequirementName("Requirement_"); + //value = tdp.findRequirementName("Requirement_"); oldValue = value; - + myImageIcon = IconManager.imgic5100; - - diagramText = "no diagram"; - + + diagramText = "no diagram"; + actionOnAdd(); } - - - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - int w, c; - int size; - + + + public void internalDrawing(Graphics g) { + Font f = g.getFont(); + Font fold = f; + int w, c; + int size; + if (!tdp.isScaled()) { graphics = g; } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - if(currentFontSize <minFontSize) { - displayText = false; - } else { - displayText = true; - } - - int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); - - g.drawLine(x, y+lineHeight, x+width, y+lineHeight); - g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); + + if (((rescaled) && (!tdp.isScaled())) || myFont == null) { + currentFontSize = tdp.getFontSize(); + //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); + myFont = f.deriveFont((float)currentFontSize); + myFontB = myFont.deriveFont(Font.BOLD); + + if (rescaled) { + rescaled = false; + } + } + + if(currentFontSize <minFontSize) { + displayText = false; + } else { + displayText = true; + } + + int h = g.getFontMetrics().getHeight(); + + g.drawRect(x, y, width, height); + + g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); g.fillRect(x+1, y+1, width-1, lineHeight-1); - g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); - g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); - ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - drawLimitedString(g, PROPERTY, x, y + size, width, 1); - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - /*g.setFont(myFont); - - size = lineHeight + currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - // Violated action - if (size < (height - 2)) { - drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - }*/ + g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + if ((lineHeight > 23) && (width > 23)){ + g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); + } + + if (displayText) { + size = currentFontSize - 2; + g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); + drawLimitedString(g, PROPERTY, x, y + size, width, 1); + size += currentFontSize; + g.setFont(myFontB); + w = g.getFontMetrics().stringWidth(value); + drawLimitedString(g, value, x, y + size, width, 1); + + } + + /*g.setFont(myFont); + + size = lineHeight + currentFontSize; + if (size < (height - 2)) { + drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); + size += currentFontSize; + // Violated action + if (size < (height - 2)) { + drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); + } + }*/ g.setFont(f); } - + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { oldValue = value; - - if ((displayText) && (_y <= (y + lineHeight))) { - String texti = getName() + ": "; - if (hasFather()) { - texti = getTopLevelName() + " / " + diagramText; - } - String s = (String)JOptionPane.showInputDialog(frame, texti, - "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, - null, - getValue()); - - if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { - //boolean b; - if (!TAttribute.isAValidId(s, false, false)) { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the Property: the new name is not a valid name", - "Error", - JOptionPane.INFORMATION_MESSAGE); - return false; - } - - if (!tdp.isRequirementNameUnique(s)) { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the Property: the new name is already in use", - "Error", - JOptionPane.INFORMATION_MESSAGE); - return false; - } - - - int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; - minDesiredWidth = Math.max(size, minWidth); - if (minDesiredWidth != width) { - newSizeForSon(null); - } - setValue(s); - - if (tdp.actionOnDoubleClick(this)) { - return true; - } else { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the Property: this name is already in use", - "Error", - JOptionPane.INFORMATION_MESSAGE); - setValue(oldValue); - } - } - return false; - } else { - //return editAttributes(); - return false; - } - + + if ((displayText) && (_y <= (y + lineHeight))) { + String texti = getName() + ": "; + if (hasFather()) { + texti = getTopLevelName() + " / " + diagramText; + } + String s = (String)JOptionPane.showInputDialog(frame, texti, + "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, + null, + getValue()); + + if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { + //boolean b; + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + if (!tdp.isRequirementNameUnique(s)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: the new name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + + int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; + minDesiredWidth = Math.max(size, minWidth); + if (minDesiredWidth != width) { + newSizeForSon(null); + } + setValue(s); + + if (tdp.actionOnDoubleClick(this)) { + return true; + } else { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: this name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + setValue(oldValue); + } + } + return false; + } else { + //return editAttributes(); + return false; + } + } - - /*public boolean editAttributes() { - JDialogObserver jdo = new JDialogObserver(tdp.getGUI().getFrame(), "Setting diagrams of Observer " + getRequirementObserverName(), diagramText, violatedAction); - jdo.setSize(750, 400); - GraphicLib.centerOnParent(jdo); - jdo.show(); - - if (!jdo.isRegularClose()) { - return false; - } - - diagramText = jdo.getText(); - violatedAction = jdo.getViolatedAction(); - - return true; - }*/ - - public void rescale(double scaleFactor){ - dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; - lineHeight = (int)(dlineHeight); - dlineHeight = dlineHeight - lineHeight; - minHeight = lineHeight; - - super.rescale(scaleFactor); - } - - + + /*public boolean editAttributes() { + JDialogObserver jdo = new JDialogObserver(tdp.getGUI().getFrame(), "Setting diagrams of Observer " + getRequirementObserverName(), diagramText, violatedAction); + jdo.setSize(750, 400); + GraphicLib.centerOnParent(jdo); + jdo.show(); + + if (!jdo.isRegularClose()) { + return false; + } + + diagramText = jdo.getText(); + violatedAction = jdo.getViolatedAction(); + + return true; + }*/ + + public void rescale(double scaleFactor){ + dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; + lineHeight = (int)(dlineHeight); + dlineHeight = dlineHeight - lineHeight; + minHeight = lineHeight; + + super.rescale(scaleFactor); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; } return null; } - + public String getRequirementObserverName() { return value; } - - + + public int getType() { return TGComponentManager.AVATARRD_PROPERTY; } - - /* public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { - componentMenu.addSeparator(); - JMenuItem generate = null; - // Should verify first whether it is connected to a formal requirement with a verify relation, or not - generate = new JMenuItem("Generate on diagrams"); - - generate.addActionListener(menuAL); - componentMenu.add(generate); - - JMenuItem editAttributes = new JMenuItem("Edit attributes"); - editAttributes.addActionListener(menuAL); - componentMenu.add(editAttributes); - } - - public boolean eventOnPopup(ActionEvent e) { - String s = e.getActionCommand(); - if (s.indexOf("diagrams") > -1) { - // To be implemented! - } else { - return editAttributes(); - } - return true; - }*/ - + + /* public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + JMenuItem generate = null; + // Should verify first whether it is connected to a formal requirement with a verify relation, or not + generate = new JMenuItem("Generate on diagrams"); + + generate.addActionListener(menuAL); + componentMenu.add(generate); + + JMenuItem editAttributes = new JMenuItem("Edit attributes"); + editAttributes.addActionListener(menuAL); + componentMenu.add(editAttributes); + } + + public boolean eventOnPopup(ActionEvent e) { + String s = e.getActionCommand(); + if (s.indexOf("diagrams") > -1) { + // To be implemented! + } else { + return editAttributes(); + } + return true; + }*/ + public String toString() { String ret = getValue() + PROPERTY; return ret; } - - public void autoAdjust(int mode) { - //System.out.println("Auto adjust in mode = " + mode); - - if (graphics == null) { - return; - } - - Font f = graphics.getFont(); - Font f0 = f.deriveFont((float)currentFontSize); - Font f1 = f0.deriveFont(Font.BOLD); - Font f2 = f.deriveFont((float)(currentFontSize - 2)); - - // Must find for both modes which width is desirable - String s0, s1; - - s0 = PROPERTY; - - graphics.setFont(f2); - int w0 = graphics.getFontMetrics().stringWidth(s0); - graphics.setFont(f1); - int w1 = graphics.getFontMetrics().stringWidth(value); - int w2 = Math.max(w0, w1) + (2 * iconSize); - graphics.setFont(f0); - /*int w3 = graphics.getFontMetrics().stringWidth("Diagram=\"" + diagramText + "\"") + textX; - int w4 = graphics.getFontMetrics().stringWidth("Violated_Action=\"" + violatedAction + "\"") + textX; - graphics.setFont(f); - - w2 = Math.max(w2, w3); - w2 = Math.max(w2, w4);*/ - if (mode == 1) { - resize(w2, lineHeight); - return; - } - - int h = (3 * currentFontSize) + lineHeight; - - resize(w2, h); - - } - -} \ No newline at end of file + + public void autoAdjust(int mode) { + //System.out.println("Auto adjust in mode = " + mode); + + if (graphics == null) { + return; + } + + Font f = graphics.getFont(); + Font f0 = f.deriveFont((float)currentFontSize); + Font f1 = f0.deriveFont(Font.BOLD); + Font f2 = f.deriveFont((float)(currentFontSize - 2)); + + // Must find for both modes which width is desirable + String s0, s1; + + s0 = PROPERTY; + + graphics.setFont(f2); + int w0 = graphics.getFontMetrics().stringWidth(s0); + graphics.setFont(f1); + int w1 = graphics.getFontMetrics().stringWidth(value); + int w2 = Math.max(w0, w1) + (2 * iconSize); + graphics.setFont(f0); + /*int w3 = graphics.getFontMetrics().stringWidth("Diagram=\"" + diagramText + "\"") + textX; + int w4 = graphics.getFontMetrics().stringWidth("Violated_Action=\"" + violatedAction + "\"") + textX; + graphics.setFont(f); + + w2 = Math.max(w2, w3); + w2 = Math.max(w2, w4);*/ + if (mode == 1) { + resize(w2, lineHeight); + return; + } + + int h = (3 * currentFontSize) + lineHeight; + + resize(w2, h); + + } + +} diff --git a/src/ui/avatarrd/AvatarRDRequirement.java b/src/ui/avatarrd/AvatarRDRequirement.java index ea8af892a2c116a9e430d2078b4c72535deffd54..1eb87a6402608675a73d9e2a650a576883cd529a 100755 --- a/src/ui/avatarrd/AvatarRDRequirement.java +++ b/src/ui/avatarrd/AvatarRDRequirement.java @@ -1,48 +1,48 @@ /**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, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -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. - -/** -* Class AvatarRDRequirement -* Avatar requirement: to be used in requirement diagram of AVATAR -* Creation: 20/04/2010 -* @version 1.0 20/04/2010 -* @author Ludovic APVRILLE -* @see -*/ + 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, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + 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. + + /** + * Class AvatarRDRequirement + * Avatar requirement: to be used in requirement diagram of AVATAR + * Creation: 20/04/2010 + * @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ package ui.avatarrd; @@ -61,70 +61,70 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem public String oldValue; protected int textX = 5; protected int textY = 22; - protected int lineHeight = 30; - private double dlineHeight = 0.0; + protected int lineHeight = 30; + private double dlineHeight = 0.0; //protected int reqType = 0; - // 0: normal, 1: formal, 2: security + // 0: normal, 1: formal, 2: security //protected int startFontSize = 10; protected Graphics graphics; //protected int iconSize = 30; - - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - + + private Font myFont, myFontB; + private int maxFontSize = 30; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + protected final static String[] REQ_TYPE_STR = {"<<Requirement>>", "<<Safety Requirement>>", "<<Security Requirement>>"}; - protected final static int NB_REQ_TYPE = 3; - - protected final static int REGULAR_REQ = 0; - protected final static int SAFETY_REQ = 1; - protected final static int SECURITY_REQ = 2; - + protected final static int NB_REQ_TYPE = 3; + + protected final static int REGULAR_REQ = 0; + protected final static int SAFETY_REQ = 1; + protected final static int SECURITY_REQ = 2; + public final static int HIGH = 0; public final static int MEDIUM = 1; public final static int LOW = 2; - - protected String text; + + protected String text; protected String []texts; protected String kind = ""; protected String criticality = ""; - protected int reqType = 0; + protected int reqType = 0; protected String violatedAction = ""; - protected String attackTreeNode = ""; - protected String referenceElements = ""; - protected String id = ""; - - protected boolean satisfied = false; - protected boolean verified = false; - - private JMenuItem isRegular = null; + protected String attackTreeNode = ""; + protected String referenceElements = ""; + protected String id = ""; + + protected boolean satisfied = false; + protected boolean verified = false; + + private JMenuItem isRegular = null; private JMenuItem isSafety = null; - private JMenuItem isSecurity = null; - private JMenuItem menuNonSatisfied = null; - private JMenuItem menuSatisfied = null; - private JMenuItem menuNonVerified = null; - private JMenuItem menuVerified = null; - JMenuItem editAttributes = null; - - - // Icon - private int iconSize = 18; - private boolean iconIsDrawn = false; - + private JMenuItem isSecurity = null; + private JMenuItem menuNonSatisfied = null; + private JMenuItem menuSatisfied = null; + private JMenuItem menuNonVerified = null; + private JMenuItem menuVerified = null; + JMenuItem editAttributes = null; + + + // Icon + private int iconSize = 18; + private boolean iconIsDrawn = false; + public AvatarRDRequirement(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); - - initScaling(200, 120); - oldScaleFactor = tdp.getZoom(); - dlineHeight = lineHeight * oldScaleFactor; - lineHeight = (int)dlineHeight; - dlineHeight = dlineHeight - lineHeight; - - minWidth = 1; + + initScaling(200, 120); + oldScaleFactor = tdp.getZoom(); + dlineHeight = lineHeight * oldScaleFactor; + lineHeight = (int)dlineHeight; + dlineHeight = dlineHeight - lineHeight; + + minWidth = 1; minHeight = lineHeight; - + nbConnectingPoint = 28; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.0, 0.25, TGConnectingPoint.WEST); @@ -137,8 +137,8 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem connectingPoint[7] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 0.0, TGConnectingPoint.NORTH); connectingPoint[8] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.75, 0.0, TGConnectingPoint.NORTH); connectingPoint[9] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.25, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[10] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[11] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.75, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[10] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[11] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.75, 1.0, TGConnectingPoint.SOUTH); connectingPoint[12] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.0, 0.25, TGConnectingPoint.WEST); connectingPoint[13] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.0, 0.5, TGConnectingPoint.WEST); connectingPoint[14] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.0, 0.75, TGConnectingPoint.WEST); @@ -149,419 +149,419 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem connectingPoint[19] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.5, 0.0, TGConnectingPoint.NORTH); connectingPoint[20] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.75, 0.0, TGConnectingPoint.NORTH); connectingPoint[21] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.25, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[22] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.5, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[23] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.75, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[24] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[25] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[26] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); - connectingPoint[27] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); - - - addTGConnectingPointsCommentTop(); - + connectingPoint[22] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[23] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.75, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[24] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[25] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[26] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[27] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + + + addTGConnectingPointsCommentTop(); + nbInternalTGComponent = 0; //tgcomponent = new TGComponent[nbInternalTGComponent]; - + int h = 1; //TAttributeRequirement tgc0; //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); //tgcomponent[0] = tgc0; - + moveable = true; editable = true; removable = true; userResizable = true; - multieditable = true; - + multieditable = true; + //reqType = 0; - - id = "0"; - + + id = "0"; + // Name of the requirement name = "Requirement"; - id = tdp.findAvatarRequirementID(id); - try { - value = tdp.findAvatarRequirementName("Requirement_", Integer.decode(id).intValue()); - } catch (Exception e) { - value = tdp.findAvatarRequirementName("Requirement_", 0); - } + id = tdp.findAvatarRequirementID(id); + try { + value = tdp.findAvatarRequirementName("Requirement_", Integer.decode(id).intValue()); + } catch (Exception e) { + value = tdp.findAvatarRequirementName("Requirement_", 0); + } oldValue = value; - + myImageIcon = IconManager.imgic5006; - - text = "Requirement description:\nDouble-click to edit"; - + + text = "Requirement description:\nDouble-click to edit"; + actionOnAdd(); } - - public void makeValue() { + + public void makeValue() { texts = Conversion.wrapText(text); } - + public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - int w, c; - int size; - - if (texts == null) { - makeValue(); - } - + Font f = g.getFont(); + Font fold = f; + int w, c; + int size; + + if (texts == null) { + makeValue(); + } + if (!tdp.isScaled()) { graphics = g; } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - if(currentFontSize <minFontSize) { - displayText = false; - } else { - displayText = true; - } - - int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); - - g.drawLine(x, y+lineHeight, x+width, y+lineHeight); - g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); + + if (((rescaled) && (!tdp.isScaled())) || myFont == null) { + currentFontSize = tdp.getFontSize(); + //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); + myFont = f.deriveFont((float)currentFontSize); + myFontB = myFont.deriveFont(Font.BOLD); + + if (rescaled) { + rescaled = false; + } + } + + if(currentFontSize <minFontSize) { + displayText = false; + } else { + displayText = true; + } + + int h = g.getFontMetrics().getHeight(); + + g.drawRect(x, y, width, height); + + g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); g.fillRect(x+1, y+1, width-1, lineHeight-1); - g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); - g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); - ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - - drawLimitedString(g, REQ_TYPE_STR[reqType], x, y + size, width, 1); - - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - if (verified) { - if (satisfied) { - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.green); - g.drawLine(x+width-2, y-6+lineHeight, x+width-6, y-2+lineHeight); - g.drawLine(x+width-6, y-3+lineHeight, x+width-8, y-6+lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } else { - //g.drawString("acc", x + width - 10, y+height-10); - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.red); - g.drawLine(x+width-2, y-2+lineHeight, x+width-8, y-8+lineHeight); - g.drawLine(x+width-8, y-2+lineHeight, x+width-2, y-8+lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } - } - - g.setFont(myFont); - String texti = "Text"; - String s ; - int i; - size = lineHeight + currentFontSize; - - //ID - if (size < (height - 2)) { - drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0); - } - size += currentFontSize; - - //text + g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + if ((lineHeight > 23) && (width > 23)){ + g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); + } + + if (displayText) { + size = currentFontSize - 2; + g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); + + drawLimitedString(g, REQ_TYPE_STR[reqType], x, y + size, width, 1); + + size += currentFontSize; + g.setFont(myFontB); + w = g.getFontMetrics().stringWidth(value); + drawLimitedString(g, value, x, y + size, width, 1); + + } + + if (verified) { + if (satisfied) { + Color tmp = g.getColor(); + GraphicLib.setMediumStroke(g); + g.setColor(Color.green); + g.drawLine(x+width-2, y-6+lineHeight, x+width-6, y-2+lineHeight); + g.drawLine(x+width-6, y-3+lineHeight, x+width-8, y-6+lineHeight); + g.setColor(tmp); + GraphicLib.setNormalStroke(g); + } else { + //g.drawString("acc", x + width - 10, y+height-10); + Color tmp = g.getColor(); + GraphicLib.setMediumStroke(g); + g.setColor(Color.red); + g.drawLine(x+width-2, y-2+lineHeight, x+width-8, y-8+lineHeight); + g.drawLine(x+width-8, y-2+lineHeight, x+width-2, y-8+lineHeight); + g.setColor(tmp); + GraphicLib.setNormalStroke(g); + } + } + + g.setFont(myFont); + String texti = "Text"; + String s ; + int i; + size = lineHeight + currentFontSize; + + //ID + if (size < (height - 2)) { + drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0); + } + size += currentFontSize; + + //text for(i=0; i<texts.length; i++) { - if (size < (height - 2)) { - s = texts[i]; - if (i == 0) { - s = texti + "=\"" + s; - } - if (i == (texts.length - 1)) { - s = s + "\""; - } - drawLimitedString(g, s, x + textX, y + size, width, 0); - } - size += currentFontSize; - + if (size < (height - 2)) { + s = texts[i]; + if (i == 0) { + s = texti + "=\"" + s; + } + if (i == (texts.length - 1)) { + s = s + "\""; + } + drawLimitedString(g, s, x + textX, y + size, width, 0); + } + size += currentFontSize; + } // Type and risk - if (size < (height - 2)) { - drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - - drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0); - - size += currentFontSize; - if (size < (height - 2)) { - - if (reqType == SECURITY_REQ) { - drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0); - } - - if (reqType == SAFETY_REQ) { - drawLimitedString(g, "Violated action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - } - } - } - } - - + if (size < (height - 2)) { + drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0); + size += currentFontSize; + if (size < (height - 2)) { + drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0); + size += currentFontSize; + if (size < (height - 2)) { + + drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0); + + size += currentFontSize; + if (size < (height - 2)) { + + if (reqType == SECURITY_REQ) { + drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0); + } + + if (reqType == SAFETY_REQ) { + drawLimitedString(g, "Violated action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); + } + } + } + } + } + + g.setFont(f); } - - public boolean editOndoubleClick(JFrame frame, int _x, int _y) { - // On the name ? + + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + // On the name ? oldValue = value; - + if ((displayText) && (_y <= (y + lineHeight))) { - String text = getName() + ": "; - if (hasFather()) { - text = getTopLevelName() + " / " + text; - } - String s = (String)JOptionPane.showInputDialog(frame, text, - "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, - null, - getValue()); - - if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { - //boolean b; - if (!TAttribute.isAValidId(s, false, false)) { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the Requirement: the new name is not a valid name", - "Error", - JOptionPane.INFORMATION_MESSAGE); - return false; - } - - if (!tdp.isRequirementNameUnique(s)) { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the Requirement: the new name is already in use", - "Error", - JOptionPane.INFORMATION_MESSAGE); - return false; - } - - - int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; - minDesiredWidth = Math.max(size, minWidth); - if (minDesiredWidth != width) { - newSizeForSon(null); - } - setValue(s); - - if (tdp.actionOnDoubleClick(this)) { - return true; - } else { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the Requirement: this name is already in use", - "Error", - JOptionPane.INFORMATION_MESSAGE); - setValue(oldValue); - } - } - return false; - } - - return editAttributes(); - + String text = getName() + ": "; + if (hasFather()) { + text = getTopLevelName() + " / " + text; + } + String s = (String)JOptionPane.showInputDialog(frame, text, + "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, + null, + getValue()); + + if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { + //boolean b; + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Requirement: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + if (!tdp.isRequirementNameUnique(s)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Requirement: the new name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + + int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; + minDesiredWidth = Math.max(size, minWidth); + if (minDesiredWidth != width) { + newSizeForSon(null); + } + setValue(s); + + if (tdp.actionOnDoubleClick(this)) { + return true; + } else { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Requirement: this name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + setValue(oldValue); + } + } + return false; + } + + return editAttributes(); + } - - public boolean editAttributes() { - //String oldValue = value; - String atn = null; - String va = null; - - if (reqType == SECURITY_REQ) { - atn = attackTreeNode; - } - - - if (reqType == SAFETY_REQ) { - va = violatedAction; - } - + + public boolean editAttributes() { + //String oldValue = value; + String atn = null; + String va = null; + + if (reqType == SECURITY_REQ) { + atn = attackTreeNode; + } + + + if (reqType == SAFETY_REQ) { + va = violatedAction; + } + JDialogRequirement jdr = new JDialogRequirement(tdp.getGUI().getFrame(), "Setting attributes of Requirement " + getRequirementName(), id, text, kind, criticality, va, reqType, atn, referenceElements); jdr.setSize(750, 400); GraphicLib.centerOnParent(jdr); jdr.show(); - + if (!jdr.isRegularClose()) { return false; } - - + + if (reqType == SAFETY_REQ) { - violatedAction = jdr.getViolatedAction(); + violatedAction = jdr.getViolatedAction(); } if (reqType == SECURITY_REQ) { - attackTreeNode = jdr.getAttackTreeNode(); - } - referenceElements = jdr.getReferenceElements(); + attackTreeNode = jdr.getAttackTreeNode(); + } + referenceElements = jdr.getReferenceElements(); id = jdr.getId(); text = jdr.getText(); kind = jdr.getKind(); criticality = jdr.getCriticality(); - + makeValue(); return true; - } - - public void rescale(double scaleFactor){ - dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; - lineHeight = (int)(dlineHeight); - dlineHeight = dlineHeight - lineHeight; - - minHeight = lineHeight; - - super.rescale(scaleFactor); - } - - + } + + public void rescale(double scaleFactor){ + dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; + lineHeight = (int)(dlineHeight); + dlineHeight = dlineHeight - lineHeight; + + minHeight = lineHeight; + + super.rescale(scaleFactor); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; } return null; } - + public String getRequirementName() { return value; } - + public boolean isSafety() { return (reqType == 1); } - + public void setRequirementType(int _type) { reqType = _type; } - + public int getRequirementType() { - return reqType; + return reqType; } - + public boolean isSatisfied() { - return satisfied; + return satisfied; } - - public boolean isVerified() { - return verified; - } - + + public boolean isVerified() { + return verified; + } + public int getType() { return TGComponentManager.AVATARRD_REQUIREMENT; } - + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { - - componentMenu.addSeparator(); - - isRegular = new JMenuItem("Set as regular requirement"); - isSafety = new JMenuItem("Set as safety requirement"); - isSecurity = new JMenuItem("Set as security requirement"); - menuNonSatisfied = new JMenuItem("Set as non satisfied"); - menuSatisfied = new JMenuItem("Set as satisfied"); - menuNonVerified = new JMenuItem("Set as non verified"); - menuVerified = new JMenuItem("Set as verified"); - - - isRegular.addActionListener(menuAL); - isSafety.addActionListener(menuAL); - isSecurity.addActionListener(menuAL); - menuNonSatisfied.addActionListener(menuAL); - menuSatisfied.addActionListener(menuAL); - menuNonVerified.addActionListener(menuAL); - menuVerified.addActionListener(menuAL); - - editAttributes = new JMenuItem("Edit attributes"); - editAttributes.addActionListener(menuAL); - - isRegular.setEnabled(reqType != REGULAR_REQ); - isSafety.setEnabled(reqType != SAFETY_REQ); - isSecurity.setEnabled(reqType != SECURITY_REQ); - - menuNonSatisfied.setEnabled(satisfied); - menuSatisfied.setEnabled(!satisfied); - - menuNonVerified.setEnabled(verified); - menuVerified.setEnabled(!verified); - - componentMenu.add(isRegular); - componentMenu.add(isSafety); - componentMenu.add(isSecurity); - componentMenu.addSeparator(); - componentMenu.add(menuNonSatisfied); - componentMenu.add(menuSatisfied); - componentMenu.add(menuNonVerified); - componentMenu.add(menuVerified); - componentMenu.add(editAttributes); + + componentMenu.addSeparator(); + + isRegular = new JMenuItem("Set as regular requirement"); + isSafety = new JMenuItem("Set as safety requirement"); + isSecurity = new JMenuItem("Set as security requirement"); + menuNonSatisfied = new JMenuItem("Set as non satisfied"); + menuSatisfied = new JMenuItem("Set as satisfied"); + menuNonVerified = new JMenuItem("Set as non verified"); + menuVerified = new JMenuItem("Set as verified"); + + + isRegular.addActionListener(menuAL); + isSafety.addActionListener(menuAL); + isSecurity.addActionListener(menuAL); + menuNonSatisfied.addActionListener(menuAL); + menuSatisfied.addActionListener(menuAL); + menuNonVerified.addActionListener(menuAL); + menuVerified.addActionListener(menuAL); + + editAttributes = new JMenuItem("Edit attributes"); + editAttributes.addActionListener(menuAL); + + isRegular.setEnabled(reqType != REGULAR_REQ); + isSafety.setEnabled(reqType != SAFETY_REQ); + isSecurity.setEnabled(reqType != SECURITY_REQ); + + menuNonSatisfied.setEnabled(satisfied); + menuSatisfied.setEnabled(!satisfied); + + menuNonVerified.setEnabled(verified); + menuVerified.setEnabled(!verified); + + componentMenu.add(isRegular); + componentMenu.add(isSafety); + componentMenu.add(isSecurity); + componentMenu.addSeparator(); + componentMenu.add(menuNonSatisfied); + componentMenu.add(menuSatisfied); + componentMenu.add(menuNonVerified); + componentMenu.add(menuVerified); + componentMenu.add(editAttributes); } - + public boolean eventOnPopup(ActionEvent e) { String s = e.getActionCommand(); - - if (e.getSource() == menuNonSatisfied) { - satisfied = false; - } else if (e.getSource() == menuSatisfied) { - satisfied = true; - } else if (e.getSource() == menuNonVerified) { - verified = false; - } else if (e.getSource() == menuVerified) { - verified = true; - } else if (e.getSource() == isRegular) { - reqType = REGULAR_REQ; - } else if (e.getSource() == isSafety) { - reqType = SAFETY_REQ; - } else if (e.getSource() == isSecurity) { - reqType = SECURITY_REQ; - } else { - return editAttributes(); - } - - + + if (e.getSource() == menuNonSatisfied) { + satisfied = false; + } else if (e.getSource() == menuSatisfied) { + satisfied = true; + } else if (e.getSource() == menuNonVerified) { + verified = false; + } else if (e.getSource() == menuVerified) { + verified = true; + } else if (e.getSource() == isRegular) { + reqType = REGULAR_REQ; + } else if (e.getSource() == isSafety) { + reqType = SAFETY_REQ; + } else if (e.getSource() == isSecurity) { + reqType = SECURITY_REQ; + } else { + return editAttributes(); + } + + return true; } - + public String toString() { String ret = getValue(); - - ret += "ID=" + id; - - ret += " " + text; - ret += " criticality=" + criticality; - + + ret += "ID=" + id; + + ret += " " + text; + ret += " criticality=" + criticality; + return ret; } - + protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); - - if (texts != null) { + + if (texts != null) { for(int i=0; i<texts.length; i++) { //value = value + texts[i] + "\n"; sb.append("<textline data=\""); @@ -575,16 +575,16 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem sb.append("<criticality data=\""); sb.append(criticality); sb.append("\" />\n"); - sb.append("<reqType data=\""); + sb.append("<reqType data=\""); sb.append(reqType); sb.append("\" />\n"); - sb.append("<id data=\""); + sb.append("<id data=\""); sb.append(id); sb.append("\" />\n"); - sb.append("<satisfied data=\""); + sb.append("<satisfied data=\""); sb.append(satisfied); sb.append("\" />\n"); - sb.append("<verified data=\""); + sb.append("<verified data=\""); sb.append(verified); sb.append("\" />\n"); sb.append("<attackTreeNode data=\""); @@ -599,20 +599,20 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem sb.append("</extraparam>\n"); return new String(sb); } - - + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ try { NodeList nli; Node n1, n2; Element elt; - String oldtext = text; + String oldtext = text; text = ""; - String s; - + String s; + //System.out.println("Loading tclass " + getValue()); //System.out.println(nl.toString()); - + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); if (n1.getNodeType() == Node.ELEMENT_NODE) { @@ -664,90 +664,90 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem if (s.equals("null")) { reqType = REGULAR_REQ; } else { - try { - reqType = Integer.decode(s).intValue(); - } catch (Exception e) { - reqType = REGULAR_REQ; - } - } - if (reqType > (NB_REQ_TYPE-1)) { - reqType = REGULAR_REQ; - } - + try { + reqType = Integer.decode(s).intValue(); + } catch (Exception e) { + reqType = REGULAR_REQ; + } + } + if (reqType > (NB_REQ_TYPE-1)) { + reqType = REGULAR_REQ; + } + } else if (elt.getTagName().equals("id")) { //System.out.println("Analyzing line3"); id = elt.getAttribute("data"); if (id.equals("null")) { id = ""; } - //System.out.println("Analyzing line4"); - } else if (elt.getTagName().equals("satisfied")) { + //System.out.println("Analyzing line4"); + } else if (elt.getTagName().equals("satisfied")) { //System.out.println("Analyzing line3"); s = elt.getAttribute("data"); if (s.equals("null")) { satisfied = false; } else { - if (s.equals("true")) { - satisfied = true; - } else { - satisfied = false; - } - } - //System.out.println("Analyzing line4"); - } else if (elt.getTagName().equals("verified")) { + if (s.equals("true")) { + satisfied = true; + } else { + satisfied = false; + } + } + //System.out.println("Analyzing line4"); + } else if (elt.getTagName().equals("verified")) { //System.out.println("Analyzing line3"); s = elt.getAttribute("data"); if (s.equals("null")) { verified = false; } else { - if (s.equals("true")) { - verified = true; - } else { - verified = false; - } - } - } - //System.out.println("Analyzing line4"); + if (s.equals("true")) { + verified = true; + } else { + verified = false; + } + } + } + //System.out.println("Analyzing line4"); } } } } - if (text.length() == 0) { + if (text.length() == 0) { text = oldtext; } } catch (Exception e) { - TraceManager.addError("Failed when loading requirement extra parameters (AVATARRD)"); + TraceManager.addError("Failed when loading requirement extra parameters (AVATARRD)"); throw new MalformedModelingException(); } - - makeValue(); + + makeValue(); } - - + + public String getText() { return text; } - - public String getID() { - return id; - } - - public String getKind() { - return kind; - } - - public String getViolatedAction() { + + public String getID() { + return id; + } + + public String getKind() { + return kind; + } + + public String getViolatedAction() { return violatedAction; } - + public String getAttackTreeNode() { return attackTreeNode; } - + public String getReferenceElements() { return referenceElements; } - + public int getCriticality() { //System.out.println("Criticality=" + criticality); if (criticality.compareTo("High") == 0) { @@ -758,87 +758,87 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem return AvatarRDRequirement.LOW; } } - - public String getAttributes() { - String attr = "ID=" + id + "\n"; - attr += "Text= " + text + "\n"; - attr += "Kind= " + kind + "\n"; - attr += "Risk= " + criticality + "\n"; - attr += "References= " + referenceElements + "\n"; - if (reqType == SAFETY_REQ) { - attr += "Violated action= " + violatedAction + "\n"; - } - if (reqType == SECURITY_REQ) { - attr += "Attack tree node(s)= " + attackTreeNode + "\n"; - } - return attr; - } - - public void autoAdjust(int mode) { - //System.out.println("Auto adjust in mode = " + mode); - - if (graphics == null) { - return; - } - - Font f = graphics.getFont(); - Font f0 = f.deriveFont((float)currentFontSize); - Font f1 = f0.deriveFont(Font.BOLD); - Font f2 = f.deriveFont((float)(currentFontSize - 2)); - - // Must find for both modes which width is desirable - String s0, s1; - s0 = REQ_TYPE_STR[reqType]; - s1 = "Text="; - - graphics.setFont(f2); - int w0 = graphics.getFontMetrics().stringWidth(s0); - graphics.setFont(f1); - int w1 = graphics.getFontMetrics().stringWidth(value); - int w2 = Math.max(w0, w1) + (2 * iconSize); - - graphics.setFont(f0); - int w3, w4 = w2; - int i; - - if(texts.length == 1) { - w3 = graphics.getFontMetrics().stringWidth(s1 + "=\"" + texts[0] + "\""); - w4 = Math.max(w4, w3); - } else { - for(i=0; i<texts.length; i++) { - if (i == 0) { - w3 = graphics.getFontMetrics().stringWidth(s1 + "=\"" + texts[i]); - } else if (i == (texts.length - 1)) { - w3 = graphics.getFontMetrics().stringWidth(texts[i] + "\""); - } else { - w3 = graphics.getFontMetrics().stringWidth(texts[i]); - } - - w4 = Math.max(w4, w3+2); - } - } - w3 = graphics.getFontMetrics().stringWidth("Kind=\"" + kind + "\"") + 2; - w4 = Math.max(w4, w3); - w3 = graphics.getFontMetrics().stringWidth("Risk=\"" + criticality + "\"") + 2; - w4 = Math.max(w4, w3); - w3 = graphics.getFontMetrics().stringWidth("ID=\"" + id + "\"") + 2; - w4 = Math.max(w4, w3); - - if (mode == 1) { - resize(w4, lineHeight); - return; - } - - int h; - if (mode == 2) { - h = ((texts.length + 4) * currentFontSize) + lineHeight; - } else { - h = ((texts.length + 5) * currentFontSize) + lineHeight; - } - - - resize(w4, h); - - } - + + public String getAttributes() { + String attr = "ID=" + id + "\n"; + attr += "Text= " + text + "\n"; + attr += "Kind= " + kind + "\n"; + attr += "Risk= " + criticality + "\n"; + attr += "References= " + referenceElements + "\n"; + if (reqType == SAFETY_REQ) { + attr += "Violated action= " + violatedAction + "\n"; + } + if (reqType == SECURITY_REQ) { + attr += "Attack tree node(s)= " + attackTreeNode + "\n"; + } + return attr; + } + + public void autoAdjust(int mode) { + //System.out.println("Auto adjust in mode = " + mode); + + if (graphics == null) { + return; + } + + Font f = graphics.getFont(); + Font f0 = f.deriveFont((float)currentFontSize); + Font f1 = f0.deriveFont(Font.BOLD); + Font f2 = f.deriveFont((float)(currentFontSize - 2)); + + // Must find for both modes which width is desirable + String s0, s1; + s0 = REQ_TYPE_STR[reqType]; + s1 = "Text="; + + graphics.setFont(f2); + int w0 = graphics.getFontMetrics().stringWidth(s0); + graphics.setFont(f1); + int w1 = graphics.getFontMetrics().stringWidth(value); + int w2 = Math.max(w0, w1) + (2 * iconSize); + + graphics.setFont(f0); + int w3, w4 = w2; + int i; + + if(texts.length == 1) { + w3 = graphics.getFontMetrics().stringWidth(s1 + "=\"" + texts[0] + "\""); + w4 = Math.max(w4, w3); + } else { + for(i=0; i<texts.length; i++) { + if (i == 0) { + w3 = graphics.getFontMetrics().stringWidth(s1 + "=\"" + texts[i]); + } else if (i == (texts.length - 1)) { + w3 = graphics.getFontMetrics().stringWidth(texts[i] + "\""); + } else { + w3 = graphics.getFontMetrics().stringWidth(texts[i]); + } + + w4 = Math.max(w4, w3+2); + } + } + w3 = graphics.getFontMetrics().stringWidth("Kind=\"" + kind + "\"") + 2; + w4 = Math.max(w4, w3); + w3 = graphics.getFontMetrics().stringWidth("Risk=\"" + criticality + "\"") + 2; + w4 = Math.max(w4, w3); + w3 = graphics.getFontMetrics().stringWidth("ID=\"" + id + "\"") + 2; + w4 = Math.max(w4, w3); + + if (mode == 1) { + resize(w4, lineHeight); + return; + } + + int h; + if (mode == 2) { + h = ((texts.length + 4) * currentFontSize) + lineHeight; + } else { + h = ((texts.length + 5) * currentFontSize) + lineHeight; + } + + + resize(w4, h); + + } + } diff --git a/src/ui/avatarsmd/AvatarSMDTransitionInfo.java b/src/ui/avatarsmd/AvatarSMDTransitionInfo.java index 8e078aec71ca6cd2e0a9807fd22058c46fa6ce5a..4f75237baf1af9f685516edf3a397fa09c4c32ee 100755 --- a/src/ui/avatarsmd/AvatarSMDTransitionInfo.java +++ b/src/ui/avatarsmd/AvatarSMDTransitionInfo.java @@ -237,8 +237,6 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent { if ((getState() == TGState.POINTER_ON_ME) || (getState() == TGState.POINTED)|| (getState() == TGState.MOVING)){ g.drawRoundRect(x-1, y-h+2, width+2, height+2, 5, 5); } - - } diff --git a/src/ui/tmldd/TMLArchiCPNode.java b/src/ui/tmldd/TMLArchiCPNode.java index 67e6af206eb41ec64770475bd2396f729dda42eb..38c2a71eadfa2eba4ef8604bb24f50609bf2ea3a 100755 --- a/src/ui/tmldd/TMLArchiCPNode.java +++ b/src/ui/tmldd/TMLArchiCPNode.java @@ -68,10 +68,10 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow private String reference=""; private Vector<String> mappedUnits = new Vector<String>(); private Vector<String> assignedAttributes = new Vector<String>(); - private String cpMEC = "VOID"; - private int transferType1 = -1; - private int transferType2 = -1; - private String completeName; + private String cpMEC = "VOID"; + private int transferType1 = -1; + private int transferType2 = -1; + private String completeName; public TMLArchiCPNode(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); @@ -126,7 +126,7 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow g.drawString(ster, x + (width - w)/2, y + textY1); g.setFont(f); String val = name + "::" + reference; - completeName = val; + completeName = val; w = g.getFontMetrics().stringWidth(val); g.drawString(val, x + (width - w)/2, y + textY2); @@ -207,10 +207,10 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow //setJDialogOptions(jdab); name = dialog.getNodeName(); mappedUnits = dialog.getMappedUnits(); - cpMEC = dialog.getCPMEC(); - transferType1 = dialog.getTransferTypes().get(0); - transferType2 = dialog.getTransferTypes().get(1); - assignedAttributes = dialog.getAssignedAttributes(); + cpMEC = dialog.getCPMEC(); + transferType1 = dialog.getTransferTypes().get(0); + transferType2 = dialog.getTransferTypes().get(1); + assignedAttributes = dialog.getAssignedAttributes(); if( !dialog.isRegularClose() ) { return false; @@ -277,7 +277,7 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow String sstereotype = null, snodeName = null; mappedUnits.removeAllElements(); - assignedAttributes.removeAllElements(); + assignedAttributes.removeAllElements(); for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); //System.out.println(n1); @@ -291,11 +291,11 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow if (elt.getTagName().equals("info")) { sstereotype = elt.getAttribute("stereotype"); snodeName = elt.getAttribute("nodeName"); - if( ( elt.getAttribute("cpMEC") != null ) && ( elt.getAttribute("cpMEC").length() > 0 ) ) { - cpMEC = elt.getAttribute( "cpMEC" ); - transferType1 = Integer.parseInt(elt.getAttribute( "transferType1" ) ); - transferType2 = Integer.parseInt(elt.getAttribute( "transferType2" ) ); - } + if( ( elt.getAttribute("cpMEC") != null ) && ( elt.getAttribute("cpMEC").length() > 0 ) ) { + cpMEC = elt.getAttribute( "cpMEC" ); + transferType1 = Integer.parseInt(elt.getAttribute( "transferType1" ) ); + transferType2 = Integer.parseInt(elt.getAttribute( "transferType2" ) ); + } } if (sstereotype != null) { stereotype = sstereotype; @@ -392,49 +392,49 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow return mappedUnits; } - public int getCPMEC() { - if( cpMEC.equals( "Memory Copy" ) ) { - return CPMEC.CpuMemoryCopyMEC; - } - if( cpMEC.equals( "Single DMA" ) ) { - return CPMEC.SingleDmaMEC; - } - if( cpMEC.equals( "Double DMA" ) ) { - return CPMEC.DoubleDmaMEC; - } - return -1; - } - - public String getCompleteName() { - return completeName; - } - - public Vector<String> getAssignedAttributes() { - - Vector<String> vectorToReturn; - switch( cpMEC ) { - case CPMEC.MemoryCopy: - TraceManager.addDev( "**** ASSIGNED ATTRIBUTES ****\\" + assignedAttributes ); - vectorToReturn = CpuMemoryCopyMEC.sortAttributes( assignedAttributes ); - break; - case CPMEC.SingleDMA: - vectorToReturn = SingleDmaMEC.sortAttributes( assignedAttributes ); - break; - case CPMEC.DoubleDMA: - vectorToReturn = DoubleDmaMEC.sortAttributes( assignedAttributes ); - break; - default: - TraceManager.addDev( "ERROR in returning assignedAttributes" ); - vectorToReturn = assignedAttributes; - break; - } - return vectorToReturn; - } - - public ArrayList<Integer> getTransferTypes() { - ArrayList<Integer> transferTypes = new ArrayList<Integer>(); - transferTypes.add( transferType1 ); - transferTypes.add( transferType2 ); - return transferTypes; - } + public int getCPMEC() { + if( cpMEC.equals( "Memory Copy" ) ) { + return CPMEC.CpuMemoryCopyMEC; + } + if( cpMEC.equals( "Single DMA" ) ) { + return CPMEC.SingleDmaMEC; + } + if( cpMEC.equals( "Double DMA" ) ) { + return CPMEC.DoubleDmaMEC; + } + return -1; + } + + public String getCompleteName() { + return completeName; + } + + public Vector<String> getAssignedAttributes() { + + Vector<String> vectorToReturn; + switch( cpMEC ) { + case CPMEC.MemoryCopy: + TraceManager.addDev( "**** ASSIGNED ATTRIBUTES ****\\" + assignedAttributes ); + vectorToReturn = CpuMemoryCopyMEC.sortAttributes( assignedAttributes ); + break; + case CPMEC.SingleDMA: + vectorToReturn = SingleDmaMEC.sortAttributes( assignedAttributes ); + break; + case CPMEC.DoubleDMA: + vectorToReturn = DoubleDmaMEC.sortAttributes( assignedAttributes ); + break; + default: + TraceManager.addDev( "ERROR in returning assignedAttributes" ); + vectorToReturn = assignedAttributes; + break; + } + return vectorToReturn; + } + + public ArrayList<Integer> getTransferTypes() { + ArrayList<Integer> transferTypes = new ArrayList<Integer>(); + transferTypes.add( transferType1 ); + transferTypes.add( transferType2 ); + return transferTypes; + } }