diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index 59011d2133ae7cf7ce11d73b39a71e4f9ae5400c..eee1f68aadd85ff932b6fc0cb8ffa37739d985bb 100644 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -927,6 +927,8 @@ public class ActionPerformer { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_PORT_CONVERTER); } else if (command.equals(mgui.actions[TGUIAction.CAMS_CLUSTER].getActionCommand())) { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_CLUSTER); + } else if (command.equals(mgui.actions[TGUIAction.CAMS_BLOCK_GPIO2VCI].getActionCommand())) { + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_BLOCK_GPIO2VCI); } else if (command.equals(mgui.actions[TGUIAction.CAMS_GENCODE].getActionCommand())){ mgui.syscamsExecutableCodeGeneration(); diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index e64212db6a9b1b32ceb120bcd101e81013738fb7..2a8d21ad7224fb715ec5878c5f9f385a75a5852f 100644 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -344,6 +344,7 @@ public class TGComponentManager { public static final int CAMS_PORT_DE = 1605; public static final int CAMS_PORT_CONVERTER = 1606; public static final int CAMS_CLUSTER = 1607; + public static final int CAMS_BLOCK_GPIO2VCI = 1608; // ELN public static final int ELN_CONNECTOR = 1610; @@ -1278,6 +1279,9 @@ public class TGComponentManager { case CAMS_CLUSTER: tgc = new SysCAMSCompositeComponent(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case CAMS_BLOCK_GPIO2VCI: + tgc = new SysCAMSBlockGPIO2VCI(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; // ELN case ELN_PORT_TERMINAL: tgc = new ELNPortTerminal(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -1714,6 +1718,8 @@ public class TGComponentManager { return CAMS_PORT_CONVERTER; } else if (tgc instanceof SysCAMSCompositeComponent) { return CAMS_CLUSTER; + } else if (tgc instanceof SysCAMSBlockGPIO2VCI) { + return CAMS_BLOCK_GPIO2VCI; // ELN } else if (tgc instanceof ELNConnector) { diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index 642ba2194436f4d901954755961f438bfb3bceb2..c9dde824bc8635101495a93101f243c96a96489d 100644 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -284,6 +284,7 @@ public class TGUIAction extends AbstractAction { public static final int CAMS_PORT_CONVERTER = 479; public static final int CAMS_CLUSTER = 480; public static final int CAMS_GENCODE = 481; + public static final int CAMS_BLOCK_GPIO2VCI = 497; // ELN public static final int ELN_EDIT = 482; @@ -654,7 +655,7 @@ public class TGUIAction extends AbstractAction { public static final int MOVE_ENABLED = 463; public static final int FIRST_DIAGRAM = 464; - public static final int NB_ACTION = 497; + public static final int NB_ACTION = 498; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -1157,7 +1158,8 @@ public class TGUIAction extends AbstractAction { actions[CAMS_PORT_CONVERTER] = new TAction("C-AMS-port-converter", "Add a converter port", IconManager.imgic8003, IconManager.imgic8003, "Converter port", "Add a converter port to the currently opened SystemC-AMS Diagram", 0); actions[CAMS_CLUSTER] = new TAction("C-AMS-cluster", "Add a cluster", IconManager.imgic8006, IconManager.imgic8006, "Cluster", "Add a cluster to the currently opened SystemC-AMS Diagram", 0); actions[CAMS_GENCODE] = new TAction("GENCODE", "GENCODE",IconManager.imgic94, IconManager.imgic94, "Generate SystemC-AMS code", "SystemC-AMS diagram without check syntax", 0); - + actions[CAMS_BLOCK_GPIO2VCI] = new TAction("C-AMS-block-GPIO2VCI", "Add a block GPIO2VCI",IconManager.imgic8009, IconManager.imgic8009, "GPIO2VCI block", "Add a GPIO2VCI block to the currently opened SystemC-AMS Diagram", 0); + // ELN actions[ELN_EDIT] = new TAction("add-action-eln", "Action state", IconManager.imgic100, IconManager.imgic101, "Action state", "Add an action state to the currently opened ELN diagram", 0); actions[ELN_CONNECTOR] = new TAction("eln-connector", "Add a connection", IconManager.imgic202, IconManager.imgic202, "Connector", "Connects two block of the currently opened ELN Diagram", 0); diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java index e1377a2d0211d8074902836223583850db08473f..05335252589c758ef23a5367abb35dff9738d60d 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockDE.java +++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java @@ -54,7 +54,7 @@ import java.util.LinkedList; /** * Class SysCAMSBlockDE - * Primitive Component. To be used in SystemC-AMSdiagrams + * Primitive Component. To be used in SystemC-AMS diagrams * Creation: 13/05/2018 * @version 1.0 13/05/2018 * @author Irina Kit Yan LEE diff --git a/src/main/java/ui/syscams/SysCAMSBlockGPIO2VCI.java b/src/main/java/ui/syscams/SysCAMSBlockGPIO2VCI.java new file mode 100644 index 0000000000000000000000000000000000000000..1ef7d67dd3299a6293bd80ebb614d7322c7d7ace --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSBlockGPIO2VCI.java @@ -0,0 +1,231 @@ +/* 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.JDialogSysCAMSBlockDE; +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.LinkedList; + +/** + * Class SysCAMSBlockGPIO2VCI + * Primitive Component. To be used in SystemC-AMS diagrams + * Creation: 09/07/2018 + * @version 1.0 09/07/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSBlockGPIO2VCI extends TGCScalableWithInternalComponent implements SwallowedTGComponent { + + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + private Color myColor; + + private int textX = 15; + private double dtextX = 0.0; + + public String oldValue; + + public SysCAMSBlockGPIO2VCI(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 = false; + editable = false; + removable = true; + userResizable = true; + + value = "Block_GPIO2VCI"; + name = "Primitive component - Block GPIO2VCI"; + + myImageIcon = IconManager.imgic1202; + + actionOnAdd(); + } + + public void internalDrawing(Graphics g) { + int w; + Font f = g.getFont(); + Font fold = f; + + if (myColor == null) { + myColor = Color.white; + } + + if (this.rescaled && !this.tdp.isScaled()) { + this.rescaled = false; + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); + f = f.deriveFont((float) maxCurrentFontSize); + + while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { + if (g.getFontMetrics().stringWidth(value) < (width - (2 * textX))) { + break; + } + maxCurrentFontSize--; + f = f.deriveFont((float) maxCurrentFontSize); + } + + if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { + maxCurrentFontSize++; + f = f.deriveFont((float) maxCurrentFontSize); + } + g.setFont(f); + this.currentFontSize = maxCurrentFontSize; + } else { + f = f.deriveFont(this.currentFontSize); + } + + 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); + } + + g.setFont(fold); + } + + 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 int getType() { + return TGComponentManager.CAMS_BLOCK_GPIO2VCI; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + return tgc instanceof SysCAMSPortDE; + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + if (tgc instanceof SysCAMSPortDE) { + 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 SysCAMSPortDE) { + tgcomponent[i].resizeWithFather(); + } + } + } + + public int getCurrentFontSize() { + return currentFontSize; + } + + public java.util.List<SysCAMSPortDE> getAllDEOriginPorts() { + return getAllPorts(1, 1); + } + + public java.util.List<SysCAMSPortDE> getAllDEDestinationPorts() { + return getAllPorts(1, 0); + } + + public java.util.List<SysCAMSPortDE> getAllPorts(int _type, int _isOrigin) { + java.util.List<SysCAMSPortDE> ret = new LinkedList<SysCAMSPortDE>(); + SysCAMSPortDE port; + + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSPortDE) { + port = (SysCAMSPortDE)tgcomponent[i]; + if ((port.getPortType() == _type) && (port.getOrigin() == _isOrigin)) { + ret.add(port); + } + } + } + return ret; + } + + public java.util.List<SysCAMSPortDE> getAllInternalPortsDE() { + java.util.List<SysCAMSPortDE> list = new ArrayList<SysCAMSPortDE>(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSPortDE) { + list.add((SysCAMSPortDE)(tgcomponent[i])); + } + } + return list; + } +} \ No newline at end of file diff --git a/src/main/java/ui/util/IconManager.java b/src/main/java/ui/util/IconManager.java index 24cc34118927f73fa0b14595e707f6ac470c5d26..aa45540b10c3e3279a383a73a2d48810766ea0c1 100755 --- a/src/main/java/ui/util/IconManager.java +++ b/src/main/java/ui/util/IconManager.java @@ -183,7 +183,7 @@ public class IconManager { public static ImageIcon imgic2111; //New icon created by Solange // SystemC-AMS - public static ImageIcon imgic8000, imgic8001, imgic8002, imgic8003, imgic8004, imgic8005, imgic8006, imgic8007, imgic8008; + public static ImageIcon imgic8000, imgic8001, imgic8002, imgic8003, imgic8004, imgic8005, imgic8006, imgic8007, imgic8008, imgic8009; // ELN public static ImageIcon imgic8010, imgic8011, imgic8012, imgic8013, imgic8014, imgic8015, imgic8016, imgic8017, imgic8018, imgic8019, imgic8020, @@ -674,7 +674,9 @@ public class IconManager { private static String icon8006 = "camsclusterblock.gif"; private static String icon8007 = "camstdfblock.gif"; private static String icon8008 = "camsdeblock.gif"; + private static String icon8009 = "camsgpio2vciblock.gif"; + // ELN private static String icon8010 = "elnresistor.gif"; private static String icon8011 = "elncapacitor.gif"; private static String icon8012 = "elninductor.gif"; @@ -1184,6 +1186,7 @@ public class IconManager { imgic8006 = getIcon(icon8006); imgic8007 = getIcon(icon8007); imgic8008 = getIcon(icon8008); + imgic8009 = getIcon(icon8009); imgic8010 = getIcon(icon8010); imgic8011 = getIcon(icon8011);