From 3de0af955585f7c612ada57259e5f1839e207d1d Mon Sep 17 00:00:00 2001 From: apvrille <ludovic.apvrille@eurecom.fr> Date: Tue, 22 May 2018 17:09:45 +0200 Subject: [PATCH] Removing useless files --- src/main/java/ui/SysCAMSPanelTranslator.java | 175 ----- .../java/ui/syscams/SysCAMSCompositePort.java | 325 --------- .../ui/syscams/SysCAMSPrimitiveComponent.java | 620 ------------------ 3 files changed, 1120 deletions(-) delete mode 100644 src/main/java/ui/SysCAMSPanelTranslator.java delete mode 100644 src/main/java/ui/syscams/SysCAMSCompositePort.java delete mode 100644 src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java diff --git a/src/main/java/ui/SysCAMSPanelTranslator.java b/src/main/java/ui/SysCAMSPanelTranslator.java deleted file mode 100644 index 09467f4e9f..0000000000 --- a/src/main/java/ui/SysCAMSPanelTranslator.java +++ /dev/null @@ -1,175 +0,0 @@ -/* 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. - */ - -package ui; - -import syscamstranslator.*; -import ui.syscams.*; - -import java.util.*; - -/** - * Class SysCAMSPanelTranslator - * Translation of semantics of SystemC-AMS Diagrams - * Creation: 08/05/2018 - * @version 1.0 08/05/2018 - * @author Irina Kit Yan LEE -*/ - -public class SysCAMSPanelTranslator { - - private List<TGComponent> tgcComponents; - - private List<SysCAMSTComponent> syscamsComponents; - private List<SysCAMSTConnector> syscamsConnectors; - - public SysCAMSPanelTranslator(SysCAMSComponentTaskDiagramPanel _syscamsDiagramPanel) { - tgcComponents = _syscamsDiagramPanel.getComponentList(); - - syscamsComponents = new LinkedList<SysCAMSTComponent>(); - syscamsConnectors = new LinkedList<SysCAMSTConnector>(); - - MakeListOfComponent(_syscamsDiagramPanel); - } - - private void MakeListOfComponent(SysCAMSComponentTaskDiagramPanel syscamsDiagramPanel) { - - Map<TGComponent, SysCAMSTComponent> syscamsMap = new HashMap<TGComponent, SysCAMSTComponent>(); - - for (TGComponent dp : tgcComponents) { - if (dp instanceof SysCAMSBlockTDF) { - SysCAMSBlockTDF blockTDF = (SysCAMSBlockTDF) dp; - - String blockTDFName = blockTDF.getValue(); - int period = blockTDF.getPeriod(); - String processCode = blockTDF.getProcessCode(); - java.util.List<SysCAMSPortTDF> tdfports = blockTDF.getAllInternalPortsTDF(); - java.util.List<SysCAMSPortConverter> convports = blockTDF.getAllInternalPortsConv(); - - SysCAMSTBlockTDF syscamsBlockTDF = new SysCAMSTBlockTDF(blockTDFName, period, processCode, tdfports, convports); - - syscamsMap.put(dp, syscamsBlockTDF); - syscamsComponents.add(syscamsBlockTDF); - - } else if (dp instanceof SysCAMSBlockDE) { - SysCAMSBlockDE blockDE = (SysCAMSBlockDE) dp; - - String blockDEName = blockDE.getValue(); - int period = blockDE.getPeriod(); - java.util.List<SysCAMSPortDE> ports = blockDE.getAllInternalPortsDE(); - - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, period, ports); - - syscamsMap.put(dp, syscamsBlockDE); - syscamsComponents.add(syscamsBlockDE); - } else if (dp instanceof SysCAMSCompositeComponent) { - SysCAMSCompositeComponent cluster = (SysCAMSCompositeComponent) dp; - - String clusterName = cluster.getValue(); - java.util.List<SysCAMSBlockTDF> blocks = cluster.getAllBlockTDFComponents(); - - SysCAMSTCluster syscamsCluster = new SysCAMSTCluster(clusterName, blocks); - - syscamsMap.put(dp, syscamsCluster); - syscamsComponents.add(syscamsCluster); - } else if (dp instanceof SysCAMSPortConverter) { - SysCAMSPortConverter portConverter = (SysCAMSPortConverter) dp; - - String portName = portConverter.getValue(); - int period = portConverter.getPeriod(); - int rate = portConverter.getRate(); - int delay = portConverter.getDelay(); - String type = portConverter.getConvType(); - - SysCAMSTPortConverter syscamsClusterPort = new SysCAMSTPortConverter(portName, period, rate, delay, type); - - syscamsMap.put(dp, syscamsClusterPort); - syscamsComponents.add(syscamsClusterPort); - } else if (dp instanceof SysCAMSPortTDF) { - SysCAMSPortTDF portTDF = (SysCAMSPortTDF) dp; - - String portName = portTDF.getValue(); - int period = portTDF.getPeriod(); - int rate = portTDF.getRate(); - int delay = portTDF.getDelay(); - String type = portTDF.getTDFType(); - int origin = portTDF.getOrigin(); - - SysCAMSTPortTDF syscamsPortTDF = new SysCAMSTPortTDF(portName, period, rate, delay, origin, type); - - syscamsMap.put(dp, syscamsPortTDF); - syscamsComponents.add(syscamsPortTDF); - } else if (dp instanceof SysCAMSPortDE) { - SysCAMSPortDE portDE = (SysCAMSPortDE) dp; - - String portName = portDE.getValue(); - int period = portDE.getPeriod(); - int rate = portDE.getRate(); - int delay = portDE.getDelay(); - String type = portDE.getDEType(); - int origin = portDE.getOrigin(); - - SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, period, rate, delay, origin, type); - - syscamsMap.put(dp, syscamsPortDE); - syscamsComponents.add(syscamsPortDE); - } else if (dp instanceof SysCAMSPortConnector) { - SysCAMSPortConnector connector = (SysCAMSPortConnector) dp; - - TGConnectingPoint connectingPoint1 = connector.get_p1(); - TGConnectingPoint connectingPoint2 = connector.get_p2(); - - TGComponent owner_p1 = syscamsDiagramPanel.getComponentToWhichBelongs(connectingPoint1); - TGComponent owner_p2 = syscamsDiagramPanel.getComponentToWhichBelongs(connectingPoint2); - - SysCAMSTComponent avowner_p1 = syscamsMap.get(owner_p1); - SysCAMSTComponent avowner_p2 = syscamsMap.get(owner_p2); - - SysCAMSTConnectingPoint avConnectingPoint1 = new SysCAMSTConnectingPoint(avowner_p1); - SysCAMSTConnectingPoint avConnectingPoint2 = new SysCAMSTConnectingPoint(avowner_p2); - - SysCAMSTConnector avconnector = new SysCAMSTConnector(avConnectingPoint1, avConnectingPoint2); - syscamsConnectors.add(avconnector); - } - } - } - - public SysCAMSSpecification getSysCAMSSpecification() { - return new SysCAMSSpecification(syscamsComponents, syscamsConnectors); - } -} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSCompositePort.java b/src/main/java/ui/syscams/SysCAMSCompositePort.java deleted file mode 100644 index 5a8ac86da5..0000000000 --- a/src/main/java/ui/syscams/SysCAMSCompositePort.java +++ /dev/null @@ -1,325 +0,0 @@ -/* 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. - */ - -package ui.syscams; - -import myutil.GraphicLib; -import ui.*; -import ui.util.IconManager; -import ui.window.JDialogSysCAMSPortConverter; - -import java.awt.*; -import javax.swing.ImageIcon; -import javax.swing.JFrame; - -/** - * Class SysCAMSCompositePort - * Composite port. To be used in SystemC-AMS diagrams - * Creation: 29/04/2018 - * @version 1.0 29/04/2018 - * @author Irina Kit Yan LEE - */ - -public class SysCAMSCompositePort extends SysCAMSChannelFacility implements SwallowedTGComponent, WithAttributes { - private int oldx, oldy; - private int halfwidth = 13; - private int currentOrientation = GraphicLib.NORTH; - protected int decPoint = 3; - private ImageIcon portImageIconW, portImageIconE, portImageIconN, portImageIconS; - public String commName; - - // Attributes - public String portName; - public int period; - public int rate; - public int delay; - public String type; - public String origin; - - public SysCAMSCompositePort(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(2*halfwidth, 2*halfwidth); - - minWidth = 10; - minHeight = 10; - - nbConnectingPoint = 10; - connectingPoint = new TGConnectingPoint[10]; - int i; - for (i=0; i<5; i++) { - connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); - } - for(i=5; i<10; i++) { - connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); - } - - addTGConnectingPointsComment(); - - nbInternalTGComponent = 0; - - value = ""; - name = "Composite port"; - commName = "port"; - - myImageIcon = IconManager.imgic1204; - portImageIconW = IconManager.imgic8002; - portImageIconE = IconManager.imgic8003; - portImageIconN = IconManager.imgic8004; - portImageIconS = IconManager.imgic8005; - - // Initialization of port attributes - ((SysCAMSPortConverter) this).setPeriod(0); - ((SysCAMSPortConverter) this).setDelay(0); - ((SysCAMSPortConverter) this).setRate(0); - ((SysCAMSPortConverter) this).setConvType(""); - ((SysCAMSPortConverter) this).setOrigin(""); - } - - public void internalDrawing(Graphics g) { - if ((x != oldx) | (oldy != y)) { - // Component has moved! - manageMove(); - oldx = x; - oldy = y; - } - if (rescaled) { - rescaled = false; - } - - calculatePortColor(); - - // Zoom is assumed to be computed - Color c = g.getColor(); - g.setColor(c); - - TGComponent tgc = getFather(); - - if ((tgc != null) && (tgc instanceof SysCAMSCompositeComponent)) { - if (tgc instanceof SysCAMSCompositeComponent && this instanceof SysCAMSCompositePort) { - switch(currentOrientation) { - case GraphicLib.NORTH: - g.drawRect(x-1+width/2-portImageIconN.getIconWidth()/2, y-1+height/2-portImageIconN.getIconHeight()/2, portImageIconN.getIconWidth()+2, portImageIconN.getIconHeight()+2); - g.drawImage(portImageIconN.getImage(), x+width/2-portImageIconN.getIconWidth()/2, y+height/2-portImageIconN.getIconHeight()/2, null); - break; - case GraphicLib.SOUTH: - g.drawRect(x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, portImageIconS.getIconWidth(), portImageIconS.getIconHeight()); - g.drawImage(portImageIconS.getImage(), x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, null); - break; - case GraphicLib.WEST: - g.drawRect(x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, portImageIconW.getIconWidth(), portImageIconW.getIconHeight()); - g.drawImage(portImageIconW.getImage(), x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, null); - break; - case GraphicLib.EAST: - default: - g.drawRect(x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, portImageIconE.getIconWidth(), portImageIconE.getIconHeight()); - g.drawImage(portImageIconE.getImage(), x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, null); - } - } - } - - int ft = 10; - if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) { - ft = ((SysCAMSPrimitiveComponent)tgc).getCurrentFontSize(); - } - int w; - Font f = g.getFont(); - Font fold = f; - - int si = Math.min(8, (int)((float)ft - 2)); - f = f.deriveFont((float)si); - g.setFont(f); - w = g.getFontMetrics().stringWidth(commName); - if (w < ((int)(width * 1.5))) { - g.drawString(commName, x, y-1); - } - - g.setFont(fold); - - // Draw arrow showing the connection if necessary - if ((!conflict) && (outp != null || inp != null)) { - int wayTo = currentOrientation; - if (inp != null) { - if (inpIndex > 4) { - wayTo = (wayTo + 2 )% 4; - } - } else { - if (outpIndex < 5) { - wayTo = (wayTo + 2 )% 4; - } - } - - int []px = new int[3]; - int []py = new int[3]; - switch(wayTo) { - case GraphicLib.NORTH: - case GraphicLib.SOUTH: - px[0] = x+width/2; - px[1] = x +width/2; - py[0] = y; - py[1] = y + height; - break; - case GraphicLib.EAST: - case GraphicLib.WEST: - default: - px[0] = x; - px[1] = x +width; - py[0] = y+height/2; - py[1] = y + height/2; - break; - } - g.drawPolygon(px, py, 2); - } - } - - public void manageMove() { - if (father != null) { - Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); - - x = p.x - width/2; - y = p.y - height/2; - - setMoveCd(x, y); - - int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); - if (orientation != currentOrientation) { - setOrientation(orientation); - } - } - } - - // TGConnecting points .. - public void setOrientation(int orientation) { - currentOrientation = orientation; - double w0, h0,w1, h1; - - switch(orientation) { - case GraphicLib.NORTH: - w0 = 0.5; - h0 = 0.0; - w1 = 0.5; - h1 = 1.0; - break; - case GraphicLib.WEST: - w0 = 0.0; - h0 = 0.5; - w1 = 1.0; - h1 = 0.5; - break; - case GraphicLib.SOUTH: - w1 = 0.5; - h1 = 0.0; - w0 = 0.5; - h0 = 1.0; - break; - case GraphicLib.EAST: - default: - w1 = 0.0; - h1 = 0.5; - w0 = 1.0; - h0 = 0.5; - } - - for (int i=0; i<5; i++) { - ((SysCAMSPortConnectingPoint)(connectingPoint[i])).setW(w0); - ((SysCAMSPortConnectingPoint)(connectingPoint[i])).setH(h0); - ((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setW(w1); - ((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setH(h1); - } - } - - public int getType() { - return TGComponentManager.TMLCTD_CPORT; - } - - public void wasSwallowed() { - myColor = null; - } - - public void wasUnswallowed() { - myColor = null; - setFather(null); - TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); - } - - public void resizeWithFather() { - if ((father != null) && (father instanceof SysCAMSCompositeComponent)) { - // Too large to fit in the father? -> resize it! - setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2)); - setMoveCd(x, y); - oldx = -1; - oldy = -1; - } - } - - public boolean editOndoubleClick(JFrame frame) { - JDialogSysCAMSPortConverter jtdf = new JDialogSysCAMSPortConverter((SysCAMSPortConverter) this); - jtdf.setVisible(true); - - ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts(); - return true; - } - - public String getPortName() { - return commName; - } - - public void setPortName(String s) { - commName = s; - } - - public void purge() { - inp = null; - outp = null; - conflict = false; - inpIndex = -1; - outpIndex = -1; - myColor = null; - calculatePortColor(); - } - - public void myActionWhenRemoved() { - tdp = null; - TGComponent tgc = getFather(); - if (tgc instanceof SysCAMSCompositeComponent) { - ((SysCAMSCompositeComponent)(tgc)).portRemoved(); - } - father = null; - } -} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java b/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java deleted file mode 100644 index 152f6ea18b..0000000000 --- a/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java +++ /dev/null @@ -1,620 +0,0 @@ -/* 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. - */ - -package ui.syscams; - -import myutil.GraphicLib; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import ui.*; -import ui.util.IconManager; -//import ui.window.JDialogAttribute; -import ui.window.JDialogSysCAMSBlockDE; -import ui.window.JDialogSysCAMSBlockTDF; - -import javax.swing.*; -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Vector; - -/** - * Class SysCAMSPrimitiveComponent - * Primitive Component. To be used in SystemC-AMSdiagrams - * Creation: 27/04/2018 - * @version 1.0 27/04/2018 - * @author Irina Kit Yan LEE - */ - -public class SysCAMSPrimitiveComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, WithAttributes { - private int maxFontSize = 14; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private Color myColor; - - private boolean isAttacker=false; - // Icon - private int iconSize = 15; -// private boolean iconIsDrawn = false; - - // Attributes - public HashMap<String, Integer> attrMap = new HashMap<String, Integer>(); - public String mappingName; - protected LinkedList<TAttribute> myAttributes; - private int textX = 15; // border for ports - private double dtextX = 0.0; - - public String oldValue; - - public SysCAMSPrimitiveComponent(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, 150); - - oldScaleFactor = tdp.getZoom(); - dtextX = textX * oldScaleFactor; - textX = (int)dtextX; - dtextX = dtextX - textX; - - minWidth = 1; - minHeight = 1; - - nbConnectingPoint = 0; - - addTGConnectingPointsComment(); - - nbInternalTGComponent = 0; - - moveable = true; - multieditable = true; - editable = true; - removable = true; - userResizable = true; - - if (this instanceof SysCAMSBlockTDF) { - value = "TDF_Block"; - } else if (this instanceof SysCAMSBlockDE) { - value = "DE_Block"; - } - -// oldValue = value; -// setName("Primitive component"); - name = "Primitive component"; - - myImageIcon = IconManager.imgic1202; - - myAttributes = new LinkedList<TAttribute> (); - - actionOnAdd(); - } - - public void internalDrawing(Graphics g) { - int w; - Font f = g.getFont(); - Font fold = f; - - if (myColor == null) { - if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) { - myColor = Color.white; - } else { - if (this instanceof SysCAMSBlockTDF) { - myColor = Color.lightGray; - } else { - myColor = Color.white; - } - } - } - if ((rescaled) && (!tdp.isScaled())) { - if (currentFontSize == -1) { - currentFontSize = f.getSize(); - } - rescaled = false; - // Must set the font size .. - // Find the biggest font not greater than max_font size - // By Increment of 1 - // Or decrement of 1 - // If font is less than 4, no text is displayed - - int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize)); - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - while(maxCurrentFontSize > (minFontSize-1)) { - if (g.getFontMetrics().stringWidth(value) < (width - iconSize - (2 * textX))) { - break; - } - maxCurrentFontSize --; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - } - currentFontSize = maxCurrentFontSize; - if(currentFontSize <minFontSize) { - displayText = false; - } else { - displayText = true; - f = f.deriveFont((float)currentFontSize); - g.setFont(f); - } - } - - // Zoom is assumed to be computed - Color c = g.getColor(); - g.drawRect(x, y, width, height); - if ((width > 2) && (height > 2)) { - g.setColor(myColor); - g.fillRect(x+1, y+1, width-1, height-1); - g.setColor(c); - } - - // Font size - if (displayText) { - f = f.deriveFont((float)currentFontSize); - g.setFont(f); - w = g.getFontMetrics().stringWidth(value); - if (w > (width - 2 * (iconSize + textX))) { - g.drawString(value, x + textX + 1, y + currentFontSize + textX); - - if (this instanceof SysCAMSBlockTDF) { - String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod(); - g.drawString(s, x + textX + 1, y + height - currentFontSize - textX); - } else if (this instanceof SysCAMSBlockDE) { - String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod(); - g.drawString(s, x + textX + 1, y + height - currentFontSize - textX); - } - } else { - g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); - if (this instanceof SysCAMSBlockTDF) { - String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod(); - w = g.getFontMetrics().stringWidth(s); - g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX); - } else if (this instanceof SysCAMSBlockDE) { - String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod(); - w = g.getFontMetrics().stringWidth(s); - g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX); - } - } - } - -// // Icon -// if ((width>30) && (height > (iconSize + 2*textX))) { -// iconIsDrawn = true; -// g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); -// } else { -// iconIsDrawn = false; -// } -// if (isAttacker){ -// g.drawImage(IconManager.imgic7008.getImage(), x + width - 2*iconSize - textX, y + 2*textX, null); -// } - - // Attributes - if (tdp.areAttributesVisible()) { - int index = 0; - int cpt = currentFontSize + 2 * textX; - String attr; - - TAttribute a; - - int si = Math.min(12, (int)((float)currentFontSize - 2)); - - f = g.getFont(); - f = f.deriveFont((float)si); - g.setFont(f); - int step = si + 2; - - while(index < myAttributes.size()) { - cpt += step; - if (cpt >= (height - textX)) { - break; - } - a = myAttributes.get (index); - attr = a.toString(); - w = g.getFontMetrics().stringWidth(attr); - if ((w + (2 * textX) + 1) < width) { - g.drawString(attr, x + textX, y + cpt); - drawVerification(g, x + textX, y+ cpt, a.getConfidentialityVerification()); - } else { - attr = "..."; - w = g.getFontMetrics().stringWidth(attr); - if ((w + textX + 2) < width) { - g.drawString(attr, x + textX + 1, y + cpt); - } else { - // skip attribute - cpt -= step; - } - } - index ++; - } - } - g.setFont(fold); - } - public void drawVerification(Graphics g, int x, int y, int checkConfStatus){ - Color c = g.getColor(); - Color c1; - switch(checkConfStatus) { - case TAttribute.CONFIDENTIALITY_OK: - c1 = Color.green; - break; - case TAttribute.CONFIDENTIALITY_KO: - c1 = Color.red; - break; - default: - return; - } - g.drawOval(x-10, y-10, 6, 9); - g.setColor(c1); - g.fillRect(x-12, y-5, 9, 7); - g.setColor(c); - g.drawRect(x-12, y-5, 9, 7); - } - - public void rescale(double scaleFactor){ - dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; - textX = (int)(dtextX); - dtextX = dtextX - textX; - super.rescale(scaleFactor); - } - - public TGComponent isOnOnlyMe(int _x, int _y) { - if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { - return this; - } - return null; - } - - - public boolean isAttacker(){ - return isAttacker; - } - - public boolean editOndoubleClick(JFrame frame, int _x, int _y) { -// // On the icon? -// if (iconIsDrawn) { -// if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) { -// tdp.getMouseManager().setSelection(-1, -1); -// tdp.selectTab(getValue()); -// return true; -// } -// } - // On the name ? -// if ((displayText) && (_y <= (y + currentFontSize + textX))) { -//// oldValue = value; -// String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name", -// JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, -// null, -// getValue()); -// if ((s != null) && (s.length() > 0)) { -// // Check whether this name is already in use, or not -// if (!TAttribute.isAValidId(s, false, false)) { -// JOptionPane.showMessageDialog(frame, -// "Could not change the name of the component: the new name is not a valid name", -// "Error", -// JOptionPane.INFORMATION_MESSAGE); -// return false; -// } -// if (oldValue.compareTo(s) != 0) { -// if (((SysCAMSComponentTaskDiagramPanel)(tdp)).namePrimitiveComponentInUse(oldValue, s)) { -// JOptionPane.showMessageDialog(frame, -// "Error: the name is already in use", -// "Name modification", -// JOptionPane.ERROR_MESSAGE); -// return false; -// } -// } -// if (((SysCAMSComponentTaskDiagramPanel)(tdp)).isCompositeNameUsed(s)) { -// JOptionPane.showMessageDialog(frame, -// "Error: the name is already in use", -// "Name modification", -// JOptionPane.ERROR_MESSAGE); -// return false; -// } -// setComponentName(s); -// setValueWithChange(s); -//// isAttacker = s.contains("Attacker"); -// rescaled = true; -// return true; -// -// } -// return false; -// } - - // And so -> attributes! -// JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting attributes of " + value, "Attribute"); -// setJDialogOptions(jda); -// GraphicLib.centerOnParent(jda, 650, 375); - if (this instanceof SysCAMSBlockTDF) { - JDialogSysCAMSBlockTDF jtdf = new JDialogSysCAMSBlockTDF((SysCAMSBlockTDF) this); - jtdf.setVisible(true); - } else { - JDialogSysCAMSBlockDE jde = new JDialogSysCAMSBlockDE((SysCAMSBlockDE) this); - jde.setVisible(true); - } -// jda.setVisible(true); // blocked until dialog has been closed - rescaled = true; - return true; - - } - -// protected void setJDialogOptions(JDialogAttribute jda) { -// jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); -// jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); -// jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true); -// jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true); -// -// Vector<String> records = ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this); -// for(String s: records) { -// jda.addType(s, false); -// } -// jda.enableInitialValue(true); -// jda.enableRTLOTOSKeyword(true); -// jda.enableJavaKeyword(false); -// jda.enableTMLKeyword(false); -// } - - public Vector<String> getAllRecords() { - return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this); - } - - public SysCAMSRecordComponent getRecordNamed(String _nameOfRecord) { - return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getRecordNamed(this, _nameOfRecord); - } - - public int getType() { - return TGComponentManager.TMLCTD_PCOMPONENT; - } - - public void wasSwallowed() { - myColor = null; - } - - public void wasUnswallowed() { - myColor = null; - setFather(null); - TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); - } - - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof SysCAMSPrimitivePort; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - //TraceManager.addDev("Add swallow component"); - // Choose its position - // Make it an internal component - // It's one of my son - //Set its coordinates - if (tgc instanceof SysCAMSPrimitivePort) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof SysCAMSPrimitivePort) { - tgcomponent[i].resizeWithFather(); - } - } - if (getFather() != null) { - resizeWithFather(); - } - } - - public void resizeWithFather() { - if ((father != null) && (father instanceof SysCAMSCompositeComponent)) { - // Too large to fit in the father? -> resize it! - resizeToFatherSize(); - - setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); - setMoveCd(x, y); - } - } - - public int getChildCount() { - return myAttributes.size() + nbInternalTGComponent + 1; - } - - public Object getChild(int index) { - if (index == 0) { - return value; - } else { - if (index <= myAttributes.size()) { - return myAttributes.get (index-1); - } else { - return tgcomponent[index-1-myAttributes.size()]; - } - } - } - - public int getIndexOfChild(Object child) { - if (child instanceof String) { - return 0; - } else { - if (myAttributes.indexOf(child) > -1) { - return myAttributes.indexOf(child) + 1; - } else { - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] == child) { - return myAttributes.size() + 1 + i; - } - } - } - } - return -1; - } - - protected String translateExtraParam() { - TAttribute a; - StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append("<Data isAttacker=\""); - sb.append(isAttacker() ? "Yes": "No"); - sb.append("\" />\n"); - for(int i=0; i<myAttributes.size(); i++) { - a = myAttributes.get (i); - sb.append("<Attribute access=\""); - sb.append(a.getAccess()); - sb.append("\" id=\""); - sb.append(a.getId()); - sb.append("\" value=\""); - sb.append(a.getInitialValue()); - sb.append("\" type=\""); - sb.append(a.getType()); - sb.append("\" typeOther=\""); - sb.append(a.getTypeOther()); - sb.append("\" />\n"); - } - 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; - int access, type; - String typeOther; - String id, valueAtt; - - for(int i=0; i<nl.getLength(); i++) { - n1 = nl.item(i); - if (n1.getNodeType() == Node.ELEMENT_NODE) { - nli = n1.getChildNodes(); - for(int j=0; j<nli.getLength(); j++) { - n2 = nli.item(j); - if (n2.getNodeType() == Node.ELEMENT_NODE) { - elt = (Element) n2; - if (elt.getTagName().equals("Data")) { - isAttacker = elt.getAttribute("isAttacker").equals("Yes"); - } - if (elt.getTagName().equals("Attribute")) { - access = Integer.decode(elt.getAttribute("access")).intValue(); - type = Integer.decode(elt.getAttribute("type")).intValue(); - try { - typeOther = elt.getAttribute("typeOther"); - } catch (Exception e) { - typeOther = ""; - } - id = elt.getAttribute("id"); - valueAtt = elt.getAttribute("value"); - - if (valueAtt.equals("null")) { - valueAtt = ""; - } - if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) { - TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther); - myAttributes.add (ta); - } - } - } - } - } - } - } catch (Exception e) { - throw new MalformedModelingException(); - } - } - - public int getCurrentFontSize() { - return currentFontSize; - } - - public java.util.List<TAttribute> getAttributeList() { - return myAttributes; - } - - public java.util.List<SysCAMSPrimitivePort> getAllTDFOriginPorts() { - return getAllPorts(0, true); - } - - public java.util.List<SysCAMSPrimitivePort> getAllTDFDestinationPorts() { - return getAllPorts(0, false); - } - - public java.util.List<SysCAMSPrimitivePort> getAllDEOriginPorts() { - return getAllPorts(1, true); - } - - public java.util.List<SysCAMSPrimitivePort> getAllDEDestinationPorts() { - return getAllPorts(1, false); - } - - public java.util.List<SysCAMSPrimitivePort> getAllPorts(int _type, boolean _isOrigin) { - java.util.List<SysCAMSPrimitivePort> ret = new LinkedList<SysCAMSPrimitivePort>(); - SysCAMSPrimitivePort port; - - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof SysCAMSPrimitivePort) { - port = (SysCAMSPrimitivePort)tgcomponent[i]; - if ((port.getPortType() == _type) && (port.isOrigin() == _isOrigin)) { - ret.add(port); - } - } - } - return ret; - } - - public java.util.List<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() { - java.util.List<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>(); - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof SysCAMSPrimitivePort) { - list.add((SysCAMSPrimitivePort)(tgcomponent[i])); - } - } - return list; - } - - public String getAttributes() { - String attr = ""; - for (TAttribute a: myAttributes) { - attr += a.toAvatarString() + "\n"; - } - return attr; - } -} \ No newline at end of file -- GitLab