diff --git a/src/ui/tmlcompd/TMLCPath.java b/src/ui/tmlcompd/TMLCPath.java index 62ed4cca8e50a2dd8c5b350c06084f8eb2c61dd7..4bdcc6d875f98a669f01c5976a12ec3218cfbdef 100755 --- a/src/ui/tmlcompd/TMLCPath.java +++ b/src/ui/tmlcompd/TMLCPath.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 TMLCPath - * Notion of Path. To be used to analyze the correctness of paths in the model - * Creation: 7/03/2014 - * @version 1.0 7/03/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 TMLCPath + * Notion of Path. To be used to analyze the correctness of paths in the model + * Creation: 7/03/2014 + * @version 1.0 7/03/2014 + * @author Ludovic APVRILLE + * @see + */ package ui.tmlcompd; @@ -59,250 +59,289 @@ import ui.window.*; import tmltranslator.*; public class TMLCPath { - - public ArrayList<TMLCPrimitivePort> producerPorts; - public ArrayList<TMLCPrimitivePort> consumerPorts; - - // Facilities - public ArrayList<TMLCCompositePort> cports; - public ArrayList<TMLCFork> forks; - public ArrayList<TMLCJoin> joins; - - private HashMap links; - // Create the notion of pair of (tgcomponent, tgcomponent) as the key of the hashmap. - - private boolean errorOfConnection = false; - - private int errorNumber; - - private String[] errors = {"Fork and Join operators in the same path", - "Must have at least one sender", - "Must have at least one receiver", - "More than one sender in a path with a fork", - "Senders and receivers are not of the same kind", - "One of more element of the path is badly connected"}; - - public TMLCPath() { - cports = new ArrayList<TMLCCompositePort>(); - producerPorts = new ArrayList<TMLCPrimitivePort>(); - consumerPorts = new ArrayList<TMLCPrimitivePort>(); - forks = new ArrayList<TMLCFork>(); - joins = new ArrayList<TMLCJoin>(); - links = new HashMap(); - } - - public void addComponent(TGComponent _tgc) { - if (_tgc instanceof TMLCCompositePort) { - cports.add((TMLCCompositePort)_tgc); - } - - if (_tgc instanceof TMLCPrimitivePort) { - TMLCPrimitivePort p = (TMLCPrimitivePort)_tgc; - if (p.isOrigin()) { - producerPorts.add(p); - } else { - consumerPorts.add(p); - } - } - - if (_tgc instanceof TMLCFork) { - forks.add((TMLCFork)_tgc); - } - - if (_tgc instanceof TMLCJoin) { - joins.add((TMLCJoin)_tgc); - } - - - } - - public void setErrorOfConnection(boolean _err) { - errorOfConnection = _err; - } - - public boolean getErrorOfConnection() { - return errorOfConnection; - } - - public boolean contains(TGComponent tgc) { - if (cports.contains(tgc)) { - return true; - } - - if (producerPorts.contains(tgc)) { - return true; - } - - if (consumerPorts.contains(tgc)) { - return true; - } - - if (forks.contains(tgc)) { - return true; - } - - if (joins.contains(tgc)) { - return true; - } - - return false; - - } - - public void mergeWith(TMLCPath _path) { - cports.addAll(_path.cports); - producerPorts.addAll(_path.producerPorts); - consumerPorts.addAll(_path.consumerPorts); - forks.addAll(_path.forks); - joins.addAll(_path.joins); - setErrorOfConnection(getErrorOfConnection() || _path.getErrorOfConnection()); - } - - - public boolean hasError() { - return (errorNumber != -1); - } - - public String getErrorMessage() { - if (hasError()) { - return errors[errorNumber]; - } - - return ""; - } - - - public void checkRules() { - errorNumber = -1; - - //rule0: fork or join, but not both - if ((forks.size() > 0) && (joins.size() >0)) { - errorNumber = 0; - } - - //rule1: Must have at least one producer - if (producerPorts.size() == 0) { - errorNumber = 1; - } - - //rule2: Must have at least one receiver - if (consumerPorts.size() == 0) { - errorNumber = 2; - } - - //rule3: If fork: must have only one producer - if ((forks.size() > 0) && (producerPorts.size() >1)) { - errorNumber = 3; - } - - //rule4: producers and consumers must be of the same type - if ((consumerPorts.size()>0) && (producerPorts.size()>0)) { - int type = consumerPorts.get(0).getPortType(); - for(TMLCPrimitivePort porto: producerPorts) { - if (porto.getPortType() != type) { - errorNumber = 4; - break; - } - } - for(TMLCPrimitivePort porti: consumerPorts) { - if (porti.getPortType() != type) { - errorNumber = 4; - break; - } - } - } - - //rule5: Error of connection - if (errorOfConnection) { - errorNumber = 5; - } + + public ArrayList<TMLCPrimitivePort> producerPorts; + public ArrayList<TMLCPrimitivePort> consumerPorts; + + // Facilities + public ArrayList<TMLCCompositePort> cports; + public ArrayList<TMLCFork> forks; + public ArrayList<TMLCJoin> joins; + + private HashMap links; + // Create the notion of pair of (tgcomponent, tgcomponent) as the key of the hashmap. + + private boolean errorOfConnection = false; + + private int errorNumber; + + private String[] errors = {"Fork and Join operators in the same path", + "Must have at least one sender", + "Must have at least one receiver", + "More than one sender in a path with a fork", + "Senders and receivers are not of the same kind", + "One of more element of the path is badly connected", + "Events are not compatible with fork/join", + "Requests are not compatible with fork/join"}; + + public TMLCPath() { + cports = new ArrayList<TMLCCompositePort>(); + producerPorts = new ArrayList<TMLCPrimitivePort>(); + consumerPorts = new ArrayList<TMLCPrimitivePort>(); + forks = new ArrayList<TMLCFork>(); + joins = new ArrayList<TMLCJoin>(); + links = new HashMap(); + } + + public void addComponent(TGComponent _tgc) { + if (_tgc instanceof TMLCCompositePort) { + cports.add((TMLCCompositePort)_tgc); + } + + if (_tgc instanceof TMLCPrimitivePort) { + TMLCPrimitivePort p = (TMLCPrimitivePort)_tgc; + if (p.isOrigin()) { + producerPorts.add(p); + } else { + consumerPorts.add(p); + } + } + + if (_tgc instanceof TMLCFork) { + forks.add((TMLCFork)_tgc); + } + + if (_tgc instanceof TMLCJoin) { + joins.add((TMLCJoin)_tgc); + } + + + } + + public void setErrorOfConnection(boolean _err) { + errorOfConnection = _err; + } + + public boolean getErrorOfConnection() { + return errorOfConnection; + } + + public boolean contains(TGComponent tgc) { + if (cports.contains(tgc)) { + return true; + } + + if (producerPorts.contains(tgc)) { + return true; + } + + if (consumerPorts.contains(tgc)) { + return true; + } + + if (forks.contains(tgc)) { + return true; + } + + if (joins.contains(tgc)) { + return true; + } + + return false; + + } + + public void mergeWith(TMLCPath _path) { + cports.addAll(_path.cports); + producerPorts.addAll(_path.producerPorts); + consumerPorts.addAll(_path.consumerPorts); + forks.addAll(_path.forks); + joins.addAll(_path.joins); + setErrorOfConnection(getErrorOfConnection() || _path.getErrorOfConnection()); + } + + + public boolean hasError() { + return (errorNumber != -1); + } + + public String getErrorMessage() { + if (hasError()) { + return errors[errorNumber]; + } + + return ""; + } + + + public void checkRules() { + errorNumber = -1; + + //rule0: fork or join, but not both + if ((forks.size() > 0) && (joins.size() >0)) { + errorNumber = 0; + } + + //rule1: Must have at least one producer + if (producerPorts.size() == 0) { + errorNumber = 1; + } + + //rule2: Must have at least one receiver + if (consumerPorts.size() == 0) { + errorNumber = 2; + } + + //rule3: If fork: must have only one producer + if ((forks.size() > 0) && (producerPorts.size() >1)) { + errorNumber = 3; + } + + //rule4: producers and consumers must be of the same type + if ((consumerPorts.size()>0) && (producerPorts.size()>0)) { + int type = consumerPorts.get(0).getPortType(); + for(TMLCPrimitivePort porto: producerPorts) { + if (porto.getPortType() != type) { + errorNumber = 4; + break; + } + } + for(TMLCPrimitivePort porti: consumerPorts) { + if (porti.getPortType() != type) { + errorNumber = 4; + break; + } + } + } + + //rule5: Error of connection + if (errorOfConnection) { + errorNumber = 5; + } + + //rule6: events cannot be connected through fork or join + if ((forks.size() > 0) || (joins.size() >0)) { + // Look for event, either at origin, or at destination + for(TMLCPrimitivePort porto: producerPorts) { + if (porto.getPortType() == 1) { + errorNumber = 6; + break; + } + } + for(TMLCPrimitivePort porti: consumerPorts) { + if (porti.getPortType() == 1) { + errorNumber = 6; + break; + } + } + } - - public void setColor() { - /*if (hasError()) { - // Setting the red color - }*/ - - // For each channel facility, - // set the inp and outp primitive ports if possible (otherwise, null) - // if no error: set conflict to false - // If error -> set the conflict to true - - for(TMLCFork fork: forks) { - if (producerPorts.size() > 0) { - fork.setOutPort(producerPorts.get(0)); - } else { - fork.setOutPort(null); - } - - if (consumerPorts.size() > 0) { - fork.setInPort(consumerPorts.get(0)); - } else { - fork.setInPort(null); - } - - if (hasError()) { - fork.setConflict(hasError(), errors[errorNumber]); - } else { - fork.setConflict(false, ""); - } - } - - for(TMLCJoin join: joins) { - if (producerPorts.size() > 0) { - join.setOutPort(producerPorts.get(0)); - } else { - join.setOutPort(null); - } - - if (consumerPorts.size() > 0) { - join.setInPort(consumerPorts.get(0)); - } else { - join.setInPort(null); - } - if (hasError()) { - join.setConflict(hasError(), errors[errorNumber]); - } else { - join.setConflict(false, ""); - } - } - - for(TMLCCompositePort port: cports) { - if (producerPorts.size() > 0) { - port.setOutPort(producerPorts.get(0)); - } else { - port.setOutPort(null); - } - - if (consumerPorts.size() > 0) { - port.setInPort(consumerPorts.get(0)); - } else { - port.setInPort(null); - } - if (hasError()) { - port.setConflict(hasError(), errors[errorNumber]); - } else { - port.setConflict(false, ""); - } - } - - for(TMLCPrimitivePort pport: producerPorts) { - if (hasError()) { - pport.setConflict(hasError(), errors[errorNumber]); - } else { - pport.setConflict(false, ""); - } - } - for(TMLCPrimitivePort cport: consumerPorts) { - if (hasError()) { - cport.setConflict(hasError(), errors[errorNumber]); - } else { - cport.setConflict(false, ""); - } - } + + //rule7: requests cannot be connected through fork or join + if ((forks.size() > 0) || (joins.size() >0)) { + // Look for event, either at origin, or at destination + for(TMLCPrimitivePort porto: producerPorts) { + if (porto.getPortType() == 2) { + errorNumber = 7; + break; + } + } + for(TMLCPrimitivePort porti: consumerPorts) { + if (porti.getPortType() == 2) { + errorNumber = 7; + break; + } + } + } - + } + + public void setColor() { + /*if (hasError()) { + // Setting the red color + }*/ + + // For each channel facility, + // set the inp and outp primitive ports if possible (otherwise, null) + // if no error: set conflict to false + // If error -> set the conflict to true + + for(TMLCFork fork: forks) { + if (producerPorts.size() > 0) { + fork.setOutPort(producerPorts.get(0)); + } else { + fork.setOutPort(null); + } + + if (consumerPorts.size() > 0) { + fork.setInPort(consumerPorts.get(0)); + } else { + fork.setInPort(null); + } + + if (hasError()) { + fork.setConflict(hasError(), errors[errorNumber]); + } else { + fork.setConflict(false, ""); + } + } + + for(TMLCJoin join: joins) { + if (producerPorts.size() > 0) { + join.setOutPort(producerPorts.get(0)); + } else { + join.setOutPort(null); + } + + if (consumerPorts.size() > 0) { + join.setInPort(consumerPorts.get(0)); + } else { + join.setInPort(null); + } + if (hasError()) { + join.setConflict(hasError(), errors[errorNumber]); + } else { + join.setConflict(false, ""); + } + } + + for(TMLCCompositePort port: cports) { + if (producerPorts.size() > 0) { + port.setOutPort(producerPorts.get(0)); + } else { + port.setOutPort(null); + } + + if (consumerPorts.size() > 0) { + port.setInPort(consumerPorts.get(0)); + } else { + port.setInPort(null); + } + if (hasError()) { + port.setConflict(hasError(), errors[errorNumber]); + } else { + port.setConflict(false, ""); + } + } + + for(TMLCPrimitivePort pport: producerPorts) { + if (hasError()) { + pport.setConflict(hasError(), errors[errorNumber]); + } else { + pport.setConflict(false, ""); + } + } + for(TMLCPrimitivePort cport: consumerPorts) { + if (hasError()) { + cport.setConflict(hasError(), errors[errorNumber]); + } else { + cport.setConflict(false, ""); + } + } + } + + + - } diff --git a/src/ui/tmlcompd/TMLCPortConnector.java b/src/ui/tmlcompd/TMLCPortConnector.java index 95f1a191fb65d4c119d355189988880bff0631ff..2c3df9b8291bc232bbbb45550d4df6d670884ed0 100755 --- a/src/ui/tmlcompd/TMLCPortConnector.java +++ b/src/ui/tmlcompd/TMLCPortConnector.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 TMLCPortConnector - * Connector used in TML Component task diagrams - * Creation: 12/03/2008 - * @version 1.0 12/03/2008 - * @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 TMLCPortConnector + * Connector used in TML Component task diagrams + * Creation: 12/03/2008 + * @version 1.0 12/03/2008 + * @author Ludovic APVRILLE + * @see + */ package ui.tmlcompd; @@ -62,211 +62,211 @@ import ui.window.*; public class TMLCPortConnector extends TGConnector implements ScalableTGComponent, SpecificActionAfterAdd, SpecificActionAfterMove{ //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; - - //protected int priority = 0; // Between 0 and 10 - - //protected double dx, dy; - protected double oldScaleFactor; - //protected TGConnectingPoint oldp1, oldp2; - - + + //protected int priority = 0; // Between 0 and 10 + + //protected double dx, dy; + protected double oldScaleFactor; + //protected TGConnectingPoint oldp1, oldp2; + + public TMLCPortConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; value = "Connector between ports"; editable = false; - - oldScaleFactor = tdp.getZoom(); - - //oldp1 = null; - //oldp2 = null; - - //System.out.println("Action on add from connector"); - //actionOnAdd(); - //System.out.println("Action on add done from connector"); + + oldScaleFactor = tdp.getZoom(); + + //oldp1 = null; + //oldp2 = null; + + //System.out.println("Action on add from connector"); + //actionOnAdd(); + //System.out.println("Action on add done from connector"); } - + /*public boolean editOndoubleClick(JFrame frame) { - JDialogTMLConnectorNode dialog = new JDialogTMLConnectorNode(frame, "Setting connector attributes", this); - dialog.setSize(350, 300); - GraphicLib.centerOnParent(dialog); - dialog.show(); // blocked until dialog has been closed - - if (!dialog.isRegularClose()) { - return false; - } - - priority = dialog.getPriority(); - - return true; - }*/ - + JDialogTMLConnectorNode dialog = new JDialogTMLConnectorNode(frame, "Setting connector attributes", this); + dialog.setSize(350, 300); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + priority = dialog.getPriority(); + + return true; + }*/ + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { - /*if ((p1 != oldp1) || (p2 != oldp2)) { - if (tdp instanceof TMLComponentTaskDiagramPanel) { - ((TMLComponentTaskDiagramPanel)tdp).updateConnectors(this, oldp1, oldp2, p1, p2); - } - }*/ - - try { - TMLCPortConnectingPoint pt1 = (TMLCPortConnectingPoint)p1; - TMLCPortConnectingPoint pt2 = (TMLCPortConnectingPoint)p2; - - - if (!pt1.positionned) { - pt1.positionned = true; - if (pt1.getFather() instanceof TMLCPrimitivePort) { - pt1.port = (TMLCPrimitivePort)(pt1.getFather()); - } - } - - if (!pt2.positionned) { - pt2.positionned = true; - if (pt2.getFather() instanceof TMLCPrimitivePort) { - pt2.port = (TMLCPrimitivePort)(pt2.getFather()); - } - } - - if ((pt1.port != null) && (pt2.port != null)) { - String name1 = pt1.port.getPortName(); - String name2 = pt2.port.getPortName(); - if (name1.equals(name2)) { - int w = g.getFontMetrics().stringWidth(name1); - Font fold = g.getFont(); - Font f = fold.deriveFont(Font.ITALIC, (float)(tdp.getFontSize())); - g.setFont(f); - g.drawString(name1, (x1 + x2 - w)/2, (y1 + y2)/2); - g.setFont(fold); - } - } - + /*if ((p1 != oldp1) || (p2 != oldp2)) { + if (tdp instanceof TMLComponentTaskDiagramPanel) { + ((TMLComponentTaskDiagramPanel)tdp).updateConnectors(this, oldp1, oldp2, p1, p2); + } + }*/ + + try { + TMLCPortConnectingPoint pt1 = (TMLCPortConnectingPoint)p1; + TMLCPortConnectingPoint pt2 = (TMLCPortConnectingPoint)p2; + + + if (!pt1.positionned) { + pt1.positionned = true; + if (pt1.getFather() instanceof TMLCPrimitivePort) { + pt1.port = (TMLCPrimitivePort)(pt1.getFather()); + } + } + + if (!pt2.positionned) { + pt2.positionned = true; + if (pt2.getFather() instanceof TMLCPrimitivePort) { + pt2.port = (TMLCPrimitivePort)(pt2.getFather()); + } + } + + if ((pt1.port != null) && (pt2.port != null)) { + String name1 = pt1.port.getPortName(); + String name2 = pt2.port.getPortName(); + if (name1.equals(name2)) { + int w = g.getFontMetrics().stringWidth(name1); + Font fold = g.getFont(); + Font f = fold.deriveFont(Font.ITALIC, (float)(tdp.getFontSize())); + g.setFont(f); + g.drawString(name1, (x1 + x2 - w)/2, (y1 + y2)/2); + g.setFont(fold); + } + } + g.drawLine(x1, y1, x2, y2); - return; - } catch (Exception e) { - //System.out.println("Exception " + e.getMessage()); - } - g.drawLine(x1, y1, x2, y2); - - + return; + } catch (Exception e) { + //System.out.println("Exception " + e.getMessage()); + } + g.drawLine(x1, y1, x2, y2); + + //} else { // GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); //} } - - public void rescale(double scaleFactor){ - //System.out.println("Rescale connector"); - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - //System.out.println("Internal comp xx= " + xx + " y==" + yy); - tgcomponent[i].dx = (tgcomponent[i].dx + xx) / oldScaleFactor * scaleFactor; - tgcomponent[i].dy = (tgcomponent[i].dy + yy) / oldScaleFactor * scaleFactor; - xx = (int)(tgcomponent[i].dx); - tgcomponent[i].dx = tgcomponent[i].dx - xx; - yy = (int)(tgcomponent[i].dy); - tgcomponent[i].dy = tgcomponent[i].dy - yy; - - tgcomponent[i].setCd(xx, yy); - - //System.out.println("Internal comp xx= " + xx + " y==" + yy); + + public void rescale(double scaleFactor){ + //System.out.println("Rescale connector"); + int xx, yy; + + for(int i=0; i<nbInternalTGComponent; i++) { + xx = tgcomponent[i].getX(); + yy = tgcomponent[i].getY(); + //System.out.println("Internal comp xx= " + xx + " y==" + yy); + tgcomponent[i].dx = (tgcomponent[i].dx + xx) / oldScaleFactor * scaleFactor; + tgcomponent[i].dy = (tgcomponent[i].dy + yy) / oldScaleFactor * scaleFactor; + xx = (int)(tgcomponent[i].dx); + tgcomponent[i].dx = tgcomponent[i].dx - xx; + yy = (int)(tgcomponent[i].dy); + tgcomponent[i].dy = tgcomponent[i].dy - yy; + + tgcomponent[i].setCd(xx, yy); + + //System.out.println("Internal comp xx= " + xx + " y==" + yy); } - - oldScaleFactor = scaleFactor; - } - - + + oldScaleFactor = scaleFactor; + } + + public int getType() { return TGComponentManager.CONNECTOR_PORT_TMLC; } - - public void specificActionAfterAdd() { - //System.out.println("Specific action after add"); - ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); - } - - public void specificActionAfterMove() { - //System.out.println("Specific action after move"); - ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); - } - - /*public void structureChanged() { - System.out.println("Structure changed"); - ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); - }*/ - - /*protected String translateExtraParam() { - StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append("<info priority=\""); - sb.append(priority); - sb.append("\" />\n"); - sb.append("</extraparam>\n"); - return new String(sb); - }*/ - - /*public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ - //System.out.println("*** load extra synchro ***"); - try { - - NodeList nli; - Node n1, n2; - Element elt; - int t1id; - String prio; - - for(int i=0; i<nl.getLength(); i++) { - n1 = nl.item(i); - //System.out.println(n1); - if (n1.getNodeType() == Node.ELEMENT_NODE) { - nli = n1.getChildNodes(); - for(int j=0; i<nli.getLength(); i++) { - n2 = nli.item(i); - //System.out.println(n2); - if (n2.getNodeType() == Node.ELEMENT_NODE) { - elt = (Element) n2; - if (elt.getTagName().equals("info")) { - prio = elt.getAttribute("priority"); - if (elt != null) { - priority = Integer.decode(prio).intValue(); - } - } - } - } - } - } - - } catch (Exception e) { - throw new MalformedModelingException(); - } - }*/ - - - /*public TMLArchiCPUNode getOriginNode() { - TGComponent tgc = tdp.getComponentToWhichBelongs(getTGConnectingPointP1()); - if (tgc instanceof TMLArchiCPUNode) { - return (TMLArchiCPUNode)tgc; - } else { - return null; - } + + public void specificActionAfterAdd() { + //System.out.println("Specific action after add"); + ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); + } + + public void specificActionAfterMove() { + //System.out.println("Specific action after move"); + ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); + } + + /*public void structureChanged() { + System.out.println("Structure changed"); + ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); + }*/ + + /*protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info priority=\""); + sb.append(priority); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + }*/ + + /*public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String prio; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + prio = elt.getAttribute("priority"); + if (elt != null) { + priority = Integer.decode(prio).intValue(); } - - public TMLArchiCPUNode getDestinationNode() { - TGComponent tgc = tdp.getComponentToWhichBelongs(getTGConnectingPointP2()); - if (tgc instanceof TMLArchiCPUNode) { - return (TMLArchiCPUNode)tgc; - } else { - return null; - } } - - public int getPriority() { - return priority; - } - - public String getAttributes() { - return "Priority = " + priority; - }*/ - + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + }*/ + + + /*public TMLArchiCPUNode getOriginNode() { + TGComponent tgc = tdp.getComponentToWhichBelongs(getTGConnectingPointP1()); + if (tgc instanceof TMLArchiCPUNode) { + return (TMLArchiCPUNode)tgc; + } else { + return null; + } + } + + public TMLArchiCPUNode getDestinationNode() { + TGComponent tgc = tdp.getComponentToWhichBelongs(getTGConnectingPointP2()); + if (tgc instanceof TMLArchiCPUNode) { + return (TMLArchiCPUNode)tgc; + } else { + return null; + } + } + + public int getPriority() { + return priority; + } + + public String getAttributes() { + return "Priority = " + priority; + }*/ + } diff --git a/src/ui/tmlcompd/TMLCPrimitivePort.java b/src/ui/tmlcompd/TMLCPrimitivePort.java index 12d11333ce920e4732c8ecd0b1062fb7cae711ac..6365437f50295686cc1230ef8d098c2866adb622 100755 --- a/src/ui/tmlcompd/TMLCPrimitivePort.java +++ b/src/ui/tmlcompd/TMLCPrimitivePort.java @@ -81,7 +81,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent protected boolean isPrex = false; protected int lossPercentage; protected int maxNbOfLoss; //-1 means no max - + public int checkStatus; public boolean checkConf; public static int NOCHECK= 0; @@ -112,12 +112,12 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent editable = true; removable = true; userResizable = false; - checkConf=false; + checkConf=false; commName = "comm"; //value = "MyName"; makeValue(); setName("Primitive port"); - checkStatus= NOCHECK; + checkStatus= NOCHECK; list = new TType[nbMaxAttribute]; for(int i=0; i<nbMaxAttribute; i++) { list[i] = new TType(); @@ -318,11 +318,11 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent g.drawString(lname, x+width - w - 1, y+(int)(si)-2); } }*/ - if (checkConf){ - drawVerification(g); - } + if (checkConf){ + drawVerification(g); + } g.setFont(fold); - + drawParticularity(g); } @@ -344,13 +344,13 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent default: return; } - g.drawString(mappingName, x-15, y-8); - g.drawOval(x-10, y, 6, 9); - g.setColor(c1); - g.fillRect(x-12, y+3, 9, 7); - g.setColor(c); - g.drawRect(x-12, y+3, 9, 7); - + g.drawString(mappingName, x-15, y-8); + g.drawOval(x-10, y, 6, 9); + g.setColor(c1); + g.fillRect(x-12, y+3, 9, 7); + g.setColor(c); + g.drawRect(x-12, y+3, 9, 7); + } @@ -482,17 +482,17 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent maxNbOfLoss = jda.getMaxNbOfLoss(); oldTypep = typep; typep = jda.getPortType(); - checkConf = jda.checkConf; - if (checkConf){ - if (checkStatus==NOCHECK){ - checkStatus=TOCHECK; - } - } - else { - if (checkStatus!=NOCHECK){ - checkStatus=NOCHECK; - } - } + checkConf = jda.checkConf; + if (checkConf){ + if (checkStatus==NOCHECK){ + checkStatus=TOCHECK; + } + } + else { + if (checkStatus!=NOCHECK){ + checkStatus=NOCHECK; + } + } for(int i=0; i<nbMaxAttribute; i++) { //TraceManager.addDev("Getting string type: " + jda.getStringType(i)); list[i].setType(jda.getStringType(i)); @@ -506,7 +506,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); - + return true; } @@ -544,8 +544,8 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent sb.append("\" maxNbOfLoss=\"" + maxNbOfLoss); sb.append("\" dataFlowType=\"" + dataFlowType); sb.append("\" associatedEvent=\"" + associatedEvent); - sb.append("\" checkConf=\"" + checkConf); - sb.append("\" checkStatus=\"" + checkStatus); + sb.append("\" checkConf=\"" + checkConf); + sb.append("\" checkStatus=\"" + checkStatus); sb.append("\" />\n"); for(int i=0; i<nbMaxAttribute; i++) { //System.out.println("Attribute:" + i); @@ -623,8 +623,8 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent maxNbOfLoss = Integer.decode(elt.getAttribute("maxNbOfLoss")).intValue(); dataFlowType = elt.getAttribute("dataFlowType"); associatedEvent = elt.getAttribute("associatedEvent"); - checkConf = (elt.getAttribute("checkConf").compareTo("true")==0); - checkStatus = Integer.valueOf(elt.getAttribute("checkStatus")); + checkConf = (elt.getAttribute("checkConf").compareTo("true")==0); + checkStatus = Integer.valueOf(elt.getAttribute("checkStatus")); isLossy = (elt.getAttribute("isLossy").compareTo("true") ==0); isPrex = (elt.getAttribute("isPrex").compareTo("true") ==0); isPostex = (elt.getAttribute("isPostex").compareTo("true") ==0); @@ -813,21 +813,21 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent } } } - - public String getDataFlowType() { - return dataFlowType; - } - public boolean isPrex() { - return isPrex; - } + public String getDataFlowType() { + return dataFlowType; + } + + public boolean isPrex() { + return isPrex; + } - public boolean isPostex() { - return isPostex; - } + public boolean isPostex() { + return isPostex; + } - public String getAssociatedEvent() { - return associatedEvent; - } + public String getAssociatedEvent() { + return associatedEvent; + } }