diff --git a/src/main/java/ui/het/CAMSBlock.java b/src/main/java/ui/het/CAMSBlock.java new file mode 100755 index 0000000000000000000000000000000000000000..97852637283904d48b72f3e71f9ce9ff1391c7b0 --- /dev/null +++ b/src/main/java/ui/het/CAMSBlock.java @@ -0,0 +1,394 @@ +/* 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.het; + +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.JDialogCAMSBlocks; +import heterogeneoustranslator.systemCAMStranslator.*; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; + + +/** +* Class CAMSBlock +* Block for SystemC-AMS Diagrams +* Creation: 27/06/2017 +* @version 1.0 27/06/2017 +* @author Côme DEMARIGNY + */ +public class CAMSBlock extends TGComponent { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "block"; + + private int nbOfIn = 0; + private int nbOfOut = 0; + private int nbOfHybridIn = 0; + private int nbOfHybridOut = 0; + private int totIn = 0; + private int totOut = 0; + + protected int index = 0; + + private int maxFontSize = 12; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + private int textX = 7; + + private int limitName = -1; + private int limitAttr = -1; + private int limitMethod = -1; + + public String name; + public String Value= "Block0"; + private JDialogCAMSBlocks dialog; + + // TAttribute, ProcessCode, CAMSSignal + protected LinkedList<TAttribute> myAttributes; + protected LinkedList<CAMSSignal> mySignals; + protected String [] processCode; + + //Simulation Object + private CAMSBlocks SBlock; + + public CAMSBlock (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); + tdp = _tdp; + width = 250; + height = 200; + minWidth = 150; + minHeight = 100; + + createConnectingPoints(); + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + getBlockName(); + + myImageIcon = IconManager.imgic700; + + if(this.myAttributes == null){this.myAttributes = new LinkedList<TAttribute>();} + if(this.mySignals == null){this.mySignals = new LinkedList<CAMSSignal>();} + + SBlock= new CAMSBlocks(name, nbOfIn, nbOfOut, nbOfHybridIn, nbOfHybridOut, myAttributes, mySignals, processCode); + } + + public void createConnectingPoints(){ + int i; + double h; + + resetInOut(); + + if(this.mySignals!=null){ + for(i=0;i<mySignals.size();i++){ + if(mySignals.get(i).getInout()==0){ + nbOfIn++; + } else if(mySignals.get(i).getInout()==1) { + nbOfOut++; + } else if(mySignals.get(i).getInout()==2) { + nbOfHybridIn++; + } else{ + nbOfHybridOut++; + } + } + } + + nbConnectingPoint = nbOfIn + nbOfOut + nbOfHybridIn + nbOfHybridOut; + totIn = nbOfIn + nbOfHybridIn; + totOut = nbOfOut + nbOfHybridOut; + + connectingPoint = new CAMSConnectingPoint[nbConnectingPoint]; + + for (i = 1; i<= totIn; i++){ + h = i/(totIn + 1.0); + if((i-1)<nbOfIn){ + connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, false, 0.0, h); + } else{ + connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, true, 0.0, h); + } + } + + for (i = 1; i<=totOut; i++){ + h = i/(totOut + 1.0); + if ((i+totIn-1)<(nbOfOut + totIn)){ + connectingPoint[i+totIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, false, 1.0, h); + } else { + connectingPoint[i+totIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, true, 1.0, h); + } + } + + addTGConnectingPointsComment(); + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.HWA_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + + actionOnAdd(); + } + + public void addSignal(CAMSSignal sig){ + mySignals.add(sig); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + return null; + } + + public void setState(int _s){ + } + + public TGComponent isOnMe(int _x, int _y){ + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public boolean editOndoubleClick(JFrame frame) { + + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + boolean changeMade=false; + + if(dialog ==null){ + dialog = new JDialogCAMSBlocks(this.myAttributes, this.mySignals, null, frame, "Setting Block attributes", "Attributes", this, processCode, true); + } + setJDialogOptions(dialog); + GraphicLib.centerOnParent(dialog, 1050, 700); + dialog.setVisible( true ); // blocked until dialog has been closed + mySignals = dialog.getSignals(); + createConnectingPoints(); + getBlockName(); + setSimulationBlock(); + + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + return true; + } + + + @Override + public void loadExtraParam(NodeList bl, int decX, int decY, int decId) throws MalformedModelingException{ + try { + + NodeList bli; + Node b1, b2; + Element elt; + String sstereotype = null, sblockName = null; + + for(int i=0; i<bl.getLength(); i++) { + b1 = bl.item(i); + //System.out.println(n1); + if (b1.getNodeType() == Node.ELEMENT_NODE) { + bli = b1.getChildNodes(); + for(int j=0; j<bli.getLength(); j++) { + b2 = bli.item(j); + if (b2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) b2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + sblockName = elt.getAttribute("blockName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (sblockName != null){ + name = sblockName; + } + + if (elt.getTagName().equals("attributes")) { + + nbOfIn = Integer.decode(elt.getAttribute("nbOfIn")).intValue(); + nbOfOut =Integer.decode(elt.getAttribute("nbOfOut")).intValue(); + + } + } + } + } + } + } catch (Exception e) { + System.out.println("load failure"); + throw new MalformedModelingException(); + } + } + + public void setSimulationBlock(){ + SBlock.setBlockName(name); + SBlock.setNbOfIn(nbOfIn); + SBlock.setNbOfOut(nbOfOut); + SBlock.setNbOfHybridIn(nbOfHybridIn); + SBlock.setNbOfHybridOut(nbOfHybridOut); + SBlock.setMyAttributes(myAttributes); + SBlock.setMySignals(mySignals); + SBlock.setProcessCode(processCode); + } + + protected void setJDialogOptions(JDialogCAMSBlocks _jdab) { + _jdab.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); + _jdab.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); + _jdab.addType(TAttribute.getStringCAMSType(TAttribute.BOOLEAN), true); + _jdab.addType(TAttribute.getStringCAMSType(TAttribute.DOUBLE), true); + _jdab.enableInitialValue(true); + _jdab.enableRTLOTOSKeyword(false); + _jdab.enableJavaKeyword(false); + } + + public String getAttributes() { + String attr = ""; + attr += "Nb of in = " + totIn + "\n"; + attr += "Nb of out = " + totOut + "\n"; + + return attr; + } + + public int getType() { + return TGComponentManager.CAMS_BLOCK; + } + + public boolean hasBlockWithName(){ + return true; + } + + public void getBlockName() { + if(dialog != null) { + name = dialog.getBlockName(); + if (name.length()==0){ + name = tdp.findCAMSBlockName("Block"); + return ; + } + return ; + } + name = Value; + } + + public void resetInOut(){ + nbOfIn = 0; + nbOfOut= 0; + nbOfHybridIn = 0; + nbOfHybridOut= 0; + totIn = 0; + totOut= 0; + } + + public int getNbOfIn() { + return totIn; + } + + public int getNbOfOut() { + return totOut; + } + + public int getNbOfHybridIn() { + return nbOfHybridIn; + } + + public int getNbOfHybridOut() { + return nbOfHybridOut; + } + + public int getNbOfNonHybridIn() { + return nbOfIn; + } + + public int getNbOfNonHybridOut() { + return nbOfOut; + } + + public int getDefaultConnector() { + return TGComponentManager.CAMS_CONNECTOR; + } + +} diff --git a/src/main/java/ui/het/CAMSBlockConnector.java b/src/main/java/ui/het/CAMSBlockConnector.java new file mode 100755 index 0000000000000000000000000000000000000000..36edcd8bc817943e4d5235292b3dd35ee622489c --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockConnector.java @@ -0,0 +1,302 @@ +/* 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.het; + +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.awt.*; +import java.awt.geom.Point2D; +import java.util.Vector; + + +/** + * Class SystemCAMSConnectingPoint + * Definition of connecting points on which attribute connectors can be connected + * Creation: 27/06/2017 + * @version 1.0 27/06/2017 + * @author Côme Demarigny + */ +public class CAMSBlockConnector extends TGConnector { + + public CAMSBlockConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, CAMSConnectingPoint _p1, CAMSConnectingPoint _p2, Vector<Point> _listPoint){ + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; + + name = "connector"; + _p1.setReferenceToConnector( this ); + _p2.setReferenceToConnector( this ); + + } + + public int getType() { + return TGComponentManager.CAMS_CONNECTOR; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { + g.drawLine(x1, y1, x2, y2); + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + } + } + + // protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + // Point p_one; + // boolean isp1; + // if (getIndexOfLastTGCPointOfConnector() == -1) { + // p_one = new Point(p1.getX(), p1.getY()); + // isp1 = true; + // } else { + // TGComponent tmpc = tgcomponent[getIndexOfLastTGCPointOfConnector()]; + // p_one = new Point(tmpc.getX(), tmpc.getY()); + // isp1 = false; + // } + + // //g.drawLine(x1, y1, x2, y2); + // Color col = g.getColor(); + // int cz = (int)(tdp.getZoom() * c); + // if (isAsynchronous()) { + // g.setColor(Color.WHITE); + // } + // g.fillRect(x2-(cz/2), y2-(cz/2), cz, cz); + // g.fillRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz); + // g.setColor(col); + // if (isAsynchronous()) { + // g.drawRect(x2-(cz/2), y2-(cz/2), cz, cz); + // g.drawRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz); + // if (isBlocking()) { + // g.drawLine(x2-(cz/2), y2-(cz/2), x2-(cz/2)+cz, y2-(cz/2)+cz); + // g.drawLine(x2-(cz/2), y2-(cz/2)+cz, x2-(cz/2)+cz, y2-(cz/2)); + // g.drawLine(p1.getX()-(cz/2), p1.getY()+(cz/2), p1.getX()+(cz/2), p1.getY()-(cz/2)); + // g.drawLine(p1.getX()-(cz/2), p1.getY()-(cz/2), p1.getX()+(cz/2), p1.getY()+(cz/2)); + // } + // } + + + // if (!isPrivate() /*&& !isAsynchronous()*/) { + // int czz = (int)(cz*1.4); + // int x3 = p1.getX(); + // int y3 = p1.getY(); + + // Polygon p1 = new Polygon(); + // p1.addPoint(x2-(czz/2)+czz, y2-cz); + // p1.addPoint(x2+(czz/2)+czz, y2-cz); + // p1.addPoint(x2+czz, y2-(2*czz)); + + // Polygon p2 = new Polygon(); + // p2.addPoint(x3-(czz/2)+czz, y3-cz); + // p2.addPoint(x3+(czz/2)+czz, y3-cz); + // p2.addPoint(x3+czz, y3-(2*czz)); + + // // Adding illuminatis sign at the end + // g.setColor(Color.WHITE); + // g.fillPolygon(p1); + // g.fillPolygon(p2); + + // g.setColor(col); + // g.drawPolygon(p1); + // g.drawPolygon(p2); + // g.drawOval(x2+czz-4, y2-cz-7, 8, 6); + // g.drawOval(x3+czz-4, y3-cz-7, 8, 6); + // g.fillOval(x2+czz-2, y2-cz-6, 5, 4); + // g.fillOval(x3+czz-2, y3-cz-6, 5, 4); + + // } + + + // Point p11; + // if (isp1) { + // p11 = GraphicLib.intersectionRectangleSegment(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz, x1, y1, x2, y2); + // } else { + // p11 = new Point(p_one.x, p_one.y); + // } + // if (p11 == null) { + // p11 = new Point(p1.getX(), p1.getY()); + // //System.out.println("null point"); + // } + // Point p22 = GraphicLib.intersectionRectangleSegment(x2-(cz/2), y2-(cz/2), cz, cz, x1, y1, x2, y2); + // if (p22 == null) { + // p22 = new Point(p2.getX(), p2.getY()); + // //System.out.println("null point"); + // } + + // g.drawLine(p11.x, p11.y, p22.x, p22.y); + + // Font f = g.getFont(); + // Font fold = f; + // f = f.deriveFont((float)fontSize); + // g.setFont(f); + // int h = - decY; + // int step = fontSize + 1; + // int w; + // String s; + + + // if (((g.getColor() == ColorManager.POINTER_ON_ME_0) && (tdp.getAttributeState() == tdp.PARTIAL)) || (tdp.getAttributeState() == tdp.FULL)) { + // // Signals at origin + // if (inSignalsAtOrigin.size() > 0) { + // //g.drawString("in:", p1.getX() + decX, p1.getY() + h); + // for(String iso: inSignalsAtOrigin) { + // h += step; + // s = getShortName(iso); + // if (p1.getX() <= p2.getX()) { + // g.drawString(s, p1.getX() + decX, p1.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + // } + // } + // } + // if (outSignalsAtOrigin.size() > 0) { + // //h += step; + // //g.drawString("out:", p1.getX() + decX, p1.getY() + h); + // for(String oso: outSignalsAtOrigin) { + // h += step; + // s = getShortName(oso); + // if (p1.getX() <= p2.getX()) { + // g.drawString(s, p1.getX() + decX, p1.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + // } + // } + // } + // // Signals at destination + // h = - decY; + // if (outSignalsAtDestination.size() > 0) { + // //h += step; + // //g.drawString("out:", p2.getX() + decX, p2.getY() + h); + // for(String osd: outSignalsAtDestination) { + // h += step; + // s = getShortName(osd); + // if (p1.getX() > p2.getX()) { + // g.drawString(s, p2.getX() + decX, p2.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + // } + // } + // } + // if (inSignalsAtDestination.size() > 0) { + // //g.drawString("in:", p2.getX() + decX, p2.getY() + h); + // for(String isd: inSignalsAtDestination) { + // h += step; + // s = getShortName(isd); + // if (p1.getX() > p2.getX()) { + // g.drawString(s, p2.getX() + decX, p2.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + // } + // } + // } + // } + + // g.setFont(fold); + + // /*if (value.length() > 0) { + // Font f = g.getFont(); + // if (tdp.getZoom() < 1) { + // Font f0 = f.deriveFont((float)(fontSize*tdp.getZoom())); + // g.setFont(f0); + // } + // g.drawString(value, x2-(cz/2), y2-(cz/2)-1); + // g.setFont(f); + // }*/ + + // // Animation? + // if ((TDiagramPanel.AVATAR_ANIMATE_ON) && (isAsynchronous())){ + // //TraceManager.addDev("anim port connector: " + this); + // String messageInformation[] = tdp.getMGUI().hasMessageInformationForAvatarConnector(this); + // if (messageInformation != null) { + // if (messageInformation[0] != null) { + // g.setColor(Color.BLUE); + // g.drawString(messageInformation[0], p1.getX() + decX, p1.getY()); + // } + // if (messageInformation[1] != null) { + // g.setColor(Color.BLUE); + // g.drawString(messageInformation[1], p2.getX() + decX, p2.getY()); + // } + // g.setColor(Color.BLACK); + // } + // } + // } + + @Override + 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 tmp = null; + + 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(); + + // Issue #17 copy-paste error on j index + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + +} //class diff --git a/src/main/java/ui/het/CAMSBlockDiagramPanel.java b/src/main/java/ui/het/CAMSBlockDiagramPanel.java new file mode 100755 index 0000000000000000000000000000000000000000..b00ae26c6af890492710c3841dc5df1dada4b84c --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockDiagramPanel.java @@ -0,0 +1,217 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici + * + * ludovic.apvrille AT enst.fr + * andrea.enrici 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.het; + + +import myutil.TraceManager; +import org.w3c.dom.Element; +import ui.*; + +import java.util.*; + +/** + * Class CAMSBlockDiagramPanel + * Panel for drawing TML Blocks + * Creation: 26/06/2017 + * @version 1.0 26/06/2017 + * @author Côme DEMARIGNY + */ +public class CAMSBlockDiagramPanel extends TDiagramPanel implements TDPWithAttributes { + + public CAMSBlockDiagramPanel(MainGUI mgui, TToolBar _ttb) { + super(mgui, _ttb); + } + + public void initFromDiplodocus(){ + TGComponentManager.addComponent(100,100,TGComponentManager.CAMS_BLOCK,this); + TGComponentManager.addComponent(600,100,TGComponentManager.CAMS_BLOCK,this); + } + + public boolean actionOnDoubleClick(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + TCDTClass t = (TCDTClass)tgc; + return mgui.newTClassName(tp, t.oldValue, t.getValue()); + } else if (tgc instanceof TCDActivityDiagramBox) { + if (tgc.getFather() instanceof TCDTClass) { + mgui.selectTab(tp, tgc.getFather().getValue()); + } else if (tgc.getFather() instanceof TCDTObject) { + TCDTObject to = (TCDTObject)(tgc.getFather()); + TCDTClass t = to.getMasterTClass(); + if (t != null) { + mgui.selectTab(tp, t.getValue()); + } + } + return false; // because no change made on any diagram + }*/ + return false; + } + + public boolean actionOnAdd(TGComponent tgc) { + return false; + } + + public boolean actionOnRemove(TGComponent tgc) { + return false; + } + + public boolean actionOnValueChanged(TGComponent tgc) { + return false; + } + + public void setConnectorsToFront() { + TGComponent tgc; + + //System.out.println("list size=" + componentList.size()); + + Iterator iterator = componentList.listIterator(); + + ArrayList<TGComponent> list = new ArrayList<TGComponent>(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (!(tgc instanceof TGConnector)) { + list.add(tgc); + } + } + + //System.out.println("Putting to back ..."); + for(TGComponent tgc1: list) { + //System.out.println("Putting to back: " + tgc1); + componentList.remove(tgc1); + componentList.add(tgc1); + } + } + + public String getXMLHead() { + return "<CAMSBlockDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + zoomParam() +" >"; + } + + public String getXMLTail() { + return "</CAMSBlockDiagramPanel>"; + } + + public String getXMLSelectedHead() { + return "<CAMSBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; + } + + public String getXMLSelectedTail() { + return "</CAMSBlockDiagramPanelCopy>"; + } + + public String getXMLCloneHead() { + return "<CAMSBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; + } + + public String getXMLCloneTail() { + return "</CAMSBlockDiagramPanelCopy>"; + } + + + + public boolean areAttributesVisible() { + return attributesVisible; + } + + + public boolean areChannelVisible() { + return synchroVisible; + } + + public void setAttributesVisible(boolean b) { + attributesVisible = b; + } + + + public void setChannelVisible(boolean b) { + channelVisible = b; + } + + public String displayParam() { + String s = ""; + if (channelsVisible) { + s += " channels=\"true\""; + } else { + s += " channels=\"false\""; + } + if (eventsVisible) { + s += " events=\"true\""; + } else { + s += " events=\"false\""; + } + if (requestsVisible) { + s += " requests=\"true\""; + } else { + s += " requests=\"false\""; + } + + return s; + } + + public boolean areAllVisible() { + return channelsVisible && eventsVisible && requestsVisible; + } + + public boolean areChannelsVisible() { + return channelsVisible; + } + + public boolean areEventsVisible() { + return eventsVisible; + } + + public boolean areRequestsVisible() { + return requestsVisible; + } + + public void setChannelsVisible(boolean b) { + channelsVisible = b; + } + + public void setEventsVisible(boolean b) { + eventsVisible = b; + } + + public void setRequestsVisible(boolean b) { + requestsVisible = b; + } +} diff --git a/src/main/java/ui/het/CAMSBlockDiagramToolBar.java b/src/main/java/ui/het/CAMSBlockDiagramToolBar.java new file mode 100755 index 0000000000000000000000000000000000000000..993669fd52105317a60f42e93a515ea6a5ac23c3 --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockDiagramToolBar.java @@ -0,0 +1,134 @@ +/* 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.het; + +import ui.MainGUI; +import ui.TGUIAction; +import ui.TToolBar; + +import javax.swing.*; + +/** + * Class TMLTaskDiagramToolBar + * Implements the toolbar to be used in conjunction with the panel of a TMLTask diagram + * Creation: 26/06/2017 + * @version 1.0 26/06/2017 + * @author Côme DEMARIGNY + * @see TMLBlockDiagramToolbar + */ +public class CAMSBlockDiagramToolBar extends TToolBar { + + public CAMSBlockDiagramToolBar(MainGUI _mgui) { + super(_mgui); + + } + + protected void setActive(boolean b) { + mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b); + mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.CAMS_BLOCK].setEnabled(b); + mgui.actions[TGUIAction.CAMS_CONNECTOR].setEnabled(b); + + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(true); + mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(true); + mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(true); + + mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); + mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); + mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b); + + mgui.updateZoomInfo(); + } + + protected void setButtons() { + JButton button; + + button = this.add(mgui.actions[TGUIAction.CAMS_EDIT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.UML_NOTE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK]); + button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_ASSOC]); + // button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CAMS_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + // this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_TASK]); + // button.addMouseListener(mgui.mouseHandler); + + + // this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_CHANNEL]); + // button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_EVENT]); + // button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_REQ]); + // button.addMouseListener(mgui.mouseHandler); + + + this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]); + // button.addMouseListener(mgui.mouseHandler); + + } + +} // Class + + + + + diff --git a/src/main/java/ui/het/CAMSConnectingPoint.java b/src/main/java/ui/het/CAMSConnectingPoint.java new file mode 100755 index 0000000000000000000000000000000000000000..7839f4d2d9577949633ba47f9f1dfea748b11e29 --- /dev/null +++ b/src/main/java/ui/het/CAMSConnectingPoint.java @@ -0,0 +1,173 @@ +/* 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.het; + +import myutil.GraphicLib; +import ui.*; +import ui.window.JDialogCAMSConnectingPoint; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Point2D; +import javax.swing.*; +import java.util.Vector; + + +/** + * Class SystemCAMSConnectingPoint + * Definition of connecting points on which attribute connectors can be connected + * Creation: 27/06/2017 + * @version 1.0 27/06/2017 + * @author Côme Demarigny + */ +public class CAMSConnectingPoint extends TGConnectingPointWidthHeight { + + protected int x, y; // relative cd and center of the point + protected int state; + protected CDElement container; + private boolean free = true; + protected boolean editable= true; + + private int id; + + protected TGConnectingPointGroup cpg; + + public String type, rate, ccpName = "Connection"; + + protected boolean in; + protected boolean out; + protected boolean hybrid; + + public JDialogCAMSConnectingPoint dialog; + + protected Color myColor; + + protected static final Color IN = Color.gray; + protected static final Color OUT = Color.black; + protected static final Color INOUT = Color.red; + protected static final Color NO = Color.white; + + + protected TGConnector referenceToConnector; + + public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out,boolean _hybrid, double _w, double _h) { + super(_container, _x, _y, _in, _out, _w, _h); + hybrid = _hybrid; + + //color selection + if (_in) { + if (_out) { + myColor = INOUT; + } else { + myColor = IN; + } + } else { + if (_out) { + myColor = OUT; + } else { + myColor = NO; + } + } + + id = TGComponent.getGeneralId(); + TGComponent.setGeneralId(id + 1); + + } + + // public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + // super(_container, _x, _y, _in, _out, _w, _h); + // CAMSConnectingPoint camsco = new CAMSConnectingPoint (_container, _x, _y, _in, _out, false, _w, _h); + // } + + public void draw(Graphics g) { + int mx = getX(); + int my = getY(); + g.setColor(myColor); + + //taking into account hybrid connectors + if(this.hybrid==false){ + g.fillRect(mx - width, my - width, width*2, height*2); + }else if (this.in==true){ + System.out.println("test"); + g.setColor(Color.white); + g.fillRect(mx - width, my - width, width*2, height*2); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width, height*2); + }else { + g.setColor(Color.white); + g.fillRect(mx - width, my - width, width*2, height*2); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width, height*2); + } + + GraphicLib.doubleColorRect(g, mx - width, my - width, width*2, height*2, Color.white, Color.black); + } + + public boolean editOndoubleClick(JFrame frame) { + + if(dialog == null){ + dialog = new JDialogCAMSConnectingPoint(frame, "Setting connector attributes", this); + } + dialog.setSize(350, 300); + GraphicLib.centerOnParent(dialog); + dialog.setVisible(true); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + return true; + } + + public String getccpName() { + return ccpName; + } + + public String getPointType() { + return type; + } + + public String getRate() { + return rate; + } + +} //class