diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md new file mode 100644 index 0000000000000000000000000000000000000000..31afbe1ff37c97f1a17dccd74688ac67a265fbae --- /dev/null +++ b/.gitlab/issue_templates/Bug.md @@ -0,0 +1,38 @@ +# Summary + +(Summarize the bug encountered concisely) + +# Steps to reproduce + +(How one can reproduce the issue - this is very important) + + +# Example Project + +(If possible, please create an example project here on GitLab.com that exhibits the problematic behaviour, and link to it here in the bug report) + +(If you are using an older version of GitLab, this will also determine whether the bug has been fixed in a more recent version) + + +# What is the current bug behavior? + +(What actually happens) + + +# What is the expected correct behavior? + +(What you should see instead) + + +# Relevant logs and/or screenshots + +(Paste any relevant logs - please use code blocks (```) to format console output, +logs, and code as it's very hard to read otherwise.) + + +# Possible fixes + +(If you can, link to the line of code that might be responsible for the problem) + +/label ~bug ~reproduced ~needs-investigation + diff --git a/doc/dev_infrastructure/.gitignore b/doc/dev_infrastructure/.gitignore index e7309e96c8c39061059b545e5c2e85728047bba5..3c5c11d222694811fae0b644a884a1aa705c4ceb 100644 --- a/doc/dev_infrastructure/.gitignore +++ b/doc/dev_infrastructure/.gitignore @@ -5,3 +5,5 @@ /*.log /*.out /*.toc +/ttool_development_infrastructur.synctex.gz +/*.class \ No newline at end of file diff --git a/src/.classpath b/src/.classpath index 52a7ed71d360ed1f959809647a1c20e1d37e18a1..95eb21f4c34c4d6deb818edf9de2e04072ecfa22 100644 --- a/src/.classpath +++ b/src/.classpath @@ -1,7 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="main/java"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> + <attributes> + <attribute name="module" value="true"/> + </attributes> + </classpathentry> <classpathentry kind="lib" path="/libs/commons-codec-1.10.jar"/> <classpathentry kind="lib" path="/libs/commons-io-2.4.jar"/> <classpathentry kind="lib" path="/libs/derby.jar"/> @@ -20,5 +24,9 @@ <classpathentry kind="lib" path="/libs/jautomata-core.jar"/> <classpathentry kind="lib" path="/libs/jna-3.3.0.jar"/> <classpathentry kind="lib" path="/libs/com.microsoft.z3.jar"/> + <classpathentry kind="lib" path="/libs/jgrapht-core-1.3.0.jar"/> + <classpathentry kind="lib" path="/libs/jgrapht-ext-1.3.0.jar"/> + <classpathentry kind="lib" path="/libs/jgrapht-io-1.3.0.jar"/> + <classpathentry kind="lib" path="/libs/jgraphx-3.4.1.3.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/src/main/java/graph/AUTBlock.java b/src/main/java/graph/AUTBlock.java index c0ebab67e008e0296937d76965b2ffe5ee2dd6c6..89bb1b04660f2c960c818e53f34ff3c86619d983 100755 --- a/src/main/java/graph/AUTBlock.java +++ b/src/main/java/graph/AUTBlock.java @@ -161,7 +161,7 @@ public class AUTBlock implements Comparable<AUTBlock> { public void computeHash() { Collections.sort(states); int[] hash = new int[states.size()]; - int cpt = 0; + //int cpt = 0; for(int i=0; i<hash.length; i++) { hash[i] = states.get(i).id; } @@ -204,14 +204,13 @@ public class AUTBlock implements Comparable<AUTBlock> { } public static AUTBlock concat(AUTBlock b1, AUTBlock b2) { - AUTBlock ret = new AUTBlock(); - for(AUTState st1: b1.states) { - ret.addState(st1); - } - for(AUTState st2: b2.states) { - ret.addState(st2); - } - return ret; + AUTBlock ret = new AUTBlock(); + for(AUTState st1: b1.states) { + ret.addState(st1); + } + for(AUTState st2: b2.states) { + ret.addState(st2); + } + return ret; } - } diff --git a/src/main/java/tmltranslator/HwA.java b/src/main/java/tmltranslator/HwA.java index 92a68d18efcdb1ba429eb02a2f8135aabe917bda..8b8e8e7cf2225b7e936dfaf83fbbf2354af57621 100755 --- a/src/main/java/tmltranslator/HwA.java +++ b/src/main/java/tmltranslator/HwA.java @@ -67,11 +67,13 @@ public class HwA extends HwExecutionNode { public HwA(String _name) { super(_name); } - + + @Override public String getType() { return "HWA"; } - + + @Override public String toXML() { String s = "<HWA name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" execiTime=\"" + execiTime + "\" execcTime=\"" + execcTime + "\" />\n"; return s; diff --git a/src/main/java/tmltranslator/HwBridge.java b/src/main/java/tmltranslator/HwBridge.java index e2d0c637e5184c71ddfaf4e35f52ced7867bce6d..734191ff4b07374c921c62c0ef4ede790dfdd88c 100755 --- a/src/main/java/tmltranslator/HwBridge.java +++ b/src/main/java/tmltranslator/HwBridge.java @@ -42,11 +42,11 @@ package tmltranslator; import java.util.ArrayList; +import java.util.List; import java.util.HashMap; -import java.util.HashSet; +import java.util.HashSet; import java.util.Objects; - /** * Class HwBridge * Creation: 23/11/2007 @@ -58,14 +58,15 @@ public class HwBridge extends HwCommunicationNode { public static final int DEFAULT_BUFFER_BYTE_DATA_SIZE = 4; public boolean isFirewall; - public ArrayList<String> firewallRules = new ArrayList<String>(); + public List<String> firewallRules = new ArrayList<String>(); public int latency = 0; public int bufferByteSize = DEFAULT_BUFFER_BYTE_DATA_SIZE; // In bytes. Should more than 0 public HwBridge(String _name) { super(_name); } - + + @Override public String toXML() { String s = "<BRIDGE name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" bufferByteSize=\"" + bufferByteSize + "\" />\n"; return s; diff --git a/src/main/java/tmltranslator/HwBus.java b/src/main/java/tmltranslator/HwBus.java index 8f824501c3b4c14d671c1b526443d8955bca19bb..f295908fcbccb61b929ac58bd3905b7d6b22996b 100755 --- a/src/main/java/tmltranslator/HwBus.java +++ b/src/main/java/tmltranslator/HwBus.java @@ -69,7 +69,8 @@ public class HwBus extends HwCommunicationNode { public HwBus(String _name) { super(_name); } - + + @Override public String toXML() { String s = "<BUS name=\"" + getName() + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" pipelineSize=\"" + pipelineSize + "\" arbitration=\"" + arbitration + "\" sliceTime=\"" + sliceTime + "\" />\n"; return s; diff --git a/src/main/java/tmltranslator/HwCPU.java b/src/main/java/tmltranslator/HwCPU.java index 5049c34f1d9f177364fbce15b8d17b721f3bc0a0..fb7bd2651505590486c398980ff0189cdfb27d05 100755 --- a/src/main/java/tmltranslator/HwCPU.java +++ b/src/main/java/tmltranslator/HwCPU.java @@ -37,6 +37,8 @@ */ + + package tmltranslator; import tmltranslator.modelcompiler.ArchUnitMEC; @@ -56,9 +58,9 @@ public class HwCPU extends HwExecutionNode { public static final int BASIC_ROUND_ROBIN = 0; public static final int ROUND_ROBIN_PRIORITY_BASED = 1; - public static final int ENCRYPTION_NONE = 0; - public static final int ENCRYPTION_SW = 1; - public static final int ENCRYPTION_HW = 2; + public static final int ENCRYPTION_NONE= 0; + public static final int ENCRYPTION_SW= 1; + public static final int ENCRYPTION_HW= 2; public static final int DEFAULT_NB_OF_CORES = 1; public static final int DEFAULT_BYTE_DATA_SIZE = 4; public static final int DEFAULT_PIPELINE_SIZE = 5; @@ -71,7 +73,7 @@ public class HwCPU extends HwExecutionNode { public static final int DEFAULT_SLICE_TIME = 10000; // in microseconds public static final ArchUnitMEC DEFAULT_MODEL_EXTENSION_CONSTRUCT = new CpuMEC(); - public int encryption = 0; + public int encryption = 0; public int nbOfCores = DEFAULT_NB_OF_CORES; // Should be equal or greater than 1 public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // Should be greater than 0 public int pipelineSize = DEFAULT_PIPELINE_SIZE; // Should be greater than 0 @@ -88,14 +90,15 @@ public class HwCPU extends HwExecutionNode { super(_name); maximumNbOfTasks = 100; } - + + @Override public String getType() { - switch (schedulingPolicy) { - case ROUND_ROBIN_PRIORITY_BASED: - return "CPURRPB"; - case BASIC_ROUND_ROBIN: - default: - return "CPURR"; + switch(schedulingPolicy) { + case ROUND_ROBIN_PRIORITY_BASED: + return "CPURRPB"; + case BASIC_ROUND_ROBIN: + default: + return "CPURR"; } } diff --git a/src/main/java/tmltranslator/HwCrossbar.java b/src/main/java/tmltranslator/HwCrossbar.java index c5d63c9067f88880d2bf069e9257510a6cb0c035..0cd9f9131de441f3f32d8308234a6c6475978e1d 100755 --- a/src/main/java/tmltranslator/HwCrossbar.java +++ b/src/main/java/tmltranslator/HwCrossbar.java @@ -57,7 +57,8 @@ public class HwCrossbar extends HwCommunicationNode { public HwCrossbar(String _name) { super(_name); } - + + @Override public String toXML() { String s = "<CROSSBAR name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" />\n"; return s; diff --git a/src/main/java/tmltranslator/HwDMA.java b/src/main/java/tmltranslator/HwDMA.java index cb68f6338dcf875e538997df513c29aca605ec4a..6c461dfe1c1f6b2341c5b7fed55699b91f0979d8 100755 --- a/src/main/java/tmltranslator/HwDMA.java +++ b/src/main/java/tmltranslator/HwDMA.java @@ -60,7 +60,8 @@ public class HwDMA extends HwCommunicationNode { public HwDMA(String _name) { super(_name); } - + + @Override public String toXML() { String s = "<DMA name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" nbOfChannels=\"" + nbOfChannels + "\" execiTime=\"" + "1" + "\" execcTime=\"" + "1" +"\" />\n"; return s; diff --git a/src/main/java/tmltranslator/HwFPGA.java b/src/main/java/tmltranslator/HwFPGA.java index a1b038fb6dec73008f12c3f267a5a6eb000928ab..0d0a3ba598f380d2a33fa699a2f53a49779d9f06 100755 --- a/src/main/java/tmltranslator/HwFPGA.java +++ b/src/main/java/tmltranslator/HwFPGA.java @@ -41,8 +41,6 @@ package tmltranslator; import tmltranslator.modelcompiler.ArchUnitMEC; -import java.util.Objects; - /** * Class HwFPGA @@ -53,6 +51,7 @@ import java.util.Objects; */ public class HwFPGA extends HwExecutionNode { + public static final int DEFAULT_BYTE_DATA_SIZE = 4; public static final int DEFAULT_GO_IDLE_TIME = 10; public static final int DEFAULT_MAX_CONSECUTIVE_IDLE_CYCLES = 10; @@ -60,6 +59,8 @@ public class HwFPGA extends HwExecutionNode { public static final int DEFAULT_MAPPING_PENALTY = 0; public static final int DEFAULT_RECONFIGURATION_TIME = 50; + + public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // Should be greater than 0 public int goIdleTime = DEFAULT_GO_IDLE_TIME; // Should be greater or equal to 0 public int maxConsecutiveIdleCycles = DEFAULT_MAX_CONSECUTIVE_IDLE_CYCLES; // Should be greater or equal to 0 @@ -72,7 +73,8 @@ public class HwFPGA extends HwExecutionNode { public HwFPGA(String _name) { super(_name); } - + + @Override public String getType() { return "FPGA"; } @@ -80,7 +82,8 @@ public class HwFPGA extends HwExecutionNode { public void setScheduling(String scheduling) { this.scheduling = scheduling;} public String getScheduling() {return scheduling;} - + + @Override public String toXML() { String s = "<FPGA name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" execiTime=\"" + execiTime + "\" execcTime=\"" + execcTime + "\" pipelineSize=\""; @@ -89,16 +92,16 @@ public class HwFPGA extends HwExecutionNode { return s; } - public boolean equalSpec(Object o) { - if (!(o instanceof HwFPGA)) return false; - if(!super.equalSpec(o)) return false; - HwFPGA hwFPGA = (HwFPGA) o; - return byteDataSize == hwFPGA.byteDataSize && - goIdleTime == hwFPGA.goIdleTime && - maxConsecutiveIdleCycles == hwFPGA.maxConsecutiveIdleCycles && - capacity == hwFPGA.capacity && - mappingPenalty == hwFPGA.mappingPenalty && - reconfigurationTime == hwFPGA.reconfigurationTime && - scheduling.equals(hwFPGA.scheduling); - } + public boolean equalSpec(Object o) { + if (!(o instanceof HwFPGA)) return false; + if(!super.equalSpec(o)) return false; + HwFPGA hwFPGA = (HwFPGA) o; + return byteDataSize == hwFPGA.byteDataSize && + goIdleTime == hwFPGA.goIdleTime && + maxConsecutiveIdleCycles == hwFPGA.maxConsecutiveIdleCycles && + capacity == hwFPGA.capacity && + mappingPenalty == hwFPGA.mappingPenalty && + reconfigurationTime == hwFPGA.reconfigurationTime && + scheduling.equals(hwFPGA.scheduling); + } } diff --git a/src/main/java/tmltranslator/HwLink.java b/src/main/java/tmltranslator/HwLink.java index 51c8cc03d4fc4f79feaa85bfc8f7e304936088ad..6e65de2b59ca2c8a3d001fc4b99c79ce44e6bb0d 100755 --- a/src/main/java/tmltranslator/HwLink.java +++ b/src/main/java/tmltranslator/HwLink.java @@ -73,7 +73,8 @@ public class HwLink implements Comparable<HwLink> { public void setPriority(int _priority) { priority = _priority; } - + + @Override public int compareTo(HwLink o) { if (priority > o.getPriority()) return 1; if (priority < o.getPriority()) return -1; diff --git a/src/main/java/tmltranslator/HwMemory.java b/src/main/java/tmltranslator/HwMemory.java index abf43a84dfb7dffbe59a4e7576fedd24d3a86d49..aa528dbc8cbee3fef17a51582e3c62735ea6ff9c 100755 --- a/src/main/java/tmltranslator/HwMemory.java +++ b/src/main/java/tmltranslator/HwMemory.java @@ -64,6 +64,7 @@ public class HwMemory extends HwCommunicationNode { } + @Override public String toXML() { String s = "<MEMORY name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" memorySize=\"" + memorySize + "\" bufferType=\"" + bufferType + "\" />\n"; return s; diff --git a/src/main/java/ui/ZoomGraphics.java b/src/main/java/tmltranslator/HwRouter.java old mode 100644 new mode 100755 similarity index 69% rename from src/main/java/ui/ZoomGraphics.java rename to src/main/java/tmltranslator/HwRouter.java index a18047fd26556884532d77d67902a9a42fe2a502..36fe61f81c270435043ac42eeae4c90ce2db2038 --- a/src/main/java/ui/ZoomGraphics.java +++ b/src/main/java/tmltranslator/HwRouter.java @@ -1,26 +1,26 @@ /* 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, @@ -31,7 +31,7 @@ * 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. */ @@ -39,42 +39,33 @@ -package ui; +package tmltranslator; + +import java.util.ArrayList; -import java.awt.*; /** - * Class ZoomGraphics - * Working with zooms on graphics - * Creation: 19/11/2004 - * @version 1.0 19/11/2004 + * Class HwRouter + * Creation: 07/01/2019 + * @version 1.0 07/01/2019 * @author Ludovic APVRILLE */ -public class ZoomGraphics { - private Graphics g; - private double zoom; - - public ZoomGraphics(Graphics _g, double _zoom) { - g = _g; - zoom = _zoom; - } - - public Graphics getGraphics() { - return g; - } - +public class HwRouter extends HwCommunicationNode { + + public static final int DEFAULT_BUFFER_BYTE_DATA_SIZE = 4; + + public int latency = 0; + public int bufferByteSize = DEFAULT_BUFFER_BYTE_DATA_SIZE; // In bytes. Should more than 0 + public int size = 2; //2x2 by default - public void drawRoundRect(int x, int y, int w, int h, int arc1, int arc2) { - g.drawRoundRect((int)(x*zoom), (int)(y*zoom), (int)(w*zoom), (int)(h*zoom), arc1, arc2); + public HwRouter(String _name) { + super(_name); } - public void drawLine(int x1, int y1, int x2, int y2) { - g.drawLine((int)(x1*zoom), (int)(y1*zoom), (int)(x2*zoom), (int)(y2*zoom)); + @Override + public String toXML() { + String s = "<ROUTER name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" bufferByteSize=\"" + bufferByteSize + "\" />\n"; + return s; } - public void drawString(String value, int x, int y) { - g.drawString(value, (int)(x*zoom) , (int)(y*zoom)); - } - - } diff --git a/src/main/java/tmltranslator/HwVGMN.java b/src/main/java/tmltranslator/HwVGMN.java index 372f5e7939949fad63950d16772b488b937a38b0..2409bc70842fa52f3276acc04ac8a6776826b031 100755 --- a/src/main/java/tmltranslator/HwVGMN.java +++ b/src/main/java/tmltranslator/HwVGMN.java @@ -56,7 +56,8 @@ public class HwVGMN extends HwCommunicationNode { public HwVGMN(String _name) { super(_name); } - + + @Override public String toXML() { String s = "<VGMN name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" />\n"; return s; diff --git a/src/main/java/tmltranslator/TMLActivityElementChannel.java b/src/main/java/tmltranslator/TMLActivityElementChannel.java index 39bbb09f2423383632de9ebcc2a61db954bcfba5..62699d9363059b4643c1077205f3d2bd860d6c02 100755 --- a/src/main/java/tmltranslator/TMLActivityElementChannel.java +++ b/src/main/java/tmltranslator/TMLActivityElementChannel.java @@ -108,7 +108,8 @@ public class TMLActivityElementChannel extends TMLActivityElement { channels.add(newChan); } } - + + @Override public String customExtraToXML() { String s = " nbOfSamples=\"" + nbOfSamples + "\" "; String chan = ""; diff --git a/src/main/java/tmltranslator/TMLActivityElementWithAction.java b/src/main/java/tmltranslator/TMLActivityElementWithAction.java index e4e4c1a358f359e033c36f544000221929eb6922..e92864151027d31baa0ac9346bba2a55defdfd5c 100755 --- a/src/main/java/tmltranslator/TMLActivityElementWithAction.java +++ b/src/main/java/tmltranslator/TMLActivityElementWithAction.java @@ -63,11 +63,13 @@ public class TMLActivityElementWithAction extends TMLActivityElement { public String getAction() { return action; } - + + @Override public String toString() { return "Action: " + getAction(); } - + + @Override public String customExtraToXML() { String s = " action=\"" + getAction() + "\""; return s; diff --git a/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java b/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java index b2347ee0a4b3e1a4de848d6201669a0beb612b77..50d41f58a3649186e41892f4e0d090352d0591e8 100755 --- a/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java +++ b/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java @@ -73,7 +73,8 @@ public class TMLActivityElementWithIntervalAction extends TMLActivityElement { public String getMaxDelay() { return maxDelay; } - + + @Override public String customExtraToXML() { return " min=\"" + minDelay + "\" max=\"" + maxDelay + "\" " + "isActiveDelay=\"" + isActiveDelay + "\" "; } diff --git a/src/main/java/tmltranslator/TMLArchiTextSpecification.java b/src/main/java/tmltranslator/TMLArchiTextSpecification.java index ba656f5fded0f582db4f5bfe42cad2548bea1ae0..83cbeee3735fc406dac47104f335c75ad36124e1 100755 --- a/src/main/java/tmltranslator/TMLArchiTextSpecification.java +++ b/src/main/java/tmltranslator/TMLArchiTextSpecification.java @@ -122,7 +122,8 @@ public class TMLArchiTextSpecification { return warnings; } - + + @Override public String toString() { return spec; } diff --git a/src/main/java/tmltranslator/TMLCPSyntaxChecking.java b/src/main/java/tmltranslator/TMLCPSyntaxChecking.java index acf7e2bc222c2c996cba9912fe0ea57cf0f107f3..c3348d1f17f361f8aa92c6f62222df29d3b4b6e7 100755 --- a/src/main/java/tmltranslator/TMLCPSyntaxChecking.java +++ b/src/main/java/tmltranslator/TMLCPSyntaxChecking.java @@ -381,7 +381,7 @@ public class TMLCPSyntaxChecking { for (TMLSDMessage message : messagesList) { String senderInstance = message.getSenderName(); String receiverInstance = message.getReceiverName(); - ArrayList<TMLAttribute> parametersList = message.getAttributes(); + List<TMLAttribute> parametersList = message.getAttributes(); for (TMLAttribute parameter : parametersList) { //skip numerical parameters if (!parameter.getName().matches("-?\\d+(\\.\\d+)?")) { diff --git a/src/main/java/tmltranslator/tmlcp/TMLSDMessage.java b/src/main/java/tmltranslator/tmlcp/TMLSDMessage.java index f30fb243d49dac410557bee9a15ab05b8e0fc7df..afc25dc2622d575af469f2f3cea9c2222162592f 100755 --- a/src/main/java/tmltranslator/tmlcp/TMLSDMessage.java +++ b/src/main/java/tmltranslator/tmlcp/TMLSDMessage.java @@ -37,15 +37,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package tmltranslator.tmlcp; import tmltranslator.TMLAttribute; import tmltranslator.TMLElement; import java.util.ArrayList; +import java.util.List; /** * Class TMLSDMessage @@ -56,7 +54,7 @@ import java.util.ArrayList; public class TMLSDMessage extends TMLElement { //mind the difference between TMLAttribute and TMLAttribute! - private ArrayList<TMLAttribute> attributeList; + private List<TMLAttribute> attributeList; private String senderName = ""; private String receiverName = ""; private int yCoord; @@ -78,7 +76,7 @@ public class TMLSDMessage extends TMLElement { }*/ public TMLSDMessage( String _name, String _senderName, String _receiverName, int _yCoord, - Object _referenceObject, ArrayList<String> _params ) { + Object _referenceObject, List<String> _params ) { super( _name, _referenceObject ); this.yCoord = _yCoord; this.senderName = _senderName; @@ -90,7 +88,7 @@ public class TMLSDMessage extends TMLElement { } // Constructor used for the TMLCPparser where in the TMLCP code there is no notion of yCoord and of referenceObject - public TMLSDMessage( String _name, String _senderName, String _receiverName, ArrayList<String> _params ) { + public TMLSDMessage( String _name, String _senderName, String _receiverName, List<String> _params ) { super( _name, null ); this.yCoord = -1; this.senderName = _senderName; @@ -114,7 +112,7 @@ public class TMLSDMessage extends TMLElement { attributeList.add( _attribute ); } - public ArrayList<TMLAttribute> getAttributes() { + public List<TMLAttribute> getAttributes() { return attributeList; } diff --git a/src/main/java/translator/ADActionStateWithMultipleParam.java b/src/main/java/translator/ADActionStateWithMultipleParam.java index 9df17c5d290faccb2490c46b5902ba525ec799bf..b6b3f48ac2cd7c1966016814cb0ec75f096d1d88 100755 --- a/src/main/java/translator/ADActionStateWithMultipleParam.java +++ b/src/main/java/translator/ADActionStateWithMultipleParam.java @@ -63,7 +63,7 @@ public class ADActionStateWithMultipleParam extends ADActionState { public int nbOfActions() { int cpt = 0; - int index; + //int index; for(int i=0; i<actionValue.length(); i++) { if (actionValue.charAt(i) == ';') { diff --git a/src/main/java/translator/ADChoice.java b/src/main/java/translator/ADChoice.java index ede60092e98d06e320e057514bbc2e460586f32f..9684c712b1297a3ee1fc80b3cee06940d498fe7c 100755 --- a/src/main/java/translator/ADChoice.java +++ b/src/main/java/translator/ADChoice.java @@ -248,8 +248,8 @@ public class ADChoice extends ADComponent implements NonBlockingADComponent { } public boolean isSpecialChoiceAction(boolean variableAsActions) { - ADComponent adc, adc1; - String value; + ADComponent adc;//, adc1; + //String value; for(int i=0; i<next.size(); i++) { adc = getNext(i); diff --git a/src/main/java/ui/AbstractCDElement.java b/src/main/java/ui/AbstractCDElement.java index 78dcc2bae0971ad83db39d6b406e8d20c47799a7..8e04f07d245f3399b94595773b0685acef1c6f83 100644 --- a/src/main/java/ui/AbstractCDElement.java +++ b/src/main/java/ui/AbstractCDElement.java @@ -72,9 +72,4 @@ public abstract class AbstractCDElement implements CDElement { public void acceptBackward( final ICDElementVisitor visitor ) { visitor.visit( this ); } -// -// @Override -// public boolean isFullDisabler() { -// return false; -// } } diff --git a/src/main/java/ui/DocumentationGenerator.java b/src/main/java/ui/DocumentationGenerator.java index 4ab729ac189ee150209a5f348c89b9f1dd94447f..42834a040e950c9986e48dc393b89b1360c4bab3 100644 --- a/src/main/java/ui/DocumentationGenerator.java +++ b/src/main/java/ui/DocumentationGenerator.java @@ -36,10 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - - package ui; import myutil.Conversion; @@ -57,7 +53,6 @@ import ui.util.DefaultText; import javax.imageio.ImageIO; import javax.swing.*; -import common.ConfigurationTTool; import common.SpecConfigTTool; import java.awt.image.BufferedImage; @@ -470,15 +465,16 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle tmpdoc += DefaultText.getVersion(); tmpdoc += " generation date: " + formattedDate; tmpdoc += "----\n"; - tmpdoc += "% To be compiled as follows: make all. Relies on https://github.com/pacalet/mli.git\n"; - tmpdoc += "\\documentclass[11pt,a4paper]{article}\n\n\\usepackage{graphicx}\n\n\\begin{document}\n"; - tmpdoc += "\\extrafloats{750}\n"; - tmpdoc += "\\title{" + Conversion.replaceAllString(projectName, "_", "\\_") + "}\n"; - tmpdoc += "\\date{\\today}\n"; - tmpdoc += "\\maketitle\n\n"; - tmpdoc += "\\input{"+texIncludeFileNameSvg+"}\n"; - tmpdoc += "\\end{document}\n\n"; - return tmpdoc; + tmpdoc += "% To be compiled as follows: make all. Relies on https://github.com/pacalet/mli.git\n"; + tmpdoc += "\\documentclass[11pt,a4paper]{article}\n\n\\usepackage{graphicx}\n\n\\begin{document}\n"; + tmpdoc += "\\extrafloats{750}\n"; + tmpdoc += "\\title{" + Conversion.replaceAllString(projectName, "_", "\\_") + "}\n"; + tmpdoc += "\\date{\\today}\n"; + tmpdoc += "\\maketitle\n\n"; + tmpdoc += "\\input{"+texIncludeFileNameSvg+"}\n"; + tmpdoc += "\\end{document}\n\n"; + + return tmpdoc; } public String getIncludeLatexDocumentationHeaderSvg(String _projectName) { @@ -494,5 +490,4 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle tmpdoc += "----\n\n"; return tmpdoc; } - } diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java index 60d35ace605c2abde5f84e5104e843d2d3e881a2..9b50f077ff97dfdceaa744d9ec34a8a9c657d409 100644 --- a/src/main/java/ui/GTMLModeling.java +++ b/src/main/java/ui/GTMLModeling.java @@ -3910,7 +3910,7 @@ public class GTMLModeling { } } //Map keys - ArrayList<TMLArchiKey> keys = ((TMLArchiCommunicationNode) (tgc)).getKeyList(); + List<TMLArchiKey> keys = ((TMLArchiCommunicationNode) (tgc)).getKeyList(); for (TMLArchiKey key : keys) { //TraceManager.addDev("Exploring key " + key.getValue()); SecurityPattern sp = tmlm.getSecurityPattern(key.getValue()); diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index 4c04cc4437fda927f3c7a738c5b0510c210db2d1..2e07c8d0e86a6faf64e79cd1b0cba213d469c949 100644 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -1774,7 +1774,7 @@ public class GTURTLEModeling { if (link.hwnode instanceof HwMemory) { mems.add((HwMemory) link.hwnode); TMLArchiMemoryNode memNode = (TMLArchiMemoryNode) listE.getTG(link.hwnode); - ArrayList<TMLArchiKey> keys = memNode.getKeyList(); + List<TMLArchiKey> keys = memNode.getKeyList(); String patternString = ""; for (TMLArchiKey key : keys) { if (key.getValue().equals(sp.name)) { @@ -1842,7 +1842,7 @@ public class GTURTLEModeling { if (link.hwnode instanceof HwMemory) { mems.add((HwMemory) link.hwnode); TMLArchiMemoryNode memNode = (TMLArchiMemoryNode) listE.getTG(link.hwnode); - ArrayList<TMLArchiKey> keys = memNode.getKeyList(); + List<TMLArchiKey> keys = memNode.getKeyList(); String patternString = ""; for (TMLArchiKey key : keys) { if (key.getValue().equals(sp.name)) { @@ -7497,7 +7497,7 @@ public class GTURTLEModeling { t = "" + type; } TraceManager.addDev("A badly formed component could not be created in the diagram:" + " diagram: " + tdp + " component:" + n); - + mme.printStackTrace(); UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A component could not be correctly loaded - type=" + t); ce.setTDiagramPanel(tdp); checkingErrors.add(ce); @@ -7880,7 +7880,7 @@ public class GTURTLEModeling { } catch (Exception e) { TraceManager.addError("Exception XML Component " + e.getMessage() + "trace=" + e.getStackTrace()); - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } return tgc; } diff --git a/src/main/java/ui/ScalableTGComponent.java b/src/main/java/ui/ScalableTGComponent.java index 08bc4a8ed53e07ace3c41e5b4a8ff88495ca1709..a3f73b8842826216613039df59e22ddec4ac498b 100644 --- a/src/main/java/ui/ScalableTGComponent.java +++ b/src/main/java/ui/ScalableTGComponent.java @@ -45,6 +45,7 @@ package ui; * @version 1.0 10/03/2008 * @author Ludovic APVRILLE */ -public interface ScalableTGComponent { - void rescale(double scaleFactor); +public interface ScalableTGComponent { + + void rescale(double scaleFactor); } \ No newline at end of file diff --git a/src/main/java/ui/SecurityGeneration.java b/src/main/java/ui/SecurityGeneration.java index 401b5544e01dd3e3c287c613a56d8643a4c0f722..c07d1283e4bbc97744caa5d62a478842ce3abd2d 100644 --- a/src/main/java/ui/SecurityGeneration.java +++ b/src/main/java/ui/SecurityGeneration.java @@ -83,7 +83,7 @@ public class SecurityGeneration implements Runnable { List<String> hsmTasks = new ArrayList<String>(); Map<String, String> channelSecMap = new HashMap<String, String>(); - TMLMapping<?> newMap; + TMLMapping<TGComponent> newMap; public SecurityGeneration(MainGUI gui, String name, TMLMapping<TGComponent> map, TMLArchiPanel newarch, String encComp, String overhead, String decComp, boolean autoConf, boolean autoWeakAuth, boolean autoStrongAuth, Map<String, List<String>> selectedCPUTasks){ @@ -219,7 +219,7 @@ public class SecurityGeneration implements Runnable { } public boolean portInTask(TMLTask task, String portName){ - TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel( getActivityDiagramName( task ) ); + TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel(task.getName());// FIXME ( getActivityDiagramName( task ) ); for (TGComponent tg : tad.getComponentList()) { if (tg instanceof TMLADWriteChannel) { TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg; @@ -348,7 +348,7 @@ public class SecurityGeneration implements Runnable { for (TMLTask task : map.getTMLModeling().getTasks()) { //System.out.println("Task " + task.getName()); //Check if all channel operators are secured - TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel( getActivityDiagramName( task ) ); + TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel(task.getName()); //FIXME getActivityDiagramName( task ) ) if (tad==null){ continue; @@ -475,1169 +475,1194 @@ public class SecurityGeneration implements Runnable { System.out.println("Channel found "+ chantmp); }*/ - } - if (hsmTasks.contains(chan.getOriginTask().getName().split("__")[1])){ - channelSecMap.put(chanName, "hsmSec_"+secName); - if (!hsmSecOutChannels.get(chan.getOriginTask()).contains(chanName) && portInTask(chan.getOriginTask(),chanName)){ - HSMChannel hsmchan = new HSMChannel(chanName, chan.getOriginTask().getName().split("__")[1], HSMChannel.MAC); - hsmChannelMap.get(taskHSMMap.get(chan.getOriginTask().getName().split("__")[1])).add(hsmchan); - hsmSecOutChannels.get(chan.getOriginTask()).add(chanName); - - if (autoStrongAuth) { - nonceOutChannels.get(chan.getOriginTask()).add(chanName); - hsmchan.nonceName="nonce_" + chan.getDestinationTask().getName().split("__")[1] + "_" + chan.getOriginTask().getName().split("__")[1]; - } + } + if (hsmTasks.contains(chan.getOriginTask().getName().split("__")[1])){ + channelSecMap.put(chanName, "hsmSec_"+secName); + if (!hsmSecOutChannels.get(chan.getOriginTask()).contains(chanName) && portInTask(chan.getOriginTask(),chanName)){ + HSMChannel hsmchan = new HSMChannel(chanName, chan.getOriginTask().getName().split("__")[1], HSMChannel.MAC); + hsmChannelMap.get(taskHSMMap.get(chan.getOriginTask().getName().split("__")[1])).add(hsmchan); + hsmSecOutChannels.get(chan.getOriginTask()).add(chanName); + + if (autoStrongAuth) { + nonceOutChannels.get(chan.getOriginTask()).add(chanName); + hsmchan.nonceName="nonce_" + chan.getDestinationTask().getName().split("__")[1] + "_" + chan.getOriginTask().getName().split("__")[1]; } } - else { - if (!macInChannels.get(chan.getOriginTask()).contains(chanName)) { - macOutChannels.get(chan.getOriginTask()).add(chanName); - channelSecMap.put(chanName, "autoEncrypt_"+secName); - if (autoStrongAuth) { - nonceOutChannels.get(chan.getOriginTask()).add(chanName); - } + } + else { + if (!macInChannels.get(chan.getOriginTask()).contains(chanName)) { + macOutChannels.get(chan.getOriginTask()).add(chanName); + channelSecMap.put(chanName, "autoEncrypt_"+secName); + if (autoStrongAuth) { + nonceOutChannels.get(chan.getOriginTask()).add(chanName); } } + } - if (hsmTasks.contains(chan.getDestinationTask().getName().split("__")[1])){ - if (!hsmSecInChannels.get(chan.getDestinationTask()).contains(chanName) && portInTask(chan.getDestinationTask(),chanName)) { - HSMChannel hsmchan = new HSMChannel(chanName, chan.getDestinationTask().getName().split("__")[1], HSMChannel.DEC); - hsmChannelMap.get(taskHSMMap.get(chan.getDestinationTask().getName().split("__")[1])).add(hsmchan); - hsmSecInChannels.get(chan.getDestinationTask()).add(chanName); - if (chan.checkAuth && autoStrongAuth) { - nonceInChannels.get(chan.getDestinationTask()).add(chanName); - hsmchan.nonceName="nonce_" + chan.getDestinationTask().getName().split("__")[1] + "_" + chan.getOriginTask().getName().split("__")[1]; - } + if (hsmTasks.contains(chan.getDestinationTask().getName().split("__")[1])){ + if (!hsmSecInChannels.get(chan.getDestinationTask()).contains(chanName) && portInTask(chan.getDestinationTask(),chanName)) { + HSMChannel hsmchan = new HSMChannel(chanName, chan.getDestinationTask().getName().split("__")[1], HSMChannel.DEC); + hsmChannelMap.get(taskHSMMap.get(chan.getDestinationTask().getName().split("__")[1])).add(hsmchan); + hsmSecInChannels.get(chan.getDestinationTask()).add(chanName); + if (chan.checkAuth && autoStrongAuth) { + nonceInChannels.get(chan.getDestinationTask()).add(chanName); + hsmchan.nonceName="nonce_" + chan.getDestinationTask().getName().split("__")[1] + "_" + chan.getOriginTask().getName().split("__")[1]; } } - else { - if (!secInChannels.get(chan.getDestinationTask()).contains(chanName)) { - secInChannels.get(chan.getDestinationTask()).add(chanName); - if (chan.checkAuth && autoStrongAuth) { - nonceInChannels.get(chan.getDestinationTask()).add(chanName); - } - } - } } + else { + if (!secInChannels.get(chan.getDestinationTask()).contains(chanName)) { + secInChannels.get(chan.getDestinationTask()).add(chanName); + if (chan.checkAuth && autoStrongAuth) { + nonceInChannels.get(chan.getDestinationTask()).add(chanName); + } + } + } } - else { - //Ignore strong authenticity for fork and join channels - //Only add hsm channel for own port - for (TMLTask orig: chan.getOriginTasks()){ - for (TMLTask dest:chan.getDestinationTasks()){ - if (chan.checkConf && autoConf && nonConf) { - toSecure.get(orig).add(dest); - /*if (chan.checkAuth && autoStrongAuth) { + } + else { + //Ignore strong authenticity for fork and join channels + //Only add hsm channel for own port + for (TMLTask orig: chan.getOriginTasks()){ + for (TMLTask dest:chan.getDestinationTasks()){ + if (chan.checkConf && autoConf && nonConf) { + toSecure.get(orig).add(dest); + /*if (chan.checkAuth && autoStrongAuth) { if (!toSecureRev.get(dest).contains(orig)){ toSecureRev.get(dest).add(orig); } }*/ - if (hsmTasks.contains(orig.getName().split("__")[1])){ - channelSecMap.put(chanName, "hsmSec_"+secName); - if (!hsmSecOutChannels.get(orig).contains(chanName) && portInTask(orig,chanName)){ - HSMChannel hsmchan = new HSMChannel(chanName, orig.getName().split("__")[1], HSMChannel.SENC); - hsmChannelMap.get(taskHSMMap.get(orig.getName().split("__")[1])).add(hsmchan); - hsmSecOutChannels.get(orig).add(chanName); - - /* if (chan.checkAuth && autoStrongAuth) { + if (hsmTasks.contains(orig.getName().split("__")[1])){ + channelSecMap.put(chanName, "hsmSec_"+secName); + if (!hsmSecOutChannels.get(orig).contains(chanName) && portInTask(orig,chanName)){ + HSMChannel hsmchan = new HSMChannel(chanName, orig.getName().split("__")[1], HSMChannel.SENC); + hsmChannelMap.get(taskHSMMap.get(orig.getName().split("__")[1])).add(hsmchan); + hsmSecOutChannels.get(orig).add(chanName); + + /* if (chan.checkAuth && autoStrongAuth) { nonceOutChannels.get(orig).add(chanName); hsmchan.nonceName="nonce_" + dest.getName().split("__")[1] + "_" + orig.getName().split("__")[1]; }*/ - } } - else { - if (!secOutChannels.get(orig).contains(chanName)) { - secOutChannels.get(orig).add(chanName); - channelSecMap.put(chanName, "autoEncrypt_"+secName); - /* if (chan.checkAuth && autoStrongAuth) { + } + else { + if (!secOutChannels.get(orig).contains(chanName)) { + secOutChannels.get(orig).add(chanName); + channelSecMap.put(chanName, "autoEncrypt_"+secName); + /* if (chan.checkAuth && autoStrongAuth) { nonceOutChannels.get(orig).add(chanName); }*/ - } } + } - if (hsmTasks.contains(dest.getName().split("__")[1])){ - if (!hsmSecInChannels.get(dest).contains(chanName) && portInTask(dest,chanName)) { - HSMChannel hsmchan = new HSMChannel(chanName, dest.getName().split("__")[1], HSMChannel.DEC); - hsmChannelMap.get(taskHSMMap.get(dest.getName().split("__")[1])).add(hsmchan); - hsmSecInChannels.get(dest).add(chanName); - /* if (chan.checkAuth && autoStrongAuth) { + if (hsmTasks.contains(dest.getName().split("__")[1])){ + if (!hsmSecInChannels.get(dest).contains(chanName) && portInTask(dest,chanName)) { + HSMChannel hsmchan = new HSMChannel(chanName, dest.getName().split("__")[1], HSMChannel.DEC); + hsmChannelMap.get(taskHSMMap.get(dest.getName().split("__")[1])).add(hsmchan); + hsmSecInChannels.get(dest).add(chanName); + /* if (chan.checkAuth && autoStrongAuth) { nonceInChannels.get(dest).add(chanName); hsmchan.nonceName="nonce_" + dest.getName().split("__")[1] + "_" + orig.getName().split("__")[1]; }*/ - } } - else { - if (!secInChannels.get(dest).contains(chanName)) { - secInChannels.get(dest).add(chanName); - /*if (chan.checkAuth && autoStrongAuth) { + } + else { + if (!secInChannels.get(dest).contains(chanName)) { + secInChannels.get(dest).add(chanName); + /*if (chan.checkAuth && autoStrongAuth) { nonceInChannels.get(dest).add(chanName); }*/ - } - } + } + } - } else if (chan.checkAuth && autoWeakAuth && nonAuth) { - toSecure.get(orig).add(dest); - /* if (autoStrongAuth) { + } else if (chan.checkAuth && autoWeakAuth && nonAuth) { + toSecure.get(orig).add(dest); + /* if (autoStrongAuth) { /* if (chan.getOriginTask().getReferenceObject() instanceof TMLCPrimitiveComponent && chan.getDestinationTask().getReferenceObject() instanceof TMLCPrimitiveComponent){*/ - /*if (!toSecureRev.get(dest).contains(orig)){ + /*if (!toSecureRev.get(dest).contains(orig)){ toSecureRev.get(dest).add(orig); }*/ - /*} + /*} else { TMLChannel chantmp = oldmodel.getChannelByShortName("__"+chan.getName()); System.out.println("Channel found "+ chantmp); } }*/ - if (hsmTasks.contains(orig.getName().split("__")[1])){ - channelSecMap.put(chanName, "hsmSec_"+secName); - if (!hsmSecOutChannels.get(orig).contains(chanName) && portInTask(orig,chanName)){ - HSMChannel hsmchan = new HSMChannel(chanName, orig.getName().split("__")[1], HSMChannel.MAC); - hsmChannelMap.get(taskHSMMap.get(orig.getName().split("__")[1])).add(hsmchan); - hsmSecOutChannels.get(orig).add(chanName); - - /*if (autoStrongAuth) { + if (hsmTasks.contains(orig.getName().split("__")[1])){ + channelSecMap.put(chanName, "hsmSec_"+secName); + if (!hsmSecOutChannels.get(orig).contains(chanName) && portInTask(orig,chanName)){ + HSMChannel hsmchan = new HSMChannel(chanName, orig.getName().split("__")[1], HSMChannel.MAC); + hsmChannelMap.get(taskHSMMap.get(orig.getName().split("__")[1])).add(hsmchan); + hsmSecOutChannels.get(orig).add(chanName); + + /*if (autoStrongAuth) { nonceOutChannels.get(orig).add(chanName); hsmchan.nonceName="nonce_" + dest.getName().split("__")[1] + "_" + orig.getName().split("__")[1]; }*/ - } } - else { - if (!macInChannels.get(orig).contains(chanName)) { - macOutChannels.get(orig).add(chanName); - channelSecMap.put(chanName, "autoEncrypt_"+secName); - /* if (autoStrongAuth) { + } + else { + if (!macInChannels.get(orig).contains(chanName)) { + macOutChannels.get(orig).add(chanName); + channelSecMap.put(chanName, "autoEncrypt_"+secName); + /* if (autoStrongAuth) { nonceOutChannels.get(orig).add(chanName); }*/ - } } + } - if (hsmTasks.contains(dest.getName().split("__")[1])){ + if (hsmTasks.contains(dest.getName().split("__")[1])){ - if (!hsmSecInChannels.get(dest).contains(chanName) && portInTask(dest,chanName)) { - HSMChannel hsmchan = new HSMChannel(chanName, dest.getName().split("__")[1], HSMChannel.DEC); - hsmChannelMap.get(taskHSMMap.get(dest.getName().split("__")[1])).add(hsmchan); - hsmSecInChannels.get(dest).add(chanName); - /*if (chan.checkAuth && autoStrongAuth) { + if (!hsmSecInChannels.get(dest).contains(chanName) && portInTask(dest,chanName)) { + HSMChannel hsmchan = new HSMChannel(chanName, dest.getName().split("__")[1], HSMChannel.DEC); + hsmChannelMap.get(taskHSMMap.get(dest.getName().split("__")[1])).add(hsmchan); + hsmSecInChannels.get(dest).add(chanName); + /*if (chan.checkAuth && autoStrongAuth) { nonceInChannels.get(dest).add(chanName); hsmchan.nonceName="nonce_" + dest.getName().split("__")[1] + "_" + orig.getName().split("__")[1]; }*/ - } } - else { - if (!secInChannels.get(dest).contains(chanName)) { - secInChannels.get(dest).add(chanName); - /*if (chan.checkAuth && autoStrongAuth) { + } + else { + if (!secInChannels.get(dest).contains(chanName)) { + secInChannels.get(dest).add(chanName); + /*if (chan.checkAuth && autoStrongAuth) { nonceInChannels.get(dest).add(chanName); }*/ - } - } - } + } + } } } } } + } } + } - // System.out.println("hsmchannelmap" + hsmChannelMap); - TraceManager.addDev("secChannelMap" + channelSecMap); - - TraceManager.addDev("macoutchans " + macOutChannels); - TraceManager.addDev("macinchans " + macInChannels); - TraceManager.addDev("nonsecin " + secInChannels); - TraceManager.addDev("nonsecout " + secOutChannels); - TraceManager.addDev("noncein " + nonceInChannels); - TraceManager.addDev("nonceout " + nonceOutChannels); - TraceManager.addDev("hsmsecin " + hsmSecInChannels); - TraceManager.addDev("hsmsecout " + hsmSecOutChannels); - TraceManager.addDev("tosecrev " + toSecureRev); - - //Add a HSM Task for each selected CPU on the component diagram, add associated channels, etc - for (String cpuName : selectedCPUTasks.keySet()) { - TMLCPrimitiveComponent hsm = new TMLCPrimitiveComponent(0, tcdp.getMaxY()-200, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxY(), false, null, tcdp); - TAttribute index = new TAttribute(2, "channelIndex", "0", 0); - hsm.getAttributeList().add(index); - tcdp.addComponent(hsm, 0, 500, false, true); - hsm.setValueWithChange("HSM_" + cpuName); - - //Find all associated components - List<TMLCPrimitiveComponent> comps = new ArrayList<TMLCPrimitiveComponent>(); - //Find the component to add a HSM to - - for (TGComponent tg : tcdp.getComponentList()) { - if (tg instanceof TMLCPrimitiveComponent) { + // System.out.println("hsmchannelmap" + hsmChannelMap); + TraceManager.addDev("secChannelMap" + channelSecMap); + + TraceManager.addDev("macoutchans " + macOutChannels); + TraceManager.addDev("macinchans " + macInChannels); + TraceManager.addDev("nonsecin " + secInChannels); + TraceManager.addDev("nonsecout " + secOutChannels); + TraceManager.addDev("noncein " + nonceInChannels); + TraceManager.addDev("nonceout " + nonceOutChannels); + TraceManager.addDev("hsmsecin " + hsmSecInChannels); + TraceManager.addDev("hsmsecout " + hsmSecOutChannels); + TraceManager.addDev("tosecrev " + toSecureRev); + + //Add a HSM Task for each selected CPU on the component diagram, add associated channels, etc + for (String cpuName : selectedCPUTasks.keySet()) { + TMLCPrimitiveComponent hsm = new TMLCPrimitiveComponent(0, tcdp.getMaxY()-200, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxY(), false, null, tcdp); + TAttribute index = new TAttribute(2, "channelIndex", "0", 0); + hsm.getAttributeList().add(index); + tcdp.addComponent(hsm, 0, 500, false, true); + hsm.setValueWithChange("HSM_" + cpuName); + + //Find all associated components + List<TMLCPrimitiveComponent> comps = new ArrayList<TMLCPrimitiveComponent>(); + //Find the component to add a HSM to + + for (TGComponent tg : tcdp.getComponentList()) { + if (tg instanceof TMLCPrimitiveComponent) { + for (String compName : selectedCPUTasks.get(cpuName)) { + if (tg.getValue().equals(compName)) { + comps.add((TMLCPrimitiveComponent) tg); + break; + } + } + } else if (tg instanceof TMLCCompositeComponent) { + TMLCCompositeComponent cc = (TMLCCompositeComponent) tg; + List<TMLCPrimitiveComponent> pcomps = cc.getAllPrimitiveComponents(); + for (TMLCPrimitiveComponent pc : pcomps) { for (String compName : selectedCPUTasks.get(cpuName)) { - if (tg.getValue().equals(compName)) { - comps.add((TMLCPrimitiveComponent) tg); + if (pc.getValue().equals(compName)) { + comps.add(pc); break; } } - } else if (tg instanceof TMLCCompositeComponent) { - TMLCCompositeComponent cc = (TMLCCompositeComponent) tg; - List<TMLCPrimitiveComponent> pcomps = cc.getAllPrimitiveComponents(); - for (TMLCPrimitiveComponent pc : pcomps) { - for (String compName : selectedCPUTasks.get(cpuName)) { - if (pc.getValue().equals(compName)) { - comps.add(pc); - break; - } - } - } - } - } - if (comps.size() == 0) { - //System.out.println("No Components found"); - continue; + } } + } + if (comps.size() == 0) { + //System.out.println("No Components found"); + continue; + } - for (TMLCPrimitiveComponent comp : comps) { - - // Map<String, HSMChannel> compChannels = new HashMap<String, HSMChannel>(); - // String compName = comp.getValue(); - - List<ChannelData> hsmChans = new ArrayList<ChannelData>(); - ChannelData chd = new ChannelData("startHSM_" + cpuName, false, false); - hsmChans.add(chd); - for (HSMChannel hsmChan : hsmChannelMap.get(cpuName)) { - if (!hsmChan.task.equals(comp.getValue())){ - continue; - } - if (!channelIndexMap.containsKey(hsmChan.name)){ - channelIndexMap.put(hsmChan.name,channelIndex); - channelIndex++; - } - chd = new ChannelData("data_" + hsmChan.name + "_" + hsmChan.task, false, true); - hsmChans.add(chd); - chd = new ChannelData("retData_" + hsmChan.name + "_" + hsmChan.task, true, true); - hsmChans.add(chd); - } - for (ChannelData hsmChan : hsmChans) { - TMLCChannelOutPort originPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, hsm, tcdp); - TMLCChannelOutPort destPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, comp, tcdp); - originPort.commName = hsmChan.name; - originPort.isOrigin = hsmChan.isOrigin; - tcdp.addComponent(originPort, hsm.getX(), hsm.getY(), true, true); - destPort.commName = hsmChan.name; - if (!hsmChan.isChan) { - originPort.typep = 2; - destPort.typep = 2; - originPort.setParam(0, new TType(1)); - destPort.setParam(0, new TType(1)); - } - destPort.isOrigin = !hsmChan.isOrigin; + for (TMLCPrimitiveComponent comp : comps) { - tcdp.addComponent(destPort, comp.getX(), comp.getY(), true, true); + //Map<String, HSMChannel> compChannels = new HashMap<String, HSMChannel>(); + //String compName = comp.getValue(); - TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>()); - tcdp.addComponent(conn, 0, 0, false, true); + List<ChannelData> hsmChans = new ArrayList<ChannelData>(); + ChannelData chd = new ChannelData("startHSM_" + cpuName, false, false); + hsmChans.add(chd); + for (HSMChannel hsmChan : hsmChannelMap.get(cpuName)) { + if (!hsmChan.task.equals(comp.getValue())){ + continue; } + if (!channelIndexMap.containsKey(hsmChan.name)){ + channelIndexMap.put(hsmChan.name,channelIndex); + channelIndex++; + } + chd = new ChannelData("data_" + hsmChan.name + "_" + hsmChan.task, false, true); + hsmChans.add(chd); + chd = new ChannelData("retData_" + hsmChan.name + "_" + hsmChan.task, true, true); + hsmChans.add(chd); + } + for (ChannelData hsmChan : hsmChans) { + TMLCChannelOutPort originPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, hsm, tcdp); + TMLCChannelOutPort destPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, comp, tcdp); + originPort.commName = hsmChan.name; + originPort.isOrigin = hsmChan.isOrigin; + tcdp.addComponent(originPort, hsm.getX(), hsm.getY(), true, true); + destPort.commName = hsmChan.name; + if (!hsmChan.isChan) { + originPort.typep = 2; + destPort.typep = 2; + originPort.setParam(0, new TType(1)); + destPort.setParam(0, new TType(1)); + } + + destPort.isOrigin = !hsmChan.isOrigin; + + tcdp.addComponent(destPort, comp.getX(), comp.getY(), true, true); + + TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>()); + tcdp.addComponent(conn, 0, 0, false, true); } } + } - for (String cpuName : selectedCPUTasks.keySet()) { - buildHSMActivityDiagram(cpuName); - //Add a private bus to Hardware Accelerator with the task for hsm - - //Find the CPU the task is mapped to - TMLArchiDiagramPanel archPanel = newarch.tmlap; - TMLArchiCPUNode cpu = null; - String refTask = ""; - for (TGComponent tg : archPanel.getComponentList()) { - if (tg instanceof TMLArchiCPUNode) { - if (tg.getName().equals(cpuName)) { - cpu = (TMLArchiCPUNode) tg; - TMLArchiArtifact art = cpu.getArtifactList().get(0); - refTask = art.getReferenceTaskName(); - break; + for (String cpuName : selectedCPUTasks.keySet()) { + buildHSMActivityDiagram(cpuName); + //Add a private bus to Hardware Accelerator with the task for hsm + + //Find the CPU the task is mapped to + TMLArchiDiagramPanel archPanel = newarch.tmlap; + TMLArchiCPUNode cpu = null; + String refTask = ""; + for (TGComponent tg : archPanel.getComponentList()) { + if (tg instanceof TMLArchiCPUNode) { + if (tg.getName().equals(cpuName)) { + cpu = (TMLArchiCPUNode) tg; + TMLArchiArtifact art = cpu.getArtifactList().get(0); + refTask = art.getReferenceTaskName(); + break; - } } } + } - if (cpu == null) { - return; - } - - //Add new memory - TMLArchiMemoryNode mem = new TMLArchiMemoryNode(cpu.getX(), archPanel.getMaxY()-800, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); - archPanel.addComponent(mem, cpu.getX(), archPanel.getMaxY()-400, false, true); - mem.setName("HSMMemory_" + cpuName); - //Add Hardware Accelerator - - TMLArchiHWANode hwa = new TMLArchiHWANode(cpu.getX(), archPanel.getMaxY()-300, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); - archPanel.addComponent(hwa, cpu.getX() + 100, cpu.getY() + 100, false, true); - hwa.setName("HSM_" + cpuName); - //Add hsm task to hwa - - - TMLArchiArtifact hsmArt = new TMLArchiArtifact(cpu.getX(), archPanel.getMaxY()- 280, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, hwa, archPanel); - archPanel.addComponent(hsmArt, cpu.getX() + 100, archPanel.getMaxY()- 280, true, true); - hsmArt.setFullName("HSM_" + cpuName, refTask); - //Add bus connecting the cpu and HWA - - TMLArchiBUSNode bus = new TMLArchiBUSNode(cpu.getX() + 50, archPanel.getMaxY() -500, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); - bus.setPrivacy(1); - bus.setName("HSMBus_" + cpuName); - archPanel.addComponent(bus, cpu.getX() + 200, cpu.getY() + 200, false, true); - - //Connect Bus and CPU - TMLArchiConnectorNode connect = new TMLArchiConnectorNode(cpu.getX() + 100, archPanel.getMaxY() -300, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>()); - TGConnectingPoint p1 = bus.findFirstFreeTGConnectingPoint(true, true); - p1.setFree(false); - connect.setP2(p1); - - - TGConnectingPoint p2 = cpu.findFirstFreeTGConnectingPoint(true, true); - p2.setFree(false); - connect.setP1(p2); - archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true); - //Connect Bus and HWA - - connect = new TMLArchiConnectorNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>()); - p1 = bus.findFirstFreeTGConnectingPoint(true, true); - p1.setFree(false); - connect.setP2(p1); - - p2 = hwa.findFirstFreeTGConnectingPoint(true, true); - p2.setFree(false); - connect.setP1(p2); - - archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true); - //Connect Bus and Memory - - connect = new TMLArchiConnectorNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>()); - p1 = bus.findFirstFreeTGConnectingPoint(true, true); - p1.setFree(false); - connect.setP2(p1); - - p2 = mem.findFirstFreeTGConnectingPoint(true, true); - p2.setFree(false); - connect.setP1(p2); - archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true); + if (cpu == null) { + return; } - // - // int num=0; - //int nonceNum=0; - //Create reverse channels on component diagram to send nonces if they don't already exist + //Add new memory + TMLArchiMemoryNode mem = new TMLArchiMemoryNode(cpu.getX(), archPanel.getMaxY()-800, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); + archPanel.addComponent(mem, cpu.getX(), archPanel.getMaxY()-400, false, true); + mem.setName("HSMMemory_" + cpuName); + //Add Hardware Accelerator + + TMLArchiHWANode hwa = new TMLArchiHWANode(cpu.getX(), archPanel.getMaxY()-300, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); + archPanel.addComponent(hwa, cpu.getX() + 100, cpu.getY() + 100, false, true); + hwa.setName("HSM_" + cpuName); + //Add hsm task to hwa + + + TMLArchiArtifact hsmArt = new TMLArchiArtifact(cpu.getX(), archPanel.getMaxY()- 280, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, hwa, archPanel); + archPanel.addComponent(hsmArt, cpu.getX() + 100, archPanel.getMaxY()- 280, true, true); + hsmArt.setFullName("HSM_" + cpuName, refTask); + //Add bus connecting the cpu and HWA + + TMLArchiBUSNode bus = new TMLArchiBUSNode(cpu.getX() + 50, archPanel.getMaxY() -500, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); + bus.setPrivacy(1); + bus.setName("HSMBus_" + cpuName); + archPanel.addComponent(bus, cpu.getX() + 200, cpu.getY() + 200, false, true); + + //Connect Bus and CPU + TMLArchiConnectorNode connect = new TMLArchiConnectorNode(cpu.getX() + 100, archPanel.getMaxY() -300, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>()); + TGConnectingPoint p1 = bus.findFirstFreeTGConnectingPoint(true, true); + p1.setFree(false); + connect.setP2(p1); + + + TGConnectingPoint p2 = cpu.findFirstFreeTGConnectingPoint(true, true); + p2.setFree(false); + connect.setP1(p2); + archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true); + //Connect Bus and HWA + + connect = new TMLArchiConnectorNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>()); + p1 = bus.findFirstFreeTGConnectingPoint(true, true); + p1.setFree(false); + connect.setP2(p1); + + p2 = hwa.findFirstFreeTGConnectingPoint(true, true); + p2.setFree(false); + connect.setP1(p2); + + archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true); + //Connect Bus and Memory + + connect = new TMLArchiConnectorNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>()); + p1 = bus.findFirstFreeTGConnectingPoint(true, true); + p1.setFree(false); + connect.setP2(p1); + + p2 = mem.findFirstFreeTGConnectingPoint(true, true); + p2.setFree(false); + connect.setP1(p2); + archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true); + } + // + // int num=0; + //int nonceNum=0; + //Create reverse channels on component diagram to send nonces if they don't already exist - for (TMLTask task : toSecureRev.keySet()) { - // TraceManager.addDev("Adding nonces to " + task.getName()); - List<TMLChannel> chans = tmlmodel.getChannelsFromMe(task); - for (TMLTask task2 : toSecureRev.get(task)) { - boolean addChan = true; - for (TMLChannel chan : chans) { - if (chan.getDestinationTask() == task2) { - addChan = false; - } + for (TMLTask task : toSecureRev.keySet()) { + // TraceManager.addDev("Adding nonces to " + task.getName()); + List<TMLChannel> chans = tmlmodel.getChannelsFromMe(task); + + for (TMLTask task2 : toSecureRev.get(task)) { + boolean addChan = true; + for (TMLChannel chan : chans) { + if (chan.getDestinationTask() == task2) { + addChan = false; } + } - if (addChan) { - TMLCChannelOutPort originPort = new TMLCChannelOutPort(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp); - TMLCChannelOutPort destPort = new TMLCChannelOutPort(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp); + if (addChan) { + TMLCChannelOutPort originPort = new TMLCChannelOutPort(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp); + TMLCChannelOutPort destPort = new TMLCChannelOutPort(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp); - if (task.getReferenceObject() instanceof TMLCPrimitiveComponent){ - TGComponent tg = (TGComponent) task.getReferenceObject(); - originPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, tg, tcdp); - originPort.commName = "nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1]; - tcdp.addComponent(originPort, tg.getX(), tg.getY(), true, true); - } - if (task2.getReferenceObject() instanceof TMLCPrimitiveComponent){ - TGComponent tg = (TGComponent) task2.getReferenceObject(); - destPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, tg, tcdp); - destPort.isOrigin = false; - destPort.commName = "nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1]; - tcdp.addComponent(destPort, tg.getX(), tg.getY(), true, true); - } - tmlmodel.addChannel(new TMLChannel("nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1], originPort)); - //Add connection - TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>()); - tcdp.addComponent(conn, 0, 0, false, true); + if (task.getReferenceObject() instanceof TMLCPrimitiveComponent){ + TGComponent tg = (TGComponent) task.getReferenceObject(); + originPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, tg, tcdp); + originPort.commName = "nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1]; + tcdp.addComponent(originPort, tg.getX(), tg.getY(), true, true); } + if (task2.getReferenceObject() instanceof TMLCPrimitiveComponent){ + TGComponent tg = (TGComponent) task2.getReferenceObject(); + destPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, tg, tcdp); + destPort.isOrigin = false; + destPort.commName = "nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1]; + tcdp.addComponent(destPort, tg.getX(), tg.getY(), true, true); + } + tmlmodel.addChannel(new TMLChannel("nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1], originPort)); + //Add connection + TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>()); + tcdp.addComponent(conn, 0, 0, false, true); } } + } - // } - //Add encryption/nonces to activity diagram - for (TMLTask task : toSecure.keySet()) { - TraceManager.addDev("Securing task " + task.getName()); - TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel( getActivityDiagramName( task ) ); - if (tad==null){ - continue; - } - //Get start state position, shift everything down - int xpos = 0; - int ypos = 0; - TGConnector fromStart = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); - TGConnectingPoint point = new TGConnectingPoint(null, 0, 0, false, false); - //Find states immediately before the write channel operator - - //For each occurence of a write channel operator, add encryption/nonces before it - - - for (String channel : secOutChannels.get(task)) { - Set<TGComponent> channelInstances = new HashSet<TGComponent>(); - int yShift = 50; - TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); - if (tmlc==null){ - //Find by origin port instead - tmlc = tmlmodel.getChannelByOriginPortName(channel); - } - if (tmlc==null){ - continue; - } - //First, find the connector that points to it. We will add the encryption, nonce operators directly before the write channel operator - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADWriteChannel) { - TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg; - if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) { - if (fromStart != null) { - channelInstances.add(tg); - } - } + + // } + //Add encryption/nonces to activity diagram +for (TMLTask task : toSecure.keySet()) { + TraceManager.addDev("Securing task " + task.getName()); + TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel(task.getName()); + if (tad==null){ + continue; + } + //Get start state position, shift everything down + int xpos = 0; + int ypos = 0; + TGConnector fromStart = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); + TGConnectingPoint point = new TGConnectingPoint(null, 0, 0, false, false); + //Find states immediately before the write channel operator + + //For each occurence of a write channel operator, add encryption/nonces before it + + + for (String channel : secOutChannels.get(task)) { + Set<TGComponent> channelInstances = new HashSet<TGComponent>(); + int yShift = 50; + TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); + if (tmlc==null){ + //Find by origin port instead + tmlc = tmlmodel.getChannelByOriginPortName(channel); + } + if (tmlc==null){ + continue; + } + //First, find the connector that points to it. We will add the encryption, nonce operators directly before the write channel operator + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADWriteChannel) { + TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg; + if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) { + + if (fromStart != null) { + channelInstances.add(tg); } } - for (TGComponent comp : channelInstances) { - yShift=50; - //TMLADWriteChannel writeChannel = (TMLADWriteChannel) comp; - xpos = comp.getX(); - ypos = comp.getY(); - fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); - point = fromStart.getTGConnectingPointP2(); - //Add encryption operator - TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - TMLADReadChannel rd = new TMLADReadChannel(0, 0, 0, 0, 0, 0, false, null, tad); - if (nonceOutChannels.get(task).contains(channel)) { - //Receive any nonces if ensuring authenticity - rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - //System.out.println("tmlc " + tmlc); - // System.out.println("Checking "+ tmlc.getDestinationTask() + " " + tmlc.getOriginTask()); - List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); - - if (matches.size() > 0) { - rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); - } else { - rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - } - rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - tad.addComponent(rd, xpos, ypos + yShift, false, true); - fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); - fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - yShift += 60; - //Move encryption operator after receive nonce component - enc.setCd(xpos, ypos + yShift); - if (tmlc != null) { - enc.nonce = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; - } - } + } + } + for (TGComponent comp : channelInstances) { + yShift=50; + //TMLADWriteChannel writeChannel = (TMLADWriteChannel) comp; + xpos = comp.getX(); + ypos = comp.getY(); + fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); + point = fromStart.getTGConnectingPointP2(); + //Add encryption operator + TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + TMLADReadChannel rd = new TMLADReadChannel(0, 0, 0, 0, 0, 0, false, null, tad); + if (nonceOutChannels.get(task).contains(channel)) { + //Receive any nonces if ensuring authenticity + rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + //System.out.println("tmlc " + tmlc); + // System.out.println("Checking "+ tmlc.getDestinationTask() + " " + tmlc.getOriginTask()); + List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); + + if (matches.size() > 0) { + rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); + } else { + rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + } + rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + tad.addComponent(rd, xpos, ypos + yShift, false, true); + fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); + fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + yShift += 60; + //Move encryption operator after receive nonce component + enc.setCd(xpos, ypos + yShift); + if (tmlc != null) { + enc.nonce = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; + } + } - enc.securityContext = channelSecMap.get(channel); - enc.type = "Symmetric Encryption"; - enc.message_overhead = overhead; - enc.encTime = encComp; - enc.decTime = decComp; - tad.addComponent(enc, xpos, ypos + yShift, false, true); - yShift += 60; - fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); - fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); - - //Direct the last TGConnector back to the start of the write channel operator - - fromStart.setP2(point); - //Shift components down to make room for the added ones, and add security contexts to write channels - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADWriteChannel) { - TMLADWriteChannel wChannel = (TMLADWriteChannel) tg; - if (channel.equals(wChannel.getChannelName()) && wChannel.getSecurityContext().equals("")) { - wChannel.setSecurityContext(channelSecMap.get(channel)); - wChannel.setEncForm(true); + enc.securityContext = channelSecMap.get(channel); + enc.type = "Symmetric Encryption"; + enc.message_overhead = overhead; + enc.encTime = encComp; + enc.decTime = decComp; + tad.addComponent(enc, xpos, ypos + yShift, false, true); + yShift += 60; + fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); + fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); + + //Direct the last TGConnector back to the start of the write channel operator + + fromStart.setP2(point); + //Shift components down to make room for the added ones, and add security contexts to write channels + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADWriteChannel) { + TMLADWriteChannel wChannel = (TMLADWriteChannel) tg; + if (channel.equals(wChannel.getChannelName()) && wChannel.getSecurityContext().equals("")) { + wChannel.setSecurityContext(channelSecMap.get(channel)); + wChannel.setEncForm(true); - } - } - if (tg.getY() >= ypos && tg != enc && tg != rd) { - tg.setCd(tg.getX(), tg.getY() + yShift); - } } - tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); - tad.repaint(); + } + if (tg.getY() >= ypos && tg != enc && tg != rd) { + tg.setCd(tg.getX(), tg.getY() + yShift); } } + tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); + tad.repaint(); + } + } - for (String channel : macOutChannels.get(task)) { - //Add MAC before writechannel - int yShift = 50; - TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); - //First, find the connector that points to it. We will add the encryption, nonce operators directly before the write channel operator - if (tmlc ==null){ - tmlc = tmlmodel.getChannelByOriginPortName(channel); + for (String channel : macOutChannels.get(task)) { + //Add MAC before writechannel + int yShift = 50; + TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); + //First, find the connector that points to it. We will add the encryption, nonce operators directly before the write channel operator + if (tmlc ==null){ + tmlc = tmlmodel.getChannelByOriginPortName(channel); + } + if (tmlc ==null){ + continue; + } + Set<TGComponent> channelInstances = new HashSet<TGComponent>(); + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADWriteChannel) { + TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg; + if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) { + xpos = tg.getX(); + ypos = tg.getY(); + fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); + if (fromStart != null) { + channelInstances.add(tg); + } } - if (tmlc ==null){ - continue; + } + } + for (TGComponent comp : channelInstances) { + yShift=50; + //TMLADWriteChannel writeChannel = (TMLADWriteChannel) comp; + xpos = comp.getX(); + ypos = comp.getY(); + fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); + point = fromStart.getTGConnectingPointP2(); + + TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + + //If we need to receive a nonce + TMLADReadChannel rd = new TMLADReadChannel(0, 0, 0, 0, 0, 0, false, null, tad); + if (nonceOutChannels.get(task).contains(channel)) { + //Receive any nonces if ensuring authenticity + rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); + + if (matches.size() > 0) { + rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); + } else { + rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); } - Set<TGComponent> channelInstances = new HashSet<TGComponent>(); - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADWriteChannel) { - TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg; - if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) { - xpos = tg.getX(); - ypos = tg.getY(); - fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); - if (fromStart != null) { - channelInstances.add(tg); - } - } - } + rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + tad.addComponent(rd, xpos, ypos + yShift, false, true); + fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); + fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + yShift += 60; + //Move encryption operator after receive nonce component + enc.setCd(xpos, ypos + yShift); + if (tmlc != null) { + enc.nonce = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; } - for (TGComponent comp : channelInstances) { - yShift=50; - //TMLADWriteChannel writeChannel = (TMLADWriteChannel) comp; - xpos = comp.getX(); - ypos = comp.getY(); - fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); - point = fromStart.getTGConnectingPointP2(); - - TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - - //If we need to receive a nonce - TMLADReadChannel rd = new TMLADReadChannel(0, 0, 0, 0, 0, 0, false, null, tad); - if (nonceOutChannels.get(task).contains(channel)) { - //Receive any nonces if ensuring authenticity - rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); - - if (matches.size() > 0) { - rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); - } else { - rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - } - rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - tad.addComponent(rd, xpos, ypos + yShift, false, true); - fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); - fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - yShift += 60; - //Move encryption operator after receive nonce component - enc.setCd(xpos, ypos + yShift); - if (tmlc != null) { - enc.nonce = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; - } - } - - //Add encryption operator + } - enc.securityContext = channelSecMap.get(channel); - enc.type = "MAC"; - enc.message_overhead = overhead; - enc.encTime = encComp; - enc.decTime = decComp; - enc.size = overhead; - tad.addComponent(enc, xpos, ypos + yShift, false, true); - yShift += 60; - fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); - fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); - - //Direct the last TGConnector back to the start of the write channel operator - - fromStart.setP2(point); - //Shift components down to make room for the added ones, and add security contexts to write channels - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADWriteChannel) { - TMLADWriteChannel wChannel = (TMLADWriteChannel) tg; - if (channel.equals(wChannel.getChannelName()) && wChannel.getSecurityContext().equals("")) { - wChannel.setSecurityContext(channelSecMap.get(channel)); - wChannel.setEncForm(true); - tad.repaint(); - } - } - if (tg.getY() >= ypos && tg != enc && tg != rd) { - tg.setCd(tg.getX(), tg.getY() + yShift); - } + //Add encryption operator + + enc.securityContext = channelSecMap.get(channel); + enc.type = "MAC"; + enc.message_overhead = overhead; + enc.encTime = encComp; + enc.decTime = decComp; + enc.size = overhead; + tad.addComponent(enc, xpos, ypos + yShift, false, true); + yShift += 60; + fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); + fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); + + //Direct the last TGConnector back to the start of the write channel operator + + fromStart.setP2(point); + //Shift components down to make room for the added ones, and add security contexts to write channels + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADWriteChannel) { + TMLADWriteChannel wChannel = (TMLADWriteChannel) tg; + if (channel.equals(wChannel.getChannelName()) && wChannel.getSecurityContext().equals("")) { + wChannel.setSecurityContext(channelSecMap.get(channel)); + wChannel.setEncForm(true); + tad.repaint(); } - tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); + } + if (tg.getY() >= ypos && tg != enc && tg != rd) { + tg.setCd(tg.getX(), tg.getY() + yShift); } } - for (String channel: hsmSecOutChannels.get(task)){ - Set<TGComponent> channelInstances = new HashSet<TGComponent>(); - //TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); - // TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADWriteChannel) { - TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg; - if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) { - fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); - if (fromStart != null) { - channelInstances.add(tg); - } - } + tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); + } + } + for (String channel: hsmSecOutChannels.get(task)){ + Set<TGComponent> channelInstances = new HashSet<TGComponent>(); + //TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); + //TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADWriteChannel) { + TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg; + if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) { + fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); + if (fromStart != null) { + channelInstances.add(tg); } } - for (TGComponent chan : channelInstances) { + } + } + for (TGComponent chan : channelInstances) { - TMLADWriteChannel writeChannel = (TMLADWriteChannel) chan; - String chanName = writeChannel.getChannelName(); - TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + chanName); - if (tmlc ==null){ - tmlc = tmlmodel.getChannelByOriginPortName(channel); - } - if (tmlc ==null){ - continue; - } - writeChannel.setSecurityContext(channelSecMap.get(chanName)); - writeChannel.setEncForm(true); - xpos = chan.getX(); - ypos = chan.getY(); - fromStart = tad.findTGConnectorEndingAt(chan.getTGConnectingPointAtIndex(0)); - point = fromStart.getTGConnectingPointP2(); + TMLADWriteChannel writeChannel = (TMLADWriteChannel) chan; + String chanName = writeChannel.getChannelName(); + TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + chanName); + if (tmlc ==null){ + tmlc = tmlmodel.getChannelByOriginPortName(channel); + } + if (tmlc ==null){ + continue; + } + writeChannel.setSecurityContext(channelSecMap.get(chanName)); + writeChannel.setEncForm(true); + xpos = chan.getX(); + ypos = chan.getY(); + fromStart = tad.findTGConnectorEndingAt(chan.getTGConnectingPointAtIndex(0)); + point = fromStart.getTGConnectingPointP2(); - int yShift = 50; + int yShift = 50; - TMLADSendRequest req = new TMLADSendRequest(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - req.setRequestName("startHSM_" + taskHSMMap.get(task.getName().split("__")[1])); + TMLADSendRequest req = new TMLADSendRequest(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + req.setRequestName("startHSM_" + taskHSMMap.get(task.getName().split("__")[1])); - req.setParam(0, Integer.toString(channelIndexMap.get(chanName))); - req.makeValue(); - tad.addComponent(req, xpos, ypos + yShift, false, true); + req.setParam(0, Integer.toString(channelIndexMap.get(chanName))); + req.makeValue(); + tad.addComponent(req, xpos, ypos + yShift, false, true); - fromStart.setP2(req.getTGConnectingPointAtIndex(0)); - //tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP2(req.getTGConnectingPointAtIndex(0)); + //tad.addComponent(fromStart, xpos, ypos, false, true); - //Add connection - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(req.getTGConnectingPointAtIndex(1)); + //Add connection + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(req.getTGConnectingPointAtIndex(1)); - TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - yShift += 50; - //Add write channel operator - wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - wr.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); - wr.setEncForm(false); - wr.setSecurityContext(channelSecMap.get(chanName)); - tad.addComponent(wr, xpos, ypos + yShift, false, true); - fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); + TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - TMLADWriteChannel wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + yShift += 50; + //Add write channel operator + wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + wr.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); + wr.setEncForm(false); + wr.setSecurityContext(channelSecMap.get(chanName)); + tad.addComponent(wr, xpos, ypos + yShift, false, true); - //Receive any nonces if ensuring authenticity - if (nonceOutChannels.get(task).contains(channel)) { - //Read nonce from rec task - yShift+=50; - List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); - rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - if (matches.size() > 0) { - rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); - } else { - rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - } - rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - tad.addComponent(rd, xpos, ypos + yShift, false, true); - fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); + fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart = new TGConnectorTMLAD(rd.getX(), rd.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); - //Also send nonce to hsm - yShift+=50; - wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - wr2.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); - wr2.setSecurityContext(channelSecMap.get(chanName)); - tad.addComponent(wr2, xpos, ypos + yShift, false, true); + TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - TGConnectorTMLAD tmp = new TGConnectorTMLAD(wr2.getX(), wr2.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, rd.getTGConnectingPointAtIndex(1), wr2.getTGConnectingPointAtIndex(0), new Vector<Point>()); - tad.addComponent(tmp, xpos, ypos, false, true); + TMLADWriteChannel wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - fromStart.setP2(wr2.getTGConnectingPointAtIndex(0)); + //Receive any nonces if ensuring authenticity + if (nonceOutChannels.get(task).contains(channel)) { + //Read nonce from rec task + yShift+=50; - fromStart = new TGConnectorTMLAD(rd.getX(), rd.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(wr2.getTGConnectingPointAtIndex(1)); + List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); + rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + if (matches.size() > 0) { + rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); + } else { + rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + } + rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + tad.addComponent(rd, xpos, ypos + yShift, false, true); + fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); - yShift += 60; - } + fromStart = new TGConnectorTMLAD(rd.getX(), rd.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - //Read channel operator to receive hsm data - yShift += 60; - TMLADReadChannel rd2 = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - rd2.setChannelName("retData_" + chanName + "_" + task.getName().split("__")[1]); - rd2.setSecurityContext(channelSecMap.get(chanName)); - tad.addComponent(rd2, xpos, ypos + yShift, false, true); + //Also send nonce to hsm + yShift+=50; + wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + wr2.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); + wr2.setSecurityContext(channelSecMap.get(chanName)); + tad.addComponent(wr2, xpos, ypos + yShift, false, true); - fromStart.setP2(rd2.getTGConnectingPointAtIndex(0)); - yShift += 50; + TGConnectorTMLAD tmp = new TGConnectorTMLAD(wr2.getX(), wr2.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, rd.getTGConnectingPointAtIndex(1), wr2.getTGConnectingPointAtIndex(0), new Vector<Point>()); + tad.addComponent(tmp, xpos, ypos, false, true); - //Add connector - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(rd2.getTGConnectingPointAtIndex(1)); - yShift += 50; + fromStart.setP2(wr2.getTGConnectingPointAtIndex(0)); - //Direct the last TGConnector back to the start of the write channel operator + fromStart = new TGConnectorTMLAD(rd.getX(), rd.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(wr2.getTGConnectingPointAtIndex(1)); - fromStart.setP2(point); - //Shift components down to make room for the added ones, and add security contexts to write channels - for (TGComponent tg : tad.getComponentList()) { - if (tg.getY() >= ypos && tg != wr && tg != req && tg != rd && tg!=wr2 && tg!=rd2) { - tg.setCd(tg.getX(), tg.getY() + yShift); - } - } - tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); - tad.repaint(); - } + + yShift += 60; } - for (String channel: hsmSecInChannels.get(task)){ - //System.out.println("Checking hsmsecinchannel " + channel + " " + task.getName()); - Set<TGComponent> channelInstances = new HashSet<TGComponent>(); - //TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); - //TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADReadChannel) { - TMLADReadChannel readChannel = (TMLADReadChannel) tg; - if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) { - fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); - if (fromStart != null) { - channelInstances.add(tg); - } - } - } + + //Read channel operator to receive hsm data + + yShift += 60; + TMLADReadChannel rd2 = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + rd2.setChannelName("retData_" + chanName + "_" + task.getName().split("__")[1]); + rd2.setSecurityContext(channelSecMap.get(chanName)); + tad.addComponent(rd2, xpos, ypos + yShift, false, true); + + fromStart.setP2(rd2.getTGConnectingPointAtIndex(0)); + yShift += 50; + + //Add connector + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(rd2.getTGConnectingPointAtIndex(1)); + yShift += 50; + + //Direct the last TGConnector back to the start of the write channel operator + + + fromStart.setP2(point); + //Shift components down to make room for the added ones, and add security contexts to write channels + for (TGComponent tg : tad.getComponentList()) { + if (tg.getY() >= ypos && tg != wr && tg != req && tg != rd && tg!=wr2 && tg!=rd2) { + tg.setCd(tg.getX(), tg.getY() + yShift); } - //System.out.println("matches " + channelInstances); - for (TGComponent chan : channelInstances) { - TMLADReadChannel readChannel = (TMLADReadChannel) chan; - String chanName = readChannel.getChannelName(); - TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + chanName); - if (tmlc ==null){ - tmlc = tmlmodel.getChannelByDestinationPortName(channel); - } - if (tmlc ==null){ - continue; + } + tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); + tad.repaint(); + } + } + + for (String channel: hsmSecInChannels.get(task)){ + //System.out.println("Checking hsmsecinchannel " + channel + " " + task.getName()); + Set<TGComponent> channelInstances = new HashSet<TGComponent>(); + //TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); + //TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADReadChannel) { + TMLADReadChannel readChannel = (TMLADReadChannel) tg; + if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) { + fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); + if (fromStart != null) { + channelInstances.add(tg); } - readChannel.setSecurityContext(channelSecMap.get(chanName)); - readChannel.setEncForm(true); - xpos = chan.getX()+1; - ypos = chan.getY()+1; - fromStart = tad.findTGConnectorStartingAt(chan.getTGConnectingPointAtIndex(1)); - point = fromStart.getTGConnectingPointP2(); - - int yShift = 50; - - TMLADSendRequest req = new TMLADSendRequest(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - req.setRequestName("startHSM_" + taskHSMMap.get(task.getName().split("__")[1])); - - req.setParam(0, Integer.toString(channelIndexMap.get(chanName))); - req.makeValue(); - tad.addComponent(req, xpos, ypos + yShift, false, true); - - fromStart.setP2(req.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, xpos, ypos, false, true); - - //Add connection - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(req.getTGConnectingPointAtIndex(1)); - TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - - yShift += 50; - //Add write channel operator - wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - wr.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); - wr.setSecurityContext(channelSecMap.get(chanName)); - wr.makeValue(); - tad.addComponent(wr, xpos, ypos + yShift, false, true); - - //Add connector between request and write - fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, xpos, ypos, false, true); - - //Add connector between write and ??? - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); - - //If needed, forge nonce, send it to receiving task - TMLADEncrypt nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - TMLADWriteChannel wr3 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - TMLADWriteChannel wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - - if (nonceInChannels.get(task).contains(channel)) { - //Create a nonce operator and a write channel operator - yShift+=60; - nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; - nonce.type = "Nonce"; - nonce.message_overhead = overhead; - nonce.encTime = encComp; - nonce.decTime = decComp; - tad.addComponent(nonce, xpos, ypos + yShift, false, true); - fromStart.setP2(nonce.getTGConnectingPointAtIndex(0)); - yShift += 50; - - wr3 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver - //Find matching channels - List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); - - if (matches.size() > 0) { - wr3.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); - } else { - wr3.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - } - //send the nonce along the channel - wr3.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - tad.addComponent(wr3, xpos, ypos + yShift, false, true); + } + } + } + //System.out.println("matches " + channelInstances); + for (TGComponent chan : channelInstances) { + TMLADReadChannel readChannel = (TMLADReadChannel) chan; + String chanName = readChannel.getChannelName(); + TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + chanName); + if (tmlc ==null){ + tmlc = tmlmodel.getChannelByDestinationPortName(channel); + } + if (tmlc ==null){ + continue; + } + readChannel.setSecurityContext(channelSecMap.get(chanName)); + readChannel.setEncForm(true); + xpos = chan.getX()+1; + ypos = chan.getY()+1; + fromStart = tad.findTGConnectorStartingAt(chan.getTGConnectingPointAtIndex(1)); + point = fromStart.getTGConnectingPointP2(); + + int yShift = 50; + + + + + + TMLADSendRequest req = new TMLADSendRequest(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + req.setRequestName("startHSM_" + taskHSMMap.get(task.getName().split("__")[1])); + + + + + req.setParam(0, Integer.toString(channelIndexMap.get(chanName))); + req.makeValue(); + tad.addComponent(req, xpos, ypos + yShift, false, true); + + fromStart.setP2(req.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, xpos, ypos, false, true); - wr3.makeValue(); - TGConnector tmp = new TGConnectorTMLAD(wr3.getX(), wr3.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr3.getTGConnectingPointAtIndex(0), new Vector<Point>()); - tad.addComponent(tmp, xpos, ypos, false, true); + //Add connection + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(req.getTGConnectingPointAtIndex(1)); + TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + + yShift += 50; + //Add write channel operator + wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + wr.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); + wr.setSecurityContext(channelSecMap.get(chanName)); + wr.makeValue(); + tad.addComponent(wr, xpos, ypos + yShift, false, true); + + //Add connector between request and write + fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, xpos, ypos, false, true); + + //Add connector between write and ??? + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); + + + + + + + //If needed, forge nonce, send it to receiving task + TMLADEncrypt nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + TMLADWriteChannel wr3 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + TMLADWriteChannel wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + + if (nonceInChannels.get(task).contains(channel)) { + //Create a nonce operator and a write channel operator + yShift+=60; + nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; + nonce.type = "Nonce"; + nonce.message_overhead = overhead; + nonce.encTime = encComp; + nonce.decTime = decComp; + tad.addComponent(nonce, xpos, ypos + yShift, false, true); + fromStart.setP2(nonce.getTGConnectingPointAtIndex(0)); + yShift += 50; + + wr3 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver + //Find matching channels + List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); + + if (matches.size() > 0) { + wr3.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); + } else { + wr3.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + } + //send the nonce along the channel + wr3.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + tad.addComponent(wr3, xpos, ypos + yShift, false, true); + + wr3.makeValue(); + TGConnector tmp = new TGConnectorTMLAD(wr3.getX(), wr3.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr3.getTGConnectingPointAtIndex(0), new Vector<Point>()); + tad.addComponent(tmp, xpos, ypos, false, true); - //Also send nonce to hsm - yShift+=50; - wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - wr2.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); - wr2.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - tad.addComponent(wr2, xpos, ypos + yShift, false, true); + //Also send nonce to hsm + yShift+=50; + wr2 = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + wr2.setChannelName("data_" + chanName + "_" + task.getName().split("__")[1]); + wr2.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + tad.addComponent(wr2, xpos, ypos + yShift, false, true); - tmp = new TGConnectorTMLAD(wr2.getX(), wr2.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr3.getTGConnectingPointAtIndex(1), wr2.getTGConnectingPointAtIndex(0), new Vector<Point>()); - tad.addComponent(tmp, xpos, ypos, false, true); + tmp = new TGConnectorTMLAD(wr2.getX(), wr2.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr3.getTGConnectingPointAtIndex(1), wr2.getTGConnectingPointAtIndex(0), new Vector<Point>()); + tad.addComponent(tmp, xpos, ypos, false, true); - fromStart = new TGConnectorTMLAD(wr2.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr2.getTGConnectingPointAtIndex(1), null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - //Connect created write channel operator to start of read channel operator - fromStart.setP1(wr2.getTGConnectingPointAtIndex(1)); - fromStart.setP2(point); + fromStart = new TGConnectorTMLAD(wr2.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr2.getTGConnectingPointAtIndex(1), null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + //Connect created write channel operator to start of read channel operator + fromStart.setP1(wr2.getTGConnectingPointAtIndex(1)); + fromStart.setP2(point); - /* //Shift everything from the read channel on down + /* //Shift everything from the read channel on down for (TGComponent tg : tad.getComponentList()) { if (tg.getY() >= ypos && tg != nonce && tg != wr2 && tg!=wr3) { tg.setCd(tg.getX(), tg.getY() + yShift); } }*/ - } + } - //Add read channel operator + //Add read channel operator - yShift += 60; - TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - rd.setChannelName("retData_" + chanName + "_" + task.getName().split("__")[1]); - rd.setSecurityContext(channelSecMap.get(chanName)); - rd.setEncForm(false); - tad.addComponent(rd, xpos, ypos + yShift, false, true); + yShift += 60; + TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + rd.setChannelName("retData_" + chanName + "_" + task.getName().split("__")[1]); + rd.setSecurityContext(channelSecMap.get(chanName)); + rd.setEncForm(false); + tad.addComponent(rd, xpos, ypos + yShift, false, true); - fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); - yShift += 50; + fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); + yShift += 50; - //Add connector - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - yShift += 50; + //Add connector + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + yShift += 50; - //Direct the last TGConnector back to the start of the operator after the read channel + //Direct the last TGConnector back to the start of the operator after the read channel - fromStart.setP2(point); + fromStart.setP2(point); - //Shift components down to make room for the added ones, and add security contexts to write channels - for (TGComponent tg : tad.getComponentList()) { - if (tg.getY() >= ypos && tg != wr && tg != req && tg != rd && tg!=wr2 && tg!=nonce && tg!=wr3) { - tg.setCd(tg.getX(), tg.getY() + yShift); - } - } - tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); - tad.repaint(); - } + //Shift components down to make room for the added ones, and add security contexts to write channels + for (TGComponent tg : tad.getComponentList()) { + if (tg.getY() >= ypos && tg != wr && tg != req && tg != rd && tg!=wr2 && tg!=nonce && tg!=wr3) { + tg.setCd(tg.getX(), tg.getY() + yShift); + } } - for (String channel : macInChannels.get(task)) { - //Add decryptmac after readchannel - int yShift = 50; - Set<TGComponent> channelInstances = new HashSet<TGComponent>(); - TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); - TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); - //Find read channel operator - TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); - if (tmlc ==null){ - tmlc = tmlmodel.getChannelByDestinationPortName(channel); + tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); + tad.repaint(); + } + } + for (String channel : macInChannels.get(task)) { + //Add decryptmac after readchannel + int yShift = 50; + Set<TGComponent> channelInstances = new HashSet<TGComponent>(); + TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); + TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); + //Find read channel operator + TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); + if (tmlc ==null){ + tmlc = tmlmodel.getChannelByDestinationPortName(channel); + } + if (tmlc ==null){ + continue; + } + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADReadChannel) { + TMLADReadChannel readChannel = (TMLADReadChannel) tg; + if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) { + fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); + if (fromStart != null) { + channelInstances.add(tg); + } } - if (tmlc ==null){ - continue; + } + } + + + for (TGComponent comp : channelInstances) { + yShift=50; + fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); + point = fromStart.getTGConnectingPointP2(); + conn = tad.findTGConnectorStartingAt(comp.getTGConnectingPointAtIndex(1)); + next = conn.getTGConnectingPointP2(); + xpos = fromStart.getX(); + ypos = fromStart.getY(); + + + TMLADReadChannel readChannel = (TMLADReadChannel) comp; + readChannel.setSecurityContext(channelSecMap.get(readChannel.getChannelName())); + tad.repaint(); + + TMLADWriteChannel wr = new TMLADWriteChannel(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + //Create nonce and send it + if (nonceInChannels.get(task).contains(channel)) { + //Create a nonce operator and a write channel operator + TMLADEncrypt nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; + nonce.type = "Nonce"; + nonce.message_overhead = overhead; + nonce.encTime = encComp; + nonce.decTime = decComp; + tad.addComponent(nonce, xpos, ypos + yShift, false, true); + fromStart.setP2(nonce.getTGConnectingPointAtIndex(0)); + yShift += 50; + wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver + //Find matching channels + List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); + + if (matches.size() > 0) { + wr.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); + } else { + wr.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); } + //send the nonce along the channel + wr.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + tad.addComponent(wr, xpos, ypos + yShift, false, true); + wr.makeValue(); + TGConnector tmp = new TGConnectorTMLAD(wr.getX(), wr.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr.getTGConnectingPointAtIndex(0), new Vector<Point>()); + tad.addComponent(tmp, xpos, ypos, false, true); + fromStart = new TGConnectorTMLAD(wr.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr.getTGConnectingPointAtIndex(1), null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + //Connect created write channel operator to start of read channel operator + fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); + fromStart.setP2(point); + yShift+=40; + //Shift everything from the read channel on down for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADReadChannel) { - TMLADReadChannel readChannel = (TMLADReadChannel) tg; - if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) { - fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); - if (fromStart != null) { - channelInstances.add(tg); - } - } + if ((tg.getY() >= ypos && tg != nonce && tg != wr) || tg == readChannel) { + tg.setCd(tg.getX(), tg.getY() + yShift); } } + } + //Add decryption operator if it does not already exist + xpos = conn.getX(); + ypos = conn.getY(); + + TMLADDecrypt dec = new TMLADDecrypt(xpos + 10, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + dec.securityContext = channelSecMap.get(readChannel.getChannelName()); + tad.addComponent(dec, dec.getX(), dec.getY(), false, true); + conn.setP2(dec.getTGConnectingPointAtIndex(0)); + yShift += 60; + conn = new TGConnectorTMLAD(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, dec.getTGConnectingPointAtIndex(1), next, new Vector<Point>()); + conn.setP1(dec.getTGConnectingPointAtIndex(1)); + conn.setP2(next); + tad.addComponent(conn, conn.getX(), conn.getY(), false, true); + //Shift everything down + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADReadChannel) { + readChannel = (TMLADReadChannel) tg; + + if (channel.equals(readChannel.getChannelName()) && readChannel.getSecurityContext().equals("")) { + readChannel.setSecurityContext(channelSecMap.get(readChannel.getChannelName())); + readChannel.setEncForm(true); - for (TGComponent comp : channelInstances) { - yShift=50; - fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); - point = fromStart.getTGConnectingPointP2(); - conn = tad.findTGConnectorStartingAt(comp.getTGConnectingPointAtIndex(1)); - next = conn.getTGConnectingPointP2(); - xpos = fromStart.getX(); - ypos = fromStart.getY(); - - - TMLADReadChannel readChannel = (TMLADReadChannel) comp; - readChannel.setSecurityContext(channelSecMap.get(readChannel.getChannelName())); - tad.repaint(); - - TMLADWriteChannel wr = new TMLADWriteChannel(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - //Create nonce and send it - if (nonceInChannels.get(task).contains(channel)) { - //Create a nonce operator and a write channel operator - TMLADEncrypt nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; - nonce.type = "Nonce"; - nonce.message_overhead = overhead; - nonce.encTime = encComp; - nonce.decTime = decComp; - tad.addComponent(nonce, xpos, ypos + yShift, false, true); - fromStart.setP2(nonce.getTGConnectingPointAtIndex(0)); - yShift += 50; - wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver - //Find matching channels - List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); - - if (matches.size() > 0) { - wr.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); - } else { - wr.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - } - //send the nonce along the channel - wr.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - tad.addComponent(wr, xpos, ypos + yShift, false, true); - wr.makeValue(); - TGConnector tmp = new TGConnectorTMLAD(wr.getX(), wr.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr.getTGConnectingPointAtIndex(0), new Vector<Point>()); - tad.addComponent(tmp, xpos, ypos, false, true); - fromStart = new TGConnectorTMLAD(wr.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr.getTGConnectingPointAtIndex(1), null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - //Connect created write channel operator to start of read channel operator - fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); - fromStart.setP2(point); - yShift+=40; - //Shift everything from the read channel on down - for (TGComponent tg : tad.getComponentList()) { - if ((tg.getY() >= ypos && tg != nonce && tg != wr) || tg == readChannel) { - tg.setCd(tg.getX(), tg.getY() + yShift); - } - } } + } + if (tg.getY() >= ypos && tg != dec && tg != comp) { - //Add decryption operator if it does not already exist - xpos = conn.getX(); - ypos = conn.getY(); - - TMLADDecrypt dec = new TMLADDecrypt(xpos + 10, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - dec.securityContext = channelSecMap.get(readChannel.getChannelName()); - tad.addComponent(dec, dec.getX(), dec.getY(), false, true); - conn.setP2(dec.getTGConnectingPointAtIndex(0)); - yShift += 60; - conn = new TGConnectorTMLAD(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, dec.getTGConnectingPointAtIndex(1), next, new Vector<Point>()); - conn.setP1(dec.getTGConnectingPointAtIndex(1)); - conn.setP2(next); - tad.addComponent(conn, conn.getX(), conn.getY(), false, true); - //Shift everything down - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADReadChannel) { - readChannel = (TMLADReadChannel) tg; - - if (channel.equals(readChannel.getChannelName()) && readChannel.getSecurityContext().equals("")) { - readChannel.setSecurityContext(channelSecMap.get(readChannel.getChannelName())); - readChannel.setEncForm(true); + tg.setCd(tg.getX(), tg.getY() + yShift); + } + } - } - } - if (tg.getY() >= ypos && tg != dec && tg != comp) { - tg.setCd(tg.getX(), tg.getY() + yShift); - } + tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); + tad.repaint(); + } + } + for (String channel : secInChannels.get(task)) { + TraceManager.addDev("securing channel " + channel); + int yShift = 20; + // String title = task.getName().split("__")[0]; + + TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); + TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); + //Find read channel operator + TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); + if (tmlc ==null){ + tmlc = tmlmodel.getChannelByDestinationPortName(channel); + } + if (tmlc ==null){ + continue; + } + TMLADReadChannel readChannel = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + HashSet<TGComponent> channelInstances = new HashSet<TGComponent>(); + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADReadChannel) { + readChannel = (TMLADReadChannel) tg; + if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) { + fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); + if (fromStart != null) { + channelInstances.add(tg); } - - - tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); - tad.repaint(); } } - for (String channel : secInChannels.get(task)) { - TraceManager.addDev("securing channel " + channel); - int yShift = 20; - // String title = task.getName().split("__")[0]; - - TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>()); - TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false); - //Find read channel operator - TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel); - if (tmlc ==null){ - tmlc = tmlmodel.getChannelByDestinationPortName(channel); - } - if (tmlc ==null){ - continue; + } + + for (TGComponent comp : channelInstances) { + yShift=30; + readChannel = (TMLADReadChannel) comp; + fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); + point = fromStart.getTGConnectingPointP2(); + conn = tad.findTGConnectorStartingAt(comp.getTGConnectingPointAtIndex(1)); + next = conn.getTGConnectingPointP2(); + xpos = comp.getX(); + ypos = comp.getY(); + TMLADWriteChannel wr = new TMLADWriteChannel(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + TMLADEncrypt nonce = new TMLADEncrypt(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + if (nonceInChannels.get(task).contains(channel)) { + //Create a nonce operator and a write channel operator + nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; + nonce.type = "Nonce"; + nonce.message_overhead = overhead; + nonce.encTime = encComp; + nonce.decTime = decComp; + tad.addComponent(nonce, xpos, ypos + yShift, false, true); + fromStart.setP2(nonce.getTGConnectingPointAtIndex(0)); + yShift += 50; + wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver + //Find matching channels + List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); + + if (matches.size() > 0) { + wr.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); + } else { + wr.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); } - TMLADReadChannel readChannel = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - HashSet<TGComponent> channelInstances = new HashSet<TGComponent>(); + yShift+=40; + //send the nonce along the channel + wr.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); + tad.addComponent(wr, xpos, ypos + yShift, false, true); + wr.makeValue(); + TGConnector tmp = new TGConnectorTMLAD(wr.getX(), wr.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr.getTGConnectingPointAtIndex(0), new Vector<Point>()); + tad.addComponent(tmp, xpos, ypos, false, true); + fromStart = new TGConnectorTMLAD(wr.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr.getTGConnectingPointAtIndex(1), null, new Vector<Point>()); + tad.addComponent(fromStart, xpos, ypos, false, true); + //Connect created write channel operator to start of read channel operator + fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); + fromStart.setP2(point); + //Shift everything from the read channel on down for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADReadChannel) { - readChannel = (TMLADReadChannel) tg; - if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) { - fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0)); - if (fromStart != null) { - channelInstances.add(tg); - } - } + if ((tg.getY() >= ypos && tg != nonce && tg != wr)) { + tg.setCd(tg.getX(), tg.getY() + yShift); } } + } + //tad.repaint(); + + //Now add the decrypt operator + yShift += 40; + readChannel.setSecurityContext(channelSecMap.get(readChannel.getChannelName())); + readChannel.setEncForm(true); + tad.repaint(); + //Add decryption operator if it does not already exist + xpos = readChannel.getX(); + ypos = readChannel.getY(); + TMLADDecrypt dec = new TMLADDecrypt(xpos + 10, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + dec.securityContext = channelSecMap.get(readChannel.getChannelName()); + tad.addComponent(dec, dec.getX(), dec.getY(), false, true); + conn.setP2(dec.getTGConnectingPointAtIndex(0)); + yShift += 60; + conn = new TGConnectorTMLAD(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, dec.getTGConnectingPointAtIndex(1), next, new Vector<Point>()); + conn.setP1(dec.getTGConnectingPointAtIndex(1)); + + conn.setP2(next); + tad.addComponent(conn, conn.getX(), conn.getY(), false, true); + //Shift everything down + for (TGComponent tg : tad.getComponentList()) { + if (tg instanceof TMLADReadChannel) { + readChannel = (TMLADReadChannel) tg; + if (channel.equals(readChannel.getChannelName()) && readChannel.getSecurityContext().equals("")) { + readChannel.setSecurityContext( channelSecMap.get(readChannel.getChannelName())); + readChannel.setEncForm(true); - for (TGComponent comp : channelInstances) { - yShift=30; - readChannel = (TMLADReadChannel) comp; - fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0)); - point = fromStart.getTGConnectingPointP2(); - conn = tad.findTGConnectorStartingAt(comp.getTGConnectingPointAtIndex(1)); - next = conn.getTGConnectingPointP2(); - xpos = comp.getX(); - ypos = comp.getY(); - TMLADWriteChannel wr = new TMLADWriteChannel(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - TMLADEncrypt nonce = new TMLADEncrypt(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - if (nonceInChannels.get(task).contains(channel)) { - //Create a nonce operator and a write channel operator - nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]; - nonce.type = "Nonce"; - nonce.message_overhead = overhead; - nonce.encTime = encComp; - nonce.decTime = decComp; - tad.addComponent(nonce, xpos, ypos + yShift, false, true); - fromStart.setP2(nonce.getTGConnectingPointAtIndex(0)); - yShift += 50; - wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver - //Find matching channels - List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask()); - - if (matches.size() > 0) { - wr.setChannelName(matches.get(0).getName().replaceAll(title + "__", "")); - } else { - wr.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - } - yShift+=40; - //send the nonce along the channel - wr.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]); - tad.addComponent(wr, xpos, ypos + yShift, false, true); - wr.makeValue(); - TGConnector tmp = new TGConnectorTMLAD(wr.getX(), wr.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr.getTGConnectingPointAtIndex(0), new Vector<Point>()); - tad.addComponent(tmp, xpos, ypos, false, true); - fromStart = new TGConnectorTMLAD(wr.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr.getTGConnectingPointAtIndex(1), null, new Vector<Point>()); - tad.addComponent(fromStart, xpos, ypos, false, true); - //Connect created write channel operator to start of read channel operator - fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); - fromStart.setP2(point); - //Shift everything from the read channel on down - for (TGComponent tg : tad.getComponentList()) { - if ((tg.getY() >= ypos && tg != nonce && tg != wr)) { - tg.setCd(tg.getX(), tg.getY() + yShift); - } - } - } - //tad.repaint(); - - //Now add the decrypt operator - yShift += 40; - readChannel.setSecurityContext(channelSecMap.get(readChannel.getChannelName())); - readChannel.setEncForm(true); - tad.repaint(); - //Add decryption operator if it does not already exist - xpos = readChannel.getX(); - ypos = readChannel.getY(); - TMLADDecrypt dec = new TMLADDecrypt(xpos + 10, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - dec.securityContext = channelSecMap.get(readChannel.getChannelName()); - tad.addComponent(dec, dec.getX(), dec.getY(), false, true); - conn.setP2(dec.getTGConnectingPointAtIndex(0)); - yShift += 60; - conn = new TGConnectorTMLAD(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, dec.getTGConnectingPointAtIndex(1), next, new Vector<Point>()); - conn.setP1(dec.getTGConnectingPointAtIndex(1)); - - conn.setP2(next); - tad.addComponent(conn, conn.getX(), conn.getY(), false, true); - //Shift everything down - for (TGComponent tg : tad.getComponentList()) { - if (tg instanceof TMLADReadChannel) { - readChannel = (TMLADReadChannel) tg; - if (channel.equals(readChannel.getChannelName()) && readChannel.getSecurityContext().equals("")) { - readChannel.setSecurityContext( channelSecMap.get(readChannel.getChannelName())); - readChannel.setEncForm(true); - - } - } - if (tg.getY() >= ypos && tg != dec && tg!= wr && tg != nonce && tg!= comp) { - - tg.setCd(tg.getX(), tg.getY() + yShift); - } } + } + if (tg.getY() >= ypos && tg != dec && tg!= wr && tg != nonce && tg!= comp) { - tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); - - tad.repaint(); + tg.setCd(tg.getX(), tg.getY() + yShift); } } + + tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift); + + tad.repaint(); } + } +} - // GTMLModeling gtm = new GTMLModeling(newarch, false); - // map = gtm.translateToTMLMapping(); - //if (gtm.getCheckingErrors().size() > 0){ - //System.out.println("@$()(#"); - //map= null; - // } - /*for (TMLTask task : newmodel.getTasks()) { +// GTMLModeling gtm = new GTMLModeling(newarch, false); +// map = gtm.translateToTMLMapping(); +//if (gtm.getCheckingErrors().size() > 0){ +//System.out.println("@$()(#"); +//map= null; +// } +/*for (TMLTask task : newmodel.getTasks()) { task.setName(tabName + "_" + name + "__" + task.getName()); } for (TMLTask task : tmlmodel.getTasks()) { @@ -1649,343 +1674,343 @@ public class SecurityGeneration implements Runnable { } }*/ - //map.setTMLModeling(newmodel); +//map.setTMLModeling(newmodel); - // map.setTMLModeling(newmodel); +// map.setTMLModeling(newmodel); +return; +} +public void buildHSMActivityDiagram(String cpuName){ + int xpos = 0; + int ypos = 0; + TGConnector fromStart; + //Build HSM Activity diagram + + TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel("HSM_" + cpuName); + if (tad ==null){ + System.out.println("Missing task "); return; } - public void buildHSMActivityDiagram(String cpuName){ - int xpos = 0; - int ypos = 0; - TGConnector fromStart; - //Build HSM Activity diagram + TMLADStartState start = (TMLADStartState) tad.getComponentList().get(0); + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - TMLActivityDiagramPanel tad = tmlcdp.getTMLActivityDiagramPanel("HSM_" + cpuName); - if (tad ==null){ - System.out.println("Missing task "); - return; - } + if (hsmChannelMap.get(cpuName).size() ==0){ + TMLADStopState stop = new TMLADStopState(100, 100, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + tad.addComponent(stop, 100, 100, false, true); - TMLADStartState start = (TMLADStartState) tad.getComponentList().get(0); + + //Connect stop and start fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(start.getTGConnectingPointAtIndex(0)); + fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 100, 100, false, true); + return; + } - if (hsmChannelMap.get(cpuName).size() ==0){ - TMLADStopState stop = new TMLADStopState(100, 100, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - tad.addComponent(stop, 100, 100, false, true); + TMLADReadRequestArg req = new TMLADReadRequestArg(300, 100, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + tad.addComponent(req, 300, 100, false, true); + req.setParam(0, "channelIndex"); + req.makeValue(); - //Connect stop and start - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(start.getTGConnectingPointAtIndex(0)); - fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 100, 100, false, true); - return; - } + //Connect start and readrequest + fromStart.setP1(start.getTGConnectingPointAtIndex(0)); + fromStart.setP2(req.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - TMLADReadRequestArg req = new TMLADReadRequestArg(300, 100, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - tad.addComponent(req, 300, 100, false, true); - req.setParam(0, "channelIndex"); - req.makeValue(); + TMLADChoice choice = new TMLADChoice(300, 200, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + tad.addComponent(choice, 300, 200, false, true); - //Connect start and readrequest - fromStart.setP1(start.getTGConnectingPointAtIndex(0)); - fromStart.setP2(req.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + //Connect readrequest and choice + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(req.getTGConnectingPointAtIndex(1)); + fromStart.setP2(choice.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - TMLADChoice choice = new TMLADChoice(300, 200, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - tad.addComponent(choice, 300, 200, false, true); + int xc = 150; + //Allows 9 channels max to simplify the diagram - //Connect readrequest and choice - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(req.getTGConnectingPointAtIndex(1)); - fromStart.setP2(choice.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + //If more than 3 channels, build 2 levels of choices + if (hsmChannelMap.get(cpuName).size() > 3) { + TMLADChoice choice2 = new TMLADChoice(xc, 400, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + int i = 0; + for (HSMChannel ch : hsmChannelMap.get(cpuName)) { + if (i>8){ + break; + } + if (i % 3 == 0) { + //Add a new choice every third channel + choice2 = new TMLADChoice(xc, 250, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + tad.addComponent(choice2, xc, 400, false, true); + //Connect new choice operator to top choice + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(choice.getTGConnectingPointAtIndex(i / 3 + 1)); + fromStart.setP2(choice2.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); + } + TMLADReadChannel rd = new TMLADReadChannel(xc, 300, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + rd.setChannelName("data_" + ch.name + "_" + ch.task); + rd.setSecurityContext(channelSecMap.get(ch.name)); + tad.addComponent(rd, xc, 300, false, true); + //Connect choice and readchannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(choice2.getTGConnectingPointAtIndex(i % 3 + 1)); + fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); - int xc = 150; - //Allows 9 channels max to simplify the diagram + tad.addComponent(fromStart, 300, 200, false, true); + TMLADWriteChannel wr = new TMLADWriteChannel(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + wr.setChannelName("retData_" + ch.name + "_" + ch.task); + tad.addComponent(wr, xc, 600, false, true); + wr.setSecurityContext(channelSecMap.get(ch.name)); - //If more than 3 channels, build 2 levels of choices - if (hsmChannelMap.get(cpuName).size() > 3) { - TMLADChoice choice2 = new TMLADChoice(xc, 400, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - int i = 0; - for (HSMChannel ch : hsmChannelMap.get(cpuName)) { - if (i>8){ - break; - } - if (i % 3 == 0) { - //Add a new choice every third channel - choice2 = new TMLADChoice(xc, 250, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - tad.addComponent(choice2, xc, 400, false, true); - //Connect new choice operator to top choice - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(choice.getTGConnectingPointAtIndex(i / 3 + 1)); - fromStart.setP2(choice2.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); - } - TMLADReadChannel rd = new TMLADReadChannel(xc, 300, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - rd.setChannelName("data_" + ch.name + "_" + ch.task); - rd.setSecurityContext(channelSecMap.get(ch.name)); - tad.addComponent(rd, xc, 300, false, true); - //Connect choice and readchannel + if (ch.secType == HSMChannel.DEC) { + TMLADDecrypt dec = new TMLADDecrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + dec.securityContext = channelSecMap.get(ch.name); + tad.addComponent(dec, xc, 500, false, true); fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(choice2.getTGConnectingPointAtIndex(i % 3 + 1)); - fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); - + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + fromStart.setP2(dec.getTGConnectingPointAtIndex(0)); tad.addComponent(fromStart, 300, 200, false, true); - TMLADWriteChannel wr = new TMLADWriteChannel(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - wr.setChannelName("retData_" + ch.name + "_" + ch.task); - tad.addComponent(wr, xc, 600, false, true); - wr.setSecurityContext(channelSecMap.get(ch.name)); - - - if (ch.secType == HSMChannel.DEC) { - TMLADDecrypt dec = new TMLADDecrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - dec.securityContext = channelSecMap.get(ch.name); - tad.addComponent(dec, xc, 500, false, true); - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - fromStart.setP2(dec.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); - - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - fromStart.setP2(dec.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); - - //Connect encrypt and writechannel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(dec.getTGConnectingPointAtIndex(1)); - fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); - } else { - TMLADEncrypt enc = new TMLADEncrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - enc.securityContext = channelSecMap.get(ch.name); - if (ch.secType == HSMChannel.SENC) { - enc.type = "Symmetric Encryption"; - } else if (ch.secType == HSMChannel.AENC) { - enc.type = "Asymmetric Encryption"; - } else if (ch.secType == HSMChannel.MAC) { - enc.type = "MAC"; - } else if (ch.secType == HSMChannel.NONCE) { - enc.type = "Nonce"; - } - enc.message_overhead = overhead; - enc.encTime = encComp; - enc.decTime = decComp; - enc.nonce = ch.nonceName; - tad.addComponent(enc, xc, 500, false, true); + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + fromStart.setP2(dec.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - //Connect encrypt and readchannel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + //Connect encrypt and writechannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(dec.getTGConnectingPointAtIndex(1)); + fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); + } else { + TMLADEncrypt enc = new TMLADEncrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + enc.securityContext = channelSecMap.get(ch.name); + if (ch.secType == HSMChannel.SENC) { + enc.type = "Symmetric Encryption"; + } else if (ch.secType == HSMChannel.AENC) { + enc.type = "Asymmetric Encryption"; + } else if (ch.secType == HSMChannel.MAC) { + enc.type = "MAC"; + } else if (ch.secType == HSMChannel.NONCE) { + enc.type = "Nonce"; + } - //Connect encrypt and writechannel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); - fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + enc.message_overhead = overhead; + enc.encTime = encComp; + enc.decTime = decComp; + enc.nonce = ch.nonceName; + tad.addComponent(enc, xc, 500, false, true); - //Add Stop - TMLADStopState stop = new TMLADStopState(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - tad.addComponent(stop, xc, 700, false, true); + //Connect encrypt and readchannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); + //Connect encrypt and writechannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); + fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - //Connext stop and write channel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); - fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + //Add Stop + TMLADStopState stop = new TMLADStopState(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + tad.addComponent(stop, xc, 700, false, true); - } - xc += 300; - i++; - } - } else { - int i = 1; + //Connext stop and write channel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); + fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - for (HSMChannel ch : hsmChannelMap.get(cpuName)) { + } + xc += 300; + i++; + } + } else { - //Add guard as channelindex - choice.setGuard("[channelIndex=="+channelIndexMap.get(ch.name)+"]",i-1); + int i = 1; - TMLADReadChannel rd = new TMLADReadChannel(xc, 300, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - rd.setChannelName("data_" + ch.name + "_" + ch.task); - rd.setSecurityContext(channelSecMap.get(ch.name)); - tad.addComponent(rd, xc, 300, false, true); + for (HSMChannel ch : hsmChannelMap.get(cpuName)) { - //Recieve plaintext data if encrypting - if (ch.secType != HSMChannel.DEC) { - rd.setEncForm(false); - } + //Add guard as channelindex + choice.setGuard("[channelIndex=="+channelIndexMap.get(ch.name)+"]",i-1); - //Connect choice and readchannel + TMLADReadChannel rd = new TMLADReadChannel(xc, 300, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + rd.setChannelName("data_" + ch.name + "_" + ch.task); + rd.setSecurityContext(channelSecMap.get(ch.name)); + tad.addComponent(rd, xc, 300, false, true); - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(choice.getTGConnectingPointAtIndex(i)); - fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, xc, 300, false, true); + //Recieve plaintext data if encrypting + if (ch.secType != HSMChannel.DEC) { + rd.setEncForm(false); + } + //Connect choice and readchannel - fromStart = new TGConnectorTMLAD(xc, 350, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(choice.getTGConnectingPointAtIndex(i)); + fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, xc, 300, false, true); - //If needed, receive nonce from task - if (!ch.nonceName.equals("")){ + fromStart = new TGConnectorTMLAD(xc, 350, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - tad.addComponent(fromStart, 300, 200, false, true); - rd = new TMLADReadChannel(xc, 350, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - rd.setChannelName("data_" + ch.name + "_" + ch.task); - rd.setSecurityContext(ch.nonceName); - tad.addComponent(rd, xc, 350, false, true); + //If needed, receive nonce from task + if (!ch.nonceName.equals("")){ + tad.addComponent(fromStart, 300, 200, false, true); - fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); + rd = new TMLADReadChannel(xc, 350, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + rd.setChannelName("data_" + ch.name + "_" + ch.task); + rd.setSecurityContext(ch.nonceName); + tad.addComponent(rd, xc, 350, false, true); - fromStart = new TGConnectorTMLAD(xc, 350, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - } + fromStart.setP2(rd.getTGConnectingPointAtIndex(0)); + fromStart = new TGConnectorTMLAD(xc, 350, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - //Send data back to task - TMLADWriteChannel wr = new TMLADWriteChannel(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - wr.setChannelName("retData_" + ch.name + "_" + ch.task); + } - //Return plaintext data if decrypting - if (ch.secType == HSMChannel.DEC) { - wr.setEncForm(false); - } + //Send data back to task + TMLADWriteChannel wr = new TMLADWriteChannel(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + wr.setChannelName("retData_" + ch.name + "_" + ch.task); - tad.addComponent(wr, xc, 600, false, true); - wr.setSecurityContext(channelSecMap.get(ch.name)); + //Return plaintext data if decrypting + if (ch.secType == HSMChannel.DEC) { + wr.setEncForm(false); + } - if (ch.secType == HSMChannel.DEC) { - //Add Decrypt operator - TMLADDecrypt dec = new TMLADDecrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - dec.securityContext = channelSecMap.get(ch.name); - tad.addComponent(dec, xc, 500, false, true); + tad.addComponent(wr, xc, 600, false, true); + wr.setSecurityContext(channelSecMap.get(ch.name)); - //Connect decrypt and readchannel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - fromStart.setP2(dec.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); - //Connect encrypt and writechannel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(dec.getTGConnectingPointAtIndex(1)); - fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + if (ch.secType == HSMChannel.DEC) { + //Add Decrypt operator + TMLADDecrypt dec = new TMLADDecrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + dec.securityContext = channelSecMap.get(ch.name); + tad.addComponent(dec, xc, 500, false, true); - //Add Stop - TMLADStopState stop = new TMLADStopState(xc, 700, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - tad.addComponent(stop, xc, 700, false, true); + //Connect decrypt and readchannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + fromStart.setP2(dec.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); + //Connect encrypt and writechannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(dec.getTGConnectingPointAtIndex(1)); + fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - //Connect stop and write channel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); - fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + //Add Stop + TMLADStopState stop = new TMLADStopState(xc, 700, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + tad.addComponent(stop, xc, 700, false, true); - } else { - TMLADEncrypt enc = new TMLADEncrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - enc.securityContext = channelSecMap.get(ch.name); - if (ch.secType == HSMChannel.SENC) { - enc.type = "Symmetric Encryption"; - } else if (ch.secType == HSMChannel.AENC) { - enc.type = "Asymmetric Encryption"; - } else if (ch.secType == HSMChannel.MAC) { - enc.type = "MAC"; - } else if (ch.secType == HSMChannel.NONCE) { - enc.type = "Nonce"; - } - enc.message_overhead = overhead; - enc.encTime = encComp; - enc.decTime = decComp; - tad.addComponent(enc, xc, 500, false, true); + //Connect stop and write channel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); + fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - //Connect encrypt and readchannel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); - fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + } else { + TMLADEncrypt enc = new TMLADEncrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + enc.securityContext = channelSecMap.get(ch.name); + if (ch.secType == HSMChannel.SENC) { + enc.type = "Symmetric Encryption"; + } else if (ch.secType == HSMChannel.AENC) { + enc.type = "Asymmetric Encryption"; + } else if (ch.secType == HSMChannel.MAC) { + enc.type = "MAC"; + } else if (ch.secType == HSMChannel.NONCE) { + enc.type = "Nonce"; + } - //Connect encrypt and writechannel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); - fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + enc.message_overhead = overhead; + enc.encTime = encComp; + enc.decTime = decComp; + tad.addComponent(enc, xc, 500, false, true); - //Add Stop - TMLADStopState stop = new TMLADStopState(xc, 700, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); - tad.addComponent(stop, xc, 700, false, true); + //Connect encrypt and readchannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(rd.getTGConnectingPointAtIndex(1)); + fromStart.setP2(enc.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); + //Connect encrypt and writechannel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(enc.getTGConnectingPointAtIndex(1)); + fromStart.setP2(wr.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - //Connect stop and write channel - fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); - fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); - fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); - tad.addComponent(fromStart, 300, 200, false, true); + //Add Stop + TMLADStopState stop = new TMLADStopState(xc, 700, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad); + tad.addComponent(stop, xc, 700, false, true); - } + //Connect stop and write channel + fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>()); + fromStart.setP1(wr.getTGConnectingPointAtIndex(1)); + fromStart.setP2(stop.getTGConnectingPointAtIndex(0)); + tad.addComponent(fromStart, 300, 200, false, true); - xc += 300; - i++; } + + xc += 300; + i++; } } - class HSMChannel { - public String name; - public static final int SENC = 0; - public static final int NONCE_ENC = 1; - public static final int MAC = 2; - public static final int DEC = 3; - public static final int AENC = 4; - public static final int NONCE = 5; - public String task; - public String securityContext = ""; - public int secType; - public String nonceName = ""; - - public HSMChannel(String n, String t, int type) { - name = n; - task = t; - secType = type; - } - } +} - class ChannelData { - public String name; - public boolean isOrigin; - public boolean isChan; +class HSMChannel { + public String name; + public static final int SENC = 0; + public static final int NONCE_ENC = 1; + public static final int MAC = 2; + public static final int DEC = 3; + public static final int AENC = 4; + public static final int NONCE = 5; + public String task; + public String securityContext = ""; + public int secType; + public String nonceName = ""; + + public HSMChannel(String n, String t, int type) { + name = n; + task = t; + secType = type; + } +} - public ChannelData(String n, boolean orig, boolean isCh) { - name = n; - isOrigin = orig; - isChan = isCh; - } +class ChannelData { + public String name; + public boolean isOrigin; + public boolean isChan; + public ChannelData(String n, boolean orig, boolean isCh) { + name = n; + isOrigin = orig; + isChan = isCh; } + +} + } diff --git a/src/main/java/ui/TGCNote.java b/src/main/java/ui/TGCNote.java index 910ecb735f7e22872efbdb8a8849980e8d174c3c..b0ad44f63666a153c1a4fbac58c91462a967402e 100644 --- a/src/main/java/ui/TGCNote.java +++ b/src/main/java/ui/TGCNote.java @@ -60,11 +60,15 @@ import java.awt.*; public class TGCNote extends TGCScalableWithoutInternalComponent { protected String[] values; - protected int textX = 1; - protected int textY = 2; - protected int marginY = 20; - protected int marginX = 20; - protected int limit = 15; + + // Issue #31 +// protected int textX = 1; +// protected int textY = 2; +// protected int marginY = 20; +// protected int marginX = 20; +// protected int limit = 15; + private static final int LIMIT = 15; + private static final int MARGIN_X = 20; protected Graphics myg; protected Color myColor; @@ -79,12 +83,16 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { public TGCNote(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - this.width = 150; - this.height = 30; + // Issue #31 +// this.width = 150; +// this.height = 30; + textX = 1; + textY = 2; this.minWidth = 20; this.minHeight = 10; + initScaling( 150, 20 ); - this.oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); this.nbConnectingPoint = 0; int len = this.makeTGConnectingPointsComment(16); @@ -119,7 +127,7 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { } @Override - public void internalDrawing(Graphics graph) { + protected void internalDrawing(Graphics graph) { if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; this.currentFontSize = this.tdp.getFontSize(); @@ -134,7 +142,11 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { Color c = graph.getColor(); int desiredWidth = this.minWidth; - for (int i = 0; i < this.values.length; i++) + + // Issue #31 + final int marginX = scale( MARGIN_X ); + + for (int i = 0; i < this.values.length; i++) { /* !!! WARNING !!! * Note that here we use TDiagramPanel.stringWidth instead of graph.getFontMetrics().stringWidth * Indeed, TGComponent (and so TGCNote) objects are drawn twice when the bird view is enabled. @@ -148,27 +160,29 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { * from the Graphics object. * Thus we use a saved FontMetrics object in TDiagramPanel that only changes when zoom changes. */ - desiredWidth = Math.max(desiredWidth, this.tdp.stringWidth(graph, this.values[i]) + this.marginX); - + desiredWidth = Math.max(desiredWidth, this.tdp.stringWidth(graph, this.values[i]) + marginX ); // Issue #31 + } int desiredHeight = (this.values.length * this.currentFontSize) + this.textY + 1; if (desiredWidth != this.width || desiredHeight != this.height) this.resize(desiredWidth, desiredHeight); + // Issue #31 + final int limit = scale( LIMIT ); graph.drawLine(this.x, this.y, this.x + this.width, this.y); graph.drawLine(this.x, this.y, this.x, this.y + this.height); - graph.drawLine(this.x, this.y + this.height, this.x + this.width - this.limit, this.y + this.height); - graph.drawLine(this.x + this.width, this.y, this.x + this.width, this.y + this.height - this.limit); + graph.drawLine(this.x, this.y + this.height, this.x + this.width - limit, this.y + this.height); + graph.drawLine(this.x + this.width, this.y, this.x + this.width, this.y + this.height - limit); graph.setColor(ColorManager.UML_NOTE_BG); - int[] px1 = {this.x + 1, this.x + this.width, this.x + this.width, this.x + this.width - this.limit, this.x + 1}; - int[] py1 = {this.y + 1, this.y + 1, this.y + this.height - this.limit, this.y + this.height, this.y + this.height}; + int[] px1 = {this.x + 1, this.x + this.width, this.x + this.width, this.x + this.width - limit, this.x + 1}; + int[] py1 = {this.y + 1, this.y + 1, this.y + this.height - limit, this.y + this.height, this.y + this.height}; graph.fillPolygon(px1, py1, 5); graph.setColor(c); - int[] px = {this.x + this.width, this.x + this.width - 4, this.x + this.width - 10, this.x + this.width - this.limit}; - int[] py = {this.y + this.height - this.limit, this.y + this.height - this.limit + 3, this.y + this.height - this.limit + 2, this.y + this.height}; + int[] px = {this.x + this.width, this.x + this.width - 4, this.x + this.width - 10, this.x + this.width - limit}; + int[] py = {this.y + this.height - limit, this.y + this.height - limit + 3, this.y + this.height - limit + 2, this.y + this.height}; graph.drawPolygon(px, py, 4); if (c == ColorManager.NORMAL_0) @@ -280,7 +294,7 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } } diff --git a/src/main/java/ui/TGCOneLineText.java b/src/main/java/ui/TGCOneLineText.java index d9db3c656949ab3c9baec22b5a700c60a720f2dd..139455f925449af994e918509b1e55da92373db5 100644 --- a/src/main/java/ui/TGCOneLineText.java +++ b/src/main/java/ui/TGCOneLineText.java @@ -52,7 +52,7 @@ import java.awt.*; * @version 1.0 21/12/2003 * @author Ludovic APVRILLE */ -public class TGCOneLineText extends TGCWithoutInternalComponent{ +public class TGCOneLineText extends TGCWithoutInternalComponent { protected boolean emptyText; @@ -60,7 +60,7 @@ public class TGCOneLineText extends TGCWithoutInternalComponent{ super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); nbConnectingPoint = 0; - minWidth = 10; + minWidth = scale( 10 ); nbInternalTGComponent = 0; moveable = true; @@ -75,13 +75,15 @@ public class TGCOneLineText extends TGCWithoutInternalComponent{ } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (!tdp.isScaled()) { width = g.getFontMetrics().stringWidth(value); height = g.getFontMetrics().getHeight(); } + g.drawString(value, x, y); - if (value.equals("")) { + + if ( value.isEmpty() ) { g.drawString("value?", x, y); } } diff --git a/src/main/java/ui/TGCPanelInfo.java b/src/main/java/ui/TGCPanelInfo.java index f92fd3b98904068c1f560c250551d2e287b34b37..40f60b54d27456c0c05457f46062cadc16f44554 100644 --- a/src/main/java/ui/TGCPanelInfo.java +++ b/src/main/java/ui/TGCPanelInfo.java @@ -36,19 +36,18 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui; -import myutil.GraphicLib; -import myutil.TraceManager; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; + import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import ui.util.IconManager; -import java.awt.*; +import myutil.GraphicLib; +import ui.util.IconManager; /** * Class TGCPanelInfo @@ -69,8 +68,11 @@ public class TGCPanelInfo extends TGCScalableWithoutInternalComponent { public final static int LOWER_MIDDLE = 8; public final static int LOWER_RIGHT = 9; - protected int marginY = 5; - protected int marginX = 5; + // Issue #31 + private static final int MARGIN_X = 5; + private static final int MARGIN_Y = 5; +// protected int marginY = 5; +// protected int marginX = 5; protected Graphics myg; @@ -96,7 +98,8 @@ public class TGCPanelInfo extends TGCScalableWithoutInternalComponent { minWidth = 20; minHeight = 20; - oldScaleFactor = tdp.getZoom(); + // Issue #31 + //oldScaleFactor = tdp.getZoom(); nbConnectingPoint = 0; //addTGConnectingPointsComment(); @@ -130,7 +133,7 @@ public class TGCPanelInfo extends TGCScalableWithoutInternalComponent { } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { Font f = g.getFont(); //Font fold = f; @@ -162,6 +165,10 @@ public class TGCPanelInfo extends TGCScalableWithoutInternalComponent { //int h = g.getFontMetrics().getHeight(); int w = g.getFontMetrics().stringWidth(value); + // Issue #31 + final int marginX = scale( MARGIN_X ); + final int marginY = scale( MARGIN_Y ); + switch(stringPos) { case UPPER_LEFT: xStr += marginX; yStr += marginY + currentFontSize; break; @@ -203,15 +210,15 @@ public class TGCPanelInfo extends TGCScalableWithoutInternalComponent { return null; } - @Override - public void rescale(double scaleFactor){ +// @Override +// public void rescale(double scaleFactor){ /*dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); dlineHeight = dlineHeight - lineHeight; minHeight = lineHeight;*/ - super.rescale(scaleFactor); - } +// super.rescale(scaleFactor); +// } @Override public int getType() { diff --git a/src/main/java/ui/TGCPointOfConnector.java b/src/main/java/ui/TGCPointOfConnector.java index 5d8608d4fb2d66b902606c478f4159d81c39867e..36a7e6f960ec4785bd1acaad1df04380e47a21e1 100644 --- a/src/main/java/ui/TGCPointOfConnector.java +++ b/src/main/java/ui/TGCPointOfConnector.java @@ -51,15 +51,15 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class TGCPointOfConnector extends TGCScalableWithoutInternalComponent { - private int width = 8; - private int height = 8; +// private int width = 8; +// private int height = 8; public TGCPointOfConnector(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); nbConnectingPoint = 0; - initScaling(0, 0); + initScaling( 8, 8 ); nbInternalTGComponent = 0; diff --git a/src/main/java/ui/TGCScalableWithInternalComponent.java b/src/main/java/ui/TGCScalableWithInternalComponent.java index ac9c0cce48b8d751d5648d195f87250baaf3ea50..d97fdec92199904c40c8b4d04bca1b7e811e7c09 100644 --- a/src/main/java/ui/TGCScalableWithInternalComponent.java +++ b/src/main/java/ui/TGCScalableWithInternalComponent.java @@ -38,6 +38,8 @@ package ui; +import java.awt.Graphics; + /** * Class TGCScalableWithInternalComponent * Graphical component that contains one or more internal components, and which is scalable @@ -45,116 +47,129 @@ package ui; * @version 1.0 10/03/2008 * @author Ludovic APVRILLE */ -public abstract class TGCScalableWithInternalComponent extends TGCWithInternalComponent implements ScalableTGComponent { +public abstract class TGCScalableWithInternalComponent extends TGCWithInternalComponent /*implements ScalableTGComponent*/ { - protected boolean rescaled = false; - protected double oldScaleFactor; +// protected boolean rescaled = false; +// protected double oldScaleFactor; public TGCScalableWithInternalComponent(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); } - - @Override - public void rescale(double scaleFactor){ - /*TraceManager.addDev("rescaling for " + this.getClass() + " with oldScaleFactor=" + oldScaleFactor + - " new scale factor = " + scaleFactor + " dx=" + dx + " dy=" + dy + - " x=" + x + " y=" + y + " width=" + width + " height=" + height);*/ - rescaled = true; - - final double factor = scaleFactor / oldScaleFactor; - - dwidth = (width + dwidth) * factor;//oldScaleFactor * scaleFactor; - dheight = (height + dheight) * factor;//oldScaleFactor * scaleFactor; - dx = (dx + x) * factor;//oldScaleFactor * scaleFactor; - dy = (dy + y) * factor;//oldScaleFactor * scaleFactor; - dMinWidth = (minWidth + dMinWidth) * factor;//oldScaleFactor * scaleFactor; - dMinHeight = (minHeight + dMinHeight) * factor;//oldScaleFactor * scaleFactor; - dMaxWidth = (maxWidth + dMaxWidth) * factor;//oldScaleFactor * scaleFactor; - dMaxHeight = (maxHeight + dMaxHeight) * factor;//oldScaleFactor * scaleFactor; - - width = (int)(dwidth); - dwidth = dwidth - width; - height = (int)(dheight); - dheight = dheight - height; - minWidth = (int)(dMinWidth); - minHeight = (int)(dMinHeight); - maxWidth = (int)(dMaxWidth); - maxHeight = (int)(dMaxHeight); - - //TraceManager.addDev("tgc= " + this + " minHeight=" + minHeight); - //TraceManager.addDev("tgc= " + this + " maxHeight=" + maxHeight + " height= " + height); - - dMinWidth = dMinWidth - minWidth; - dMinHeight = dMinHeight - minHeight; - dMaxWidth = dMaxWidth - maxWidth; - dMaxHeight = dMaxHeight - maxHeight; - x = (int)(dx); - dx = dx - x; - y = (int)(dy); - dy = dy - y; - - // Issue #81: We also need to update max coordinate values - maxX *= factor; - maxY *= factor; - - - - //TraceManager.addDev("x=" + x + " y=" + y + " width=" + width + " height=" + height); - - oldScaleFactor = scaleFactor; - - if (father != null) { - // Must rescale my zone... - resizeWithFather(); - } else { - minX = (int)(tdp.getMinX()/tdp.getZoom()); - maxX = (int)(tdp.getMaxX()/tdp.getZoom()); - minY = (int)(tdp.getMinY()/tdp.getZoom()); - maxY = (int)(tdp.getMaxY()/tdp.getZoom()); - } - - setMoveCd(x, y, true); - - //TraceManager.addDev("x=" + x + " y=" + y + " width=" + width + " height=" + height); - - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ScalableTGComponent) { - ((ScalableTGComponent)tgcomponent[i]).rescale(scaleFactor); - } - } - hasBeenResized(); - } - - protected void initScaling(int w, int h) { - oldScaleFactor = tdp.getZoom(); - - dx = 0; - dy = 0; - - dwidth = w * oldScaleFactor; - width = (int)dwidth; - dwidth = dwidth - width; - - dheight = h * oldScaleFactor; - height = (int)(dheight); - dheight = dheight - height; - - dMaxWidth = defMaxWidth * oldScaleFactor; - dMaxHeight = defMaxHeight * oldScaleFactor; - - maxWidth = defMaxWidth; - maxHeight = defMaxHeight; - - dMaxWidth = dMaxWidth - maxWidth; - dMaxHeight = dMaxHeight - maxHeight; - - if (father == null) { - minX = (int)(tdp.getMinX()/tdp.getZoom()); - maxX = (int)(tdp.getMaxX()/tdp.getZoom()); - minY = (int)(tdp.getMinY()/tdp.getZoom()); - maxY = (int)(tdp.getMaxY()/tdp.getZoom()); - } - - rescaled = true; + + // Issue #31 + /** + * With the graphic and the string it will calculate the center of the box to draw + * @param g + * @param str + * @return + */ + protected int getCenterOfBox(Graphics g, String str) + { + int stringWidth = g.getFontMetrics().stringWidth(str); + return x + (width - stringWidth)/2; } +// +// @Override +// public void rescale(double scaleFactor){ +// /*TraceManager.addDev("rescaling for " + this.getClass() + " with oldScaleFactor=" + oldScaleFactor + +// " new scale factor = " + scaleFactor + " dx=" + dx + " dy=" + dy + +// " x=" + x + " y=" + y + " width=" + width + " height=" + height);*/ +// rescaled = true; +// +// final double factor = scaleFactor / oldScaleFactor; +// +// dwidth = (width + dwidth) * factor;//oldScaleFactor * scaleFactor; +// dheight = (height + dheight) * factor;//oldScaleFactor * scaleFactor; +// dx = (dx + x) * factor;//oldScaleFactor * scaleFactor; +// dy = (dy + y) * factor;//oldScaleFactor * scaleFactor; +// dMinWidth = (minWidth + dMinWidth) * factor;//oldScaleFactor * scaleFactor; +// dMinHeight = (minHeight + dMinHeight) * factor;//oldScaleFactor * scaleFactor; +// dMaxWidth = (maxWidth + dMaxWidth) * factor;//oldScaleFactor * scaleFactor; +// dMaxHeight = (maxHeight + dMaxHeight) * factor;//oldScaleFactor * scaleFactor; +// +// width = (int)(dwidth); +// dwidth = dwidth - width; +// height = (int)(dheight); +// dheight = dheight - height; +// minWidth = (int)(dMinWidth); +// minHeight = (int)(dMinHeight); +// maxWidth = (int)(dMaxWidth); +// maxHeight = (int)(dMaxHeight); +// +// //TraceManager.addDev("tgc= " + this + " minHeight=" + minHeight); +// //TraceManager.addDev("tgc= " + this + " maxHeight=" + maxHeight + " height= " + height); +// +// dMinWidth = dMinWidth - minWidth; +// dMinHeight = dMinHeight - minHeight; +// dMaxWidth = dMaxWidth - maxWidth; +// dMaxHeight = dMaxHeight - maxHeight; +// x = (int)(dx); +// dx = dx - x; +// y = (int)(dy); +// dy = dy - y; +// +// // Issue #81: We also need to update max coordinate values +// maxX *= factor; +// maxY *= factor; +// +// +// +// //TraceManager.addDev("x=" + x + " y=" + y + " width=" + width + " height=" + height); +// +// oldScaleFactor = scaleFactor; +// +// if (father != null) { +// // Must rescale my zone... +// resizeWithFather(); +// } else { +// minX = (int)(tdp.getMinX()/tdp.getZoom()); +// maxX = (int)(tdp.getMaxX()/tdp.getZoom()); +// minY = (int)(tdp.getMinY()/tdp.getZoom()); +// maxY = (int)(tdp.getMaxY()/tdp.getZoom()); +// } +// +// setMoveCd(x, y, true); +// +// //TraceManager.addDev("x=" + x + " y=" + y + " width=" + width + " height=" + height); +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// if (tgcomponent[i] instanceof ScalableTGComponent) { +// ((ScalableTGComponent)tgcomponent[i]).rescale(scaleFactor); +// } +// } +// hasBeenResized(); +// } +// +// protected void initScaling(int w, int h) { +// oldScaleFactor = tdp.getZoom(); +// +// dx = 0; +// dy = 0; +// +// dwidth = w * oldScaleFactor; +// width = (int)dwidth; +// dwidth = dwidth - width; +// +// dheight = h * oldScaleFactor; +// height = (int)(dheight); +// dheight = dheight - height; +// +// dMaxWidth = defMaxWidth * oldScaleFactor; +// dMaxHeight = defMaxHeight * oldScaleFactor; +// +// maxWidth = defMaxWidth; +// maxHeight = defMaxHeight; +// +// dMaxWidth = dMaxWidth - maxWidth; +// dMaxHeight = dMaxHeight - maxHeight; +// +// if (father == null) { +// minX = (int)(tdp.getMinX()/tdp.getZoom()); +// maxX = (int)(tdp.getMaxX()/tdp.getZoom()); +// minY = (int)(tdp.getMinY()/tdp.getZoom()); +// maxY = (int)(tdp.getMaxY()/tdp.getZoom()); +// } +// +// rescaled = true; +// } } diff --git a/src/main/java/ui/TGCScalableWithoutInternalComponent.java b/src/main/java/ui/TGCScalableWithoutInternalComponent.java index 5d978910f5d51cb9449b539a1f3b51ae5144427b..db471b6e229c8ed3694b12333b108cd44b15ea8f 100644 --- a/src/main/java/ui/TGCScalableWithoutInternalComponent.java +++ b/src/main/java/ui/TGCScalableWithoutInternalComponent.java @@ -45,102 +45,105 @@ package ui; * @version 1.0 14/04/2014 * @author Ludovic APVRILLE */ -public abstract class TGCScalableWithoutInternalComponent extends TGCWithoutInternalComponent implements ScalableTGComponent { +public abstract class TGCScalableWithoutInternalComponent extends TGCWithoutInternalComponent /*implements ScalableTGComponent*/ { - protected boolean rescaled = false; - - protected double oldScaleFactor; +// protected boolean rescaled = false; +// +// protected double oldScaleFactor; public TGCScalableWithoutInternalComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - } - - @Override - public void rescale (double scaleFactor){ - rescaled = true; - - final double factor = scaleFactor / oldScaleFactor; - - dwidth = (width + dwidth) * factor;// oldScaleFactor * scaleFactor; - dheight = (height + dheight) * factor;// oldScaleFactor * scaleFactor; - dx = (dx + x) * factor;// oldScaleFactor * scaleFactor; - dy = (dy + y) * factor;// oldScaleFactor * scaleFactor; - dMinWidth = (minWidth + dMinWidth) * factor;// oldScaleFactor * scaleFactor; - dMinHeight = (minHeight + dMinHeight) * factor;// oldScaleFactor * scaleFactor; - dMaxWidth = (maxWidth + dMaxWidth) * factor;// oldScaleFactor * scaleFactor; - dMaxHeight = (maxHeight + dMaxHeight) * factor;// oldScaleFactor * scaleFactor; - - width = (int)(dwidth); - dwidth = dwidth - width; - height = (int)(dheight); - dheight = dheight - height; - minWidth = (int)(dMinWidth); - minHeight = (int)(dMinHeight); - maxWidth = (int)(dMaxWidth); - maxHeight = (int)(dMaxHeight); - - //TraceManager.addDev("tgc= " + this + " minHeight=" + minHeight); - //TraceManager.addDev("tgc= " + this + " maxHeight=" + maxHeight); - - dMinWidth = dMinWidth - minWidth; - dMinHeight = dMinHeight - minHeight; - dMaxWidth = dMaxWidth - maxWidth; - dMaxHeight = dMaxHeight - maxHeight; - x = (int)(dx); - dx = dx - x; - y = (int)(dy); - dy = dy - y; - // Issue #81: We also need to update max coordinate values - maxX *= factor; - maxY *= factor; - - oldScaleFactor = scaleFactor; - - if (father != null) { - // Must rescale my zone... - resizeWithFather(); - } else { - minX = (int)(tdp.getMinX()/tdp.getZoom()); - maxX = (int)(tdp.getMaxX()/tdp.getZoom()); - minY = (int)(tdp.getMinY()/tdp.getZoom()); - maxY = (int)(tdp.getMaxY()/tdp.getZoom()); - - } - - setMoveCd(x, y, true); +// // Isssue #31 +// oldScaleFactor = 1.0; } - protected void initScaling(int w, int h) { - oldScaleFactor = tdp.getZoom(); - - dx = 0; - dy = 0; - - dwidth = w * oldScaleFactor; - width = (int)dwidth; - dwidth = dwidth - width; - - dheight = h * oldScaleFactor; - height = (int)(dheight); - dheight = dheight - height; - - dMaxWidth = defMaxWidth * oldScaleFactor; - dMaxHeight = defMaxHeight * oldScaleFactor; - - maxWidth = defMaxWidth; - maxHeight = defMaxHeight; - - dMaxWidth = dMaxWidth - maxWidth; - dMaxHeight = dMaxHeight - maxHeight; - - if (father == null) { - minX = (int)(tdp.getMinX()/tdp.getZoom()); - maxX = (int)(tdp.getMaxX()/tdp.getZoom()); - minY = (int)(tdp.getMinY()/tdp.getZoom()); - maxY = (int)(tdp.getMaxY()/tdp.getZoom()); - } - - rescaled = true; - } +// @Override +// public void rescale (double scaleFactor){ +// rescaled = true; +// +// final double factor = scaleFactor / oldScaleFactor; +// +// dwidth = (width + dwidth) * factor;// oldScaleFactor * scaleFactor; +// dheight = (height + dheight) * factor;// oldScaleFactor * scaleFactor; +// dx = (dx + x) * factor;// oldScaleFactor * scaleFactor; +// dy = (dy + y) * factor;// oldScaleFactor * scaleFactor; +// dMinWidth = (minWidth + dMinWidth) * factor;// oldScaleFactor * scaleFactor; +// dMinHeight = (minHeight + dMinHeight) * factor;// oldScaleFactor * scaleFactor; +// dMaxWidth = (maxWidth + dMaxWidth) * factor;// oldScaleFactor * scaleFactor; +// dMaxHeight = (maxHeight + dMaxHeight) * factor;// oldScaleFactor * scaleFactor; +// +// width = (int)(dwidth); +// dwidth = dwidth - width; +// height = (int)(dheight); +// dheight = dheight - height; +// minWidth = (int)(dMinWidth); +// minHeight = (int)(dMinHeight); +// maxWidth = (int)(dMaxWidth); +// maxHeight = (int)(dMaxHeight); +// +// //TraceManager.addDev("tgc= " + this + " minHeight=" + minHeight); +// //TraceManager.addDev("tgc= " + this + " maxHeight=" + maxHeight); +// +// dMinWidth = dMinWidth - minWidth; +// dMinHeight = dMinHeight - minHeight; +// dMaxWidth = dMaxWidth - maxWidth; +// dMaxHeight = dMaxHeight - maxHeight; +// x = (int)(dx); +// dx = dx - x; +// y = (int)(dy); +// dy = dy - y; +// +// // Issue #81: We also need to update max coordinate values +// maxX *= factor; +// maxY *= factor; +// +// oldScaleFactor = scaleFactor; +// +// if (father != null) { +// // Must rescale my zone... +// resizeWithFather(); +// } else { +// minX = (int)(tdp.getMinX()/tdp.getZoom()); +// maxX = (int)(tdp.getMaxX()/tdp.getZoom()); +// minY = (int)(tdp.getMinY()/tdp.getZoom()); +// maxY = (int)(tdp.getMaxY()/tdp.getZoom()); +// +// } +// +// setMoveCd(x, y, true); +// } +// +// protected void initScaling(int w, int h) { +// oldScaleFactor = tdp.getZoom(); +// +// dx = 0; +// dy = 0; +// +// dwidth = w * oldScaleFactor; +// width = (int)dwidth; +// dwidth = dwidth - width; +// +// dheight = h * oldScaleFactor; +// height = (int)(dheight); +// dheight = dheight - height; +// +// dMaxWidth = defMaxWidth * oldScaleFactor; +// dMaxHeight = defMaxHeight * oldScaleFactor; +// +// maxWidth = defMaxWidth; +// maxHeight = defMaxHeight; +// +// dMaxWidth = dMaxWidth - maxWidth; +// dMaxHeight = dMaxHeight - maxHeight; +// +// if (father == null) { +// minX = (int)(tdp.getMinX()/tdp.getZoom()); +// maxX = (int)(tdp.getMaxX()/tdp.getZoom()); +// minY = (int)(tdp.getMinY()/tdp.getZoom()); +// maxY = (int)(tdp.getMaxY()/tdp.getZoom()); +// } +// +// rescaled = true; +// } } diff --git a/src/main/java/ui/TGCWithInternalComponent.java b/src/main/java/ui/TGCWithInternalComponent.java index 833bc50b1d75cce2f7893fc8197b17304c4e411f..0ac930c57a531b03c1f2b8d45b72cd7418066e0b 100644 --- a/src/main/java/ui/TGCWithInternalComponent.java +++ b/src/main/java/ui/TGCWithInternalComponent.java @@ -45,7 +45,7 @@ package ui; * @version 1.0 22/12/2003 * @author Ludovic APVRILLE */ -public abstract class TGCWithInternalComponent extends TGComponent { +public abstract class TGCWithInternalComponent extends TGScalableComponent /* Issue #31 TGComponent*/{ public TGCWithInternalComponent(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); diff --git a/src/main/java/ui/TGCWithoutInternalComponent.java b/src/main/java/ui/TGCWithoutInternalComponent.java index dcf49f283fd14fa75ef0da880400740a16acbb04..50383b0139667ac517607e259bda1447e6315997 100644 --- a/src/main/java/ui/TGCWithoutInternalComponent.java +++ b/src/main/java/ui/TGCWithoutInternalComponent.java @@ -45,7 +45,7 @@ package ui; * @version 1.0 21/12/2003 * @author Ludovic APVRILLE */ -public abstract class TGCWithoutInternalComponent extends TGComponent{ +public abstract class TGCWithoutInternalComponent extends TGScalableComponent /* Issue #31 TGComponent*/{ public TGCWithoutInternalComponent(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); diff --git a/src/main/java/ui/TGComponent.java b/src/main/java/ui/TGComponent.java index 68c801083c8d1b3da6aa440109c3ef1a72e29b13..883c7ee0004d3673c080aadfb2c29beb7f06def9 100644 --- a/src/main/java/ui/TGComponent.java +++ b/src/main/java/ui/TGComponent.java @@ -211,7 +211,8 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem protected boolean breakpoint; // Zoom - public double dx = 0, dy = 0, dwidth, dheight, dMaxWidth, dMaxHeight, dMinWidth, dMinHeight; + // Issue #31: Moved to scalable component + //double dx = 0, dy = 0, dwidth, dheight, dMaxWidth, dMaxHeight, dMinWidth, dMinHeight; //Constructor @@ -237,7 +238,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem // abstract operations - public abstract void internalDrawing(Graphics g); + protected abstract void internalDrawing(Graphics g); public abstract TGComponent isOnMe(int _x, int _y); @@ -1018,6 +1019,38 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem } + /** + * Issue #31 + * @return + */ + protected int getReachabilityMargin() { + return 18; + } + + /** + * Issue #31 + * @return + */ + protected int getLivenessMargin() { + return 10; + } + + /** + * Issue #31 + * @return + */ + protected int getUnknownMargin() { + return 2; + } + + /** + * Issue #31 + * @return + */ + protected int getExclusionMargin() { + return 12; + } + public void draw(Graphics g) { RunningInfo ri; LoadInfo li; @@ -1044,11 +1077,11 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem } if ((accessibility) || (reachability != ACCESSIBILITY_UNKNOWN) || (liveness != ACCESSIBILITY_UNKNOWN)) { - drawAccessibility(reachability, g, x + width - 18, y - 1, "R"); - drawAccessibility(liveness, g, x + width - 10, y - 1, "L"); + drawAccessibility(reachability, g, x + width - getReachabilityMargin() /* Issue # 31 18*/, y - 1, "R"); + drawAccessibility(liveness, g, x + width - getLivenessMargin() /* Issue #31 10*/, y - 1, "L"); if ((reachability == ACCESSIBILITY_UNKNOWN) && (liveness == ACCESSIBILITY_UNKNOWN)) { - drawAccessibility(liveness, g, x + width - 2, y - 2, "?"); + drawAccessibility(liveness, g, x + width - getUnknownMargin() /* Issue # 31 2 */, y - 1 /* Issue # 31 2*/, "?"); } // Old way to do .. @@ -1062,13 +1095,16 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem if (invariant) { g.setColor(ColorManager.ACCESSIBILITY); //GraphicLib.setMediumStroke(g); + // Issue #31 + final int exclusionMargin = getExclusionMargin(); + if (mutex == MUTEX_NOT_YET_STUDIED) { - g.drawString("mutual exclusion?", x + width + 1, y - 12); + g.drawString("mutual exclusion?", x + width + 1, y - exclusionMargin /* Issue #31 12*/); } else if (mutex == MUTEX_UNKNOWN) { - g.drawString("mutual exclusion: cannot be proved", x + width + 1, y - 12); + g.drawString("mutual exclusion: cannot be proved", x + width + 1, y - exclusionMargin); } else if (mutex == MUTEX_OK) { g.setColor(ColorManager.MUTEX_OK); - g.drawString("mutual exclusion: OK", x + width + 1, y - 12); + g.drawString("mutual exclusion: OK", x + width + 1, y - exclusionMargin); } /*g.drawLine(x+width-2, y+2, x+width-6, y+6); @@ -2327,6 +2363,14 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem return y; } + public double getZoomFactor() { + if ( tdp == null ) { + return 1.0; + } + + return tdp.getZoom(); + } + public int getXZoom() { if (tdp == null) { return x; diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index b06aacfd5044435acbd6a719ac121cc97d7f3272..02b95536b887b2ba8d80942b2715558bdb7d4dba 100644 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -2126,7 +2126,7 @@ public class TGComponentManager { return TMLAD_EXECI; } else if (tgc instanceof TMLADExecIInterval) { return TMLAD_EXECI_INTERVAL; - } else if (tgc instanceof TMLADExecC) { + } else if (tgc instanceof TADExec) { return TMLAD_EXECC; } else if (tgc instanceof TMLADExecCInterval) { return TMLAD_EXECC_INTERVAL; diff --git a/src/main/java/ui/TGConnectingPoint.java b/src/main/java/ui/TGConnectingPoint.java index ce52122bf6f13e606d376610a712c4bd88c8b5df..cbe34bd8aaa66848cda93e7904f003434d6c1fef 100644 --- a/src/main/java/ui/TGConnectingPoint.java +++ b/src/main/java/ui/TGConnectingPoint.java @@ -98,7 +98,7 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* y = _y; in = _in; out = _out; - + /* if (in) { if (out) { myColor = INOUT; @@ -111,11 +111,37 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* } else { myColor = NO; } - } + }*/ + + // Factorization of above commented text for more readability + if (in && out) + myColor = INOUT; + else if (in) + myColor = IN; + else if (out) + myColor = OUT; + else + myColor = NO; id = TGComponent.getGeneralId(); TGComponent.setGeneralId(id + 1); } + + protected int scaledValue( final int value ) { + return (int) ( value * getZoomFactor() ); + } + + protected double getZoomFactor() { + return ( container instanceof TGComponent ) ? ( (TGComponent) container ).getZoomFactor() : 1.0; + } + + protected int scaledX() { + return scaledValue( x ); + } + + protected int scaledY() { + return scaledValue( y ); + } public void draw(Graphics g) { int mx = getX(); @@ -167,7 +193,7 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* int my = getY(); return GraphicLib.isInRectangle(_x, _y, mx - width /2, my - height /2, width, height); } - + public void setCdX(int _x) { x = _x; } @@ -175,34 +201,36 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* public void setCdY(int _y) { y = _y; } - + + @Override public void setCd(int x, int y) { this.x = x; this.y = y; } - + @Override public int getX() { if (container != null) { - return x + container.getX(); + return scaledX() + container.getX(); } - return x; + return scaledX(); } - + @Override public int getY() { if (container != null) { - return y + container.getY(); + return scaledY() + container.getY(); } - return y; + return scaledY(); } public int getId() { return id; } - + @Override public int getWidth() { return width; } - + + @Override public int getHeight() { return height; } @@ -261,7 +289,8 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* cpg.setFree(b); } } - + + @Override public String getName() { return container.getName(); } diff --git a/src/main/java/ui/TGConnectingPointComment.java b/src/main/java/ui/TGConnectingPointComment.java index 8d1a542dbe5e3fc08c87fea6a806f088497105bc..a6f7aa6236ab2c2365fa4c0260aa005cc92470f3 100644 --- a/src/main/java/ui/TGConnectingPointComment.java +++ b/src/main/java/ui/TGConnectingPointComment.java @@ -36,15 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui; -//import java.awt.*; - -//import myutil.*; - /** * Class TGConnectingPointComment * Definition of connecting points on which connectors can be connected to UML comments @@ -58,14 +51,8 @@ public class TGConnectingPointComment extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_COMMENT; } } - - - - - - - diff --git a/src/main/java/ui/TGConnectingPointCommentConnector.java b/src/main/java/ui/TGConnectingPointCommentConnector.java index ddd46d8ecc6a97be0dbf4bce995db6235e9cde28..ffa9cc6ad99bdd543827e6f4d7376625ce33cdf6 100644 --- a/src/main/java/ui/TGConnectingPointCommentConnector.java +++ b/src/main/java/ui/TGConnectingPointCommentConnector.java @@ -36,15 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui; -//import java.awt.*; - -//import myutil.*; - /** * Class TGConnectingPointCommentConnector * Definition of connecting points for connectors on which connectors can be connected to UML comments @@ -52,20 +45,14 @@ package ui; * @version 1.0 25/05/2011 * @author Ludovic APVRILLE */ -public class TGConnectingPointCommentConnector extends TGConnectingPointTwoFathers { +public class TGConnectingPointCommentConnector extends TGConnectingPointTwoFathers { public TGConnectingPointCommentConnector(CDElement _container1, CDElement _container2, int _x, int _y, boolean _in, boolean _out) { super(_container1, _container2, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_COMMENT; } } - - - - - - - diff --git a/src/main/java/ui/TGConnectingPointTmp.java b/src/main/java/ui/TGConnectingPointTmp.java index 8596f9dc3b80e2ef3c4fca45704ded91890263d4..daefcf04d4222cffaaa745ec4006d7198c7095f3 100644 --- a/src/main/java/ui/TGConnectingPointTmp.java +++ b/src/main/java/ui/TGConnectingPointTmp.java @@ -35,14 +35,9 @@ * 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 java.awt.*; - /** * Class TGConnectingPointTmp * Definition of connecting points that are used when model is loaded @@ -50,7 +45,7 @@ package ui; * @version 1.0 16/12/2003 * @author Ludovic APVRILLE */ -public class TGConnectingPointTmp extends TGConnectingPoint{ +public class TGConnectingPointTmp extends TGConnectingPoint { private int id; public TGConnectingPointTmp(CDElement _container, int _x, int _y, int _id) { @@ -58,19 +53,13 @@ public class TGConnectingPointTmp extends TGConnectingPoint{ id = _id; } + @Override public boolean isCompatibleWith(int type) { return false; } + @Override public int getId() { return id; } - } - - - - - - - diff --git a/src/main/java/ui/TGConnectingPointTwoFathers.java b/src/main/java/ui/TGConnectingPointTwoFathers.java index 6e37f16eee9dfaad8dbda9de747ce18271146817..45c86b20150b465816f45251a3e86d9dbf67d34f 100644 --- a/src/main/java/ui/TGConnectingPointTwoFathers.java +++ b/src/main/java/ui/TGConnectingPointTwoFathers.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui; import myutil.GraphicLib; @@ -52,7 +49,7 @@ import java.awt.*; * @version 1.0 22/12/2003 * @author Ludovic APVRILLE */ -public class TGConnectingPointTwoFathers extends TGConnectingPoint{ +public class TGConnectingPointTwoFathers extends TGConnectingPoint { protected CDElement container2; public TGConnectingPointTwoFathers(CDElement _container1, CDElement _container2, int _x, int _y, boolean _in, boolean _out) { @@ -60,9 +57,10 @@ public class TGConnectingPointTwoFathers extends TGConnectingPoint{ container2 = _container2; } + @Override public void draw(Graphics g) { - int mx = x + (container.getX() + container2.getX())/2; - int my = y + (container.getY() + container2.getY())/2; + int mx = scaledX() + (container.getX() + container2.getX())/2; + int my = scaledY() + (container.getY() + container2.getY())/2; if (state == SELECTED) { mx = mx - width / 2; my = my - height / 2; @@ -85,8 +83,8 @@ public class TGConnectingPointTwoFathers extends TGConnectingPoint{ } public boolean isCloseTo(int _x, int _y) { - int mx = x + (container.getX() + container2.getX())/2; - int my = y + (container.getY() + container2.getY())/2; + int mx = scaledX() + (container.getX() + container2.getX())/2; + int my = scaledY() + (container.getY() + container2.getY())/2; return GraphicLib.isInRectangle(_x, _y, mx - width /2, my - height /2, width, height); } @@ -113,12 +111,4 @@ public class TGConnectingPointTwoFathers extends TGConnectingPoint{ public void setFather2(CDElement cd) { container2 = cd; } - } - - - - - - - diff --git a/src/main/java/ui/TGConnectingPointWidthHeight.java b/src/main/java/ui/TGConnectingPointWidthHeight.java index 46d95a7615f67802358c51f105fff164bc179615..b8233265b86ac39b336f9a8a5d9aa1fb3cf5976c 100644 --- a/src/main/java/ui/TGConnectingPointWidthHeight.java +++ b/src/main/java/ui/TGConnectingPointWidthHeight.java @@ -45,7 +45,7 @@ package ui; * @version 1.0 09/12/2003 * @author Ludovic APVRILLE */ -public class TGConnectingPointWidthHeight extends TGConnectingPoint{ +public class TGConnectingPointWidthHeight extends TGConnectingPoint { protected double w; @@ -56,15 +56,16 @@ public class TGConnectingPointWidthHeight extends TGConnectingPoint{ w = _w; h = _h; } - + /* From Interface ui.CDElement*/ @Override public int getX() { - return x + container.getX() + (int)(container.getWidth() * w); + return scaledX() + container.getX() + (int)(container.getWidth() * w ); } - + + /* From Interface ui.CDElement*/ @Override public int getY() { - return y + container.getY() + (int)(container.getHeight() * h); + return scaledY() + container.getY() + (int)(container.getHeight() * h); } public void setW(double _w) { diff --git a/src/main/java/ui/TGConnector.java b/src/main/java/ui/TGConnector.java old mode 100755 new mode 100644 index c3b3a2fe514253242fcb6a1ecc0eda8b5b8c856a..b49d8863ee03c20013e30a938782325b8ffde4c1 --- a/src/main/java/ui/TGConnector.java +++ b/src/main/java/ui/TGConnector.java @@ -83,7 +83,7 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { p1 = _p1; p2 = _p2; - initScaling(0, 0); + //initScaling(0, 0); initPoints( _listPoint ); // nbInternalTGComponent = _listPoint.size(); @@ -197,7 +197,7 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { }*/ @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { TGComponent p3, p4; if (hasTGCPointOfConnector()) { diff --git a/src/main/java/ui/TGConnectorWithCommentConnectionPoints.java b/src/main/java/ui/TGConnectorWithCommentConnectionPoints.java index 0f3b3cd017dccf5760a13f8ac0ecf0d58112ced4..330535a232e05de4aa137284bf4f6297397c92b5 100644 --- a/src/main/java/ui/TGConnectorWithCommentConnectionPoints.java +++ b/src/main/java/ui/TGConnectorWithCommentConnectionPoints.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui; import myutil.TraceManager; @@ -51,14 +48,17 @@ import java.util.Vector; /** * Class TGConnectorWithCommentConnectingPoints - * Generic + * Generic (abstract class) Connector With Comment * Creation: 25/05/2011 * @version 1.0 25/05/2011 * @author Ludovic APVRILLE */ public abstract class TGConnectorWithCommentConnectionPoints extends TGConnector { protected TGConnectingPointGroup tg; - + /** + * Fills the points array witht the current points, + * P1 = initial point, P2 = destination point + * */ public TGConnectorWithCommentConnectionPoints(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); @@ -69,13 +69,13 @@ public abstract class TGConnectorWithCommentConnectionPoints extends TGConnector getTGCPointOfConnectors(points); //Connecting points have cd relatives to 2 component connectingPoint = new TGConnectingPointTwoFathers[nbConnectingPoint]; - if (nbConnectingPoint == 1) { + if (nbConnectingPoint == 1) connectingPoint[0] = new TGConnectingPointCommentConnector(p1, p2, 0, 0, true, true); - } else { + else + { connectingPoint[0] = new TGConnectingPointCommentConnector(p1, points[0], 0, 0, true, true); - for(int i=1; i<nbInternalTGComponent; i++) { + for (int i = 1; i < nbInternalTGComponent; i++) connectingPoint[i] = new TGConnectingPointCommentConnector(points[i-1], points[i], 0, 0, true, true); - } connectingPoint[nbInternalTGComponent] = new TGConnectingPointCommentConnector(points[nbInternalTGComponent-1], p2, 0, 0, true, true); } @@ -84,21 +84,32 @@ public abstract class TGConnectorWithCommentConnectionPoints extends TGConnector //myImageIcon = IconManager.imgic102; } - + /** + * setP1: initial point + * @param p TGConnectingPoint + * */ + @Override public void setP1(TGConnectingPoint p) { p1 = p; if (nbConnectingPoint > 0) { connectingPoint[0].setFather(p); } } - + /** + * setP2: destination point + * @param TGConnectingPoint p + */ + @Override public void setP2(TGConnectingPoint p) { p2 = p; if (nbConnectingPoint > 0) { ((TGConnectingPointCommentConnector)(connectingPoint[getNbInternalPoints()])).setFather2(p); } } - + /** + * @param tgc TGCPointOfConnector + */ + @Override public void pointHasBeenRemoved(TGCPointOfConnector tgc) { TraceManager.addDev("Internal Points:" + nbInternalTGComponent); @@ -111,7 +122,7 @@ public abstract class TGConnectorWithCommentConnectionPoints extends TGConnector // I.e. we remove the point which father1 is tgc // Looking for the connecting point that has been removed - for(i=0; i<nbConnectingPoint; i++) { + for (i = 0; i < nbConnectingPoint; i++) { if (connectingPoint[i].getFather() == tgc) { index = i; found = true; @@ -152,7 +163,7 @@ public abstract class TGConnectorWithCommentConnectionPoints extends TGConnector nbConnectingPoint --; } - + @Override public void pointHasBeenAdded(TGCPointOfConnector tgc, int index, int indexCon) { int ind = index + indexCon; CDElement tg1, tg2; diff --git a/src/main/java/ui/TGScalableComponent.java b/src/main/java/ui/TGScalableComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..939c4ac6b6a0a831469803e14c1c4ccc0f58b9e8 --- /dev/null +++ b/src/main/java/ui/TGScalableComponent.java @@ -0,0 +1,475 @@ +package ui; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Image; + +import javax.swing.ImageIcon; + +import ui.util.IconManager; + +/** + * Issue #31 + * @author dblouin + * + */ +public abstract class TGScalableComponent extends TGComponent implements ScalableTGComponent { + + protected boolean rescaled; + + protected double oldScaleFactor; + + protected boolean displayText; + protected int textX; // border for ports + protected double dtextX; + protected int textY; + protected double dtextY; + protected int arc; + protected double darc; + + protected int lineLength; + protected double dLineLength; + protected int linebreak; + protected double dLinebreak; + + protected double dx = 0, dy = 0, dwidth, dheight, dMaxWidth, dMaxHeight, dMinWidth, dMinHeight; + + public TGScalableComponent(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); + + rescaled = false; + oldScaleFactor = tdp.getZoom(); + + textX = 15; + textY = 15; + + arc = 5; + + lineLength = 5; + linebreak = 10; + displayText = true; + } + + //Issue #31: + /** + * Verifies that the text is readable if its not it shall not be drawn + * fontsize 8 is the limit that is set to be "readable". It can be changed + * @param iconSize + * @return + */ + protected boolean isTextReadable(Graphics g) + { + int textSize = g.getFont().getSize(); + return textSize > 7; + } + + /** + * Gets the center of the rectangle/box + * @param g + * @param str + * @return + */ + protected int getCenter(Graphics g, String str) + { + int w = g.getFontMetrics().stringWidth(str); + return x + (width - w)/2; + } + + /** + * Verifies that the text is small enough to be drawn into the box + * If The actual box does not have an icon, make sure call the function as following: + * canTextGoInTheBox(g, fontSize, text, 0); + * @param g + * @param fontSize + * @param text + * @param iconSize + * @return a boolean indicating that the txt can or not be drawn + */ + protected boolean canTextGoInTheBox(Graphics g, int fontSize, String text, int iconSize) + { + int txtWidth = g.getFontMetrics().stringWidth(text) + (textX * 2); + int spaceTakenByIcon = iconSize + textX; + return (fontSize + (textY * 2) < height) // enough space in height + && (txtWidth + spaceTakenByIcon < width) // enough space in width + ; + } + /** + * Draw a box of two rectangle: one for the title and one for the content of the box + * lineHeight defines the height of the first box + * @param g + * @param lineHeight + */ + protected void drawDoubleRectangleBoxType(Graphics g, int lineHeight, Color cbefore, Color cafter) + { + //Rectangle + drawSimpleRectangle(g);//g.drawRect(x, y, width, height); + g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + + //Filling + g.setColor(cbefore); // for example: ColorManager.AVATAR_ASSUMPTION_TOP + g.fillRect(x+1, y+1, width-1, lineHeight-1); + g.setColor(cafter); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + } + /** + * Draw one box without any color filling + * @param g + */ + protected void drawSimpleRectangle(Graphics g) + { + g.drawRect(x, y, width, height); + } + /** + * used to draw the icon "icon" at position x = x + width - scale(iconsize) - borders + * and y = y + borders + * @param g + * @param icon + * @param iconSize + */ + protected void drawIcon(Graphics g, Image icon, int iconSize) { + if (!isTextReadable(g)) + return; + int borders = scale(3); + g.drawImage(scale(icon), x + width - scale(iconSize) - borders, y + borders, Color.yellow, null); + } + + protected void drawImageWithCheck(Graphics g, Image image, int xpos, int ypos) { + if (!isTextReadable(g)) + return; + g.drawImage(scale(image), xpos, ypos, null); + } + /** + * Draw string if text is readable + * @param g + * @param s + */ + protected void drawSingleString(Graphics g, String s, int xpos, int ypos) + { + if (!isTextReadable(g)) + return; + //int currentFontSize = setCurrentFontSize ? g.getFont().getSize() : 0; + g.drawString(s, xpos, ypos); + } + + /** + * Same as drawSingleString + * @param g + * @param s + * @param xpos + * @param ypos + * @param maxWidth + * @param pos + */ + protected void drawSingleLimitedString(Graphics g, String s, int xpos, int ypos, int maxWidth, int pos) + { + if (!isTextReadable(g)) + return; + drawLimitedString(g, s, xpos, ypos, maxWidth, pos); + } + + /** + * draw two string one under another: + * + * @param g + * @param topText + * @param bottomText + */ + protected void drawDoubleLimitedString(Graphics g, String topText, String bottomText) + { + if (!isTextReadable(g)) + return; + + Font f = g.getFont(); + + int currentFontSize = f.getSize(); + g.setFont(f.deriveFont(Font.BOLD)); + drawLimitedString(g, topText, x, y + currentFontSize + textY, width, 1); + g.setFont(f.deriveFont(Font.PLAIN)); + drawLimitedString(g, bottomText, y, y + currentFontSize * 2 + textY, width, 1); + } + + /** + * draw two string one under another: + * + * @param g + * @param topText + * @param bottomText + */ + protected void drawDoubleString(Graphics g, String topText, String bottomText) + { + if (!isTextReadable(g)) + return; + + Font f = g.getFont(); + + int currentFontSize = f.getSize(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(topText, getCenter(g, topText), y + currentFontSize + textY); + g.setFont(f.deriveFont(Font.PLAIN)); + g.drawString(bottomText, getCenter(g, bottomText), y + currentFontSize * 2 + textY); + } + // END Issue #31 + + /** + * Scale from a value and a factor + * @param value + * @param factor + * @return scaling value of param: value and factor + * */ + public static int scale( final int value, + final double factor ) { + return (int) ( value * factor ); + } + + /** + * Scale from a value and the oldScaleFactor previously saved + * @param value + * @return scaling value of param: value and oldScaleFactor + * */ + protected int scale( final int value ) { + return scale( value, oldScaleFactor ); + } + + /** + * init the scaling values + * @param w (width) + * @param h (height) + * */ + protected void initScaling(int w, int h) { + oldScaleFactor = tdp.getZoom(); + + dx = 0; + dy = 0; + + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + dtextY = textY * oldScaleFactor; + textY = (int) dtextY; + dtextY = dtextY - textY; + + darc = arc * oldScaleFactor; + arc = (int) darc; + darc = darc - arc; + + dwidth = w * oldScaleFactor; + width = (int)dwidth; + dwidth = dwidth - width; + + dheight = h * oldScaleFactor; + height = (int)(dheight); + dheight = dheight - height; + + darc = arc * oldScaleFactor; + arc = (int)(darc); + darc = darc - arc; + + dLineLength = lineLength * oldScaleFactor; + lineLength = (int) dLineLength; + dLineLength = dLineLength - lineLength; + + dLinebreak = linebreak * oldScaleFactor; + linebreak = (int) dLinebreak; + dLinebreak = dLinebreak - linebreak; + + dMinWidth = minWidth * oldScaleFactor; + dMinHeight = minHeight * oldScaleFactor; + dMaxWidth = defMaxWidth * oldScaleFactor; + dMaxHeight = defMaxHeight * oldScaleFactor; + + maxWidth = defMaxWidth; + maxHeight = defMaxHeight; + + dMinWidth = dMinWidth -minWidth; + dMinHeight = dMinHeight - minHeight; + dMaxWidth = dMaxWidth - maxWidth; + dMaxHeight = dMaxHeight - maxHeight; + + if (father == null) { + minX = (int)(tdp.getMinX()/tdp.getZoom()); + maxX = (int)(tdp.getMaxX()/tdp.getZoom()); + minY = (int)(tdp.getMinY()/tdp.getZoom()); + maxY = (int)(tdp.getMaxY()/tdp.getZoom()); + } + + rescaled = true; + } + + /** + * Rescale with the help of a scaleFactor + * @param scaleFactor + * + * */ + @Override + public void rescale( final double scaleFactor ) { + rescaled = true; + + final double factor = scaleFactor / oldScaleFactor; + + dwidth = (width + dwidth) * factor; + dheight = (height + dheight) * factor; + dx = (dx + x) * factor; + dy = (dy + y) * factor; + dMinWidth = (minWidth + dMinWidth) * factor; + dMinHeight = (minHeight + dMinHeight) * factor;//oldScaleFactor * scaleFactor; + dMaxWidth = (maxWidth + dMaxWidth) * factor;//oldScaleFactor * scaleFactor; + dMaxHeight = (maxHeight + dMaxHeight) * factor;//oldScaleFactor * scaleFactor; + + width = (int)(dwidth); + dwidth = dwidth - width; + height = (int)(dheight); + dheight = dheight - height; + minWidth = (int)(dMinWidth); + minHeight = (int)(dMinHeight); + maxWidth = (int)(dMaxWidth); + maxHeight = (int)(dMaxHeight); + + dMinWidth = dMinWidth - minWidth; + dMinHeight = dMinHeight - minHeight; + dMaxWidth = dMaxWidth - maxWidth; + dMaxHeight = dMaxHeight - maxHeight; + x = (int)(dx); + dx = dx - x; + y = (int)(dy); + dy = dy - y; + + dtextX = (textX + dtextX) * factor; + textX = (int) (dtextX); + dtextX = dtextX - textX; + + dtextY = (textY + dtextY) * factor; + textY = (int) (dtextY); + dtextY = dtextY - textY; + + darc = (arc + darc) * factor; + arc = (int) (darc); + darc = darc - arc; + + dLineLength = (lineLength + dLineLength) * factor; + lineLength = (int) dLineLength; + dLineLength = dLineLength - lineLength; + + dLinebreak = (linebreak + dLinebreak) * factor; + linebreak = (int) dLinebreak; + dLinebreak = dLinebreak - linebreak; + + // Issue #81: We also need to update max coordinate values + maxX *= factor; + maxY *= factor; + + oldScaleFactor = scaleFactor; + + if (father != null) { + // Must rescale my zone... + resizeWithFather(); + } else { + minX = (int)(tdp.getMinX()/tdp.getZoom()); + maxX = (int)(tdp.getMaxX()/tdp.getZoom()); + minY = (int)(tdp.getMinY()/tdp.getZoom()); + maxY = (int)(tdp.getMaxY()/tdp.getZoom()); + } + + setMoveCd(x, y, true); + + //TraceManager.addDev("x=" + x + " y=" + y + " width=" + width + " height=" + height); + + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof ScalableTGComponent) { + ((ScalableTGComponent)tgcomponent[i]).rescale(scaleFactor); + } + } + + hasBeenResized(); + } + + /** + * Issue #31 + * @return + */ + @Override + protected int getReachabilityMargin() { + return scale( super.getReachabilityMargin() ); + } + + /** + * Issue #31 + * @return + */ + @Override + protected int getLivenessMargin() { + return scale( super.getLivenessMargin() ); + } + + /** + * Issue #31 + * @return + */ + @Override + protected int getExclusionMargin() { + return scale( super.getExclusionMargin() ); + } + + /** + * Issue #31 + * @return + */ + protected int getUnknownMargin() { + return scale( super.getUnknownMargin() ); + } + + /** + * Issue #31: Shared this check + * @param graphics + */ + protected int checkWidth( final Graphics graphics ) { + return checkWidth( graphics, value ); + } + + /** + * Issue #31: Check the Width, increase the width in case the actual width is not enough to display the text. + * Used when a component is created + * @param graphics + * @param text + * @return textWidth + * */ + protected int checkWidth( final Graphics graphics, + final String text ) { + final int textWidth = graphics.getFontMetrics().stringWidth( text ); + final int textWidthBorder = Math.max( minWidth, textWidth + 2 * textX ); + + if ( textWidthBorder > width & !tdp.isScaled() ) { + setCd(x - ( textWidthBorder - width ) / 2 , y); + width = textWidthBorder; + } + + return textWidth; + } + + /** + * Scale an image directly + * @param image + * @return the scaled image + * */ + protected Image scale( final Image image ) { + if ( image == null ) { + return image; + } + + return scale( image, scale( image.getWidth( null ) ) ); + } + + /** + * Scale an image directly with a custom width + * @param image + * @param width + * @return the scaled image + * */ + protected Image scale( final Image image, + final int width ) { + return new ImageIcon( image.getScaledInstance( width, - 1, Image.SCALE_SMOOTH ) ).getImage(); + } +} diff --git a/src/main/java/ui/TMLDesignPanel.java b/src/main/java/ui/TMLDesignPanel.java index 08a7fad8033aa280d620c55be2b4793a9c82b05c..12ee51a8074a26c400962746f328d8b3801f97bd 100644 --- a/src/main/java/ui/TMLDesignPanel.java +++ b/src/main/java/ui/TMLDesignPanel.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui; import myutil.GraphicLib; @@ -57,6 +54,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; +import java.util.List; import java.util.Iterator; import java.util.Vector; @@ -150,37 +148,39 @@ public class TMLDesignPanel extends TURTLEPanel { mgui.changeMade(tmltdp, TDiagramPanel.NEW_COMPONENT); //jsp.setVisible(true); - } + @Override public String saveHeaderInXml(String extensionToName) { - if (extensionToName == null) { - return "<Modeling type=\"TML Design\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; - } - return "<Modeling type=\"TML Design\" nameTab=\"" + mgui.getTabName(this) + extensionToName + "\" >\n"; + if (extensionToName == null) { + return "<Modeling type=\"TML Design\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; + } + return "<Modeling type=\"TML Design\" nameTab=\"" + mgui.getTabName(this) + extensionToName + "\" >\n"; } + @Override public String saveTailInXml() { return "</Modeling>\n\n\n"; } + @Override public String toString() { return mgui.getTitleAt(this) + " (TML Functional View)"; } - public ArrayList<String> getAllTMLTaskNames(String _name) { + public List<String> getAllTMLTaskNames(String _name) { return tmltdp.getAllTMLTaskNames(_name); } - public ArrayList<String> getAllTMLCommunicationNames(String _name) { + public List<String> getAllTMLCommunicationNames(String _name) { return tmltdp.getAllTMLCommunicationNames(_name); } - public ArrayList<String> getAllTMLEventNames( String _name ) { + public List<String> getAllTMLEventNames( String _name ) { return tmltdp.getAllTMLEventNames( _name ); } - public java.util.List<String> getAllNonMappedTMLTaskNames(String _name, TMLArchiDiagramPanel _tadp, boolean ref, String name) { + public List<String> getAllNonMappedTMLTaskNames(String _name, TMLArchiDiagramPanel _tadp, boolean ref, String name) { return tmltdp.getAllNonMappedTMLTaskNames(_name, _tadp, ref, name); } diff --git a/src/main/java/ui/ZoomUtil.java b/src/main/java/ui/ZoomUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..1644d60c293e196f4516a595672f01944168ff54 --- /dev/null +++ b/src/main/java/ui/ZoomUtil.java @@ -0,0 +1,135 @@ +/* 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; + +/** + * Class ZoomGraphics + * Working with zooms on graphics + * Creation: 19/11/2004 + * @version 1.0 19/11/2004 + * @author Ludovic APVRILLE + */ +public class ZoomUtil { +// private Graphics g; +// private double zoom; + + private ZoomUtil(/*Graphics _g, double _zoom*/) { +// g = _g; +// zoom = _zoom; + } +// +// public Graphics getGraphics() { +// return g; +// } +// +// public void drawRoundRect(int x, int y, int w, int h, int arc1, int arc2) { +// g.drawRoundRect((int)(x*zoom), (int)(y*zoom), (int)(w*zoom), (int)(h*zoom), arc1, arc2); +// } +// +// public void drawLine(int x1, int y1, int x2, int y2) { +// g.drawLine((int)(x1*zoom), (int)(y1*zoom), (int)(x2*zoom), (int)(y2*zoom)); +// } +// +// public void drawString(String value, int x, int y) { +// g.drawString(value, (int)(x*zoom) , (int)(y*zoom)); +// } + +// public static void rescale( final TGComponent component, +// final double scaleFactor ) { +// //rescaled = true; +// +// //final double factor = scaleFactor / oldScaleFactor; +// +// component.dwidth = (component.getWidth() + component.dwidth) * scaleFactor;// oldScaleFactor * scaleFactor; +// component.dheight = (component.getHeight() + component.dheight) * scaleFactor;// oldScaleFactor * scaleFactor; +// component.dx = (component.dx + component.getX()) * scaleFactor;// oldScaleFactor * scaleFactor; +// component.dy = (component.dy + component.getY()) * scaleFactor;// oldScaleFactor * scaleFactor; +// component.dMinWidth = (component.getMinWidth() + component.dMinWidth) * scaleFactor;// oldScaleFactor * scaleFactor; +// component.dMinHeight = (component.getMinHeight() + component.dMinHeight) * scaleFactor;// oldScaleFactor * scaleFactor; +// component.dMaxWidth = (component.getMaxWidth() + component.dMaxWidth) * scaleFactor;// oldScaleFactor * scaleFactor; +// component.dMaxHeight = (component.getMaxHeight() + component.dMaxHeight) * scaleFactor;// oldScaleFactor * scaleFactor; +// +// component.width = (int)(component.dwidth); +// component.dwidth = component.dwidth - component.getWidth(); +// component.height = (int)(component.dheight); +// component.dheight = component.dheight - component.getHeight(); +// component.minWidth = (int)(component.dMinWidth); +// component.minHeight = (int)(component.dMinHeight); +// component.maxWidth = (int)(component.dMaxWidth); +// component.maxHeight = (int)(component.dMaxHeight); +// +// component.dMinWidth = component.dMinWidth - component.getMinWidth(); +// component.dMinHeight = component.dMinHeight - component.getMinHeight(); +// component.dMaxWidth = component.dMaxWidth - component.getMaxWidth(); +// component.dMaxHeight = component.dMaxHeight - component.getMaxHeight(); +// component.x = (int)(component.dx); +// component.dx = component.dx - component.getX(); +// component.y = (int)(component.dy); +// component.dy = component.dy - component.getY(); +// +// +// //oldScaleFactor = scaleFactor; +// +// if ( component.getFather() != null) { +// +// // Issue #81: We also need to update max coordinate values +// component.maxX *= scaleFactor; +// component.maxY *= scaleFactor; +// +// // Must rescale my zone... +// component.resizeWithFather(); +// } +// else { +// component.minX = (int)(tdp.getMinX()/tdp.getZoom()); +// component.maxX = (int)(tdp.getMaxX()/tdp.getZoom()); +// component.minY = (int)(tdp.getMinY()/tdp.getZoom()); +// component.maxY = (int)(tdp.getMaxY()/tdp.getZoom()); +// +// } +// +// component.setMoveCd(component.x, component.y, true); +// +// for( final TGComponent subCompo : component.tgcomponent ) { +// if ( subCompo instanceof ScalableTGComponent ) { +// ( (ScalableTGComponent) subCompo ).rescale( scaleFactor ); +// } +// } +// } +} + diff --git a/src/main/java/ui/ad/TADActionState.java b/src/main/java/ui/ad/TADActionState.java index a99752dca2228217c788dc40d6377af4674ec437..02865b0516a49868e281ff437c4f88ba5f1d711a 100755 --- a/src/main/java/ui/ad/TADActionState.java +++ b/src/main/java/ui/ad/TADActionState.java @@ -53,10 +53,12 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ implements PreJavaCode, PostJavaCode, CheckableAccessibility, ActionStateErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; + //protected int lineLength = 5; + + // Issue #31 +// protected int textX = 5; +// protected int textY = 15; + //protected int arc = 5; protected int stateAction = 0; // 0: unchecked 1: attribute; 2: gate; 3:unknown @@ -64,11 +66,17 @@ public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ public TADActionState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - + // Issue #31 + // Must be created before the dimensions are scaled for zoom createConnectingPoints(); +// width = 30; +// height = 20; + + initScaling( 30, 20 ); + + minWidth = scale( 30 ); + textX = scale( 5 ); + // nbConnectingPoint = 2; // connectingPoint = new TGConnectingPoint[2]; // connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); @@ -95,15 +103,16 @@ public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } - + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateAction > 0) { Color c = g.getColor(); diff --git a/src/main/java/ui/ad/TADChoice.java b/src/main/java/ui/ad/TADChoice.java index c5f064e56c76fa117e92df28e78b229762ddd867..a0d289be4ea47c8da36c34cdad0a96eb5e6b6e11 100755 --- a/src/main/java/ui/ad/TADChoice.java +++ b/src/main/java/ui/ad/TADChoice.java @@ -62,40 +62,38 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit private static final String TRUE_GUARD_TEXT = "[ true ]"; - protected int lineLength = 10; + //protected int lineLength = 10; - protected int lineOutLength = 25; + protected static final int OUT_LINE_LENGTH = 25; + protected static final int MARGIN = 5; - private int textX1, textY1, textX2, textY2, textX3, textY3; +// Issue # 31 private int textX1, textY1, textX2, textY2, textX3, textY3; + //private double dtextX1, dtextY1, dtextX2, dtextY2, dtextX3, dtextY3; protected int stateOfError = 0; public TADChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 30; - textX1 = -lineOutLength; - textY1 = height/2 - 5; - textX2 = width + 5; - textY2 = height/2 - 5; - textX3 = width /2 + 5; - textY3 = height + 15; - + // Issue #31 createConnectingPoints(); -// nbConnectingPoint = 4; -// connectingPoint = new TGConnectingPoint[nbConnectingPoint]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); -// connectingPoint[2] = new TGConnectingPointAD(this, lineOutLength, 0, false, true, 1.0, 0.5); -// connectingPoint[3] = new TGConnectingPointAD(this, 0, lineOutLength, false, true, 0.5, 1.0); -// addTGConnectingPointsComment(); + +// width = 30; +// height = 30; + initScaling( 30, 30 ); nbInternalTGComponent = 3; tgcomponent = new TGComponent[nbInternalTGComponent]; - createGuards(); +// dtextX1 = -lineOutLength; +// final int margin = scale( 5 ); +// dtextY1 = height/2 - margin; +// dtextX2 = width + margin; +// dtextY2 = height/2 - margin; +// dtextX3 = width /2 + margin; +// dtextY3 = height + scale( 15 ); + // TGCOneLineText tgc = new TGCOneLineText(x+textX1-50, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); // tgc.setValue("[ ]"); // tgc.setName("guard 1"); @@ -124,31 +122,42 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit nbConnectingPoint = 4; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[2] = new TGConnectingPointAD(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[3] = new TGConnectingPointAD(this, 0, lineOutLength, false, true, 0.5, 1.0); + connectingPoint[1] = new TGConnectingPointAD(this, -OUT_LINE_LENGTH, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new TGConnectingPointAD(this, OUT_LINE_LENGTH, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new TGConnectingPointAD(this, 0, OUT_LINE_LENGTH, false, true, 0.5, 1.0); addTGConnectingPointsComment(); } protected void createGuards() { - TGCOneLineText tgc = new TGCOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, tdp); + + // Issue #31 + final int textX1 = - scale( OUT_LINE_LENGTH ); + final int scaledMargin = scale( MARGIN ); + final int textY1 = height / 2 - scaledMargin; + TGCOneLineText tgc = new TGCOneLineText( x + textX1, y + textY1, textX1-50, textX1 + 5 , textY1, textY1 + 25, true, this, tdp ); tgc.setValue( EMPTY_GUARD_TEXT ); tgc.setName("guard 1"); tgcomponent[ 0 ] = tgc; - tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, tdp); + // Issue #31 + final int textX2 = width + scaledMargin; + final int textY2 = height / 2 - scaledMargin; + tgc = new TGCOneLineText( x + textX2, y + textY2, textX2, textX2 + 20, textY2, textY2 + 25, true, this, tdp); tgc.setValue( EMPTY_GUARD_TEXT ); tgc.setName("guard 2"); tgcomponent[ 1 ] = tgc; - tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, tdp); + // Issue #31 + final int textX3 = width / 2 + scaledMargin; + final int textY3 = height + scale( 15 ); + tgc = new TGCOneLineText( x + textX3, y + textY3, textX3, textX3 + 20, textY3, textY3 + 25, true, this, tdp ); tgc.setValue( EMPTY_GUARD_TEXT ); tgc.setName("guard 3"); tgcomponent[ 2 ] = tgc; } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { @@ -170,6 +179,9 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit g.drawLine(x + width/2, y, x, y + height/2); g.drawLine(x + width, y + height/2, x + width/2, y + height); + // Issue #31 + final int lineOutLength = scale( OUT_LINE_LENGTH ); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); @@ -182,6 +194,9 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit return this; } + // Issue #31 + final int lineOutLength = scale( OUT_LINE_LENGTH ); + // horizontal line if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { return this; diff --git a/src/main/java/ui/ad/TADComponentWithSubcomponents.java b/src/main/java/ui/ad/TADComponentWithSubcomponents.java index d667814cfd000f8d2bed1cd8582708623d84acb2..86fa2c2d42382101a9ad2a5d35dd0a7e299bf468 100644 --- a/src/main/java/ui/ad/TADComponentWithSubcomponents.java +++ b/src/main/java/ui/ad/TADComponentWithSubcomponents.java @@ -8,8 +8,8 @@ import ui.TGComponent; * Issue #69 * @author dblouin * - */ -public abstract class TADComponentWithSubcomponents extends TGCScalableWithInternalComponent /*TGCWithInternalComponent*/ { + */ +public abstract class TADComponentWithSubcomponents extends TGCScalableWithInternalComponent { public TADComponentWithSubcomponents(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { diff --git a/src/main/java/ui/ad/TADComponentWithoutSubcomponents.java b/src/main/java/ui/ad/TADComponentWithoutSubcomponents.java index f55ad3d18afee4f458df30dce738185b1dd9ea22..29aaac24b92ad2b6bd8867ac6419ab9bf7bd3d6a 100644 --- a/src/main/java/ui/ad/TADComponentWithoutSubcomponents.java +++ b/src/main/java/ui/ad/TADComponentWithoutSubcomponents.java @@ -1,7 +1,7 @@ package ui.ad; import ui.TDiagramPanel; -import ui.TGCWithoutInternalComponent; +import ui.TGCScalableWithoutInternalComponent; import ui.TGComponent; /** @@ -9,7 +9,7 @@ import ui.TGComponent; * @author dblouin * */ -public abstract class TADComponentWithoutSubcomponents extends TGCWithoutInternalComponent { +public abstract class TADComponentWithoutSubcomponents extends TGCScalableWithoutInternalComponent /* Issue #31 TGCWithoutInternalComponent*/ { public TADComponentWithoutSubcomponents(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { diff --git a/src/main/java/ui/ad/TADExec.java b/src/main/java/ui/ad/TADExec.java new file mode 100755 index 0000000000000000000000000000000000000000..37701331c3f3c921c4d0402af9c8f49e85b6903f --- /dev/null +++ b/src/main/java/ui/ad/TADExec.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.ad; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.geom.Line2D; + +import myutil.GraphicLib; +import ui.AllowedBreakpoint; +import ui.BasicErrorHighlight; +import ui.CDElement; +import ui.ColorManager; +import ui.EmbeddedComment; +import ui.ErrorHighlight; +import ui.TDiagramPanel; +import ui.TGCOneLineText; +import ui.TGComponent; +import ui.TGConnectingPoint; +import ui.TGScalableComponent; +import ui.util.IconManager; + +/** + * @author dblouin + * + */ +public abstract class TADExec extends TADComponentWithSubcomponents implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + + // private int ilength;// = 10; + // private int lineLength1;// = 2; + + protected int stateOfError = 0; // Not yet checked + + public TADExec( int _x, + int _y, + int _minX, + int _maxX, + int _minY, + int _maxY, + boolean _pos, + TGComponent _father, + TDiagramPanel _tdp, + final String value, + final String name ) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = createConnectingPoint(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = createConnectingPoint(this, 0, + lineLength, false, true, 0.5, 1.0); + + initScaling( 10, 30 ); +// ilength = 10; +// lineLength1 = 2; + textX = width + scale( 5 ); + textY = height/2 + scale( 5 ); + + nbInternalTGComponent = 1; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGScalableComponent tgc = createInternalComponent(); + tgc.setValue( value ); + tgc.setName( name ); + tgcomponent[0] = tgc; + + moveable = true; + editable = false; + removable = true; + + myImageIcon = IconManager.imgic214; + } + + protected TGScalableComponent createInternalComponent() { + return new TGCOneLineText( x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, tdp ); + } + + protected abstract TGConnectingPointAD createConnectingPoint( final CDElement _container, + final int _x, + final int _y, + final boolean _in, + final boolean _out, + final double _w, + final double _h ); + + @Override + protected void internalDrawing(Graphics g) { + if (stateOfError > 0) { + Color c = g.getColor(); + switch(stateOfError) { + case ErrorHighlight.OK: + g.setColor(ColorManager.EXEC); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + + g.fillRect(x, y, width, height); + g.setColor(c); + } + + g.drawRect(x, y, width, height); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + + drawInternalSymbol( g, scale( 2 ), scale( 10 ) ); + } + + protected abstract void drawInternalSymbol( Graphics g, + int symbolWidth, + int symbolHeight ); + + @Override + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { + return this; + } + + return null; + } + + public String getDelayValue() { + return tgcomponent[0].getValue(); + } + + public void setDelayValue(String value) { + tgcomponent[0].setValue(value); + } + + @Override + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } +} diff --git a/src/main/java/ui/ad/TADForLoop.java b/src/main/java/ui/ad/TADForLoop.java index e0dafe7cf0687fe9208e601e76b7b056ad3133e2..3732eab9049559068223b6f5b87597db3cf17b12 100644 --- a/src/main/java/ui/ad/TADForLoop.java +++ b/src/main/java/ui/ad/TADForLoop.java @@ -25,10 +25,12 @@ public abstract class TADForLoop extends TADComponentWithoutSubcomponents implem protected static final int INDEX_INSIDE_LOOP = 1; protected static final int INDEX_EXIT_LOOP = 2; - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; + //protected int lineLength = 5; + + // Issue #31 +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; protected int stateOfError = 0; @@ -43,9 +45,13 @@ public abstract class TADForLoop extends TADComponentWithoutSubcomponents implem TDiagramPanel _tdp ) { super( _x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp ); - width = 30; - height = 20; - minWidth = 30; + // Issue #31 + createConnectingPoints(); +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = scale( 30 ); + textX = scale( 5 ); moveable = true; editable = true; @@ -54,6 +60,8 @@ public abstract class TADForLoop extends TADComponentWithoutSubcomponents implem myImageIcon = IconManager.imgic912; } + protected abstract void createConnectingPoints(); + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { diff --git a/src/main/java/ui/ad/TADOneLineText.java b/src/main/java/ui/ad/TADOneLineText.java index db8fc5c86fbd056e708cf369b98de3eaf9908409..d1b4225ef368c4a231ed870ae95499bdf57ffa53 100644 --- a/src/main/java/ui/ad/TADOneLineText.java +++ b/src/main/java/ui/ad/TADOneLineText.java @@ -4,7 +4,7 @@ import ui.TDiagramPanel; import ui.TGCOneLineText; import ui.TGComponent; -public abstract class TADOneLineText extends TGCOneLineText { +public abstract class TADOneLineText extends TGCOneLineText /* Issue #31 implements ScalableTGComponent*/ { public TADOneLineText(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { diff --git a/src/main/java/ui/ad/TADSequence.java b/src/main/java/ui/ad/TADSequence.java index ffc07b425e5c9d41fc4adcaf62b41399b014fbd6..9d3d453697be6dd96fc335a7b66e88d08b29ba64 100755 --- a/src/main/java/ui/ad/TADSequence.java +++ b/src/main/java/ui/ad/TADSequence.java @@ -56,30 +56,24 @@ import ui.util.IconManager; */ public class TADSequence extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ { - protected int lineLength = 0; + // Issue #31 + //protected int lineLength = 0; - private int textX, textY; + //private int textX, textY; public TADSequence(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); + lineLength = 0; - width = 150; - height = 5; - - textX = width - 6; - textY = height + 2; - + // Issue #31 createConnectingPoints(); -// nbConnectingPoint = 6; -// connectingPoint = new TGConnectingPoint[6]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.167, 1.0); -// connectingPoint[2] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.333, 1.0); -// connectingPoint[3] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); -// connectingPoint[4] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.667, 1.0); -// connectingPoint[5] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.833, 1.0); -// addTGConnectingPointsCommentCorner(); +// width = 150; +// height = 5; + initScaling( 150, 5 ); + + textX = width - scale( 6 ); + textY = height + scale( 2 ); nbInternalTGComponent = 1; tgcomponent = new TGComponent[nbInternalTGComponent]; @@ -113,7 +107,7 @@ public class TADSequence extends TADComponentWithSubcomponents /* Issue #69 TGCW } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } diff --git a/src/main/java/ui/ad/TADStartState.java b/src/main/java/ui/ad/TADStartState.java index b4d21f778eae2d336594cca6ffb956005f9f68dc..230888b85d1b5bbbfcb994f37cfa5030936636b7 100755 --- a/src/main/java/ui/ad/TADStartState.java +++ b/src/main/java/ui/ad/TADStartState.java @@ -54,18 +54,16 @@ import java.awt.geom.Line2D; */ public class TADStartState extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ { - protected int lineLength = 5; + //protected int lineLength = 5; public TADStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 15; - height = 15; - + // Issue #3& createConnectingPoints(); -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); +// width = 15; +// height = 15; + initScaling( 15, 15 ); nbInternalTGComponent = 0; @@ -85,9 +83,11 @@ public class TADStartState extends TADComponentWithoutSubcomponents/* Issue #69 } @Override - public void internalDrawing(Graphics g) { - g.fillOval(x, y, width, height); - g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + protected void internalDrawing(Graphics g) { + final int radius = width / 2; + + g.fillOval(x, y, radius * 2, radius * 2 );//width, height); + g.drawLine(x+(width/2), y+height, x+(width/2), (int) (y + lineLength /** oldScaleFactor*/ + height)); } @Override diff --git a/src/main/java/ui/ad/TADStopState.java b/src/main/java/ui/ad/TADStopState.java index 04dc7556e0493784bdcc0b6d14dcaa5137e9c0e0..75a07f87953f94aaba0268b82ab16141579b5fb4 100755 --- a/src/main/java/ui/ad/TADStopState.java +++ b/src/main/java/ui/ad/TADStopState.java @@ -53,20 +53,19 @@ import java.awt.*; */ public class TADStopState extends TADComponentWithoutSubcomponents /* Issue #69 TGCWithoutInternalComponent*/ { - private int internalCircleSize = 16; + //private int internalCircleSize = 16; + private static final double INTERNAL_CIRCLE_RATIO = 0.8; - protected int lineLength = 5; + //protected int lineLength = 5; public TADStopState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 20; - height = 20; - + // Issue #31 createConnectingPoints(); -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, - lineLength, true, false, 0.5, 0.0); +// width = 20; +// height = 20; + initScaling( 20, 20 ); nbInternalTGComponent = 0; @@ -86,11 +85,14 @@ public class TADStopState extends TADComponentWithoutSubcomponents /* Issue #69 } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { // Issue #69 ColorManager.setColor( g, state, 0, isEnabled() ); // ColorManager.setColor(g, state, 0); + + // Issue #3& + final int internalCircleSize = (int) ( width * INTERNAL_CIRCLE_RATIO ); g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); g.drawOval(x, y, width, height); g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); diff --git a/src/main/java/ui/ad/TActivityDiagramToolBar.java b/src/main/java/ui/ad/TActivityDiagramToolBar.java index 02d83a32ba40d2454e58008d3b61263b3b47672a..a0c18d30b0db284cc9d82cb066d6a5253f71c045 100755 --- a/src/main/java/ui/ad/TActivityDiagramToolBar.java +++ b/src/main/java/ui/ad/TActivityDiagramToolBar.java @@ -81,9 +81,13 @@ public class TActivityDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_TOGGLE_JAVA].setEnabled(b); mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); diff --git a/src/main/java/ui/ad/TGConnectingPointAD.java b/src/main/java/ui/ad/TGConnectingPointAD.java index df8f136712d9297ab99e3631732a41eb7cc37cab..0bddd4233fde800589332094623489e495c3b6c2 100755 --- a/src/main/java/ui/ad/TGConnectingPointAD.java +++ b/src/main/java/ui/ad/TGConnectingPointAD.java @@ -49,7 +49,7 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TGConnectingPointAD extends TGConnectingPointWidthHeight{ +public class TGConnectingPointAD extends TGConnectingPointWidthHeight { public TGConnectingPointAD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); diff --git a/src/main/java/ui/atd/ATDAttackConnectingPoint.java b/src/main/java/ui/atd/ATDAttackConnectingPoint.java index 2e9c3504e0572bb5db1c1dd1ce7c753370c036db..95fe79eab3402562fa29834657e5886d55dd9fe5 100644 --- a/src/main/java/ui/atd/ATDAttackConnectingPoint.java +++ b/src/main/java/ui/atd/ATDAttackConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.atd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class ATDAttackConnectingPoint extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.ATD_ATTACK_CONNECTOR; } - } diff --git a/src/main/java/ui/atd/ATDAttackConnector.java b/src/main/java/ui/atd/ATDAttackConnector.java index 1fc5ac368b46d88f5ac2400cf5d31a1fbcdce4e1..9c86f7a166887600203e075e9a828af423343c44 100644 --- a/src/main/java/ui/atd/ATDAttackConnector.java +++ b/src/main/java/ui/atd/ATDAttackConnector.java @@ -55,19 +55,20 @@ import java.util.Vector; * @version 1.0 09/12/2009 * @author Ludovic APVRILLE */ -public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 5; //square length - protected double oldScaleFactor; + //protected double oldScaleFactor; protected int fontSize = 12; public ATDAttackConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; value = ""; editable = true; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); } @Override @@ -184,27 +185,27 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints i return TGComponentManager.ATD_ATTACK_CONNECTOR; } - @Override - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } +// @Override Issue #31 Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } } diff --git a/src/main/java/ui/atd/ATDBlock.java b/src/main/java/ui/atd/ATDBlock.java index 5f0365b3a7f9d7233bc12eb9721d2e0e6e189014..c499fa6cd09664ed79ca524fb92a123f7f1cfeef 100644 --- a/src/main/java/ui/atd/ATDBlock.java +++ b/src/main/java/ui/atd/ATDBlock.java @@ -58,7 +58,7 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public class ATDBlock extends TGCScalableWithInternalComponent implements SwallowTGComponent { - private int textY1 = 3; +// private int textY1 = 3; private String stereotype = "block"; private int maxFontSize = 12; @@ -75,6 +75,9 @@ public class ATDBlock extends TGCScalableWithInternalComponent implements Swallo height = 200; minWidth = 5; minHeight = 2; + //Issue #31 + textY = 3; + initScaling(250, 200); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -121,7 +124,7 @@ public class ATDBlock extends TGCScalableWithInternalComponent implements Swallo Font fold = f; // - + currentFontSize = f.getSize(); if ((rescaled) && (!tdp.isScaled())) { if (currentFontSize == -1) { @@ -139,18 +142,18 @@ public class ATDBlock extends TGCScalableWithInternalComponent implements Swallo f = f.deriveFont((float)maxCurrentFontSize); g.setFont(f); // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (2*textX))) { - break; - } - maxCurrentFontSize --; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - } - currentFontSize = maxCurrentFontSize; +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (2*textX))) { +// break; +// } +// maxCurrentFontSize --; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// } +// currentFontSize = maxCurrentFontSize; if(currentFontSize <minFontSize) { displayText = false; @@ -163,7 +166,7 @@ public class ATDBlock extends TGCScalableWithInternalComponent implements Swallo } // - + currentFontSize = f.getSize(); Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); @@ -179,15 +182,15 @@ public class ATDBlock extends TGCScalableWithInternalComponent implements Swallo g.setFont(f.deriveFont(Font.BOLD)); w = g.getFontMetrics().stringWidth(ster); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); + int h = currentFontSize + textY; if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y +h); + drawSingleString(g,ster, x + (width - w)/2, y +h); } g.setFont(f0); w = g.getFontMetrics().stringWidth(value); - h = 2* (currentFontSize + (int)(textY1 * tdp.getZoom())); + h = 2* (currentFontSize + textY); if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); + drawSingleString(g,value, x + (width - w)/2, y + h); } } diff --git a/src/main/java/ui/atd/ATDCompositionConnectingPoint.java b/src/main/java/ui/atd/ATDCompositionConnectingPoint.java index 5e98ec6c2f3c72aa1fbe31cd559394ff48f4ce8f..370ac66423aef3d0c9deb262ce323f58ec6ab16c 100644 --- a/src/main/java/ui/atd/ATDCompositionConnectingPoint.java +++ b/src/main/java/ui/atd/ATDCompositionConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.atd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class ATDCompositionConnectingPoint extends TGConnectingPointWidthHeight super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.ATD_COMPOSITION_CONNECTOR; } - } diff --git a/src/main/java/ui/atd/ATDCompositionConnector.java b/src/main/java/ui/atd/ATDCompositionConnector.java index 52ee0ddb63974d72bb3740fd9898932473107cec..5ab0eb4aef91dfc92976e6658a83e16ea4b59862 100644 --- a/src/main/java/ui/atd/ATDCompositionConnector.java +++ b/src/main/java/ui/atd/ATDCompositionConnector.java @@ -51,22 +51,22 @@ import java.util.Vector; * @version 1.0 09/12/2009 * @author Ludovic APVRILLE */ -public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent{ +public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { protected int d = 20; protected int D = 26; //protected int widthValue, heightValue, maxWidthValue, h; protected Polygon p; protected int xp1, xp2, yp1, yp2; - protected double oldScaleFactor; - protected boolean rescaled; +// protected double oldScaleFactor; +// protected boolean rescaled; public ATDCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; value = "{info}"; editable = true; - oldScaleFactor = tdp.getZoom(); - rescaled = true; +// oldScaleFactor = tdp.getZoom(); +// rescaled = true; } @Override @@ -176,30 +176,30 @@ public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPo return null; } - @Override - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - rescaled = true; - } +// @Override Issue #31 Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// rescaled = true; +// } @Override public int getType() { diff --git a/src/main/java/ui/atd/ATDCountermeasureConnectingPoint.java b/src/main/java/ui/atd/ATDCountermeasureConnectingPoint.java index f1711a3de954f5fdc40200a8bd48740590515950..28bff74674b4f6f55adbd6f9fd2a124e66fbfcf1 100644 --- a/src/main/java/ui/atd/ATDCountermeasureConnectingPoint.java +++ b/src/main/java/ui/atd/ATDCountermeasureConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.atd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class ATDCountermeasureConnectingPoint extends TGConnectingPointWidthHei super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.ATD_COUNTERMEASURE_CONNECTOR; } - } diff --git a/src/main/java/ui/atd/ATDCountermeasureConnector.java b/src/main/java/ui/atd/ATDCountermeasureConnector.java index 12ae85f63395f8d2b9776a038cd430de3bbbc4c9..2e92e24118feb84d1a7e0c53d79d875cdc679d80 100644 --- a/src/main/java/ui/atd/ATDCountermeasureConnector.java +++ b/src/main/java/ui/atd/ATDCountermeasureConnector.java @@ -43,7 +43,6 @@ import java.awt.Point; import java.util.Vector; import myutil.GraphicLib; -import ui.ScalableTGComponent; import ui.TDiagramPanel; import ui.TGComponent; import ui.TGComponentManager; @@ -58,19 +57,19 @@ import ui.util.IconManager; * @version 1.0 06/06/2017 * @author Ludovic APVRILLE */ -public class ATDCountermeasureConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class ATDCountermeasureConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 5; //square length - protected double oldScaleFactor; +// protected double oldScaleFactor; protected int fontSize = 12; public ATDCountermeasureConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; value = ""; - editable = true; - oldScaleFactor = tdp.getZoom(); +// editable = true; +// oldScaleFactor = tdp.getZoom(); } @Override @@ -89,27 +88,27 @@ public class ATDCountermeasureConnector extends TGConnectorWithCommentConnectio return TGComponentManager.ATD_COUNTERMEASURE_CONNECTOR; } - @Override - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } +// @Override Issue #31 Managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } } diff --git a/src/main/java/ui/atd/AttackTreeDiagramToolbar.java b/src/main/java/ui/atd/AttackTreeDiagramToolbar.java index 264a7b9146c9b48aa6754dd4ce066ae2a9b6aa09..8c9fec9a90ba85f2459b6d51c1cc553069d529a5 100644 --- a/src/main/java/ui/atd/AttackTreeDiagramToolbar.java +++ b/src/main/java/ui/atd/AttackTreeDiagramToolbar.java @@ -61,7 +61,6 @@ public class AttackTreeDiagramToolbar extends TToolBar { public AttackTreeDiagramToolbar(MainGUI _mgui) { super(_mgui); - } protected void setActive(boolean b) { diff --git a/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java b/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java index 58d1ca96757ee600439bd0e82716d113d6c66bf3..7343f544f07846eef6079689e9dd24c567a1a4b7 100755 --- a/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java +++ b/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java @@ -55,10 +55,10 @@ import java.awt.geom.Line2D; */ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledComponent/* Issue #69 AvatarADBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; - protected int textX = 6; - protected int textY = 15; +// protected int textX = 6; +// protected int textY = 15; protected int linebreak = 10; - protected int textX1 = 2; +// protected int textX1 = 2; protected int stateOfError = 0; // Not yet checked @@ -66,7 +66,10 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon public AvatarADAcceptEventAction(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); + textY = 15; + textX = 6; initScaling(30, 20); + minWidth = (int)(30* tdp.getZoom()); oldScaleFactor = tdp.getZoom(); @@ -135,8 +138,8 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon g.drawLine(x, y, x+linebreak, y+height/2); g.drawLine(x, y+height, x+linebreak, y+height/2); - //g.drawString("evt", x+(width-w) / 2, y); - g.drawString(value, x + linebreak + textX1, y + (int)((textY*tdp.getZoom()))); + //drawSingleString(g, "evt", x+(width-w) / 2, y); + drawSingleString(g, value, x + scale(linebreak) , y + textY); } diff --git a/src/main/java/ui/avatarad/AvatarADAction.java b/src/main/java/ui/avatarad/AvatarADAction.java index 3d0e619b91a3c5eb614519cad869b7870684915a..5287641e574d9a9e20f7604c1e727ab521ed5844 100755 --- a/src/main/java/ui/avatarad/AvatarADAction.java +++ b/src/main/java/ui/avatarad/AvatarADAction.java @@ -55,8 +55,8 @@ import java.awt.geom.Line2D; */ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue #69 AvatarADBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int stateOfError = 0; // Not yet checked @@ -66,7 +66,10 @@ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue public AvatarADAction(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); + textX = 5; + textY = 15; initScaling(30, 20); + minWidth = (int)(30* tdp.getZoom()); oldScaleFactor = tdp.getZoom(); @@ -84,7 +87,7 @@ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue myImageIcon = IconManager.imgic204; } - + @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); @@ -112,7 +115,7 @@ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawString(value, x + (width - w) / 2 , y + (int)((textY*tdp.getZoom()))); + drawSingleString(g, value, x + (width - w) / 2 , y + textY); } diff --git a/src/main/java/ui/avatarad/AvatarADActivity.java b/src/main/java/ui/avatarad/AvatarADActivity.java index 1ce5f672c63b03884e3a807fccb5bac8f7c146c7..12ac1a3679b97665c30ea2a2ab5dcbaf1099619e 100644 --- a/src/main/java/ui/avatarad/AvatarADActivity.java +++ b/src/main/java/ui/avatarad/AvatarADActivity.java @@ -62,14 +62,15 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement //private int maxFontSize = 12; // private int minFontSize = 4; //private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 7; +// private boolean displayText = true; +// private int textX = 7; public String oldValue; public AvatarADActivity(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); - + + textX = 7; initScaling(100, 50); minWidth = (int)(40* tdp.getZoom()); minHeight = (int)(30* tdp.getZoom()); @@ -204,7 +205,7 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement g.drawLine(x, y+decY, x+decY, y+decY); g.drawLine(x+decY, y+decY, x+decX, y+decY-5); g.drawLine(x+decX, y+decY-5, x+decX, y); - g.drawString("act", x+1, y+decY-2); + drawSingleString(g, "act", x+1, y+decY-2); } //g.drawRoundRect(x, y, width, height, 5, 5); @@ -212,19 +213,19 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement // Strings int w; - if (displayText) { +// if (displayText) { //f = f.deriveFont((float)currentFontSize); //Font f0 = g.getFont(); //g.setFont(f.deriveFont(Font.BOLD)); - w = g.getFontMetrics().stringWidth(value); - h = g.getFontMetrics().getHeight(); - //h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y+h+1); - } - //g.setFont(f0); + w = g.getFontMetrics().stringWidth(value); + h = g.getFontMetrics().getHeight(); + //h = currentFontSize + (int)(textY1 * tdp.getZoom()); + if ((w < (2*textX + width)) && (h < height)) { + drawSingleString(g, value, x + (width - w)/2, y+h+1); } + //g.setFont(f0); +// } g.setFont(fold); } diff --git a/src/main/java/ui/avatarad/AvatarADChoice.java b/src/main/java/ui/avatarad/AvatarADChoice.java index b261c689a536b2cd5b9a24190771f5bf4b004693..54779e93cad1de0cd1b8e17adfa4f9392dd8bbac 100755 --- a/src/main/java/ui/avatarad/AvatarADChoice.java +++ b/src/main/java/ui/avatarad/AvatarADChoice.java @@ -112,9 +112,9 @@ public class AvatarADChoice extends TADChoice /* Issue #69 TGCScalableWithIntern nbConnectingPoint = 4; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new AvatarADConnectingPoint(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new AvatarADConnectingPoint(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[2] = new AvatarADConnectingPoint(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[3] = new AvatarADConnectingPoint(this, 0, lineOutLength, false, true, 0.5, 1.0); + connectingPoint[1] = new AvatarADConnectingPoint(this, -OUT_LINE_LENGTH, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new AvatarADConnectingPoint(this, OUT_LINE_LENGTH, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new AvatarADConnectingPoint(this, 0, OUT_LINE_LENGTH, false, true, 0.5, 1.0); } // // @Override diff --git a/src/main/java/ui/avatarad/AvatarADPanel.java b/src/main/java/ui/avatarad/AvatarADPanel.java index 513db7cbdc5d3d52cc9577e3524653f5545679b3..b60b16f05cc215212890af4003a81d7a48d09f63 100644 --- a/src/main/java/ui/avatarad/AvatarADPanel.java +++ b/src/main/java/ui/avatarad/AvatarADPanel.java @@ -149,7 +149,7 @@ public class AvatarADPanel extends TDiagramPanel implements TDPWithAttributes{ AvatarADPartition ontheLeft = null;//, sdi; int x = getMaxX(),xtmp; int y; - int i; +// int i; TGComponent tgc; Iterator<TGComponent> iterator = componentList.listIterator(); diff --git a/src/main/java/ui/avatarad/AvatarADSendSignalAction.java b/src/main/java/ui/avatarad/AvatarADSendSignalAction.java index 6737d597a2207ce6c8863c927dc4931c319e1f41..38aae113c7af9be27619150c2628304a68350836 100755 --- a/src/main/java/ui/avatarad/AvatarADSendSignalAction.java +++ b/src/main/java/ui/avatarad/AvatarADSendSignalAction.java @@ -55,8 +55,8 @@ import java.awt.geom.Line2D; */ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponent/* Issue #69 AvatarADBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int linebreak = 10; @@ -64,7 +64,8 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen public AvatarADSendSignalAction(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); - + textX = 5; + textY = 15; initScaling(30, 20); minWidth = (int)(30* tdp.getZoom()); oldScaleFactor = tdp.getZoom(); @@ -139,8 +140,8 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen g.drawLine(x+width-linebreak, y, x+width, y+height/2); g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); - //g.drawString("sig", x+(width-w) / 2, y); - g.drawString(value, x + (width - w) / 2 , y + (int)((textY*tdp.getZoom()))); + //drawSingleString(g, "sig", x+(width-w) / 2, y); + drawSingleString(g, value, x + (width - w) / 2 , y + textY); } @Override diff --git a/src/main/java/ui/avatarad/AvatarADStartState.java b/src/main/java/ui/avatarad/AvatarADStartState.java index 4bbe93d0e61fbc5430960480516e552317f1404e..d3e326c0bfa0a5ed44ad746f9f608508b264da98 100755 --- a/src/main/java/ui/avatarad/AvatarADStartState.java +++ b/src/main/java/ui/avatarad/AvatarADStartState.java @@ -40,6 +40,7 @@ package ui.avatarad; import myutil.GraphicLib; import ui.*; +import ui.ad.TADStartState; import ui.util.IconManager; import java.awt.*; @@ -52,56 +53,63 @@ import java.awt.geom.Line2D; * @version 1.0 01/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADStartState extends AvatarADBasicComponent implements EmbeddedComment { - private int lineLength = 5; +//public class AvatarADStartState extends TADStartState /*AvatarADBasicComponent*/ implements EmbeddedComment { +public class AvatarADStartState extends TADStartState /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment{ + //Issue #31 +// private int lineLength = 5; public AvatarADStartState(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(15, 15); - oldScaleFactor = tdp.getZoom(); - +// initScaling(15, 15); +// oldScaleFactor = tdp.getZoom(); +// +// nbConnectingPoint = 1; +// connectingPoint = new TGConnectingPoint[1]; +// connectingPoint[0] = new AvatarADConnectingPoint(this, 0, lineLength, false, true, 0.5, 1.0); +// +// nbInternalTGComponent = 0; +// +// moveable = true; +// editable = false; +// removable = true; +// +// name = "start state"; +// +// myImageIcon = IconManager.imgic222; + } + @Override + protected void createConnectingPoints() { nbConnectingPoint = 1; connectingPoint = new TGConnectingPoint[1]; connectingPoint[0] = new AvatarADConnectingPoint(this, 0, lineLength, false, true, 0.5, 1.0); - - nbInternalTGComponent = 0; - - moveable = true; - editable = false; - removable = true; - - name = "start state"; - - myImageIcon = IconManager.imgic222; - } - - @Override - public void internalDrawing(Graphics g) { - g.fillOval(x, y, width, height); - g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - } - - @Override - public TGComponent isOnMe(int _x, int _y) { - if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { - return this; - } - - if ((int)(Line2D.ptSegDistSq(x+(width/2), y+height, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { - return this; - } - - return null; } +// @Override +// public void internalDrawing(Graphics g) { +// g.fillOval(x, y, width, height); +// g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); +// } +// +// @Override +// public TGComponent isOnMe(int _x, int _y) { +// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { +// return this; +// } +// +// if ((int)(Line2D.ptSegDistSq(x+(width/2), y+height, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { +// return this; +// } +// +// return null; +// } @Override public int getType() { return TGComponentManager.AAD_START_STATE; } -// -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } + + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; + } } diff --git a/src/main/java/ui/avatarad/AvatarADStopState.java b/src/main/java/ui/avatarad/AvatarADStopState.java index e3f1e919f418aef0ab767360d4ae4c034d8fe472..4ffe019472cc01b42159627bea90b43f1b009e15 100755 --- a/src/main/java/ui/avatarad/AvatarADStopState.java +++ b/src/main/java/ui/avatarad/AvatarADStopState.java @@ -38,11 +38,12 @@ package ui.avatarad; -import myutil.GraphicLib; +//import myutil.GraphicLib; import ui.*; -import ui.util.IconManager; +import ui.ad.TADStopState; +//import ui.util.IconManager; -import java.awt.*; +//import java.awt.*; /** * Class AvatarADStopState @@ -51,53 +52,59 @@ import java.awt.*; * @version 1.0 28/10/2005 * @author Ludovic APVRILLE */ -public class AvatarADStopState extends AvatarADBasicComponent implements EmbeddedComment, AllowedBreakpoint { - private int internalCircleSize = 16; - private int lineLength = 5; +public class AvatarADStopState extends TADStopState implements EmbeddedComment, AllowedBreakpoint { + // private int internalCircleSize = 16; +// private int lineLength = 5; public AvatarADStopState(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(20, 20); - oldScaleFactor = tdp.getZoom(); - - nbConnectingPoint = 1; - connectingPoint = new TGConnectingPoint[1]; - connectingPoint[0] = new AvatarADConnectingPoint(this, 0, - lineLength, true, false, 0.5, 0.0); - - nbInternalTGComponent = 0; - - moveable = true; - editable = false; - removable = true; - - name = "stop state"; - - myImageIcon = IconManager.imgic210; +// initScaling(20, 20); +// oldScaleFactor = tdp.getZoom(); +// +// nbConnectingPoint = 1; +// connectingPoint = new TGConnectingPoint[1]; +// connectingPoint[0] = new AvatarADConnectingPoint(this, 0, - lineLength, true, false, 0.5, 0.0); +// +// nbInternalTGComponent = 0; +// +// moveable = true; +// editable = false; +// removable = true; +// +// name = "stop state"; +// +// myImageIcon = IconManager.imgic210; } - + @Override - public void internalDrawing(Graphics g) { - ColorManager.setColor(g, state, 0); - g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); - g.drawOval(x, y, width, height); - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + protected void createConnectingPoints() { + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + connectingPoint[0] = new AvatarADConnectingPoint(this, 0, - lineLength, true, false, 0.5, 0.0); } +// @Override +// public void internalDrawing(Graphics g) { +// ColorManager.setColor(g, state, 0); +// g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); +// g.drawOval(x, y, width, height); +// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); +// } - @Override - public TGComponent isOnMe(int _x, int _y) { - if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { - return this; - } - return null; - } +// @OVERRIDE +// PUBLIC TGCOMPONENT ISONME(INT _X, INT _Y) { +// IF (GRAPHICLIB.ISINRECTANGLE(_X, _Y, X, Y, WIDTH, HEIGHT)) { +// RETURN THIS; +// } +// RETURN NULL; +// } @Override public int getType() { return TGComponentManager.AAD_STOP_STATE; } -// -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } + + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; + } } diff --git a/src/main/java/ui/avatarad/AvatarADToolBar.java b/src/main/java/ui/avatarad/AvatarADToolBar.java index b1ba6354ffc0924c3f5b0bee4f23f5e6a1ebe3c2..b75b010ef1f8a3899a603f155a41348e1f496379 100644 --- a/src/main/java/ui/avatarad/AvatarADToolBar.java +++ b/src/main/java/ui/avatarad/AvatarADToolBar.java @@ -59,7 +59,8 @@ public class AvatarADToolBar extends TToolBar { public AvatarADToolBar(MainGUI _mgui) { super(_mgui); } - + + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -86,7 +87,8 @@ public class AvatarADToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(!b); } - + + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/avatarbd/AvatarBDBlock.java b/src/main/java/ui/avatarbd/AvatarBDBlock.java index 0a706c62c3e74588e8c44d3bf71fcfeb5e6aaeea..700959217e52baeaa74ed2af7ee2e10f7d4db094 100644 --- a/src/main/java/ui/avatarbd/AvatarBDBlock.java +++ b/src/main/java/ui/avatarbd/AvatarBDBlock.java @@ -87,19 +87,19 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S private static String GLOBAL_CODE_INFO = "(block code)"; - private int textY1 = 3; - +// private int textY1 = 3; +// private int textX = 7; + private static String stereotype = "block"; - private static String stereotypeCrypto = "cryptoblock"; +// private static String stereotypeCrypto = "cryptoblock"; protected static List<String> BLOCK_TYPE_STR = new ArrayList<String>(Arrays.asList("block", "cryptoblock")); protected static List<Color> BLOCK_TYPE_COLOR = new ArrayList<Color>(Arrays.asList(ColorManager.AVATAR_BLOCK, ColorManager.AVATAR_BLOCK)); private int typeStereotype = 0; // <<block>> by default private int maxFontSize = 12; - private int minFontSize = 4; +// private int minFontSize = 4; private int currentFontSize = -1; - private int textX = 7; private int limitName = -1; private int limitAttr = -1; @@ -131,6 +131,10 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S height = 200; minWidth = 5; minHeight = 2; + textY = 3; + textX = 7; + initScaling(250,200); + nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -197,161 +201,78 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S public void addSignal(AvatarSignal sig) { this.mySignals.add(sig); } - - private void internalDrawingAux(Graphics graph) { - - //TraceManager.addDev("Block drawing aux = " + this); - - // Draw outer rectangle (for border) - Color c = graph.getColor(); + /** + * Issue #31: text disappearance + * @param graph + */ + private void internalDrawingAux(Graphics graph) + { + //Rectangle + Color c = graph.getColor(); graph.drawRect(this.x, this.y, this.width, this.height); - - // Draw inner rectangle - //graph.setColor(ColorManager.AVATAR_BLOCK); - - //TraceManager.addDev("type stereotype=" + typeStereotype); - graph.setColor(BLOCK_TYPE_COLOR.get(typeStereotype)); graph.fillRect(this.x + 1, this.y + 1, this.width - 1, this.height - 1); graph.setColor(c); + + //string + int h = graph.getFontMetrics().getAscent() + graph.getFontMetrics().getLeading() + textY; - // limits - this.limitName = -1; - this.limitAttr = -1; - this.limitMethod = -1; - this.limitSignal = y + height; - - // h retains the coordinate along X where an element was last drawn - int h = 0; - - int textY1 = (int) (this.textY1 * this.tdp.getZoom()); - int textX = (int) (this.textX * this.tdp.getZoom()); - - // Draw icon - this.iconIsDrawn = this.width > IconManager.iconSize + 2 * textX && height > IconManager.iconSize + 2 * textX; - if (this.iconIsDrawn) { - graph.drawImage(IconManager.img5100, this.x + this.width - IconManager.iconSize - textX, this.y + textX, null); - } + if (h + graph.getFontMetrics().getDescent() + textY >= this.height) + return; + Font f = graph.getFont(); + // limits +// this.limitName = -1; +// this.limitAttr = -1; +// this.limitMethod = -1; +// this.limitSignal = y + height; +// +// // h retains the coordinate along X where an element was last drawn +// int h = 0; +// +// int textY1 = (int) (this.textY1 * this.tdp.getZoom()); +// int textX = (int) (this.textX * this.tdp.getZoom()); +// +// // Draw icon +// this.iconIsDrawn = this.width > IconManager.iconSize + 2 * textX && height > IconManager.iconSize + 2 * textX; +// if (this.iconIsDrawn) { +// graph.drawImage(IconManager.img5100, this.x + this.width - IconManager.iconSize - textX, this.y + textX, null); +// } +// +// +// Font font = graph.getFont(); - Font font = graph.getFont(); String ster = BLOCK_TYPE_STR.get(typeStereotype); - - //TraceManager.addDev("My ster=" + ster); - - if (this.rescaled && !this.tdp.isScaled()) { - this.rescaled = false; - // Must set the font size... - // Incrementally find the biggest font not greater than max_font size - // If font is less than min_font, no text is displayed - - // This is the maximum font size possible - int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); - font = font.deriveFont((float) maxCurrentFontSize); - - // Try to decrease font size until we get below the minimum - while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { - // Compute width of name of the function - int w0 = graph.getFontMetrics(font).stringWidth(this.value); - // Compute width of string stereotype - int w1 = graph.getFontMetrics(font).stringWidth(ster); - - // if one of the two width is small enough use this font size - if (Math.min(w0, w1) < this.width - (2 * this.textX)) - break; - - // Decrease font size - maxCurrentFontSize--; - // Scale the font - font = font.deriveFont((float) maxCurrentFontSize); - } - - // Box is too damn small - if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { - maxCurrentFontSize++; - // Scale the font - font = font.deriveFont((float) maxCurrentFontSize); - } - - // Use this font - graph.setFont(font); - this.currentFontSize = maxCurrentFontSize; - } else - font = font.deriveFont(this.currentFontSize); - - graph.setFont(font.deriveFont(Font.BOLD)); - h = graph.getFontMetrics().getAscent() + graph.getFontMetrics().getLeading() + textY1; - - if (h + graph.getFontMetrics().getDescent() + textY1 >= this.height) - return; - - // Write stereotype if small enough int w = graph.getFontMetrics().stringWidth(ster); + h = graph.getFontMetrics().getAscent() + graph.getFontMetrics().getLeading() + textY; + graph.setFont(f.deriveFont(Font.BOLD)); if (w + 2 * textX < this.width) - graph.drawString(ster, this.x + (this.width - w) / 2, this.y + h); - else { - // try to draw with "..." instead - if (!this.isCryptoBlock()) - ster = stereotype; - else - ster = stereotypeCrypto; - - for (int stringLength = ster.length() - 1; stringLength >= 0; stringLength--) { - String abbrev = "<<" + ster.substring(0, stringLength) + "...>>"; - w = graph.getFontMetrics().stringWidth(abbrev); - if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); - break; - } - } - } - - // Write value if small enough - graph.setFont(font); - h += graph.getFontMetrics().getHeight() + textY1; - if (h + graph.getFontMetrics().getDescent() + textY1 >= this.height) - return; - - w = graph.getFontMetrics().stringWidth(this.value); + drawSingleString(graph, ster, getCenter(graph, ster), this.y + h); + h += graph.getFontMetrics().getHeight() + textY; + w = graph.getFontMetrics().stringWidth(value); + graph.setFont(f.deriveFont(Font.PLAIN)); if (w + 2 * textX < this.width) - graph.drawString(this.value, this.x + (this.width - w) / 2, this.y + h); - else { - // try to draw with "..." instead - for (int stringLength = this.value.length() - 1; stringLength >= 0; stringLength--) { - String abbrev = this.value.substring(0, stringLength) + "..."; - w = graph.getFontMetrics().stringWidth(abbrev); - if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); - break; - } - } - } - - h += graph.getFontMetrics().getDescent() + textY1; - - // Update lower bound of text + drawSingleString(graph, this.value, getCenter(graph, value), this.y + h); + + //draw separator this.limitName = this.y + h; - if (h + textY1 >= this.height) + if (h + textY >= this.height) return; - - // Draw separator + h += graph.getFontMetrics().getDescent() + textY; + if (canTextGoInTheBox(graph, h, "line", 0)); graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); - + h += textY; + + //Attributes if (!this.tdp.areAttributesVisible()) return; - - // Set font size - // int attributeFontSize = Math.min (12, this.currentFontSize - 2); - int attributeFontSize = this.currentFontSize * 5 / 6; - graph.setFont(font.deriveFont((float) attributeFontSize)); + int attributeFontSize = f.getSize() * 5 / 6; + graph.setFont(f.deriveFont((float) attributeFontSize)); int step = graph.getFontMetrics().getHeight(); - - h += textY1; - - // Attributes + h += textY; limitAttr = limitName; for (TAttribute attr : this.myAttributes) { h += step; @@ -362,47 +283,31 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S // Get the string for this parameter String attrString = attr.toAvatarString(); - - // Try to draw it w = graph.getFontMetrics().stringWidth(attrString); - attrLocMap.put(attr,this.y+h); if (w + 2 * textX < this.width) { - graph.drawString(attrString, this.x + textX, this.y + h); + //graph.drawString(attrString, this.x + textX, this.y + h); + drawSingleString(graph, attrString, this.x + textX, this.y + h); this.drawConfidentialityVerification(attr.getConfidentialityVerification(), graph, this.x, this.y + h); - } else { - // If we can't, try to draw with "..." instead - int stringLength; - for (stringLength = attrString.length() - 1; stringLength >= 0; stringLength--) { - String abbrev = attrString.substring(0, stringLength) + "..."; - w = graph.getFontMetrics().stringWidth(abbrev); - if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + textX, this.y + h); - this.drawConfidentialityVerification(attr.getConfidentialityVerification(), graph, this.x, this.y + h); - break; - } - } - - if (stringLength < 0) - // skip attribute - h -= step; } } - - h += graph.getFontMetrics().getDescent() + textY1; - + + //ICON + drawImageWithCheck(graph, IconManager.img5100, this.x + this.width - scale(IconManager.iconSize) - textX, this.y + textX); + + // Remember the end of attributes this.limitAttr = this.y + h; - - if (h + textY1 >= this.height) + if (h + textY >= this.height) return; graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); - h += textY1; + h += textY; // Methods limitMethod = limitAttr; limitSignal = limitAttr; + for (AvatarMethod method : this.myMethods) { h += step; if (h >= this.height - textX) { @@ -416,7 +321,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S w = graph.getFontMetrics().stringWidth(methodString); if (w + 2 * textX < this.width) - graph.drawString(methodString, this.x + textX, this.y + h); + drawSingleString(graph, methodString, this.x + textX, this.y + h); else { // If we can't, try to draw with "..." instead int stringLength; @@ -424,7 +329,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S String abbrev = methodString.substring(0, stringLength) + "..."; w = graph.getFontMetrics().stringWidth(abbrev); if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + textX, this.y + h); + drawSingleString(graph, abbrev, this.x + textX, this.y + h); break; } } @@ -435,9 +340,9 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S } } - h += graph.getFontMetrics().getDescent() + textY1; + h += graph.getFontMetrics().getDescent() + textY; - if (h + textY1 >= this.height) { + if (h + textY >= this.height) { limitMethod = this.y + this.height; limitSignal = this.y + this.height; return; @@ -448,7 +353,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S this.limitSignal = this.y + h; graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); - h += textY1; + h += textY; // Signals for (AvatarSignal signal : this.mySignals) { @@ -461,7 +366,8 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S String signalString = "~ " + signal.toString(); w = graph.getFontMetrics().stringWidth(signalString); if (w + 2 * textX < this.width) { - graph.drawString(signalString, this.x + textX, this.y + h); +// graph.drawString(signalString, this.x + textX, this.y + h); + drawSingleString(graph, signalString, this.x + textX, this.y + h); drawInfoAttachement(signal, graph, x, y + h); } else { @@ -471,10 +377,9 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S String abbrev = signalString.substring(0, stringLength) + "..."; w = graph.getFontMetrics().stringWidth(abbrev); if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + textX, this.y + h); + //graph.drawString(abbrev, this.x + textX, this.y + h); + drawSingleString(graph, abbrev, this.x + textX, this.y + h); drawInfoAttachement(signal, graph, x, y + h); - - break; } } @@ -485,9 +390,9 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S } } - h += graph.getFontMetrics().getDescent() + textY1; + h += graph.getFontMetrics().getDescent() + textY; - if (h + textY1 >= this.height) { + if (h + textY >= this.height) { limitSignal = this.height + this.y; return; } @@ -495,18 +400,331 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S // Global code limitSignal = this.y + h; if (hasGlobalCode()) { - if (h + textY1 + step >= this.height - textX) + if (h + textY + step >= this.height - textX) return; graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); - h += textY1 + step; + h += textY + step; w = graph.getFontMetrics().stringWidth(GLOBAL_CODE_INFO); if (w + 2 * textX < this.width) - graph.drawString(GLOBAL_CODE_INFO, this.x + (this.width - w) / 2, this.y + h); + drawSingleString(graph, GLOBAL_CODE_INFO, this.x + (this.width - w) / 2, this.y + h); +// graph.drawString(GLOBAL_CODE_INFO, this.x + (this.width - w) / 2, this.y + h); } else { limitSignal = height; - } + } + } + +// private void internalDrawingAu(Graphics graph) { +// +// //TraceManager.addDev("Block drawing aux = " + this); +// +// // Draw outer rectangle (for border) +// Color c = graph.getColor(); +// graph.drawRect(this.x, this.y, this.width, this.height); +// +// // Draw inner rectangle +// //graph.setColor(ColorManager.AVATAR_BLOCK); +// +// //TraceManager.addDev("type stereotype=" + typeStereotype); +// +// graph.setColor(BLOCK_TYPE_COLOR.get(typeStereotype)); +// graph.fillRect(this.x + 1, this.y + 1, this.width - 1, this.height - 1); +// graph.setColor(c); +// +// // limits +// this.limitName = -1; +// this.limitAttr = -1; +// this.limitMethod = -1; +// this.limitSignal = y + height; +// +// // h retains the coordinate along X where an element was last drawn +// int h = 0; +// +//// int textY1 = (int) (this.textY1 * this.tdp.getZoom()); +//// int textX = (int) (this.textX * this.tdp.getZoom()); +// +// // Draw icon +// this.iconIsDrawn = this.width > IconManager.iconSize + 2 * textX && height > IconManager.iconSize + 2 * textX; +// if (this.iconIsDrawn) +// graph.drawImage(scale(IconManager.img5100), this.x + this.width - scale(IconManager.iconSize) - textX, this.y + textX, null); +// +// +// Font font = graph.getFont(); +// +// +// String ster = BLOCK_TYPE_STR.get(typeStereotype); +// +// //TraceManager.addDev("My ster=" + ster); +// +// if (this.rescaled && !this.tdp.isScaled()) { +// this.rescaled = false; +// // Must set the font size... +// // Incrementally find the biggest font not greater than max_font size +// // If font is less than min_font, no text is displayed +// +// // This is the maximum font size possible +// int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); +// font = font.deriveFont((float) maxCurrentFontSize); +// +// // Try to decrease font size until we get below the minimum +// while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { +// // Compute width of name of the function +// int w0 = graph.getFontMetrics(font).stringWidth(this.value); +// // Compute width of string stereotype +// int w1 = graph.getFontMetrics(font).stringWidth(ster); +// +// // if one of the two width is small enough use this font size +// if (Math.min(w0, w1) < this.width - (2 * this.textX)) +// break; +// +// // Decrease font size +// maxCurrentFontSize--; +// // Scale the font +// font = font.deriveFont((float) maxCurrentFontSize); +// } +// +// // Box is too damn small +// if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { +// maxCurrentFontSize++; +// // Scale the font +// font = font.deriveFont((float) maxCurrentFontSize); +// } +// +// // Use this font +// graph.setFont(font); +// this.currentFontSize = maxCurrentFontSize; +// } else +// font = font.deriveFont(this.currentFontSize); +// +// graph.setFont(font.deriveFont(Font.BOLD)); +// h = graph.getFontMetrics().getAscent() + graph.getFontMetrics().getLeading() + textY; +// +// if (h + graph.getFontMetrics().getDescent() + textY >= this.height) +// return; +// +// // Write stereotype if small enough +// int w = graph.getFontMetrics().stringWidth(ster); +// if (w + 2 * textX < this.width) +//// graph.drawString(ster, this.x + (this.width - w) / 2, this.y + h); +// drawSingleString(graph, ster, this.x + (this.width - w) / 2, this.y + h); +// else { +// // try to draw with "..." instead +// if (!this.isCryptoBlock()) +// ster = stereotype; +// else +// ster = stereotypeCrypto; +// +// for (int stringLength = ster.length() - 1; stringLength >= 0; stringLength--) { +// String abbrev = "<<" + ster.substring(0, stringLength) + "...>>"; +// w = graph.getFontMetrics().stringWidth(abbrev); +// if (w + 2 * textX < this.width) { +//// graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); +// drawSingleString(graph, abbrev, this.x + (this.width - w) / 2, this.y + h); +// break; +// } +// } +// } +// +// // Write value if small enough +// graph.setFont(font); +// h += graph.getFontMetrics().getHeight() + textY; +// if (h + graph.getFontMetrics().getDescent() + textY >= this.height) +// return; +// +// w = graph.getFontMetrics().stringWidth(this.value); +// if (w + 2 * textX < this.width) +// graph.drawString(this.value, this.x + (this.width - w) / 2, this.y + h); +// else { +// // try to draw with "..." instead +// for (int stringLength = this.value.length() - 1; stringLength >= 0; stringLength--) { +// String abbrev = this.value.substring(0, stringLength) + "..."; +// w = graph.getFontMetrics().stringWidth(abbrev); +// if (w + 2 * textX < this.width) { +// graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); +// break; +// } +// } +// } +// +// h += graph.getFontMetrics().getDescent() + textY; +// +// // Update lower bound of text +// this.limitName = this.y + h; +// +// if (h + textY >= this.height) +// return; +// +// // Draw separator +// graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); +// +// if (!this.tdp.areAttributesVisible()) +// return; +// +// // Set font size +// // int attributeFontSize = Math.min (12, this.currentFontSize - 2); +// int attributeFontSize = this.currentFontSize * 5 / 6; +// graph.setFont(font.deriveFont((float) attributeFontSize)); +// int step = graph.getFontMetrics().getHeight(); +// +// h += textY; +// +// // Attributes +// limitAttr = limitName; +// for (TAttribute attr : this.myAttributes) { +// h += step; +// if (h >= this.height - textX) { +// this.limitAttr = this.y + this.height; +// return; +// } +// +// // Get the string for this parameter +// String attrString = attr.toAvatarString(); +// +// // Try to draw it +// w = graph.getFontMetrics().stringWidth(attrString); +// +// attrLocMap.put(attr,this.y+h); +// if (w + 2 * textX < this.width) { +// graph.drawString(attrString, this.x + textX, this.y + h); +// this.drawConfidentialityVerification(attr.getConfidentialityVerification(), graph, this.x, this.y + h); +// } else { +// // If we can't, try to draw with "..." instead +// int stringLength; +// for (stringLength = attrString.length() - 1; stringLength >= 0; stringLength--) { +// String abbrev = attrString.substring(0, stringLength) + "..."; +// w = graph.getFontMetrics().stringWidth(abbrev); +// if (w + 2 * textX < this.width) { +// graph.drawString(abbrev, this.x + textX, this.y + h); +// this.drawConfidentialityVerification(attr.getConfidentialityVerification(), graph, this.x, this.y + h); +// break; +// } +// } +// +// if (stringLength < 0) +// // skip attribute +// h -= step; +// } +// } +// +// h += graph.getFontMetrics().getDescent() + textY; +// +// // Remember the end of attributes +// this.limitAttr = this.y + h; +// +// if (h + textY >= this.height) +// return; +// +// graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); +// h += textY; +// +// // Methods +// limitMethod = limitAttr; +// limitSignal = limitAttr; +// for (AvatarMethod method : this.myMethods) { +// h += step; +// if (h >= this.height - textX) { +// this.limitMethod = this.y + this.height; +// this.limitSignal = limitMethod; +// return; +// } +// +// // Get the string for this method +// String methodString = "- " + method.toString(); +// +// w = graph.getFontMetrics().stringWidth(methodString); +// if (w + 2 * textX < this.width) +// graph.drawString(methodString, this.x + textX, this.y + h); +// else { +// // If we can't, try to draw with "..." instead +// int stringLength; +// for (stringLength = methodString.length() - 1; stringLength >= 0; stringLength--) { +// String abbrev = methodString.substring(0, stringLength) + "..."; +// w = graph.getFontMetrics().stringWidth(abbrev); +// if (w + 2 * textX < this.width) { +// graph.drawString(abbrev, this.x + textX, this.y + h); +// break; +// } +// } +// +// if (stringLength < 0) +// // skip method +// h -= step; +// } +// } +// +// h += graph.getFontMetrics().getDescent() + textY; +// +// if (h + textY >= this.height) { +// limitMethod = this.y + this.height; +// limitSignal = this.y + this.height; +// return; +// } +// +// // Remember limit of methods +// this.limitMethod = this.y + h; +// this.limitSignal = this.y + h; +// +// graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); +// h += textY; +// +// // Signals +// for (AvatarSignal signal : this.mySignals) { +// h += step; +// if (h >= this.height - textX) { +// limitSignal = this.height + this.y; +// return; +// } +// +// String signalString = "~ " + signal.toString(); +// w = graph.getFontMetrics().stringWidth(signalString); +// if (w + 2 * textX < this.width) { +// graph.drawString(signalString, this.x + textX, this.y + h); +// drawInfoAttachement(signal, graph, x, y + h); +// +// } else { +// // If we can't, try to draw with "..." instead +// int stringLength; +// for (stringLength = signalString.length() - 1; stringLength >= 0; stringLength--) { +// String abbrev = signalString.substring(0, stringLength) + "..."; +// w = graph.getFontMetrics().stringWidth(abbrev); +// if (w + 2 * textX < this.width) { +// graph.drawString(abbrev, this.x + textX, this.y + h); +// drawInfoAttachement(signal, graph, x, y + h); +// +// +// break; +// } +// } +// +// if (stringLength < 0) +// // skip signal +// h -= step; +// } +// } +// +// h += graph.getFontMetrics().getDescent() + textY; +// +// if (h + textY >= this.height) { +// limitSignal = this.height + this.y; +// return; +// } +// +// // Global code +// limitSignal = this.y + h; +// if (hasGlobalCode()) { +// if (h + textY + step >= this.height - textX) +// return; +// graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); +// h += textY + step; +// +// w = graph.getFontMetrics().stringWidth(GLOBAL_CODE_INFO); +// if (w + 2 * textX < this.width) +// graph.drawString(GLOBAL_CODE_INFO, this.x + (this.width - w) / 2, this.y + h); +// } else { +// limitSignal = height; +// } +// } private void drawInfoAttachement(AvatarSignal _as, Graphics g, int _x, int _y) { if (_as.attachedToARelation) { diff --git a/src/main/java/ui/avatarbd/AvatarBDCompositionConnector.java b/src/main/java/ui/avatarbd/AvatarBDCompositionConnector.java index ffbd47212578ac742048a7d528691c6c09b3feaf..ce55c43e4ad3e1e13bfe17f05c496204628b8ec0 100644 --- a/src/main/java/ui/avatarbd/AvatarBDCompositionConnector.java +++ b/src/main/java/ui/avatarbd/AvatarBDCompositionConnector.java @@ -51,14 +51,14 @@ import java.util.Vector; * @version 1.0 06/04/2010 * @author Ludovic APVRILLE */ -public class AvatarBDCompositionConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent{ +public class AvatarBDCompositionConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { protected int d = 20; protected int D = 26; //protected int widthValue, heightValue, maxWidthValue, h; protected Polygon p; protected int xp1, xp2, yp1, yp2; - protected double oldScaleFactor; - protected boolean rescaled; +// protected double oldScaleFactor; +// protected boolean rescaled; public AvatarBDCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { @@ -68,8 +68,8 @@ public class AvatarBDCompositionConnector extends TGConnectorWithCommentConnect value = "{info}"; editable = true; - oldScaleFactor = tdp.getZoom(); - rescaled = true; +// oldScaleFactor = tdp.getZoom(); +// rescaled = true; } @Override @@ -174,30 +174,30 @@ public class AvatarBDCompositionConnector extends TGConnectorWithCommentConnect return null; } - @Override - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - rescaled = true; - } +// @Override Issue #31 Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// rescaled = true; +// } @Override public int getType() { diff --git a/src/main/java/ui/avatarbd/AvatarBDConnectingPoint.java b/src/main/java/ui/avatarbd/AvatarBDConnectingPoint.java index 0d648695c3533e42a0e7108470f2c1fae7744d67..101454c8250cd01e7076c5fbb48bdf7f8be0de17 100644 --- a/src/main/java/ui/avatarbd/AvatarBDConnectingPoint.java +++ b/src/main/java/ui/avatarbd/AvatarBDConnectingPoint.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarbd; import ui.CDElement; @@ -58,11 +55,11 @@ public class AvatarBDConnectingPoint extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { if (type == TGComponentManager.AVATARBD_COMPOSITION_CONNECTOR) { return true; } return type == TGComponentManager.AVATARBD_PORT_CONNECTOR; } - } diff --git a/src/main/java/ui/avatarbd/AvatarBDDataType.java b/src/main/java/ui/avatarbd/AvatarBDDataType.java index f844bb36fa67808e3fd84d5db00e7a9e64f65808..3e5cf47a590217978f3e42ce16a89a7c12da4b3a 100644 --- a/src/main/java/ui/avatarbd/AvatarBDDataType.java +++ b/src/main/java/ui/avatarbd/AvatarBDDataType.java @@ -62,14 +62,14 @@ import java.util.LinkedList; * @version 1.1 18/06/2010 */ public class AvatarBDDataType extends TGCScalableWithInternalComponent implements GenericTree { - private int textY1 = 3; +// private int textY1 = 3; private String stereotype = "datatype"; private int maxFontSize = 12; private int minFontSize = 4; private int currentFontSize = -1; private boolean displayText = true; - private int textX = 7; +// private int textX = 7; private int limitName = -1; // private int limitAttr = -1; @@ -87,11 +87,14 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement public AvatarBDDataType(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); - + + textY = 3; + textX = 7; width = 250; height = 200; minWidth = 5; minHeight = 2; + initScaling(250, 200); nbConnectingPoint = 0; connectingPoint = new TGConnectingPoint[0]; @@ -119,14 +122,94 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement actionOnAdd(); } - + + @Override public void internalDrawing(Graphics g) { + //Rectangle + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + g.setColor(ColorManager.AVATAR_DATATYPE); + g.fill3DRect(x + 1, y + 1, width - 1, height - 1, true); + g.setColor(c); + + //Strings + String ster = "<<" + stereotype + ">>"; + Font f = g.getFont(); + + g.setFont(f.deriveFont(Font.BOLD)); + + int strWidth = g.getFontMetrics().stringWidth(ster); + int currentHeight = f.getSize(); + if ((strWidth < (2 * textX + width)) && (currentHeight < height)) { + drawSingleString(g, ster, x + (width - strWidth) / 2, y + currentHeight); + } + + g.setFont(f.deriveFont(Font.PLAIN)); + strWidth = g.getFontMetrics().stringWidth(value); + currentHeight = 2 * f.getSize(); + if ((strWidth < (2 * textX + width)) && (currentHeight < height)) { + drawSingleString(g, value, x + (width - strWidth) / 2, y + currentHeight); + } + limitName = y + currentHeight; + + currentHeight = currentHeight + 3; + if (currentHeight < height) { + g.drawLine(x, y + currentHeight, x + width, y + currentHeight); + } + + // Icon + if ((width > 30) && (height > (iconSize + 2 * textX))) { + g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize) - textX, y + textX, null); + } + + int cpt = currentHeight; + g.setFont(f.deriveFont(Font.PLAIN)); + // Attributes + if (tdp.areAttributesVisible()) { + // limitAttr = -1; + int index = 0; + 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(); + strWidth = g.getFontMetrics().stringWidth(attr); + if ((strWidth + (2 * textX) + 1) < width) { + drawSingleString(g, attr, x + textX, y + cpt); + } else { + attr = "..."; + strWidth = g.getFontMetrics().stringWidth(attr); + if ((strWidth + textX + 2) < width) { + drawSingleString(g, attr, x + textX + 1, y + cpt); + } else { + cpt -= step; //skip attrib + } + } + index++; + } + } + + } +// @Override + public void internalDrawin(Graphics g) { String ster = "<<" + stereotype + ">>"; Font f = g.getFont(); Font fold = f; - // - if ((rescaled) && (!tdp.isScaled())) { if (currentFontSize == -1) { @@ -185,15 +268,15 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement g.setFont(f.deriveFont(Font.BOLD)); w = g.getFontMetrics().stringWidth(ster); - h = currentFontSize + (int) (textY1 * tdp.getZoom()); + h = currentFontSize + (int) (textY * tdp.getZoom()); if ((w < (2 * textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w) / 2, y + h); + drawSingleString(g, ster, x + (width - w) / 2, y + h); } g.setFont(f0); w = g.getFontMetrics().stringWidth(value); - h = 2 * (currentFontSize + (int) (textY1 * tdp.getZoom())); + h = 2 * (currentFontSize + (int) (textY * tdp.getZoom())); if ((w < (2 * textX + width)) && (h < height)) { - g.drawString(value, x + (width - w) / 2, y + h); + drawSingleString(g, value, x + (width - w) / 2, y + h); } limitName = y + h; } else { @@ -241,13 +324,13 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement attr = a.toString(); w = g.getFontMetrics().stringWidth(attr); if ((w + (2 * textX) + 1) < width) { - g.drawString(attr, x + textX, y + cpt); + drawSingleString(g, attr, x + textX, y + cpt); // limitAttr = y + cpt; } else { attr = "..."; w = g.getFontMetrics().stringWidth(attr); if ((w + textX + 2) < width) { - g.drawString(attr, x + textX + 1, y + cpt); + drawSingleString(g, attr, x + textX + 1, y + cpt); // limitAttr = y + cpt; } else { // skip attribute @@ -270,6 +353,7 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -287,6 +371,7 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement return name; } + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { // On the name ? if ((((limitName == -1) && (displayText) && (_y <= (y + 2 * currentFontSize)))) || ((displayText) && (_y < limitName))) { @@ -360,11 +445,12 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement _jdab.enableUPPAALKeyword(false); } - + @Override public int getType() { return TGComponentManager.AVATARBD_DATATYPE; } + @Override protected String translateExtraParam() { TAttribute a; @@ -454,6 +540,7 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement return value; } + @Override public int getDefaultConnector() { return TGComponentManager.AVATARBD_PORT_CONNECTOR; } @@ -466,20 +553,24 @@ public class AvatarBDDataType extends TGCScalableWithInternalComponent implement myAttributes.add(ta); } + @Override public String toString() { return "Data type: " + getValue(); } + @Override public int getChildCount() { //TraceManager.addDev("Counting childs!"); return this.myAttributes.size(); } + @Override public Object getChild(int index) { return this.myAttributes.get(index); } + @Override public int getIndexOfChild(Object child) { if (child instanceof TAttribute) { return this.myAttributes.indexOf(child); diff --git a/src/main/java/ui/avatarbd/AvatarBDFirewall.java b/src/main/java/ui/avatarbd/AvatarBDFirewall.java index bc96761b880ca4959fa72400b7cec3143709090c..d3ed15c3d6365e8a4e8b44a169940007eeffaf55 100755 --- a/src/main/java/ui/avatarbd/AvatarBDFirewall.java +++ b/src/main/java/ui/avatarbd/AvatarBDFirewall.java @@ -61,7 +61,7 @@ import java.util.ArrayList; * @author Letitia LI */ public class AvatarBDFirewall extends TGCScalableWithoutInternalComponent { - private int textY1 = 15; +// private int textY1 = 15; private int textY2 = 30; private int derivationx = 2; private int derivationy = 3; @@ -72,10 +72,13 @@ public class AvatarBDFirewall extends TGCScalableWithoutInternalComponent { public AvatarBDFirewall(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); + textY = 15; + width = 250; height = 100; minWidth = 100; minHeight = 35; + initScaling(250, 100); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -111,7 +114,8 @@ public class AvatarBDFirewall extends TGCScalableWithoutInternalComponent { myImageIcon = IconManager.imgic700; } - + + @Override public void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); @@ -133,9 +137,9 @@ public class AvatarBDFirewall extends TGCScalableWithoutInternalComponent { // Strings String ster = "<<" + stereotype + ">>"; int w = g.getFontMetrics().stringWidth(ster); - g.drawString(ster, x + (width - w)/2, y + textY1); + drawSingleString(g, ster, x + (width - w)/2, y + textY); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon @@ -168,6 +172,7 @@ public class AvatarBDFirewall extends TGCScalableWithoutInternalComponent { return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -208,10 +213,12 @@ public class AvatarBDFirewall extends TGCScalableWithoutInternalComponent { } + @Override public int getType() { return TGComponentManager.TMLARCHI_FIREWALL; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -287,7 +294,8 @@ public class AvatarBDFirewall extends TGCScalableWithoutInternalComponent { return attr; } - + + @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; diff --git a/src/main/java/ui/avatarbd/AvatarBDLibraryFunction.java b/src/main/java/ui/avatarbd/AvatarBDLibraryFunction.java index 6760b394b98856193e30b7645ffebd48f21ed363..0891723d8b1470f52f8092c9396700afddfb06a9 100644 --- a/src/main/java/ui/avatarbd/AvatarBDLibraryFunction.java +++ b/src/main/java/ui/avatarbd/AvatarBDLibraryFunction.java @@ -178,6 +178,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent this.height = 100; this.minWidth = 5; this.minHeight = 2; + initScaling(160, 100); this.nbConnectingPoint = 0; this.connectingPoint = new TGConnectingPoint[0]; @@ -336,7 +337,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent // Draw icon this.iconIsDrawn = this.width > IconManager.iconSize + 2 * paddingHorizontal && height > IconManager.iconSize + 2 * paddingHorizontal; if (this.iconIsDrawn) - graph.drawImage(IconManager.img5100, this.x + this.width - IconManager.iconSize - paddingHorizontal, this.y + paddingHorizontal, null); + graph.drawImage(scale(IconManager.img5100), this.x + this.width - scale(IconManager.iconSize) - paddingHorizontal, this.y + paddingHorizontal, null); Font font = graph.getFont(); @@ -396,7 +397,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent // Write stereotype if small enough int w = graph.getFontMetrics().stringWidth(ster); if (w + 2 * paddingHorizontal < this.width) - graph.drawString(ster, this.x + (this.width - w) / 2, this.y + h); + drawSingleString(graph, ster, this.x + (this.width - w) / 2, this.y + h); else { // try to draw with "..." instead if (!this.isCrypto) @@ -408,7 +409,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent String abbrev = "<<" + ster.substring(0, stringLength) + "...>>"; w = graph.getFontMetrics().stringWidth(abbrev); if (w + 2 * paddingHorizontal < this.width) { - graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); + drawSingleString(graph, abbrev, this.x + (this.width - w) / 2, this.y + h); break; } } @@ -422,14 +423,14 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent w = graph.getFontMetrics().stringWidth(this.value); if (w + 2 * paddingHorizontal < this.width) - graph.drawString(this.value, this.x + (this.width - w) / 2, this.y + h); + drawSingleString(graph, this.value, this.x + (this.width - w) / 2, this.y + h); else { // try to draw with "..." instead for (int stringLength = this.value.length() - 1; stringLength >= 0; stringLength--) { String abbrev = this.value.substring(0, stringLength) + "..."; w = graph.getFontMetrics().stringWidth(abbrev); if (w + 2 * paddingHorizontal < this.width) { - graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); + drawSingleString(graph, abbrev, this.x + (this.width - w) / 2, this.y + h); break; } } @@ -471,7 +472,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent // Try to draw it w = graph.getFontMetrics().stringWidth(attrString); if (w + 2 * paddingHorizontal < this.width) - graph.drawString(attrString, this.x + paddingHorizontal, this.y + h); + drawSingleString(graph, attrString, this.x + paddingHorizontal, this.y + h); else { // If we can't, try to draw with "..." instead int stringLength; @@ -479,7 +480,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent String abbrev = attrString.substring(0, stringLength) + "..."; w = graph.getFontMetrics().stringWidth(abbrev); if (w + 2 * paddingHorizontal < this.width) { - graph.drawString(abbrev, this.x + paddingHorizontal, this.y + h); + drawSingleString(graph, abbrev, this.x + paddingHorizontal, this.y + h); break; } } @@ -512,7 +513,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent String signalString = "~ " + signal.toString(); w = graph.getFontMetrics().stringWidth(signalString); if (w + 2 * paddingHorizontal < this.width) - graph.drawString(signalString, this.x + paddingHorizontal, this.y + h); + drawSingleString(graph, signalString, this.x + paddingHorizontal, this.y + h); else { // If we can't, try to draw with "..." instead int stringLength; @@ -520,7 +521,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent String abbrev = signalString.substring(0, stringLength) + "..."; w = graph.getFontMetrics().stringWidth(abbrev); if (w + 2 * paddingHorizontal < this.width) { - graph.drawString(abbrev, this.x + paddingHorizontal, this.y + h); + drawSingleString(graph, abbrev, this.x + paddingHorizontal, this.y + h); break; } } @@ -553,7 +554,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent w = graph.getFontMetrics().stringWidth(attrString); if (w + 2 * paddingHorizontal < this.width) - graph.drawString(attrString, this.x + paddingHorizontal, this.y + h); + drawSingleString(graph, attrString, this.x + paddingHorizontal, this.y + h); else { // If we can't, try to draw with "..." instead int stringLength; @@ -561,7 +562,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent String abbrev = attrString.substring(0, stringLength) + "..."; w = graph.getFontMetrics().stringWidth(abbrev); if (w + 2 * paddingHorizontal < this.width) { - graph.drawString(abbrev, this.x + paddingHorizontal, this.y + h); + drawSingleString(graph, abbrev, this.x + paddingHorizontal, this.y + h); break; } } diff --git a/src/main/java/ui/avatarbd/AvatarBDPanel.java b/src/main/java/ui/avatarbd/AvatarBDPanel.java index 31aacf57e5302109828c8969c91da876b1932355..b5541b1b4f00c5ea497535ee6aae28e7a523978c 100644 --- a/src/main/java/ui/avatarbd/AvatarBDPanel.java +++ b/src/main/java/ui/avatarbd/AvatarBDPanel.java @@ -177,31 +177,38 @@ public class AvatarBDPanel extends TDiagramPanel { } return false; } - + + @Override public boolean areAttributesVisible() { return attributesVisible; } - + + @Override public String getXMLHead() { return "<AVATARBlockDiagramPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >\n" + displayParam(); } - + + @Override public String getXMLTail() { return "</AVATARBlockDiagramPanel>"; } - + + @Override public String getXMLSelectedHead() { return "<AVATARBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - + + @Override public String getXMLSelectedTail() { return "</AVATARBlockDiagramPanelCopy>"; } - + + @Override public String getXMLCloneHead() { return "<AVATARBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - + + @Override public String getXMLCloneTail() { return "</AVATARBlockDiagramPanelCopy>"; } diff --git a/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java b/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java index ae4f76d6a20211d1d234d30228641c1cd903da76..a1411f9893ec1d5e8bf11a9347372904755bf49b 100644 --- a/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java +++ b/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java @@ -70,8 +70,8 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone protected String[] values; protected List<String> properties; - protected int textX = 40; - protected int textY = 5; +// protected int textX = 40; +// protected int textY = 5; protected int marginY = 20; protected int marginX = 20; protected int limit = 15; @@ -82,7 +82,7 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone protected Color myColor; - private Font myFont;//, myFontB; +// private Font myFont;//, myFontB; // private int maxFontSize = 30; // private int minFontSize = 4; private int currentFontSize = -1; @@ -93,10 +93,15 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone public AvatarBDPerformancePragma(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); + + textY = 5; + textX = 40; width = 200; height = 30; minWidth = 80; minHeight = 10; + initScaling(200, 30); + properties = new LinkedList<String>(); oldScaleFactor = tdp.getZoom(); @@ -136,8 +141,64 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone return properties; } - @Override - public void internalDrawing(Graphics g) { + public void internalDrawing(Graphics g) + { + //check + if (values == null) { + makeValue(); + } + //Rectangle + Color c = g.getColor(); + g.drawLine(x, y, x + width, y); + g.drawLine(x, y, x, y + height); + g.drawLine(x, y + height, x + width - limit, y + height); + g.drawLine(x + width, y, x + width, y + height - limit); + + g.setColor(ColorManager.PERFORMANCE_PRAGMA_BG); + int[] px1 = {x + 1, x + width, x + width, x + width - limit, x + 1}; + int[] py1 = {y + 1, y + 1, y + height - limit, y + height, y + height}; + g.fillPolygon(px1, py1, 5); + g.setColor(c); + + int[] px = {x + width, x + width - 4, x + width - 10, x + width - limit}; + int[] py = {y + height - limit, y + height - limit + 3, y + height - limit + 2, y + height}; + g.drawPolygon(px, py, 4); + + if (g.getColor() == ColorManager.NORMAL_0) { + g.setColor(ColorManager.PRAGMA); + } + g.fillPolygon(px, py, 4); + g.setColor(Color.black); + + //Strings + Font f = g.getFont(); + int i = 1; +// Font heading = new Font("heading", Font.BOLD, 14); + + int currentH = scale(7); + drawSingleString(g, "Performance Pragmas", getCenter(g, "Performance Pragmas")/*x + textX*/, y + textY + currentFontSize + currentH); + //g.setFont(fold); + g.setFont(f.deriveFont(f.getSize() - 10)); + for (String s : properties) { + currentH += f.getSize(); +// if (canTextGoInTheBox(g, s, )) + drawSingleString(g, s, x, y + textY + (i + 1) * currentFontSize + currentH); + drawVerification(s, g, x + textX, y + textY + (i + 1) * currentFontSize + currentH); + if (syntaxErrors.contains(s)) { + Color ctmp = g.getColor(); + g.setColor(Color.red); + g.drawLine(x + textX / 2, y + textY * 3 / 2 + i * currentFontSize, x + width - textX / 2, y + textY * 3 / 2 + (i + 1) * currentFontSize); + g.drawLine(x + width - textX / 2, y + textY * 3 / 2 + i * currentFontSize, x + textX / 2, y + textY * 3 / 2 + (i + 1) * currentFontSize); + g.setColor(ctmp); + } + i++; + } + g.setColor(c); + + } + +// @Override + public void internalDrawin(Graphics g) { Font f = g.getFont(); Font fold = f; @@ -145,16 +206,16 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone graphics = g; }*/ - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize() + 1; - // - // myFont = f.deriveFont((float)currentFontSize); - //myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize() + 1; +// // +// // myFont = f.deriveFont((float)currentFontSize); +// //myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } if (values == null) { makeValue(); @@ -163,7 +224,7 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone // int h = g.getFontMetrics().getHeight(); Color c = g.getColor(); - if (!(this.tdp.isScaled())) { +// if (!(this.tdp.isScaled())) { int desiredWidth = minWidth; desiredWidth = Math.max(desiredWidth, 2 * g.getFontMetrics().stringWidth("Performance Pragma") + marginX + textX); @@ -178,7 +239,7 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone if ((desiredWidth != width) || (desiredHeight != height)) { resize(desiredWidth, desiredHeight); } - } +// } g.drawLine(x, y, x + width, y); g.drawLine(x, y, x, y + height); @@ -205,10 +266,10 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone int i = 1; Font heading = new Font("heading", Font.BOLD, 14); g.setFont(heading); - g.drawString("Performance Pragmas", x + textX, y + textY + currentFontSize); + drawSingleString(g, "Performance Pragmas", x + textX, y + textY + currentFontSize); g.setFont(fold); for (String s : properties) { - g.drawString(s, x + textX, y + textY + (i + 1) * currentFontSize); + drawSingleString(g, s, x + textX, y + textY + (i + 1) * currentFontSize); drawVerification(s, g, x + textX, y + textY + (i + 1) * currentFontSize); if (syntaxErrors.contains(s)) { Color ctmp = g.getColor(); @@ -222,7 +283,7 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone /* for (int i = 0; i<values.length; i++) { //TraceManager.addDev("x+texX=" + (x + textX) + " y+textY=" + y + textY + i* h + ": " + values[i]); - g.drawString(values[i], x + textX, y + textY + (i+1)* currentFontSize); + drawSingleString(g, values[i], x + textX, y + textY + (i+1)* currentFontSize); } */ g.setColor(c); @@ -281,7 +342,8 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone } return false; } - + + @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -338,7 +400,7 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone } else if (status.equals("PROVED_ERROR")) { Font f = g.getFont(); g.setFont(new Font("TimesRoman", Font.BOLD, 14)); - g.drawString("?", _x - 30, _y); + drawSingleString(g, "?", _x - 30, _y); g.setFont(f); } else if (status.equals("PROVED_FALSE")) { g.setColor(Color.red); @@ -351,7 +413,7 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone } else { Font f = g.getFont(); g.setFont(new Font("TimesRoman", Font.BOLD, 10)); - g.drawString(status, _x - 35, _y); + drawSingleString(g, status, _x - 35, _y); g.setFont(f); } } diff --git a/src/main/java/ui/avatarbd/AvatarBDPortConnector.java b/src/main/java/ui/avatarbd/AvatarBDPortConnector.java index 4865de9efc1a0dd386102e6797805cdaa7131679..96f4ca5d59003d31c5af5416352b2a21abd7d420 100644 --- a/src/main/java/ui/avatarbd/AvatarBDPortConnector.java +++ b/src/main/java/ui/avatarbd/AvatarBDPortConnector.java @@ -66,11 +66,11 @@ import java.util.Vector; * @author Ludovic APVRILLE * @version 1.0 06/04/2010 */ -public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 10; //square length - protected double oldScaleFactor; + //protected double oldScaleFactor; protected int fontSize = 10; protected int decY = 12; protected int decX = 6; @@ -88,14 +88,14 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint protected boolean isBroadcast = false; protected boolean isLossy = false; - public AvatarBDPortConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; value = ""; editable = true; - oldScaleFactor = tdp.getZoom(); + // oldScaleFactor = tdp.getZoom(); inSignalsAtOrigin = new LinkedList<String>(); inSignalsAtDestination = new LinkedList<String>(); outSignalsAtOrigin = new LinkedList<String>(); @@ -210,29 +210,29 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint 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); + //drawSingleString(g, "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); + drawSingleString(g, s, p1.getX() + decX, p1.getY() + h); } else { w = g.getFontMetrics().stringWidth(s); - g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + drawSingleString(g, s, p1.getX() - decX - w, p1.getY() + h); } } } if (outSignalsAtOrigin.size() > 0) { //h += step; - //g.drawString("out:", p1.getX() + decX, p1.getY() + h); + //drawSingleString(g, "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); + drawSingleString(g, s, p1.getX() + decX, p1.getY() + h); } else { w = g.getFontMetrics().stringWidth(s); - g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + drawSingleString(g, s, p1.getX() - decX - w, p1.getY() + h); } } } @@ -240,28 +240,28 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint h = -decY; if (outSignalsAtDestination.size() > 0) { //h += step; - //g.drawString("out:", p2.getX() + decX, p2.getY() + h); + //drawSingleString(g, "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); + drawSingleString(g, s, p2.getX() + decX, p2.getY() + h); } else { w = g.getFontMetrics().stringWidth(s); - g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + drawSingleString(g, s, p2.getX() - decX - w, p2.getY() + h); } } } if (inSignalsAtDestination.size() > 0) { - //g.drawString("in:", p2.getX() + decX, p2.getY() + h); + //drawSingleString(g, "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); + drawSingleString(g, s, p2.getX() + decX, p2.getY() + h); } else { w = g.getFontMetrics().stringWidth(s); - g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + drawSingleString(g, s, p2.getX() - decX - w, p2.getY() + h); } } } @@ -275,7 +275,7 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint Font f0 = f.deriveFont((float)(fontSize*tdp.getZoom())); g.setFont(f0); } - g.drawString(value, x2-(cz/2), y2-(cz/2)-1); + drawSingleString(g, value, x2-(cz/2), y2-(cz/2)-1); g.setFont(f); }*/ @@ -286,11 +286,11 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint if (messageInformation != null) { if (messageInformation[0] != null) { g.setColor(Color.BLUE); - g.drawString(messageInformation[0], p1.getX() + decX, p1.getY()); + drawSingleString(g, messageInformation[0], p1.getX() + decX, p1.getY()); } if (messageInformation[1] != null) { g.setColor(Color.BLUE); - g.drawString(messageInformation[1], p2.getX() + decX, p2.getY()); + drawSingleString(g, messageInformation[1], p2.getX() + decX, p2.getY()); } g.setColor(Color.BLACK); } @@ -522,30 +522,30 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint public int getType() { return TGComponentManager.AVATARBD_PORT_CONNECTOR; } - - @Override - public void rescale(double scaleFactor) { - // - int xx, yy; - - for (int i = 0; i < nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } +// +// @Override Issue #31 Now managed in upper class +// public void rescale(double scaleFactor) { +// // +// int xx, yy; +// +// for (int i = 0; i < nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } public List<String> getListOfSignalsOrigin() { List<String> list = new LinkedList<String>(); diff --git a/src/main/java/ui/avatarbd/AvatarBDPragma.java b/src/main/java/ui/avatarbd/AvatarBDPragma.java index 500172231f9a3bbba660cb391002e1deb6622eee..78248976a41dbc6f116dc40490f34b65d2df55e0 100755 --- a/src/main/java/ui/avatarbd/AvatarBDPragma.java +++ b/src/main/java/ui/avatarbd/AvatarBDPragma.java @@ -71,8 +71,8 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { protected List<String> models; protected List<String> properties; public List<String> syntaxErrors; - protected int textX = 25; - protected int textY = 5; +// protected int textX = 25; +// protected int textY = 5; protected int marginY = 20; protected int marginX = 20; protected int limit = 15; @@ -102,11 +102,15 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { public AvatarBDPragma(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); - + + textX = 25; + textY = 5; width = 200; height = 30; minWidth = 80; minHeight = 10; + initScaling(200, 30); + models = new LinkedList<String>(); properties = new LinkedList<String>(); authStrongMap = new HashMap<String, Integer>(); @@ -166,16 +170,16 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { graphics = g; }*/ - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize() + 1; - // - // myFont = f.deriveFont((float)currentFontSize); - //myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize() + 1; +// // +// // myFont = f.deriveFont((float)currentFontSize); +// //myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } if (values == null) { makeValue(); @@ -203,18 +207,18 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { desiredWidth = Math.max(desiredWidth, this.tdp.stringWidth(g, values[i]) + marginX + textX); // currentFontSize= 5; - int desiredHeight = ((models.size() + properties.size() + 4) * currentFontSize) + textY + 1; +// int desiredHeight = ((models.size() + properties.size() + 4) * currentFontSize) + textY + 1; //TraceManager.addDev("resize: " + desiredWidth + "," + desiredHeight); - if ((desiredWidth != width) || (desiredHeight != height)) { - resize(desiredWidth, desiredHeight); - } +// if ((desiredWidth != width) || (desiredHeight != height)) { +// resize(desiredWidth, desiredHeight); +// } } g.drawLine(x, y, x + width, y); g.drawLine(x, y, x, y + height); - g.drawLine(x, y + height, x + width - limit, y + height); + g.drawLine(x, y + height, x + width - limit, y + height); //down g.drawLine(x + width, y, x + width, y + height - limit); g.setColor(ColorManager.PRAGMA_BG); @@ -238,11 +242,11 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { int i = 1; Font heading = new Font("heading", Font.BOLD, this.tdp.getFontSize() * 7 / 6); g.setFont(heading); - g.drawString("Security features", x + textX, y + textY + currentFontSize); + drawSingleString(g, "Security features", x + textX, y + textY + currentFontSize); g.setFont(fold); for (String s : models) { pragmaLocMap.put(s, y + textY + (i + 1) * currentFontSize); - g.drawString(s, x + textX, y + textY + (i + 1) * currentFontSize); + drawSingleString(g, s, x + textX, y + textY + (i + 1) * currentFontSize); if (syntaxErrors.contains(s)) { Color ctmp = g.getColor(); g.setColor(Color.red); @@ -254,11 +258,13 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { } // FIXME: why the empty string ? //I forget... - g.drawString(" ", x + textX, y + textY + (i + 1) * currentFontSize); + //FIXME: issue #31 without the f.getSize it would glitch + currentFontSize = f.getSize(); + drawSingleString(g, " ", x + textX, y + textY + (i + 1) * currentFontSize); i++; g.drawLine(x, y + textY / 2 + i * currentFontSize, x + width, y + textY / 2 + i * currentFontSize); g.setFont(heading); - g.drawString("Security Property", x + textX, y + textY + (i + 1) * currentFontSize); + drawSingleString(g, "Security Property", x + textX, y + textY + (i + 1) * currentFontSize); g.setFont(fold); i++; // @@ -268,7 +274,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { drawConfidentialityVerification(s, g, x + lockX, y + lockY + (i + 1) * currentFontSize); g.setFont(fold); } - g.drawString(s, x + textX, y + textY + (i + 1) * currentFontSize); + drawSingleString(g, s, x + textX, y + textY + (i + 1) * currentFontSize); pragmaLocMap.put(s, y + textY + i * currentFontSize); if (syntaxErrors.contains(s)) { Color ctmp = g.getColor(); @@ -282,7 +288,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { /* for (int i = 0; i<values.length; i++) { //TraceManager.addDev("x+texX=" + (x + textX) + " y+textY=" + y + textY + i* h + ": " + values[i]); - g.drawString(values[i], x + textX, y + textY + (i+1)* currentFontSize); + drawSingleString(g, values[i], x + textX, y + textY + (i+1)* currentFontSize); } */ g.setColor(c); @@ -383,10 +389,10 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { // g.drawRect(_x+4, _y-7, 18, 14); g.drawPolygon(xps, yps, 3); g.drawPolygon(xpw, ypw, 3); - g.drawString("S", _x + 6, _y + 2); - g.drawString("W", _x + 13, _y - 2); + drawSingleString(g, "S", _x + 6, _y + 2); + drawSingleString(g, "W", _x + 13, _y - 2); // if (c1==Color.gray){ -// g.drawString("?", _x+4, _y+2); +// drawSingleString(g, "?", _x+4, _y+2); // } } diff --git a/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java b/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java index 59b3ee62a879c55ad484041e5b9df66a2924229c..658c4f978d5d1bb8d27569afa6d7ae569dcead86 100644 --- a/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java +++ b/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java @@ -66,8 +66,8 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { protected String[] values; protected List<String> properties; - protected int textX = 25; - protected int textY = 5; +// protected int textX = 25; +// protected int textY = 5; protected int marginY = 20; protected int marginX = 20; protected int limit = 15; @@ -91,12 +91,17 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { public AvatarBDSafetyPragma(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + width = 200; + textY = 5; + textX = 25; height = 30; minWidth = 80; minHeight = 10; + initScaling(200,30); + properties = new LinkedList<String>(); - oldScaleFactor = tdp.getZoom(); +// oldScaleFactor = tdp.getZoom(); nbConnectingPoint = 0; //addTGConnectingPointsComment(); @@ -157,7 +162,7 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { makeValue(); } - // int h = g.getFontMetrics().getHeight(); +// int h = g.getFontMetrics().getHeight(); Color c = g.getColor(); if (!(this.tdp.isScaled())) { @@ -201,12 +206,12 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { g.setColor(Color.black); int i = 1; - Font heading = new Font("heading", Font.BOLD, 14); - g.setFont(heading); - g.drawString("Safety Pragmas", x + textX, y + textY + currentFontSize); +// Font heading = new Font("heading", Font.BOLD, 14); + //g.setFont(heading); + drawSingleString(g, "Safety Pragmas", x + textX, y + textY + currentFontSize); g.setFont(fold); for (String s : properties) { - g.drawString(s, x + textX, y + textY + (i + 1) * currentFontSize); + drawSingleString(g, s, x + textX, y + textY + (i + 1) * currentFontSize); if (syntaxErrors.contains(s)) { Color ctmp = g.getColor(); g.setColor(Color.red); @@ -220,7 +225,7 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { /* for (int i = 0; i<values.length; i++) { //TraceManager.addDev("x+texX=" + (x + textX) + " y+textY=" + y + textY + i* h + ": " + values[i]); - g.drawString(values[i], x + textX, y + textY + (i+1)* currentFontSize); + drawSingleString(g, values[i], x + textX, y + textY + (i+1)* currentFontSize); } */ g.setColor(c); @@ -346,7 +351,7 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { } else if (status == PROVED_ERROR) { Font f = g.getFont(); g.setFont(new Font("TimesRoman", Font.BOLD, 14)); - g.drawString("?", _x - 15, _y); + drawSingleString(g, "?", _x - 15, _y); g.setFont(f); } else { g.setColor(Color.red); diff --git a/src/main/java/ui/avatarbd/AvatarBDToolBar.java b/src/main/java/ui/avatarbd/AvatarBDToolBar.java index 53de8d401cef89276a7930dc16af1a2c01dfd2e2..86481a41d9b89374a29c12db0a20b4cb76f08bf2 100644 --- a/src/main/java/ui/avatarbd/AvatarBDToolBar.java +++ b/src/main/java/ui/avatarbd/AvatarBDToolBar.java @@ -62,7 +62,7 @@ public class AvatarBDToolBar extends TToolBar { public AvatarBDToolBar(MainGUI _mgui) { super(_mgui); } - + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -97,7 +97,8 @@ public class AvatarBDToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); } - + + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/avatarcd/AvatarCDActorBox.java b/src/main/java/ui/avatarcd/AvatarCDActorBox.java index a7229cc40f6aa63ec99e1682df5055404cff7908..3359403718d54f8ef8c41fc3329cf13d0f65636a 100755 --- a/src/main/java/ui/avatarcd/AvatarCDActorBox.java +++ b/src/main/java/ui/avatarcd/AvatarCDActorBox.java @@ -1,3 +1,4 @@ + /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille * * ludovic.apvrille AT enst.fr @@ -65,12 +66,13 @@ public class AvatarCDActorBox extends TGCScalableOneLineText { public AvatarCDActorBox(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = (int)(40 * tdp.getZoom()); - height = (int)(50 * tdp.getZoom()); - minWidth = (int)(40 * tdp.getZoom()); + //issue #31 + width = 40; + height = 50; + minWidth = 40; //(int)(40 * tdp.getZoom()); oldScaleFactor = tdp.getZoom(); - + initScaling(40,50); + nbConnectingPoint = 24; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; int i; @@ -96,6 +98,7 @@ public class AvatarCDActorBox extends TGCScalableOneLineText { myImageIcon = IconManager.imgic600; } + @Override public void internalDrawing(Graphics g) { w = g.getFontMetrics().stringWidth(value); int w1 = g.getFontMetrics().stringWidth(STEREOTYPE); @@ -103,11 +106,12 @@ public class AvatarCDActorBox extends TGCScalableOneLineText { width = Math.max(Math.max(w, w1) + space, minWidth); } h = g.getFontMetrics().getHeight(); - g.drawString(STEREOTYPE, x + ((width - w1) / 2), y + h + space/2); - g.drawString(value, x + ((width - w) / 2) , y + height - h); + drawSingleString(g, STEREOTYPE, x + ((width - w1) / 2), y + h + space/2); + drawSingleString(g, value, x + ((width - w) / 2) , y + height - h); g.drawRect(x, y, width, height); } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -118,11 +122,13 @@ public class AvatarCDActorBox extends TGCScalableOneLineText { return null; } + @Override public int getMyCurrentMinX() { return Math.min(x + width / 2 - w / 2, x); } + @Override public int getMyCurrentMaxX() { return Math.max(x + width / 2 + w / 2, x + width); } @@ -132,6 +138,7 @@ public class AvatarCDActorBox extends TGCScalableOneLineText { } + @Override public int getType() { return TGComponentManager.ACD_ACTOR_BOX; } diff --git a/src/main/java/ui/avatarcd/AvatarCDActorStickman.java b/src/main/java/ui/avatarcd/AvatarCDActorStickman.java index ea4441114ccaaa1a1cf6a4338f93916e0994efdf..13f5a2d4f6714d45f0596f072dffc303753c1bdb 100755 --- a/src/main/java/ui/avatarcd/AvatarCDActorStickman.java +++ b/src/main/java/ui/avatarcd/AvatarCDActorStickman.java @@ -64,9 +64,9 @@ public class AvatarCDActorStickman extends TGCScalableOneLineText { public AvatarCDActorStickman(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(30 * tdp.getZoom()); - height = (int)(70 * tdp.getZoom()); - oldScaleFactor = tdp.getZoom(); + width = 30;// (int)(30 * tdp.getZoom()); + height = 70; //(int)(70 * tdp.getZoom()); + oldScaleFactor = tdp.getZoom(); nbConnectingPoint = 24; @@ -109,7 +109,7 @@ public class AvatarCDActorStickman extends TGCScalableOneLineText { //right leg g.drawLine(x+width/2, y+height-width/2, x+width, y+height); //name of actor - g.drawString(value, x + width / 2 - w / 2 , y + height + h); + drawSingleString(g, value, x + width / 2 - w / 2 , y + height + h); height = height + h; } diff --git a/src/main/java/ui/avatarcd/AvatarCDAssociationConnector.java b/src/main/java/ui/avatarcd/AvatarCDAssociationConnector.java index 068fedccd5396ef881b02af2ace59749ff4f5b8f..488853506d9e699d8a09bf74c79aae112f8a2345 100755 --- a/src/main/java/ui/avatarcd/AvatarCDAssociationConnector.java +++ b/src/main/java/ui/avatarcd/AvatarCDAssociationConnector.java @@ -61,7 +61,7 @@ public class AvatarCDAssociationConnector extends TGConnectorWithCommentConnect super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ g.drawLine(x1, y1, x2, y2); //GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); @@ -69,20 +69,22 @@ public class AvatarCDAssociationConnector extends TGConnectorWithCommentConnect // Indicate semantics //w = g.getFontMetrics().stringWidth(value); //h = g.getFontMetrics().getHeight(); - //g.drawString(value, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2); + //drawSingleString(g, value, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2); } /*protected void drawMiddleSegment(Graphics g, int x1, int y1, int x2, int y2) { GraphicLib.dashedLine(g, x1, y1, x2, y2); }*/ + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { return this; } return null; } - + + @Override public int getType() { return TGComponentManager.ACD_ASSOCIATION_CONNECTOR; } diff --git a/src/main/java/ui/avatarcd/AvatarCDBlock.java b/src/main/java/ui/avatarcd/AvatarCDBlock.java index e44ffc190b7c326cbd150fc0cdbb62e473353cd1..23176cd7bdc15bf94a1905f3d4d27a004112658d 100644 --- a/src/main/java/ui/avatarcd/AvatarCDBlock.java +++ b/src/main/java/ui/avatarcd/AvatarCDBlock.java @@ -65,18 +65,19 @@ import java.util.Map; * @version 1.2 03/07/2019 */ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent { - private int textY1 = 3; +// private int textY1 = 3; +// private int textX = 7; private String stereotype = "block"; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 7; +// private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; + - private int limitName = -1; - private int limitAttr = -1; - private int limitMethod = -1; +// private int limitName = -1; +// private int limitAttr = -1; +// private int limitMethod = -1; protected List<GeneralAttribute> myAttributes; @@ -92,10 +93,13 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S public AvatarCDBlock(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); + textY = 3; + textX = 7; width = 250; height = 200; minWidth = 5; minHeight = 2; + initScaling(250,200); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -132,7 +136,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S setValue(name); oldValue = value; - currentFontSize = maxFontSize; +// currentFontSize = maxFontSize; oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic700; @@ -141,314 +145,160 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S actionOnAdd(); } - - @Override - public void internalDrawing(Graphics graph) { - Font font = graph.getFont(); - this.internalDrawingAux(graph); - graph.setFont(font); - } - - private void internalDrawingAux(Graphics graph) { - - //TraceManager.addDev("Block drawing aux = " + this); - - // Draw outer rectangle (for border) - Color c = graph.getColor(); - graph.drawRect(this.x, this.y, this.width, this.height); - - // Draw inner rectangle - //graph.setColor(ColorManager.AVATAR_BLOCK); - - //TraceManager.addDev("type stereotype=" + typeStereotype); - - //graph.setColor(BLOCK_TYPE_COLOR.get(typeStereotype)); - graph.setColor(ColorManager.AVATAR_BLOCK); - graph.fillRect(this.x + 1, this.y + 1, this.width - 1, this.height - 1); - graph.setColor(c); - - // limits - this.limitName = -1; - this.limitAttr = -1; - - // h retains the coordinate along X where an element was last drawn - int h = 0; - - int textY1 = (int) (this.textY1 * this.tdp.getZoom()); - int textX = (int) (this.textX * this.tdp.getZoom()); - - // Draw icon - /*this.iconIsDrawn = this.width > IconManager.iconSize + 2 * textX && height > IconManager.iconSize + 2 * textX; - if (this.iconIsDrawn) - graph.drawImage(IconManager.img5100, this.x + this.width - IconManager.iconSize - textX, this.y + textX, null); -*/ - - Font font = graph.getFont(); - - - //String ster = BLOCK_TYPE_STR.get(typeStereotype); - String ster = stereotype; - - //TraceManager.addDev("My ster=" + ster); - - if (this.rescaled && !this.tdp.isScaled()) { - this.rescaled = false; - // Must set the font size... - // Incrementally find the biggest font not greater than max_font size - // If font is less than min_font, no text is displayed - - // This is the maximum font size possible - int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); - font = font.deriveFont((float) maxCurrentFontSize); - - // Try to decrease font size until we get below the minimum - while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { - // Compute width of name of the function - int w0 = graph.getFontMetrics(font).stringWidth(this.value); - // Compute width of string stereotype - int w1 = graph.getFontMetrics(font).stringWidth(ster); - - // if one of the two width is small enough use this font size - if (Math.min(w0, w1) < this.width - (2 * this.textX)) - break; - - // Decrease font size - maxCurrentFontSize--; - // Scale the font - font = font.deriveFont((float) maxCurrentFontSize); - } - - // Box is too damn small - if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { - maxCurrentFontSize++; - // Scale the font - font = font.deriveFont((float) maxCurrentFontSize); - } - - // Use this font - graph.setFont(font); - this.currentFontSize = maxCurrentFontSize; - } else - font = font.deriveFont(this.currentFontSize); - - graph.setFont(font.deriveFont(Font.BOLD)); - h = graph.getFontMetrics().getAscent() + graph.getFontMetrics().getLeading() + textY1; - - if (h + graph.getFontMetrics().getDescent() + textY1 >= this.height) - return; - - // Write stereotype if small enough - int w = graph.getFontMetrics().stringWidth(ster); - if (w + 2 * textX < this.width) - graph.drawString(ster, this.x + (this.width - w) / 2, this.y + h); - else { - // try to draw with "..." instead - - - for (int stringLength = ster.length() - 1; stringLength >= 0; stringLength--) { - String abbrev = "<<" + ster.substring(0, stringLength) + "...>>"; - w = graph.getFontMetrics().stringWidth(abbrev); - if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); - break; - } - } - } - - // Write value if small enough - graph.setFont(font); - h += graph.getFontMetrics().getHeight() + textY1; - if (h + graph.getFontMetrics().getDescent() + textY1 >= this.height) - return; - - w = graph.getFontMetrics().stringWidth(this.value); - if (w + 2 * textX < this.width) - graph.drawString(this.value, this.x + (this.width - w) / 2, this.y + h); - else { - // try to draw with "..." instead - for (int stringLength = this.value.length() - 1; stringLength >= 0; stringLength--) { - String abbrev = this.value.substring(0, stringLength) + "..."; - w = graph.getFontMetrics().stringWidth(abbrev); - if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + (this.width - w) / 2, this.y + h); - break; - } - } - } - - h += graph.getFontMetrics().getDescent() + textY1; - - // Update lower bound of text - this.limitName = this.y + h; - - if (h + textY1 >= this.height) - return; - - // Draw separator - graph.drawLine(this.x, this.y + h, this.x + this.width, this.y + h); - - if (!this.tdp.areAttributesVisible()) - return; - - // Set font size - // int attributeFontSize = Math.min (12, this.currentFontSize - 2); - int attributeFontSize = this.currentFontSize * 5 / 6; - graph.setFont(font.deriveFont((float) attributeFontSize)); - int step = graph.getFontMetrics().getHeight(); - - h += textY1; - - // Attributes - limitAttr = limitName; - for (GeneralAttribute attr : this.myAttributes) { - h += step; - if (h >= this.height - textX) { - this.limitAttr = this.y + this.height; - return; - } - - // Get the string for this parameter - String attrString = attr.toString(); - - // Try to draw it - w = graph.getFontMetrics().stringWidth(attrString); - - attrLocMap.put(attr, this.y + h); - if (w + 2 * textX < this.width) { - graph.drawString(attrString, this.x + textX, this.y + h); - //this.drawConfidentialityVerification(attr.getConfidentialityVerification(), graph, this.x, this.y + h); - } else { - // If we can't, try to draw with "..." instead - int stringLength; - for (stringLength = attrString.length() - 1; stringLength >= 0; stringLength--) { - String abbrev = attrString.substring(0, stringLength) + "..."; - w = graph.getFontMetrics().stringWidth(abbrev); - if (w + 2 * textX < this.width) { - graph.drawString(abbrev, this.x + textX, this.y + h); - //this.drawConfidentialityVerification(attr.getConfidentialityVerification(), graph, this.x, this.y + h); - break; - } - } - - if (stringLength < 0) - // skip attribute - h -= step; - } - } - } - - /*public void internalDrawing(Graphics g) { - String ster = "<<" + stereotype + ">>"; - Font f = g.getFont(); - Font fold = f; - - // - - 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, maxFontSize)); - int w0, w1, w2; - f = f.deriveFont((float) maxCurrentFontSize); - g.setFont(f); - // - while (maxCurrentFontSize > (minFontSize - 1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (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); - } - - } - - // - + + /** + * Internal Drawing function of AvatarCDBlock + * draws the rectangle, fills it with color and writes the texts where it needs to be + * @param g + */ + public void internalDrawing(Graphics g) + { + //Rectangle Color c = g.getColor(); - g.draw3DRect(x, y, width, height, true); - //g.setColor(ColorManager.AVATAR_BLOCK); Color avat = ColorManager.AVATAR_BLOCK; - int h; - h = 2 * (currentFontSize + (int) (textY1 * tdp.getZoom())) + 2; + Font f = g.getFont(); + int currentHeight = f.getSize() * 2; g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); - g.fill3DRect(x + 1, y + 1, width - 1, Math.min(h, height) - 1, true); + g.fill3DRect(x + 1, y + 1, width - 1, Math.min(currentHeight, height) - 1, true); g.setColor(c); - - // Strings - int w; - h = 0; - if (displayText) { - f = f.deriveFont((float) currentFontSize); - Font f0 = g.getFont(); - g.setFont(f.deriveFont(Font.BOLD)); - - w = g.getFontMetrics().stringWidth(ster); - h = currentFontSize + (int) (textY1 * tdp.getZoom()); - if ((w < (2 * textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w) / 2, y + h); - } - g.setFont(f0); - w = g.getFontMetrics().stringWidth(value); - h = 2 * (currentFontSize + (int) (textY1 * tdp.getZoom())); - if ((w < (2 * textX + width)) && (h < height)) { - g.drawString(value, x + (width - w) / 2, y + h); - } - limitName = y + h; - } else { - limitName = -1; - } - - g.setFont(fold); - - h = h + 2; - if (h < height) { + + //Strings + String ster = "<<" + stereotype + ">>"; + g.setFont(f.deriveFont(Font.BOLD)); + currentHeight = f.getSize(); + drawSingleString(g, ster, getCenter(g, ster), y + currentHeight); + + + g.setFont(f); +// strWidth = g.getFontMetrics().stringWidth(value); + currentHeight = 2 * f.getSize(); + drawSingleString(g, value, getCenter(g, value), y + currentHeight); + + + if (currentHeight < height) { //g.drawLine(x, y+h, x+width, y+h); g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); - g.fill3DRect(x + 1, y + h, width - 1, height - 1 - h, true); + g.fill3DRect(x + 1, y + currentHeight, width - 1, height - 1 - currentHeight, true); g.setColor(c); } - - // Icon - /*if ((width>30) && (height > (iconSize + 2*textX))) { - iconIsDrawn = true; - g.drawImage(IconManager.img5100, x + width - iconSize - textX, y + textX, null); - } else { - iconIsDrawn = false; - }*/ - - //g.setFont(fold); - - - // Icon - //g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); - //} - - + } + +//// @Override +// public void internalDrawin(Graphics g) { +// String ster = "<<" + stereotype + ">>"; +// Font f = g.getFont(); +// Font fold = f; +// +// // +// +// 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, maxFontSize)); +// int w0, w1, w2; +// f = f.deriveFont((float) maxCurrentFontSize); +// g.setFont(f); +// // +// while (maxCurrentFontSize > (minFontSize - 1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (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); +// } +// +// } +// +// // +// +// Color c = g.getColor(); +// +// g.draw3DRect(x, y, width, height, true); +// +// //g.setColor(ColorManager.AVATAR_BLOCK); +// Color avat = ColorManager.AVATAR_BLOCK; +// int h; +// h = 2 * (currentFontSize + (int) (textY * tdp.getZoom())) + 2; +// g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); +// g.fill3DRect(x + 1, y + 1, width - 1, Math.min(h, height) - 1, true); +// g.setColor(c); +// +// // Strings +// int w; +// h = 0; +// if (displayText) { +// f = f.deriveFont((float) currentFontSize); +// Font f0 = g.getFont(); +// g.setFont(f.deriveFont(Font.BOLD)); +// +// w = g.getFontMetrics().stringWidth(ster); +// h = currentFontSize + (int) (textY * tdp.getZoom()); +// if ((w < (2 * textX + width)) && (h < height)) { +// drawSingleString(g, ster, x + (width - w) / 2, y + h); +// } +// g.setFont(f0); +// w = g.getFontMetrics().stringWidth(value); +// h = 2 * (currentFontSize + (int) (textY * tdp.getZoom())); +// if ((w < (2 * textX + width)) && (h < height)) { +// drawSingleString(g, value, x + (width - w) / 2, y + h); +// } +//// limitName = y + h; +// } else { +//// limitName = -1; +// } +// +// g.setFont(fold); +// +// h = h + 2; +// if (h < height) { +// //g.drawLine(x, y+h, x+width, y+h); +// g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); +// g.fill3DRect(x + 1, y + h, width - 1, height - 1 - h, true); +// g.setColor(c); +// } +// +// // Icon +// /*if ((width>30) && (height > (iconSize + 2*textX))) { +// iconIsDrawn = true; +// g.drawImage(IconManager.img5100, x + width - iconSize - textX, y + textX, null); +// } else { +// iconIsDrawn = false; +// }*/ +// +// g.setFont(fold); +// +// +// // Icon +// //g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); +// //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); +// } + + + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -465,8 +315,8 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S public String getNodeName() { return name; } - - public boolean editOndoubleClick(JFrame frame) { + /* + * public boolean editOndoubleClick(JFrame frame) { JDialogGeneralAttribute jda = new JDialogGeneralAttribute(myAttributes, null, frame, "Setting attributes of " + value, "Attribute", stereotype + "/" + value); @@ -481,10 +331,21 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S //String text = getName() + ": "; String s = jda.getValue(); - + if (s == null) { return false; } + * */ + @Override + public boolean editOndoubleClick(JFrame frame) { + + oldValue = getStereotype() + "/" + getValue(); + + //String text = getName() + ": "; + String s = (String) JOptionPane.showInputDialog(frame, "Stereotype / identifier", + "Setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, + null, + getStereotype() + "/" + getValue()); if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { //boolean b; @@ -556,17 +417,19 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return false; } - + + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof AvatarCDBlock; } - - + + @Override public int getType() { return TGComponentManager.ACD_BLOCK; } - + + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { boolean swallowed = false; @@ -612,7 +475,8 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return true; } - + + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeMyInternalComponent(tgc, false); } @@ -658,7 +522,8 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return value; } - + + @Override public void hasBeenResized() { for (int i = 0; i < nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarCDBlock) { @@ -671,7 +536,8 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S } } - + + @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarCDBlock)) { // Too large to fit in the father? -> resize it! @@ -714,11 +580,13 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S return false; } - + + @Override public int getDefaultConnector() { return TGComponentManager.ACD_COMPOSITION_CONNECTOR; } - + + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<stereotype value=\"" + GTURTLEModeling.transformString(getStereotype())); @@ -763,7 +631,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S if (elt.getTagName().equals("stereotype")) { stereotype = elt.getAttribute("value"); } - + //stay or no ?? FIXME if (elt.getTagName().equals("Attribute")) { // type = elt.getAttribute("type"); @@ -777,7 +645,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S GeneralAttribute ga = new GeneralAttribute(id, valueAtt, type); this.myAttributes.add(ga); - } + }//FIXME end } } } diff --git a/src/main/java/ui/avatarcd/AvatarCDCompositionConnector.java b/src/main/java/ui/avatarcd/AvatarCDCompositionConnector.java index 6ec16910c44bbfb3835b3071255276c21e27f12d..27390ba3d0d21a943d2b03c1d95372d68ebd6dde 100644 --- a/src/main/java/ui/avatarcd/AvatarCDCompositionConnector.java +++ b/src/main/java/ui/avatarcd/AvatarCDCompositionConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarcd; - import ui.*; import ui.util.IconManager; @@ -55,27 +51,28 @@ import java.util.Vector; * @version 1.0 31/08/2011 * @author Ludovic APVRILLE */ -public class AvatarCDCompositionConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent{ +public class AvatarCDCompositionConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { protected int d = 20; protected int D = 26; //protected int widthValue, heightValue, maxWidthValue, h; protected Polygon p; protected int xp1, xp2, yp1, yp2; - protected double oldScaleFactor; - protected boolean rescaled; +// protected double oldScaleFactor; +// protected boolean rescaled; public AvatarCDCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; - value = "{info}"; editable = true; - oldScaleFactor = tdp.getZoom(); - rescaled = true; +// oldScaleFactor = tdp.getZoom(); +// rescaled = true; } + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { if ((p == null) || (rescaled) || (xp1 != x1) || (xp2 != x2) || (yp1 != y1) || (yp2 != y2)){ p = new Polygon(); @@ -83,7 +80,7 @@ public class AvatarCDCompositionConnector extends TGConnectorWithCommentConnect xp2 = x2; yp1 = y1; yp2 = y2; - Double alpha; + //Double alpha; int dd = (int)(d*tdp.getZoom()); int DD = (int)(D*tdp.getZoom()); @@ -143,6 +140,7 @@ public class AvatarCDCompositionConnector extends TGConnectorWithCommentConnect rescaled = false; } + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (p != null) { if (p.contains(x1, y1)) { @@ -153,35 +151,33 @@ public class AvatarCDCompositionConnector extends TGConnectorWithCommentConnect return null; } - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - rescaled = true; - } - +// Issue #31 Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// rescaled = true; +// } + @Override public int getType() { return TGComponentManager.ACD_COMPOSITION_CONNECTOR; } - - - } diff --git a/src/main/java/ui/avatarcd/AvatarCDConnectingPoint.java b/src/main/java/ui/avatarcd/AvatarCDConnectingPoint.java index 2dc72b9407301ad70724fb80f0d47159912caf7e..cb7d892fa8262f5b3909c3b15f181f20b17cd1f5 100644 --- a/src/main/java/ui/avatarcd/AvatarCDConnectingPoint.java +++ b/src/main/java/ui/avatarcd/AvatarCDConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarcd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -53,17 +49,17 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 31/08/2011 * @author Ludovic APVRILLE */ -public class AvatarCDConnectingPoint extends TGConnectingPointWidthHeight { +public class AvatarCDConnectingPoint extends TGConnectingPointWidthHeight { public AvatarCDConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { if (type == TGComponentManager.ACD_COMPOSITION_CONNECTOR) { return true; } return type == TGComponentManager.ACD_ASSOCIATION_CONNECTOR; } - } diff --git a/src/main/java/ui/avatarcd/AvatarCDPanel.java b/src/main/java/ui/avatarcd/AvatarCDPanel.java index 84619c608d8b5db3bed5bed99f9430bb61907310..98ddcc98b7402dab85b6c268793d3f81e9e92317 100644 --- a/src/main/java/ui/avatarcd/AvatarCDPanel.java +++ b/src/main/java/ui/avatarcd/AvatarCDPanel.java @@ -71,41 +71,52 @@ public class AvatarCDPanel extends TDiagramPanel implements TDPWithAttributes{ addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return true; } + @Override public boolean actionOnAdd(TGComponent tgc) { return false; } + + @Override public boolean actionOnValueChanged(TGComponent tgc) { return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { return false; } + @Override public String getXMLHead() { return "<AvatarCDPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } + @Override public String getXMLTail() { return "</AvatarCDPanel>"; } + @Override public String getXMLSelectedHead() { return "<AvatarCDPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</AvatarCDPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<AvatarCDPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</AvatarCDPanelCopy>"; } @@ -119,7 +130,8 @@ public class AvatarCDPanel extends TDiagramPanel implements TDPWithAttributes{ } - + + @Override public boolean hasAutoConnect() { return false; } diff --git a/src/main/java/ui/avatarcd/AvatarCDToolBar.java b/src/main/java/ui/avatarcd/AvatarCDToolBar.java index 2f2c77b03da492323eba9489a8cecf5f54ba2faa..5165be73d1fc2f415383bf1b4a0461792f9a44a7 100644 --- a/src/main/java/ui/avatarcd/AvatarCDToolBar.java +++ b/src/main/java/ui/avatarcd/AvatarCDToolBar.java @@ -66,6 +66,7 @@ public class AvatarCDToolBar extends TToolBar { } + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -88,6 +89,7 @@ public class AvatarCDToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(!b); } + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/avatardd/ADDArtifact.java b/src/main/java/ui/avatardd/ADDArtifact.java index 168176f98ae540799e9edccb7271b88f60ae759b..149074f2acfbdf529951f89a4f4be9a0c671cb94 100755 --- a/src/main/java/ui/avatardd/ADDArtifact.java +++ b/src/main/java/ui/avatardd/ADDArtifact.java @@ -56,14 +56,22 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class ADDArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int textY2 = 35; - protected int space = 5; - protected int fileX = 20; - protected int fileY = 25; - protected int cran = 5; +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; + + // Issue #31 + private static final int SPACE = 5; + private static final int CRAN = 5; + private static final int FILE_X = 20; + private static final int FILE_Y = 25; + + +// protected int textY2 = 35; +// protected int space = 5; +// protected int fileX = 20; +// protected int fileY = 25; +// protected int cran = 5; protected String oldValue = ""; protected String referenceTaskName = "referenceToBlock"; @@ -71,10 +79,13 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe public ADDArtifact(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); - + //Issue #31 + textY = 15; + textX = 5; width = 75; height = 40; minWidth = 75; + initScaling(75,40); nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -104,25 +115,32 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe g.fillRect(x+1, y+1, width-1, height-1); g.setColor(c); + // Issue #31 + final int space = scale( SPACE ); + final int marginFileX = scale( SPACE + FILE_X ); + final int marginFileY = scale( SPACE + FILE_Y ); + final int marginCran = scale( SPACE + CRAN ); + //g.drawRoundRect(x, y, width, height, arc, arc); - g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); - g.drawLine(x+width-space-fileX, y + space, x+width-space-cran, y+space); - g.drawLine(x+width-space-cran, y+space, x+width-space, y+space + cran); - g.drawLine(x+width-space, y+space + cran, x+width-space, y+space+fileY); - g.drawLine(x+width-space, y+space+fileY, x+width-space-fileX, y+space+fileY); - g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); - g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + g.drawLine(x+width-marginFileX, y + space, x+width-marginFileX, y+marginFileY); + g.drawLine(x+width-marginFileX, y + space, x+width-marginCran, y+space); + g.drawLine(x+width-marginCran, y+space, x+width-space, y+marginCran); + g.drawLine(x+width-space, y+marginCran, x+width-space, y+marginFileY); + g.drawLine(x+width-space, y+marginFileY, x+width-marginFileX, y+marginFileY); + g.drawLine(x+width-marginCran, y+space, x+width-marginCran, y+marginCran); + g.drawLine(x+width-marginCran, y+marginCran, x + width-space, y+marginCran); - g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); + g.drawImage(scale(IconManager.img9), x + scale(width-marginFileX + 3), y + scale(space + 7), null); - g.drawString(value, x + textX , y + textY); + drawSingleString(g, value, x + textX , y + textY); } public void setValue(String val, Graphics g) { + final int marginFileX = scale( SPACE + FILE_X ); oldValue = value; int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); + int w1 = Math.max(minWidth, w + 2 * textX + marginFileX); // if (w1 != width) { @@ -284,7 +302,8 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe public String getTaskName() { return taskName; } - + + @Override public String getAttributes() { return ""; } diff --git a/src/main/java/ui/avatardd/ADDBlockArtifact.java b/src/main/java/ui/avatardd/ADDBlockArtifact.java index b299365c4fa6c87d324d85970e89e77fd0833219..f1a831bebdc73e9ebb9682602c3619141149c495 100755 --- a/src/main/java/ui/avatardd/ADDBlockArtifact.java +++ b/src/main/java/ui/avatardd/ADDBlockArtifact.java @@ -58,8 +58,8 @@ import java.awt.*; */ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int textY2 = 35; protected int space = 5; protected int fileX = 20; @@ -73,9 +73,12 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa public ADDBlockArtifact(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); + textY = 15; + textX = 5; width = 75; height = 40; minWidth = 75; + initScaling(75,40); nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -114,9 +117,12 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + + g.drawImage(scale(IconManager.img9), x+scale(width-space-fileX + 3), y + scale(space + 7), null); + //g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); - g.drawString(value, x + textX , y + textY); + drawSingleString(g, value, x + textX , y + textY); } diff --git a/src/main/java/ui/avatardd/ADDBridgeNode.java b/src/main/java/ui/avatardd/ADDBridgeNode.java index 5ce1b26a92b0a05c08744b48cc12da46195a4c58..a8153ac62e84231d158c1f895a7db03a2c587fb4 100755 --- a/src/main/java/ui/avatardd/ADDBridgeNode.java +++ b/src/main/java/ui/avatardd/ADDBridgeNode.java @@ -56,7 +56,7 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttributes { - private int textY1 = 15; +// private int textY1 = 15; private int textY2 = 30; private int derivationx = 2; private int derivationy = 3; @@ -65,10 +65,13 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute public ADDBridgeNode(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); + //Issue #31 + textY = 15; width = 250; height = 100; minWidth = 100; minHeight = 35; + initScaling(250,100); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -128,14 +131,20 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute // Strings String ster = "<<" + stereotype + ">>"; int w = g.getFontMetrics().stringWidth(ster); - g.drawString(ster, x + (width - w)/2, y + textY1); + drawSingleString(g, ster, x + (width - w)/2, y + textY); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1104.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1104.getImage(), x + 4, y + 4, null); + + int borders = scale(4); + g.drawImage(scale(IconManager.imgic1104.getImage()), x + borders, y + borders, null); + g.drawImage(scale(IconManager.img9), x + width - scale(20), y + borders, null); + +// g.drawImage(IconManager.imgic1104.getImage(), x + 4, y + 4, null); //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } @Override @@ -298,6 +307,7 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute } } + @Override public String getAttributes() { String attr = ""; //attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; diff --git a/src/main/java/ui/avatardd/ADDBusNode.java b/src/main/java/ui/avatardd/ADDBusNode.java index 58c39db4cd7f38d1771669085cd3678dccc2ca08..90a5a69db33a0538381ab0ca1c682aff90cb91be 100755 --- a/src/main/java/ui/avatardd/ADDBusNode.java +++ b/src/main/java/ui/avatardd/ADDBusNode.java @@ -57,7 +57,7 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { - private int textY1 = 15; +// private int textY1 = 15; private int textY2 = 30; private int derivationx = 2; private int derivationy = 3; @@ -71,12 +71,15 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { public ADDBusNode(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); - + + //issue #31 + textY = 15; width = 250; height = 50; minWidth = 100; minHeight = 50; - + initScaling(250, 50); + nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -138,15 +141,19 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY); g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); + int borders = scale(4); + g.drawImage(scale(IconManager.imgic1102.getImage()), x + borders, y + borders, null); + g.drawImage(scale(IconManager.img9), x + width - scale(20), y + borders, null); g.drawImage(IconManager.imgic1102.getImage(), x + 4, y + 4, null); //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } @Override @@ -360,6 +367,7 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { } } + @Override public String getAttributes() { String attr = ""; attr += "index = " + index + "\n"; diff --git a/src/main/java/ui/avatardd/ADDCPUNode.java b/src/main/java/ui/avatardd/ADDCPUNode.java index 540836b690b3f844e66fb60b84d6942c9bae2982..4df6aa7b919e528d5c6c97693419738553cb2c1c 100755 --- a/src/main/java/ui/avatardd/ADDCPUNode.java +++ b/src/main/java/ui/avatardd/ADDCPUNode.java @@ -148,10 +148,10 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); diff --git a/src/main/java/ui/avatardd/ADDChannelArtifact.java b/src/main/java/ui/avatardd/ADDChannelArtifact.java index 73d73194c1bf0d58ace130664ce980a9087627fb..6259f55b8b72ada03fb1a2cb3fbe52072d637f47 100755 --- a/src/main/java/ui/avatardd/ADDChannelArtifact.java +++ b/src/main/java/ui/avatardd/ADDChannelArtifact.java @@ -58,8 +58,8 @@ import java.awt.*; */ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int textY2 = 35; protected int space = 5; protected int fileX = 20; @@ -73,11 +73,15 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S public ADDChannelArtifact(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); - + + textY = 15; + textX = 5; width = 75; height = 40; minWidth = 75; + initScaling(75, 40); + nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -115,9 +119,11 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + g.drawImage(scale(IconManager.img9), x+scale(width-space-fileX + 3), y + scale(space + 7), null); //g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); - g.drawString(value, x + textX , y + textY); + + drawSingleString(g, value, x + textX , y + textY); } public void setValue(String val, Graphics g) { @@ -298,6 +304,7 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S return fullChannelName; } + @Override public String getStatusInformation() { return "Name of the channel: " + fullChannelName; } diff --git a/src/main/java/ui/avatardd/ADDClusterNode.java b/src/main/java/ui/avatardd/ADDClusterNode.java index 93bb2ffd26c6ead023d815ce73d8f8cd25c07385..31db31cc149c9e04cda192e19ddb924b7b948fbf 100644 --- a/src/main/java/ui/avatardd/ADDClusterNode.java +++ b/src/main/java/ui/avatardd/ADDClusterNode.java @@ -59,7 +59,7 @@ import java.awt.*; */ public class ADDClusterNode extends ADDNode implements WithAttributes { - private int textY1 = 15; +// private int textY1 = 15; private int textY2 = 30; private int derivationx = 2; private int derivationy = 3; @@ -72,11 +72,13 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { public ADDClusterNode(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); + textY = 15; width = 250; height = 200; minWidth = 150; minHeight = 100; - + initScaling(250, 200); + nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -135,16 +137,23 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY); g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon - g.drawImage(IconManager.imgic8006.getImage(), x + 4, y + 4, null); + + int borders = scale(4); + g.drawImage(scale(IconManager.imgic8006.getImage()), x + borders, y + borders, null); + g.drawImage(scale(IconManager.img9), x + width - scale(20), y + borders, null); + +// g.drawImage(IconManager.imgic8006.getImage(), x + 4, y + 4, null); //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { Polygon pol = new Polygon(); pol.addPoint(x, y); @@ -171,6 +180,7 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { return index; } + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { int i; MainGUI mgui = getTDiagramPanel().getMainGUI(); @@ -215,10 +225,12 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { return false; } + @Override public int getType() { return TGComponentManager.ADD_CLUSTERNODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -229,6 +241,7 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { return new String(sb); } + @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ try { NodeList nli; @@ -266,10 +279,12 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { } } + @Override public int getDefaultConnector() { return TGComponentManager.ADD_CONNECTOR; } + @Override public String getAttributes() { String attr = ""; attr += "index = " + index + "\n"; diff --git a/src/main/java/ui/avatardd/ADDCommunicationNode.java b/src/main/java/ui/avatardd/ADDCommunicationNode.java index 2cba7bfea06095d516dd42c93088e527cebee3a4..a79ff3650862e5d6f7932716b06cc5a6e211dd59 100755 --- a/src/main/java/ui/avatardd/ADDCommunicationNode.java +++ b/src/main/java/ui/avatardd/ADDCommunicationNode.java @@ -58,9 +58,8 @@ public abstract class ADDCommunicationNode extends ADDNode { public ADDCommunicationNode(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); } - - - + + @Override public int getDefaultConnector() { return TGComponentManager.ADD_CONNECTOR; } diff --git a/src/main/java/ui/avatardd/ADDConnectingPoint.java b/src/main/java/ui/avatardd/ADDConnectingPoint.java index 8f0bd44e4b24e349947ffa3bc7ef1aa58af134a7..46001c38860be43cd3e9b8829731c869166db4e0 100755 --- a/src/main/java/ui/avatardd/ADDConnectingPoint.java +++ b/src/main/java/ui/avatardd/ADDConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatardd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -53,14 +49,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 30/06/2014 * @author Ludovic APVRILLE */ -public class ADDConnectingPoint extends TGConnectingPointWidthHeight{ +public class ADDConnectingPoint extends TGConnectingPointWidthHeight { public ADDConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.ADD_CONNECTOR; } - } diff --git a/src/main/java/ui/avatardd/ADDConnector.java b/src/main/java/ui/avatardd/ADDConnector.java index 07e0dcba19b413c8c1e071a3a6622ed9248ba92a..d6523bcb8b530170830f195a5dc12d4346890872 100755 --- a/src/main/java/ui/avatardd/ADDConnector.java +++ b/src/main/java/ui/avatardd/ADDConnector.java @@ -90,6 +90,7 @@ public class ADDConnector extends TGConnector { return p2; } + @Override public boolean editOndoubleClick(JFrame frame) { /*JDialogTMLConnectorNode dialog = new JDialogTMLConnectorNode(frame, "Setting connector attributes", this); dialog.setSize(350, 300); @@ -104,7 +105,8 @@ public class ADDConnector extends TGConnector { return true; } - + + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ g.drawLine(x1, y1, x2, y2); @@ -122,12 +124,14 @@ public class ADDConnector extends TGConnector { public boolean hasASpy() { return hasASpy; } - + + @Override public int getType() { return TGComponentManager.ADD_CONNECTOR; } - + + @Override public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem generate = null; @@ -143,6 +147,7 @@ public class ADDConnector extends TGConnector { componentMenu.add(generate); } + @Override public boolean eventOnPopup(ActionEvent e) { String s = e.getActionCommand(); TraceManager.addDev("action: " + s); @@ -157,7 +162,8 @@ public class ADDConnector extends TGConnector { return true; } - + + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<spy value=\"" + hasASpy + "\" />\n"); diff --git a/src/main/java/ui/avatardd/ADDCoproMWMRNode.java b/src/main/java/ui/avatardd/ADDCoproMWMRNode.java index 6c1b39f75d6cceaf5f8c644ba48a099a2c0ff79f..5930f1aeaf7bea12ca623724be738bf982090196 100755 --- a/src/main/java/ui/avatardd/ADDCoproMWMRNode.java +++ b/src/main/java/ui/avatardd/ADDCoproMWMRNode.java @@ -147,10 +147,10 @@ public class ADDCoproMWMRNode extends ADDCommunicationNode implements WithAttrib 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); w = g.getFontMetrics().stringWidth(name); g.setFont(f); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); diff --git a/src/main/java/ui/avatardd/ADDCrossbarNode.java b/src/main/java/ui/avatardd/ADDCrossbarNode.java index 866a0282165315c908ffc01b7778319fa52f63b1..e2c04bae55e2fddca8d5e1a265c85efcde571fb4 100755 --- a/src/main/java/ui/avatardd/ADDCrossbarNode.java +++ b/src/main/java/ui/avatardd/ADDCrossbarNode.java @@ -142,10 +142,10 @@ public class ADDCrossbarNode extends ADDCommunicationNode implements WithAttribu 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); diff --git a/src/main/java/ui/avatardd/ADDDMANode.java b/src/main/java/ui/avatardd/ADDDMANode.java index b8e5db17b18d5565aae2297c0956f35e9fcc26a1..712c90d2d544df593147ef30c841e00c62e240e0 100755 --- a/src/main/java/ui/avatardd/ADDDMANode.java +++ b/src/main/java/ui/avatardd/ADDDMANode.java @@ -132,10 +132,10 @@ public class ADDDMANode extends ADDCommunicationNode implements WithAttributes { 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); w = g.getFontMetrics().stringWidth(name); g.setFont(f); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); @@ -169,10 +169,10 @@ public class ADDDMANode extends ADDCommunicationNode implements WithAttributes { } public boolean editOndoubleClick(JFrame frame) { - boolean error = false; - String errors = ""; - int tmp; - String tmpName; + //boolean error = false; + // String errors = ""; + //int tmp; + //String tmpName; /*JDialogDMANode dialog = new JDialogDMANode(frame, "Setting Memory attributes", this); dialog.setSize(400, 300); diff --git a/src/main/java/ui/avatardd/ADDDiagramPanel.java b/src/main/java/ui/avatardd/ADDDiagramPanel.java index 0edd4d53431698e437971440ff1a7c6986ec411f..600efaaa1dd9b6b7f6b0ee99e82f3c5dbc226f0a 100755 --- a/src/main/java/ui/avatardd/ADDDiagramPanel.java +++ b/src/main/java/ui/avatardd/ADDDiagramPanel.java @@ -37,16 +37,19 @@ * knowledge of the CeCILL license and that you accept its terms. */ - package ui.avatardd; +import java.util.Iterator; +import java.util.Vector; -import myutil.TraceManager; import org.w3c.dom.Element; -import ui.*; -import java.util.ListIterator; -import java.util.Vector; +import myutil.TraceManager; +import ui.MainGUI; +import ui.TDPWithAttributes; +import ui.TDiagramPanel; +import ui.TGComponent; +import ui.TToolBar; /** * Class ADDDiagramPanel @@ -66,6 +69,7 @@ public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { // /*if (tgc instanceof TCDTClass) { @@ -86,6 +90,7 @@ public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes return false; } + @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -96,6 +101,7 @@ public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -106,7 +112,8 @@ public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes return false; } - public boolean actionOnValueChanged(TGComponent tgc) { + @Override + public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); }*/ @@ -121,26 +128,32 @@ public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes masterClockFrequency = _masterClockFrequency; } + @Override public String getXMLHead() { return "<ADDDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + displayClock() + " >"; } + @Override public String getXMLTail() { return "</ADDDiagramPanel>"; } + @Override public String getXMLSelectedHead() { return "<ADDDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</ADDDiagramPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<ADDDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</ADDDiagramPanelCopy>"; } @@ -184,18 +197,17 @@ public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes } } - public boolean isMapped(String _ref, String _name) { - ListIterator iterator = componentList.listIterator(); + Iterator<TGComponent> iterator = componentList.listIterator(); TGComponent tgc; - ADDCPUNode node; - Vector v; + // ADDCPUNode node; + Vector<ADDBlockArtifact> v; ADDBlockArtifact artifact; int i; String name = _ref + "::" + _name; while (iterator.hasNext()) { - tgc = (TGComponent) (iterator.next()); + tgc = iterator.next(); if (tgc instanceof ADDCPUNode) { v = ((ADDCPUNode) (tgc)).getArtifactList(); for (i = 0; i < v.size(); i++) { @@ -211,16 +223,16 @@ public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes } public boolean isChannelMapped(String _ref, String _name) { - ListIterator iterator = componentList.listIterator(); + Iterator<TGComponent> iterator = componentList.listIterator(); TGComponent tgc; - ADDMemoryNode node; - Vector v; + //ADDMemoryNode node; + Vector<ADDChannelArtifact> v; ADDChannelArtifact artifact; int i; String name = _ref + "::" + _name; while (iterator.hasNext()) { - tgc = (TGComponent) (iterator.next()); + tgc = iterator.next(); if (tgc instanceof ADDRAMNode) { v = ((ADDRAMNode) (tgc)).getArtifactList(); for (i = 0; i < v.size(); i++) { diff --git a/src/main/java/ui/avatardd/ADDDiagramToolBar.java b/src/main/java/ui/avatardd/ADDDiagramToolBar.java index 16d7c880187cabfe18a5b5d6afe3e17a13a4abaf..5da7b72e0ddaab940aa9b4d830b06269c788c783 100755 --- a/src/main/java/ui/avatardd/ADDDiagramToolBar.java +++ b/src/main/java/ui/avatardd/ADDDiagramToolBar.java @@ -92,7 +92,11 @@ public class ADDDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ADD_CLUSTERNODE].setEnabled(b); mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); // julien ------------------------------------------------- diff --git a/src/main/java/ui/avatardd/ADDICUNode.java b/src/main/java/ui/avatardd/ADDICUNode.java index 90a1dc99d75730e041eeb4761a040dd3a523258c..76877f11be72fe3a61528bc5e67f8b51a655d24f 100755 --- a/src/main/java/ui/avatardd/ADDICUNode.java +++ b/src/main/java/ui/avatardd/ADDICUNode.java @@ -137,10 +137,10 @@ public class ADDICUNode extends ADDCommunicationNode implements WithAttributes { 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); w = g.getFontMetrics().stringWidth(name); g.setFont(f); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); diff --git a/src/main/java/ui/avatardd/ADDMemoryNode.java b/src/main/java/ui/avatardd/ADDMemoryNode.java index 65f4feca5ce2d780c6dd4de7c1c16e9d01493978..e62ed625f205a60e207b83b3015c82a46f06a9e1 100755 --- a/src/main/java/ui/avatardd/ADDMemoryNode.java +++ b/src/main/java/ui/avatardd/ADDMemoryNode.java @@ -101,10 +101,10 @@ public abstract class ADDMemoryNode extends ADDCommunicationNode implements With 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); w = g.getFontMetrics().stringWidth(name); g.setFont(f); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); diff --git a/src/main/java/ui/avatardd/ADDTTYNode.java b/src/main/java/ui/avatardd/ADDTTYNode.java index 8b0637361048ec076ab7ff2dadaf01e2b697e550..f8267292d9635cd07d59277d60f994795f4256ab 100755 --- a/src/main/java/ui/avatardd/ADDTTYNode.java +++ b/src/main/java/ui/avatardd/ADDTTYNode.java @@ -137,10 +137,10 @@ public class ADDTTYNode extends ADDNode implements WithAttributes { 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); diff --git a/src/main/java/ui/avatardd/ADDTimerNode.java b/src/main/java/ui/avatardd/ADDTimerNode.java index b090e33677dbc8ed1aaff14e7e8b1fac62e8a561..1d5729bc1bb9edb401e82096ad023c33e5e93bc9 100755 --- a/src/main/java/ui/avatardd/ADDTimerNode.java +++ b/src/main/java/ui/avatardd/ADDTimerNode.java @@ -137,10 +137,10 @@ public class ADDTimerNode extends ADDCommunicationNode implements WithAttributes 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); w = g.getFontMetrics().stringWidth(name); g.setFont(f); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); diff --git a/src/main/java/ui/avatardd/ADDVgmnNode.java b/src/main/java/ui/avatardd/ADDVgmnNode.java index 364f6e5a8649c3873f6a11bd5c0d3e2ecfeeed2c..9f86a0f24b8546436aaa530f97e4e4496cddab40 100755 --- a/src/main/java/ui/avatardd/ADDVgmnNode.java +++ b/src/main/java/ui/avatardd/ADDVgmnNode.java @@ -142,10 +142,10 @@ public class ADDVgmnNode extends ADDCommunicationNode implements WithAttributes 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); + drawSingleString(g, ster, x + (width - w)/2, y + textY1); g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g, name, x + (width - w)/2, y + textY2); // Icon //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); diff --git a/src/main/java/ui/avatarmad/AvatarMADAssumption.java b/src/main/java/ui/avatarmad/AvatarMADAssumption.java index 57ad6ec07a02086c7ac2e257cf872679303fa730..a3f25dabd118459eab042f603a8612dd0cc7a855 100644 --- a/src/main/java/ui/avatarmad/AvatarMADAssumption.java +++ b/src/main/java/ui/avatarmad/AvatarMADAssumption.java @@ -64,8 +64,8 @@ import java.awt.*; */ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implements WithAttributes, TGAutoAdjust { public String oldValue; - protected int textX = 5; - protected int textY = 22; + //protected int textX = 5; + //protected int textY = 22; protected int lineHeight = 30; private double dlineHeight = 0.0; //protected int reqType = 0; @@ -74,11 +74,11 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem protected Graphics graphics; //protected int iconSize = 30; - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; +// private Font myFont, myFontB; + // private int maxFontSize = 30; +// private int minFontSize = 4; private int currentFontSize = -1; - private boolean displayText = true; +// private boolean displayText = true; public final static String[] ASSUMPTION_TYPE_STR = {"<<System Assumption>>", "<<Environment Assumption>>"}; @@ -106,12 +106,15 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem // Icon private int iconSize = 18; - private boolean iconIsDrawn = false; + // private boolean iconIsDrawn = false; public AvatarMADAssumption(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); - + + textX = 5; + textY = 22; initScaling(200, 120); + oldScaleFactor = tdp.getZoom(); dlineHeight = lineHeight * oldScaleFactor; lineHeight = (int)dlineHeight; @@ -157,7 +160,7 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem nbInternalTGComponent = 0; //tgcomponent = new TGComponent[nbInternalTGComponent]; - int h = 1; + // int h = 1; //TAttributeRequirement tgc0; //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); //tgcomponent[0] = tgc0; @@ -188,156 +191,235 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem public void makeValue() { texts = Conversion.wrapText(text); } - - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - int w, c; - int size; - - if (texts == null) { - makeValue(); - } - - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; - - int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); - - g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + + /** + * Issue #31 + * @param g + */ + @Override + public void internalDrawing(Graphics g) + { + // Rectangle + Font font = g.getFont(); + g.drawRect(x, y, width, height); + g.drawLine(x, y + lineHeight, x + width, y + lineHeight); + + //Filling g.setColor(ColorManager.AVATAR_ASSUMPTION_TOP); g.fillRect(x+1, y+1, width-1, lineHeight-1); g.setColor(ColorManager.AVATAR_ASSUMPTION_ATTRIBUTES); g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - - drawLimitedString(g, ASSUMPTION_TYPE_STR[type], x, y + size, width, 1); - - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - /*if (verified) { - if (satisfied) { - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.green); - g.drawLine(x+width-2, y-6+lineHeight, x+width-6, y-2+lineHeight); - g.drawLine(x+width-6, y-3+lineHeight, x+width-8, y-6+lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } else { - //g.drawString("acc", x + width - 10, y+height-10); - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.red); - g.drawLine(x+width-2, y-2+lineHeight, x+width-8, y-8+lineHeight); - g.drawLine(x+width-8, y-2+lineHeight, x+width-2, y-8+lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } - }*/ - - g.setFont(myFont); - String texti = "Text"; - String s ; - int i; - size = lineHeight + currentFontSize; - - //ID - /*if (size < (height - 2)) { - drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0); - } - size += currentFontSize;*/ - - //text - for(i=0; i<texts.length; i++) { - if (size < (height - 2)) { - s = texts[i]; - if (i == 0) { - s = texti + "=\"" + s; - } - if (i == (texts.length - 1)) { - s = s + "\""; - } - drawLimitedString(g, s, x + textX, y + size, width, 0); - } - size += currentFontSize; - + + //check readability + if (!isTextReadable(g)) + return; + + //Strings titles + currentFontSize = font.getSize(); + drawLimitedString(g, ASSUMPTION_TYPE_STR[type], x, y + currentFontSize , width, 1); + g.setFont(font.deriveFont(Font.PLAIN)); + drawLimitedString(g, value, x, y + currentFontSize * 2, width, 1); + + if (texts == null) + makeValue(); + + int current = lineHeight; + for (int i = 0; i < texts.length; i++) { + if (current > height - 5) + return; + current += currentFontSize; + displayOnTheNextLine(g, i, current); //display texts } - if (size < (height - 2)) { - drawLimitedString(g, "Durability=\"" + DURABILITY_TYPE[durability] + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Source=\"" + SOURCE_TYPE[source] + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Status=\"" + STATUS_TYPE[status] + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Scope=\"" + LIMITATION_TYPE[limitation] + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - } - } - } + + //Other strings + current += currentFontSize; + if (current < (height - 2)) { + drawLimitedString(g, "Durability=\"" + DURABILITY_TYPE[durability] + "\"", x + textX, y + current, width, 0); + current += currentFontSize; + if (current < (height - 2)) { + drawLimitedString(g, "Source=\"" + SOURCE_TYPE[source] + "\"", x + textX, y + current, width, 0); + current += currentFontSize; + if (current < (height - 2)) { + drawLimitedString(g, "Status=\"" + STATUS_TYPE[status] + "\"", x + textX, y + current, width, 0); + current += currentFontSize; + if (current < (height - 2)) { + drawLimitedString(g, "Scope=\"" + LIMITATION_TYPE[limitation] + "\"", x + textX, y + current, width, 0); + current += currentFontSize; + } + } + } } - // Type and risk - /*if (size < (height - 2)) { - drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - - drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0); - - size += currentFontSize; - if (size < (height - 2)) { - - if (reqType == SECURITY_REQ) { - drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0); - } - - if (reqType == SAFETY_REQ) { - drawLimitedString(g, "Violated action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - } - } - } - }*/ - - - g.setFont(f); + //Icon + g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 2), y + scale(3), Color.yellow, null); + } + + private void displayOnTheNextLine(Graphics g, int i, int current) + { + String s = texts[i]; + if (i == 0) + s = "Text=\"" + s; + if (i == (texts.length - 1)) + s += "\""; + drawLimitedString(g, s, x + textX, y + current, width, 0); } + +// @Override +// public void internalDrawing(Graphics g) { +// Font f = g.getFont(); +// // Font fold = f; +// // int w, c; +// int size; +// +// if (texts == null) { +// makeValue(); +// } +// +// if (!tdp.isScaled()) { +// graphics = g; +// } +// +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// // +// myFont = f.deriveFont((float)currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } +// +// displayText = currentFontSize >= minFontSize; +// +// // int h = g.getFontMetrics().getHeight(); +// +// g.drawRect(x, y, width, height); +// +// g.drawLine(x, y+lineHeight, x+width, y+lineHeight); +// g.setColor(ColorManager.AVATAR_ASSUMPTION_TOP); +// g.fillRect(x+1, y+1, width-1, lineHeight-1); +// g.setColor(ColorManager.AVATAR_ASSUMPTION_ATTRIBUTES); +// g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); +// ColorManager.setColor(g, getState(), 0); +// if ((lineHeight > 23) && (width > 23)){ +// g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 1), y + scale(3), Color.yellow, null); +// } +// +// int fontSize = g.getFont().getSize(); +// +// if (displayText) { +// size = currentFontSize - 2; +// g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); +// +// drawLimitedString(g, ASSUMPTION_TYPE_STR[type], x, y + size, width, 1); +// +// size += currentFontSize; +// g.setFont(myFontB); +// // w = g.getFontMetrics().stringWidth(value); +// drawLimitedString(g, value, x, y + size, width, 1); +// +// } +// +// /*if (verified) { +// if (satisfied) { +// Color tmp = g.getColor(); +// GraphicLib.setMediumStroke(g); +// g.setColor(Color.green); +// g.drawLine(x+width-2, y-6+lineHeight, x+width-6, y-2+lineHeight); +// g.drawLine(x+width-6, y-3+lineHeight, x+width-8, y-6+lineHeight); +// g.setColor(tmp); +// GraphicLib.setNormalStroke(g); +// } else { +// //g.drawString("acc", x + width - 10, y+height-10); +// Color tmp = g.getColor(); +// GraphicLib.setMediumStroke(g); +// g.setColor(Color.red); +// g.drawLine(x+width-2, y-2+lineHeight, x+width-8, y-8+lineHeight); +// g.drawLine(x+width-8, y-2+lineHeight, x+width-2, y-8+lineHeight); +// g.setColor(tmp); +// GraphicLib.setNormalStroke(g); +// } +// }*/ +// +// g.setFont(myFont); +// String texti = "Text"; +// String s ; +// int i; +// size = lineHeight + currentFontSize; +// +// //ID +// /*if (size < (height - 2)) { +// drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0); +// } +// size += currentFontSize;*/ +// +// //text +// +// for(i=0; i<texts.length; i++) { +// if (size < (height - 2)) { +// s = texts[i]; +// if (i == 0) { +// s = texti + "=\"" + s; +// } +// if (i == (texts.length - 1)) { +// s = s + "\""; +// } +// drawLimitedString(g, s, x + textX, y + size, width, 0); +// } +// size += currentFontSize; +// +// } +// +// if (size < (height - 2)) { +// drawLimitedString(g, "Durability=\"" + DURABILITY_TYPE[durability] + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Source=\"" + SOURCE_TYPE[source] + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Status=\"" + STATUS_TYPE[status] + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Scope=\"" + LIMITATION_TYPE[limitation] + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// } +// } +// } +// } +// +// // Type and risk +// /*if (size < (height - 2)) { +// drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// if (size < (height - 2)) { +// +// drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0); +// +// size += currentFontSize; +// if (size < (height - 2)) { +// +// if (reqType == SECURITY_REQ) { +// drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0); +// } +// +// if (reqType == SAFETY_REQ) { +// drawLimitedString(g, "Violated action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); +// } +// } +// } +// } +// }*/ +// +// +// g.setFont(f); +// } + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { JDialogAssumption jda = new JDialogAssumption(tdp.getGUI().getFrame(), "Setting attributes of Assumption " + getAssumptionName(), getAssumptionName(), text, type, durability, source, status, limitation); @@ -397,6 +479,7 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem } + @Override public void rescale(double scaleFactor){ dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); @@ -408,6 +491,7 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -427,6 +511,7 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem return ret; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); @@ -624,6 +709,7 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem } }*/ + @Override public String getAttributes() { String attr = ""; attr += "Text= " + text + "\n"; @@ -631,6 +717,7 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem return attr; } + @Override public void autoAdjust(int mode) { // @@ -638,10 +725,10 @@ public class AvatarMADAssumption extends TGCScalableWithInternalComponent implem return; } - Font f = graphics.getFont(); - Font f0 = f.deriveFont((float)currentFontSize); - Font f1 = f0.deriveFont(Font.BOLD); - Font f2 = f.deriveFont((float)(currentFontSize - 2)); + // Font f = graphics.getFont(); + // Font f0 = f.deriveFont((float)currentFontSize); + // Font f1 = f0.deriveFont(Font.BOLD); + // Font f2 = f.deriveFont((float)(currentFontSize - 2)); /*// Must find for both modes which width is desirable String s0, s1; diff --git a/src/main/java/ui/avatarmad/AvatarMADAssumptionConnectingPoint.java b/src/main/java/ui/avatarmad/AvatarMADAssumptionConnectingPoint.java index 7e2c8a33a9d9159236f4aee256b9678129cba4bc..36f2730dda226b66c92664a142a0028c5f9a8f4c 100644 --- a/src/main/java/ui/avatarmad/AvatarMADAssumptionConnectingPoint.java +++ b/src/main/java/ui/avatarmad/AvatarMADAssumptionConnectingPoint.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarmad; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -54,22 +49,19 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 27/08/2013 * @author Ludovic APVRILLE */ -public class AvatarMADAssumptionConnectingPoint extends TGConnectingPointWidthHeight { +public class AvatarMADAssumptionConnectingPoint extends TGConnectingPointWidthHeight { public AvatarMADAssumptionConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h, int _orientation) { super(_container, _x, _y, _in, _out, _w, _h); orientation = _orientation; } + @Override public boolean isCompatibleWith(int type) { if (type == TGComponentManager.AVATARMAD_COMPOSITION_CONNECTOR) { return true; } - return type == TGComponentManager.AVATARMAD_VERSIONING_CONNECTOR; - - } - -} \ No newline at end of file +} diff --git a/src/main/java/ui/avatarmad/AvatarMADBelongsToCompositionConnector.java b/src/main/java/ui/avatarmad/AvatarMADBelongsToCompositionConnector.java index 707ca3b2f1acdb6eeaf77d02ae11d0ae8635fe07..841eb99fad2d54ad29472d92324aa0dc3754e7ec 100644 --- a/src/main/java/ui/avatarmad/AvatarMADBelongsToCompositionConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADBelongsToCompositionConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarmad; - import ui.*; import ui.util.IconManager; @@ -55,14 +51,14 @@ import java.util.Vector; * @version 1.0 16/10/2015 * @author Ludovic APVRILLE */ -public class AvatarMADBelongsToCompositionConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent{ +public class AvatarMADBelongsToCompositionConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { protected int d = 12; protected int D = 18; //protected int widthValue, heightValue, maxWidthValue, h; protected Polygon p; protected int xp1, xp2, yp1, yp2; - protected double oldScaleFactor; - protected boolean rescaled; +// protected double oldScaleFactor; +// protected boolean rescaled; public AvatarMADBelongsToCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { @@ -72,10 +68,11 @@ public class AvatarMADBelongsToCompositionConnector extends TGConnectorWithComm value = "{info}"; editable = true; - oldScaleFactor = tdp.getZoom(); - rescaled = true; +// oldScaleFactor = tdp.getZoom(); +// rescaled = true; } - + + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { if ((p == null) || (rescaled) || (xp1 != x1) || (xp2 != x2) || (yp1 != y1) || (yp2 != y2)){ p = new Polygon(); @@ -83,7 +80,7 @@ public class AvatarMADBelongsToCompositionConnector extends TGConnectorWithComm xp2 = x2; yp1 = y1; yp2 = y2; - Double alpha; + // Double alpha; int dd = (int)(d*tdp.getZoom()); int DD = (int)(D*tdp.getZoom()); @@ -166,6 +163,7 @@ public class AvatarMADBelongsToCompositionConnector extends TGConnectorWithComm rescaled = false; } + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (p != null) { if (p.contains(x1, y1)) { @@ -176,35 +174,33 @@ public class AvatarMADBelongsToCompositionConnector extends TGConnectorWithComm return null; } - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - rescaled = true; - } - - + //Issue #31 Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// rescaled = true; +// } + + @Override public int getType() { return TGComponentManager.AVATARMAD_BELONGSTOCOMPOSITION_CONNECTOR; } - - - } diff --git a/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java b/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java index 8708601a6cc7f820504486cafd4eacddab941feb..8ad78918ce448511611695b374db3d020c484fb5 100644 --- a/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java @@ -115,6 +115,7 @@ public class AvatarMADCompositionConnector extends TGConnectorWithCommentConnec return null; }*/ + @Override public int getType() { return TGComponentManager.AVATARMAD_COMPOSITION_CONNECTOR; } diff --git a/src/main/java/ui/avatarmad/AvatarMADConnector.java b/src/main/java/ui/avatarmad/AvatarMADConnector.java index 30b549c3bbbc0a655c5646cf4ece4f9776a53d58..8f8389c186780e00cad6da608d9049c311a52fa2 100644 --- a/src/main/java/ui/avatarmad/AvatarMADConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADConnector.java @@ -52,7 +52,7 @@ public abstract class AvatarMADConnector extends TGConnectorWithCommentConnectio return null; } - /* + /** * Issue #69 * @return */ @@ -68,9 +68,10 @@ public abstract class AvatarMADConnector extends TGConnectorWithCommentConnectio return visitor.isCanBeDisabled(); } - /* Issue #69 + /** Issue #69 * @return */ + @Override public boolean isEnabled( boolean checkBranch ) { if ( checkBranch && p2 != null ) { final ForwardComponentsEnabledVisitor visitor = new ForwardComponentsEnabledVisitor(); diff --git a/src/main/java/ui/avatarmad/AvatarMADDiagramReference.java b/src/main/java/ui/avatarmad/AvatarMADDiagramReference.java index 817b253774ae15c2699662dac806774756a92d2d..e7ceaa292dd2d982ca44bf8a9df944a9f70a7f1a 100644 --- a/src/main/java/ui/avatarmad/AvatarMADDiagramReference.java +++ b/src/main/java/ui/avatarmad/AvatarMADDiagramReference.java @@ -58,17 +58,17 @@ import java.awt.*; */ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent implements TGAutoAdjust { public String oldValue; - protected int textX = 5; - protected int textY = 22; + //protected int textX = 5; + //protected int textY = 22; protected int lineHeight = 30; private double dlineHeight = 0.0; //protected int startFontSize = 10; protected Graphics graphics; //protected int iconSize = 30; - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; +// private Font myFont, myFontB; +// private int maxFontSize = 30; +// private int minFontSize = 4; private int currentFontSize = -1; private boolean displayText = true; @@ -77,12 +77,12 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent protected String diagramText; private int iconSize = 18; - private boolean iconIsDrawn = false; +// private boolean iconIsDrawn = false; public AvatarMADDiagramReference(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - initScaling(150, lineHeight); +// initScaling(150, lineHeight); oldScaleFactor = tdp.getZoom(); dlineHeight = lineHeight * oldScaleFactor; lineHeight = (int)dlineHeight; @@ -90,6 +90,8 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent minWidth = 10; minHeight = lineHeight; + textY = 2; + initScaling(150, lineHeight); nbConnectingPoint = 24; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; @@ -123,7 +125,7 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent nbInternalTGComponent = 0; //tgcomponent = new TGComponent[nbInternalTGComponent]; - int h = 1; +// int h = 1; //TAttributeRequirement tgc0; //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); //tgcomponent[0] = tgc0; @@ -147,70 +149,102 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent actionOnAdd(); } - - + + //FIXME: glitches public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - int w, c; - int size; - - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; - - int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); - + //Rectangle + g.drawRect(x, y, width, height); g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + + //Filling g.setColor(ColorManager.AVATAR_ASSUMPTION_TOP); g.fillRect(x+1, y+1, width-1, lineHeight-1); g.setColor(ColorManager.AVATAR_ASSUMPTION_ATTRIBUTES); g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - drawLimitedString(g, DIAGRAM_REFERENCE, x, y + size, width, 1); - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } + + //Check readability + if (!isTextReadable(g)) + return; + + //Strings + Font f = g.getFont(); + //g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); +// drawLimitedString(g, DIAGRAM_REFERENCE, x, y + currentpos, width, 1); + g.setFont(f.deriveFont(Font.BOLD)); + drawSingleLimitedString(g, DIAGRAM_REFERENCE, x, y + f.getSize() , width, 1); + + g.setFont(f.deriveFont(Font.PLAIN)); + drawSingleLimitedString(g, value, x, y + f.getSize()*2, width, 1); + + //Icon + g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 1), y + scale(3), Color.yellow, null); - /*g.setFont(myFont); - - size = lineHeight + currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - // Violated action - if (size < (height - 2)) { - drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - }*/ - g.setFont(f); } - + +// public void internalDrawin(Graphics g) { +// Font f = g.getFont(); +//// Font fold = f; +//// int w, c; +// int size; +// +// if (!tdp.isScaled()) { +// graphics = g; +// } +// +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// // +// myFont = f.deriveFont((float)currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } +// +// displayText = currentFontSize >= minFontSize; +// +// //int h = g.getFontMetrics().getHeight(); +// +// g.drawRect(x, y, width, height); +// +// g.drawLine(x, y+lineHeight, x+width, y+lineHeight); +// g.setColor(ColorManager.AVATAR_ASSUMPTION_TOP); +// g.fillRect(x+1, y+1, width-1, lineHeight-1); +// g.setColor(ColorManager.AVATAR_ASSUMPTION_ATTRIBUTES); +// g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); +// ColorManager.setColor(g, getState(), 0); +// if ((lineHeight > 23) && (width > 23)){ +// g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 1), y + scale(3), Color.yellow, null); +// } +// +// if (displayText) { +// size = currentFontSize - 2; +// g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); +// drawLimitedString(g, DIAGRAM_REFERENCE, x, y + size, width, 1); +// size += currentFontSize; +// g.setFont(myFontB); +// //int w = g.getFontMetrics().stringWidth(value); +// drawLimitedString(g, value, x, y + size, width, 1); +// +// } +// +// /*g.setFont(myFont); +// +// size = lineHeight + currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// // Violated action +// if (size < (height - 2)) { +// drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); +// } +// }*/ +// g.setFont(f); +// } + + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { oldValue = value; @@ -252,7 +286,7 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent } - + @Override public void rescale(double scaleFactor){ dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); @@ -262,7 +296,7 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent super.rescale(scaleFactor); } - + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -270,19 +304,18 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent return null; } - - + @Override public int getType() { return TGComponentManager.AVATARMAD_DIAGRAM_REFERENCE; } - - + @Override public String toString() { String ret = getValue() + DIAGRAM_REFERENCE; return ret; } - + + @Override public void autoAdjust(int mode) { // @@ -296,7 +329,7 @@ public class AvatarMADDiagramReference extends TGCScalableWithInternalComponent Font f2 = f.deriveFont((float)(currentFontSize - 2)); // Must find for both modes which width is desirable - String s0, s1; + String s0; s0 = DIAGRAM_REFERENCE; diff --git a/src/main/java/ui/avatarmad/AvatarMADElementReference.java b/src/main/java/ui/avatarmad/AvatarMADElementReference.java index eca36ca789e35b2fd5ed82e8a1f1d33533781bba..c80cef177976a2211b3005a546f0e45e6f47e96d 100644 --- a/src/main/java/ui/avatarmad/AvatarMADElementReference.java +++ b/src/main/java/ui/avatarmad/AvatarMADElementReference.java @@ -58,17 +58,17 @@ import java.awt.*; */ public class AvatarMADElementReference extends TGCScalableWithInternalComponent implements TGAutoAdjust { public String oldValue; - protected int textX = 5; - protected int textY = 22; +// protected int textX = 5; +// protected int textY = 22; protected int lineHeight = 30; private double dlineHeight = 0.0; //protected int startFontSize = 10; protected Graphics graphics; //protected int iconSize = 30; - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; +// private Font myFont, myFontB; +// private int maxFontSize = 30; +// private int minFontSize = 4; private int currentFontSize = -1; private boolean displayText = true; @@ -77,11 +77,12 @@ public class AvatarMADElementReference extends TGCScalableWithInternalComponent protected String diagramText; private int iconSize = 18; - private boolean iconIsDrawn = false; +// private boolean iconIsDrawn = false; public AvatarMADElementReference(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); - + textX = 5; + textY = 22; initScaling(150, lineHeight); oldScaleFactor = tdp.getZoom(); dlineHeight = lineHeight * oldScaleFactor; @@ -123,7 +124,7 @@ public class AvatarMADElementReference extends TGCScalableWithInternalComponent nbInternalTGComponent = 0; //tgcomponent = new TGComponent[nbInternalTGComponent]; - int h = 1; +// int h = 1; //TAttributeRequirement tgc0; //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); //tgcomponent[0] = tgc0; @@ -147,33 +148,11 @@ public class AvatarMADElementReference extends TGCScalableWithInternalComponent actionOnAdd(); } - - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - int w, c; - int size; - - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; - - int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + g.drawRect(x, y, width, height); g.drawLine(x, y+lineHeight, x+width, y+lineHeight); g.setColor(ColorManager.AVATAR_ASSUMPTION_TOP); @@ -181,35 +160,79 @@ public class AvatarMADElementReference extends TGCScalableWithInternalComponent g.setColor(ColorManager.AVATAR_ASSUMPTION_ATTRIBUTES); g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - drawLimitedString(g, ELEMENT_REFERENCE, x, y + size, width, 1); - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - /*g.setFont(myFont); - - size = lineHeight + currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - // Violated action - if (size < (height - 2)) { - drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - }*/ - g.setFont(f); + //Strings + Font f = g.getFont(); + drawSingleLimitedString(g, ELEMENT_REFERENCE, x, y + f.getSize(), width, 1); + drawSingleLimitedString(g, value, x, y + f.getSize() * 2, width, 1); + + //ICon + g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 1), y + scale(3), Color.yellow, null); + } +// public void internalDrawin(Graphics g) { +// Font f = g.getFont(); +//// Font fold = f; +//// int w, C; +// int size; +// +// if (!tdp.isScaled()) { +// graphics = g; +// } +// +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// // +// myFont = f.deriveFont((float)currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } +// +// displayText = currentFontSize >= minFontSize; +// +//// int h = g.getFontMetrics().getHeight(); +// +// g.drawRect(x, y, width, height); +// +// g.drawLine(x, y+lineHeight, x+width, y+lineHeight); +// g.setColor(ColorManager.AVATAR_ASSUMPTION_TOP); +// g.fillRect(x+1, y+1, width-1, lineHeight-1); +// g.setColor(ColorManager.AVATAR_ASSUMPTION_ATTRIBUTES); +// g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); +// ColorManager.setColor(g, getState(), 0); +// if ((lineHeight > 23) && (width > 23)){ +// g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 1), y + scale(3), Color.yellow, null); +// } +// +// if (displayText) { +// size = currentFontSize - 2; +// g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); +// drawLimitedString(g, ELEMENT_REFERENCE, x, y + size, width, 1); +// size += currentFontSize; +// g.setFont(myFontB); +//// w = g.getFontMetrics().stringWidth(value); +// drawLimitedString(g, value, x, y + size, width, 1); +// +// } +// +// /*g.setFont(myFont); +// +// size = lineHeight + currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// // Violated action +// if (size < (height - 2)) { +// drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); +// } +// }*/ +// g.setFont(f); +// } + + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { oldValue = value; @@ -251,7 +274,7 @@ public class AvatarMADElementReference extends TGCScalableWithInternalComponent } - + @Override public void rescale(double scaleFactor){ dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); @@ -260,28 +283,28 @@ public class AvatarMADElementReference extends TGCScalableWithInternalComponent super.rescale(scaleFactor); } - - + + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; } return null; } - - - + + @Override public int getType() { return TGComponentManager.AVATARMAD_ELEMENT_REFERENCE; } - - + + @Override public String toString() { String ret = getValue() + ELEMENT_REFERENCE; return ret; } - + + @Override public void autoAdjust(int mode) { // @@ -295,9 +318,7 @@ public class AvatarMADElementReference extends TGCScalableWithInternalComponent Font f2 = f.deriveFont((float)(currentFontSize - 2)); // Must find for both modes which width is desirable - String s0, s1; - - s0 = ELEMENT_REFERENCE; + String s0 = ELEMENT_REFERENCE; graphics.setFont(f2); int w0 = graphics.getFontMetrics().stringWidth(s0); diff --git a/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java b/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java index f1b8e739b6cf6ff1319730b55702d77e11d37d24..b19c3a6923bc71528f0a9017346f624762a4c6dd 100644 --- a/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java @@ -90,7 +90,8 @@ public class AvatarMADMeetConnector extends AvatarMADConnector /* Issue #69 TGC // } // return null; // } - + + @Override public int getType() { return TGComponentManager.AVATARMAD_MEET_CONNECTOR; } diff --git a/src/main/java/ui/avatarmad/AvatarMADPanel.java b/src/main/java/ui/avatarmad/AvatarMADPanel.java index ab82982f361090a0688e8cc86641320aea21b0c1..1f1d1d38daedbc5d09f8b0c68e0e58247c71f1dd 100644 --- a/src/main/java/ui/avatarmad/AvatarMADPanel.java +++ b/src/main/java/ui/avatarmad/AvatarMADPanel.java @@ -62,10 +62,12 @@ public class AvatarMADPanel extends TDiagramPanel implements TDPWithAttributes { addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return false; } + @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -75,6 +77,7 @@ public class AvatarMADPanel extends TDiagramPanel implements TDPWithAttributes { return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -85,6 +88,7 @@ public class AvatarMADPanel extends TDiagramPanel implements TDPWithAttributes { return false; } + @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); @@ -92,26 +96,32 @@ public class AvatarMADPanel extends TDiagramPanel implements TDPWithAttributes { return false; } + @Override public String getXMLHead() { return "<AvatarMADPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } + @Override public String getXMLTail() { return "</AvatarMADPanel>"; } + @Override public String getXMLSelectedHead() { return "<AvatarMADPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</AvatarMADPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<AvatarMADPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</AvatarMADPanelCopy>"; } @@ -120,7 +130,8 @@ public class AvatarMADPanel extends TDiagramPanel implements TDPWithAttributes { public void makePostLoadingProcessing() throws MalformedModelingException { } - + + @Override public void enhance() { autoAdjust(); } diff --git a/src/main/java/ui/avatarmad/AvatarMADToAssumptionsConnectingPoint.java b/src/main/java/ui/avatarmad/AvatarMADToAssumptionsConnectingPoint.java index a511b7a4e5b1dfde864ed62e5d171df2e0cacdd9..5a75d1333f7cfe1cb2d99eb488806447d5753243 100644 --- a/src/main/java/ui/avatarmad/AvatarMADToAssumptionsConnectingPoint.java +++ b/src/main/java/ui/avatarmad/AvatarMADToAssumptionsConnectingPoint.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarmad; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPoint; @@ -68,10 +63,8 @@ public class AvatarMADToAssumptionsConnectingPoint extends TGConnectingPointWid orientation = _orientation; } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.AVATARMAD_IMPACT_CONNECTOR; - } - - } diff --git a/src/main/java/ui/avatarmad/AvatarMADToOthersConnectingPoint.java b/src/main/java/ui/avatarmad/AvatarMADToOthersConnectingPoint.java index 499d741ab210891fb80e0581b042f4acdec7e53c..dffac48057192a18e26527ee3cd4b5d9cea91422 100644 --- a/src/main/java/ui/avatarmad/AvatarMADToOthersConnectingPoint.java +++ b/src/main/java/ui/avatarmad/AvatarMADToOthersConnectingPoint.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarmad; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPoint; @@ -56,7 +51,7 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 27/08/2013 * @author Ludovic APVRILLE */ -public class AvatarMADToOthersConnectingPoint extends TGConnectingPointWidthHeight { +public class AvatarMADToOthersConnectingPoint extends TGConnectingPointWidthHeight { public AvatarMADToOthersConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); @@ -68,14 +63,12 @@ public class AvatarMADToOthersConnectingPoint extends TGConnectingPointWidthHei orientation = _orientation; } + @Override public boolean isCompatibleWith(int type) { if (type == TGComponentManager.AVATARMAD_IMPACT_CONNECTOR) { return true; } return type == TGComponentManager.AVATARMAD_BELONGSTOCOMPOSITION_CONNECTOR; - } - - } diff --git a/src/main/java/ui/avatarmad/AvatarMADToolBar.java b/src/main/java/ui/avatarmad/AvatarMADToolBar.java index 1acf06f2b0942e0ec07800640280d3a9a72e9094..58e593ca8e515054a59a30b62b2bc97efa0cd007 100644 --- a/src/main/java/ui/avatarmad/AvatarMADToolBar.java +++ b/src/main/java/ui/avatarmad/AvatarMADToolBar.java @@ -62,7 +62,8 @@ public class AvatarMADToolBar extends TToolBar { super(_mgui); } - + + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -88,7 +89,8 @@ public class AvatarMADToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b);*/ } - + + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/avatarmad/AvatarMADVersioningConnector.java b/src/main/java/ui/avatarmad/AvatarMADVersioningConnector.java index 1d1c94c48a89ee4b5598dcc58d06bddf7c71f34e..2f2bfe955ecdde3f484c067ef765822765708614 100644 --- a/src/main/java/ui/avatarmad/AvatarMADVersioningConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADVersioningConnector.java @@ -76,7 +76,7 @@ public class AvatarMADVersioningConnector extends TGConnectorWithCommentConnect myImageIcon = IconManager.imgic1008; } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); @@ -100,6 +100,7 @@ public class AvatarMADVersioningConnector extends TGConnectorWithCommentConnect g.setFont(old); } + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { return this; @@ -111,6 +112,7 @@ public class AvatarMADVersioningConnector extends TGConnectorWithCommentConnect return null; } + @Override public boolean editOndoubleClick(JFrame frame) { JDialogVersioningConnector jdvc = new JDialogVersioningConnector(frame, oldVersion, newVersion); // jdvc.setSize(400, 300); @@ -137,6 +139,7 @@ public class AvatarMADVersioningConnector extends TGConnectorWithCommentConnect return true; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<oldVersion data=\""); @@ -212,9 +215,7 @@ public class AvatarMADVersioningConnector extends TGConnectorWithCommentConnect } - - - + @Override public int getType() { return TGComponentManager.AVATARMAD_VERSIONING_CONNECTOR; } diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyConnectingPoint.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyConnectingPoint.java index da501b016a995c3bf9775156e761d28ce6a954ba..dd17c09d0b6e8ad80b253987883532fda4a1d7b2 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyConnectingPoint.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyConnectingPoint.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarmethodology; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -60,13 +55,14 @@ public class AvatarMethodologyConnectingPoint extends TGConnectingPointWidthHei super(_container, _x, _y, _in, _out, _w, _h); orientation = _orientation; } - + /** + * From ui.TGConnectingPoint.isCompatibleWith + * isCompatibleWith checks if the element to be connected are compatible ? + * @param type + * @return boolean indicating if the type is compatible + * */ + @Override public boolean isCompatibleWith(int type) { - return type == TGComponentManager.AVATARMETHODOLOGY_CONNECTOR; - - } - - -} \ No newline at end of file +} diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyConnector.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyConnector.java index 6a2093629b5baa45eb04c65f20d19afff5e703bc..60371e55c429a8ba3d76f047e0dc065124c13992 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyConnector.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyConnector.java @@ -69,14 +69,28 @@ public class AvatarMethodologyConnector extends TGConnectorWithCommentConnectio removable = false; } - + /** + * drawLastSegment: calling arrowWithLine + * Is Linking 2 diagram references ? (x1,y1) and (x2, y2) + * @param g grahics + * @param x1 int + * @param y1 int + * @param x2 int + * @param y2 int + * */ + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); GraphicLib.arrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); } - + /** + * extraIsOnOnlyMe + * @param x1 int + * @param y1 int + **/ + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { return this; @@ -84,6 +98,11 @@ public class AvatarMethodologyConnector extends TGConnectorWithCommentConnectio return null; } + /** + * get the type of the current avatar methodology connector ? + * @return int denoting of the type avatar methodology connector + */ + @Override public int getType() { return TGComponentManager.AVATARMETHODOLOGY_CONNECTOR; } diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramName.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramName.java index b5a0910910d171caa687bbdc665e2c781a3bddba..64d6654381e3ef591b5ce56e2a944c1237bbe44f 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramName.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramName.java @@ -49,7 +49,6 @@ import ui.util.IconManager; import javax.swing.*; import java.awt.*; -//import java.awt.geom.*; /** * Class AvatarMethodologyDiagramName @@ -65,7 +64,6 @@ public class AvatarMethodologyDiagramName extends TGCScalableWithoutInternalComp public final static int X_MARGIN = 5; public final static int Y_MARGIN = 3; - protected final static int SIM_ANIM = 0; protected final static int UPP = 1; protected final static int PROVERIF = 2; @@ -75,7 +73,8 @@ public class AvatarMethodologyDiagramName extends TGCScalableWithoutInternalComp protected final String[] SHORT_ACTION_NAMES = { "simu", "upp", "proverif", "inv", - "code-gen"}; + "code-gen" + }; protected final String[] LONG_ACTION_NAMES = { /*0*/ "Simulation and animate the model", @@ -97,6 +96,11 @@ public class AvatarMethodologyDiagramName extends TGCScalableWithoutInternalComp public AvatarMethodologyDiagramName(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); + //Issue #31 + minWidth = 10; + minHeight = lineLength; + initScaling(10, 10); + nbConnectingPoint = 0; minWidth = 10; nbInternalTGComponent = 0; @@ -107,215 +111,367 @@ public class AvatarMethodologyDiagramName extends TGCScalableWithoutInternalComp name = "value "; - - - initScaling(10, 10); - - + + myImageIcon = IconManager.imgic302; } + + /*Issue #31 Was used in the previous internalDrawing refactoring that was done, now its useless + private boolean canTextGoIntoTheFatherBox(Graphics g) + { + int widthText = g.getFontMetrics().stringWidth(value); + int widthFather = getFather().getWidth(); + return widthFather >= widthText + (2 * X_MARGIN); + }*/ + /** + * Set the font style to "fontStyle" when the boolean "pointerOnMe" is true and indexOnMe is equal to the index + * @param g + * @param fontStyle + * @param pointerOnMe + * @param font + * @param index + */ + private void setFontStyleWhenPointerIsOnMe(Graphics g, int fontStyle, boolean pointerOnMe, Font font, int index) { + if (pointerOnMe && indexOnMe == index) + g.setFont(font.deriveFont(fontStyle)); + } + private void manageValidations(Graphics g, Font font) + { + int widthText = g.getFontMetrics().stringWidth(value); + int widthFather = getFather().getWidth(); + int curWidth = Math.max(width, myWidth); + + if (validations == null) + if (getFather() instanceof AvatarMethodologyDiagramReference) + ((AvatarMethodologyDiagramReference)(getFather())).makeValidationInfos(this); + + if ((validations != null) && (valMinX == null)) { + valMinX = new int[validations.length]; + valMaxX = new int[validations.length]; + } + + int currentMaxWidthX = widthFather + x - 2 * (X_MARGIN); + int saveCurrentMaxX = currentMaxWidthX; + boolean oneWritten = false; + int saveWidth = 0; + g.setFont(font.deriveFont(Font.ITALIC)); + boolean pointerIsOnMe = tdp.componentPointed() == this ? true : false; + + if ((validations != null) & (validations.length > 0)) { + for (int i = validations.length - 1; i >= 0; i--) { + saveWidth = g.getFontMetrics().stringWidth(SHORT_ACTION_NAMES[validations[i]]); + +// if ((pointerIsOnMe && indexOnMe == i)) +// g.setFont(font.deriveFont(Font.ITALIC)); + setFontStyleWhenPointerIsOnMe(g,Font.ITALIC, pointerIsOnMe, font, i); + if ((currentMaxWidthX - saveWidth) > (x + widthText)) + { + //if ((pointerIsOnMe && indexOnMe == i)) + // g.setFont(font.deriveFont(Font.BOLD)); + setFontStyleWhenPointerIsOnMe(g, Font.BOLD, pointerIsOnMe, font, i); +// g.drawString(SHORT_ACTION_NAMES[validations[i]], currentMaxWidthX - saveWidth, y); + drawSingleString(g, SHORT_ACTION_NAMES[validations[i]], currentMaxWidthX - saveWidth, y); + + g.setFont(font.deriveFont(Font.ITALIC)); + valMinX[i] = currentMaxWidthX-saveWidth; + valMaxX[i] = currentMaxWidthX; + oneWritten = true; + currentMaxWidthX = currentMaxWidthX - saveWidth - 5; + } else + break; + } + } + g.setFont(font); + if (oneWritten) + makeScale(g, saveCurrentMaxX - x); + else + makeScale(g, widthText); + if (pointerIsOnMe) //Issue #31: The rectangle was not around the text when zoom: with scale it works better + //g.drawRect(x - 2, y - 12, curWidth + 5, 15); + g.drawRect(x - 2, y - scale(15), curWidth + 5, scale(15)); + } + + @Override + protected boolean canTextGoInTheBox(Graphics g, int fontSize, String text, int iconSize) + { + myHeight = g.getFontMetrics().getHeight(); + //int txtWidth = g.getFontMetrics().stringWidth(text) + (X_MARGIN * 2); + //int spaceTakenByIcon = iconSize + X_MARGIN; + return (fontSize + (Y_MARGIN * 2) < myHeight); // enough space in height + //&& (txtWidth + spaceTakenByIcon < myWidth) // enough space in width + //; + } + + /** Issue #31: Refactored internalDrawing for more comprehension + * Draws the text of the diagram references and the eventual validations + * @param g + */ + @Override + public void internalDrawing(Graphics g) + { + // Strings + String textDiagramRef = value; + //int fontSize = g.getFont().getSize(); + //boolean tooBig = !canTextGoInTheBox(g, fontSize, textDiagramRef, 0); +// if (!isTextReadable(g) /*|| canTextGoInTheBox(g, fontSize, textDiagramRef, 0)*/) +// return; + Font f = g.getFont(); + //g.drawString(textDiagramRef, x, y); + drawSingleString(g, textDiagramRef, x, y); + //validation and String + manageValidations(g, f); + } + /* + @Override + public void internalDrawing(Graphics g) + { + if ((y + Y_MARGIN) > (getFather().getY() + getFather().getHeight())) + return; + + int widthText = g.getFontMetrics().stringWidth(value); + int widthFather = getFather().getWidth(); + //String diagramRefTextName = value; + //if (!canTextGoIntoTheFatherBox(g)) + // diagramRefTextName = "."; + String diagramRefTextName = canTextGoIntoTheFatherBox(g) ? value : "."; + + Font font = g.getFont(); + boolean pointerIsOnMe = tdp.componentPointed() == this ? true : false; + //if (pointerIsonMe && indexOnMe == -1) + // g.setFont(font.deriveFont(Font.BOLD)); + setFontStyleWhenPointerIsOnMe(g, Font.BOLD, pointerIsOnMe, font, -1); + int curWidth = Math.max(width, myWidth); //int curWidth = myWidth; curWidth = Math.max(widthAppli, curWidth); + g.drawString(diagramRefTextName, x, y); + g.setFont(font); + + if (validations == null) + if (getFather() instanceof AvatarMethodologyDiagramReference) + ((AvatarMethodologyDiagramReference)(getFather())).makeValidationInfos(this); + + if ((validations != null) && (valMinX == null)) { + valMinX = new int[validations.length]; + valMaxX = new int[validations.length]; + } + + int currentMaxWidthX = widthFather + x - 2 * (X_MARGIN); + int saveCurrentMaxX = currentMaxWidthX; + + if (!canTextGoIntoTheFatherBox(g)) { + makeScale(g, widthText + (2 * X_MARGIN)); + return; + } + + boolean oneWritten = false; + int saveWidth = 0; + g.setFont(font.deriveFont(Font.ITALIC)); + + if ((validations != null) & (validations.length > 0)) { + for (int i = validations.length - 1; i >= 0; i--) { + saveWidth = g.getFontMetrics().stringWidth(SHORT_ACTION_NAMES[validations[i]]); + +// if ((pointerIsOnMe && indexOnMe == i)) +// g.setFont(font.deriveFont(Font.ITALIC)); + setFontStyleWhenPointerIsOnMe(g,Font.ITALIC, pointerIsOnMe, font, i); + if ((currentMaxWidthX - saveWidth) > (x + widthText)) + { + //if ((pointerIsOnMe && indexOnMe == i)) + // g.setFont(font.deriveFont(Font.BOLD)); + setFontStyleWhenPointerIsOnMe(g, Font.BOLD, pointerIsOnMe, font, i); + g.drawString(SHORT_ACTION_NAMES[validations[i]], currentMaxWidthX - saveWidth, y); + g.setFont(font.deriveFont(Font.ITALIC)); + valMinX[i] = currentMaxWidthX-saveWidth; + valMaxX[i] = currentMaxWidthX; + oneWritten = true; + currentMaxWidthX = currentMaxWidthX - saveWidth - 5; + } else + break; + } + } + g.setFont(font); + if (oneWritten) + makeScale(g, saveCurrentMaxX - x); + else + makeScale(g, widthText); + if (pointerIsOnMe) + g.drawRect(x - 2, y - 12, curWidth + 5, 15); + + return; + } + */ + /* Issue #31 public void internalDrawing(Graphics g) { - boolean onMe = false; - - if (tdp.componentPointed() == this) { - onMe = true; - } - - if ((y+Y_MARGIN) > (getFather().getY()+getFather().getHeight())) { + if ((y + Y_MARGIN) > (getFather().getY() + getFather().getHeight())) return; - } - //TraceManager.addDev("Internal drawing ..."); - int currentMaxX; + boolean onMe = tdp.componentPointed() == this ? true : false; + String val = value; int w = g.getFontMetrics().stringWidth(value); int wf = getFather().getWidth(); - int w1; - int saveCurrentMaxX; - boolean oneWritten; - - if (wf < w+(2*X_MARGIN)) { + + if (wf < w + (2 * X_MARGIN)) val = "."; - } - - int curWidth = myWidth; - - - + Font f = g.getFont(); - if (onMe && indexOnMe == -1) { + if (onMe && indexOnMe == -1) g.setFont(f.deriveFont(Font.BOLD)); - } + widthAppli = g.getFontMetrics().stringWidth(val); - curWidth = Math.max(widthAppli, curWidth); + int curWidth = Math.max(width, myWidth); //int curWidth = myWidth; curWidth = Math.max(widthAppli, curWidth); g.drawString(val, x, y); g.setFont(f); - if (validations == null) { - if (getFather() instanceof AvatarMethodologyDiagramReference) { + if (validations == null) + if (getFather() instanceof AvatarMethodologyDiagramReference) ((AvatarMethodologyDiagramReference)(getFather())).makeValidationInfos(this); - } - } if ((validations != null) && (valMinX == null)) { valMinX = new int[validations.length]; valMaxX = new int[validations.length]; - } - - /*if (validations == null) { - TraceManager.addDev("null validation"); - } else { - TraceManager.addDev("Validation size=" + validations.length); - }*/ + } - currentMaxX = wf + x - 2*(X_MARGIN); - saveCurrentMaxX = currentMaxX; + int currentMaxX = wf + x - 2 * (X_MARGIN); + int saveCurrentMaxX = currentMaxX; - if (wf < w+(2*X_MARGIN)) { - makeScale(g, w+(2*X_MARGIN)); + if (wf < w + (2 * X_MARGIN)) { + makeScale(g, w + (2 * X_MARGIN)); return; } - - //TraceManager.addDev("Tracing validation Validation size=" + validations.length); - oneWritten = false; - - + + boolean oneWritten = false; + int w1 = 0; g.setFont(f.deriveFont(Font.ITALIC)); - if ((validations != null) & (validations.length >0)) { - for(int i=validations.length-1; i>=0; i--) { - //TraceManager.addDev("Validations[" + i + "] = " + validations[i]); - + + if ((validations != null) & (validations.length > 0)) { + for (int i = validations.length - 1; i >= 0; i--) { w1 = g.getFontMetrics().stringWidth(SHORT_ACTION_NAMES[validations[i]]); + + if ((onMe && indexOnMe == i)) + g.setFont(f.deriveFont(Font.ITALIC)); - - if ((onMe && indexOnMe == i)) { - g.setFont(f.deriveFont(Font.ITALIC)); - } - - if ((currentMaxX - w1) > (x + w)) { - if ((onMe && indexOnMe == i)) { + if ((currentMaxX - w1) > (x + w)) + { + if ((onMe && indexOnMe == i)) g.setFont(f.deriveFont(Font.BOLD)); - } + g.drawString(SHORT_ACTION_NAMES[validations[i]], currentMaxX - w1, y); g.setFont(f.deriveFont(Font.ITALIC)); valMinX[i] = currentMaxX-w1; valMaxX[i] = currentMaxX; oneWritten = true; currentMaxX = currentMaxX - w1 - 5; - } else { + } else break; - } - } } - - - g.setFont(f); - - if (oneWritten) { + if (oneWritten) makeScale(g, saveCurrentMaxX - x); - } else { + else makeScale(g, w); - } - - //TraceManager.addDev("current width=" + curWidth); if (onMe) - g.drawRect(x-2, y-12, curWidth+5, 15); - return; - - + return; } + */ - private void makeScale(Graphics g, int _size) { - if (!tdp.isScaled()) { + private void makeScale(Graphics g, int _size) + { + //TraceManager.addDev("----- Make SCale ----"); + if (!tdp.isScaled()) + { myWidth = _size; myHeight = g.getFontMetrics().getHeight(); } } - + @Override public TGComponent isOnMe(int _x, int _y) { int oldIndex = indexOnMe; - if (GraphicLib.isInRectangle(_x, _y, x, y - height, Math.max(myWidth, minWidth), myHeight)) { + if (GraphicLib.isInRectangle(_x, _y, x, y - height, Math.max(myWidth, minWidth), myHeight)) + { indexOnMe = -2; - - if (_x <= (x+widthAppli)) { + if (_x <= (x + widthAppli)) + { indexOnMe = -1; tdp.getMGUI().setStatusBarText("Open the " + value + " model"); } - if ((validations != null) && (validations.length > 0)) { - for(int i=0; i<validations.length; i++) { - if ((_x >= valMinX[i]) && (_x <= valMaxX[i])) { + if ((validations != null) && (validations.length > 0)) + { + for (int i = 0; i < validations.length; i++) + { + if ((_x >= valMinX[i]) && (_x <= valMaxX[i])) + { indexOnMe = i; tdp.getMGUI().setStatusBarText(LONG_ACTION_NAMES[validations[i]]); - //TraceManager.addDev("Index on " + indexOnMe); break; } } } - if (oldIndex != indexOnMe) { + if (oldIndex != indexOnMe) tdp.repaint(); - } - - return this; } return null; } - public boolean editOndoubleClick(JFrame frame) { - + @Override + public boolean editOndoubleClick(JFrame frame) + { if (indexOnMe == -1) { // Opening the diagram - if (!tdp.getMGUI().selectMainTab(value)) { + if (!tdp.getMGUI().selectMainTab(value)) + { TraceManager.addDev("Diagram removed?"); return false; } - } - - - if (indexOnMe > -1) { + + if (indexOnMe > -1) + { AvatarMethodologyDiagramReference ref = ((AvatarMethodologyDiagramReference)(getFather())); ref.makeCall(value, indexOnMe); - } - - + } return true; } - - public int getType() { + @Override + public int getType() + { return TGComponentManager.AVATARMETHODOLOGY_DIAGRAM_NAME; } - public int getDefaultConnector() { + @Override + public int getDefaultConnector() + { return TGComponentManager.AVATARMETHODOLOGY_CONNECTOR; } - public void setValidationsNumber(int size) { + public void setValidationsNumber(int size) + { validations = new int[size]; } - public void setValidationsInfo(int _index, int _val) { + public void setValidationsInfo(int _index, int _val) + { validations[_index] = _val; } - public void rescale(double scaleFactor){ - - if ((valMinX != null) && (valMinX.length > 0)) { - for(int i=0; i<valMinX.length; i++) { + @Override + public void rescale(double scaleFactor) + { + if ((valMinX != null) && (valMinX.length > 0)) + { + for (int i = 0; i < valMinX.length; i++) + { valMinX[i] = (int)(valMinX[i] / oldScaleFactor * scaleFactor); valMaxX[i] = (int)(valMaxX[i] / oldScaleFactor * scaleFactor); } } - super.rescale(scaleFactor); } } diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramPanel.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramPanel.java index d3f1bb034512b64abe46d91657de6b6841c60e45..d178093323af58da35146dc0cdd39b6a56d3578f 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramPanel.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramPanel.java @@ -61,10 +61,12 @@ public class AvatarMethodologyDiagramPanel extends TDiagramPanel implements TDPW addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return true; } + @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -74,6 +76,7 @@ public class AvatarMethodologyDiagramPanel extends TDiagramPanel implements TDPW return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -84,6 +87,7 @@ public class AvatarMethodologyDiagramPanel extends TDiagramPanel implements TDPW return false; } + @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); @@ -91,26 +95,32 @@ public class AvatarMethodologyDiagramPanel extends TDiagramPanel implements TDPW return false; } + @Override public String getXMLHead() { return "<AvatarMethodologyDiagramPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } + @Override public String getXMLTail() { return "</AvatarMethodologyDiagramPanel>"; } + @Override public String getXMLSelectedHead() { return "<AvatarMethodologyDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</AvatarMethodologyDiagramPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<AvatarMethodologyDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</AvatarMethodologyDiagramPanelCopy>"; } @@ -120,6 +130,7 @@ public class AvatarMethodologyDiagramPanel extends TDiagramPanel implements TDPW } + @Override public void enhance() { autoAdjust(); } diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramReference.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramReference.java index f2cac71f4ff13fe49dd584545af1bbfa89616b01..8fcb1a8837b35300501ead3b63e67ef3b0e3cebc 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramReference.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramReference.java @@ -63,22 +63,22 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithInternalComponent implements SwallowTGComponent { - public String oldValue; - protected int textX = 5; - protected int textY = 22; - protected int lineHeight = 30; - protected double dlineHeight = 0.0; - //protected int reqType = 0; + public String oldValue; + //protected int textX = 5; +// protected int textY = 22; +// protected int lineHeight = 30; +// protected double dlineHeight = 0.0; +// protected int reqType = 0; // 0: normal, 1: formal, 2: security //protected int startFontSize = 10; - protected Graphics graphics; - protected int iconSize = 30; - + //protected Graphics graphics; + //protected int iconSize = 30; + private static final int ICON_SIZE = 30; protected Font myFont, myFontB; protected int maxFontSize = 30; protected int minFontSize = 4; - protected int currentFontSize = -1; - protected boolean displayText = true; + //protected int currentFontSize = -1; + //protected boolean displayText = true; protected int typeOfReference; @@ -102,15 +102,24 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI public AvatarMethodologyDiagramReference(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - initScaling(200, 120); - oldScaleFactor = tdp.getZoom(); - dlineHeight = lineHeight * oldScaleFactor; - lineHeight = (int)dlineHeight; - dlineHeight = dlineHeight - lineHeight; - + + // Issue #31 + lineLength = 30; + textX = 5; + textY = 22; + minWidth = 10; - minHeight = lineHeight; + minHeight = lineLength; + + initScaling(200, 120); + // Issue #31 +// oldScaleFactor = tdp.getZoom(); +// dlineHeight = lineHeight * oldScaleFactor; +// lineHeight = (int)dlineHeight; +// dlineHeight = dlineHeight - lineHeight; +// +// minWidth = 10; +// minHeight = lineLength; addTGConnectingPointsCommentTop(); @@ -127,9 +136,7 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI removable = false; userResizable = true; multieditable = true; - - - + oldValue = value; myImageIcon = IconManager.imgic5006; @@ -138,33 +145,37 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI actionOnAdd(); } - + /** + * From abstract class ui.TGComponent: declaration of abstract method + * InternalDrawing + * @param g + * */ + @Override public void internalDrawing(Graphics g) { Font f = g.getFont(); // Font fold = f; // int w, c; - int size; + //int size; value = TYPE_STR[typeOfReference]; - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; - - // int h = g.getFontMetrics().getHeight(); +// if (!tdp.isScaled()) { +// graphics = g; +// } + // Issue #31 The font is already managed when drawing the panel +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// // +// myFont = f.deriveFont((float)currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } + final int fontSize = g.getFont().getSize(); + displayText = fontSize >= minFontSize; + //issue #31 displayText = currentFontSize >= minFontSize; g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); g.fillRect(x, y, width, height); @@ -177,109 +188,33 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI //g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); //g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - + //if (!isTextReadable(g)) + // return; + if (!isTextReadable(g) || !canTextGoInTheBox(g, fontSize, value, ICON_SIZE)) + return; + //if ((lineLength > 23) && (width > 23)){ + //g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); + g.drawImage( scale( IconManager.img5100 ), x + width - scale(ICON_SIZE + 1 ), y + scale( 3 ), Color.yellow, null); + //} + if (displayText) { - size = currentFontSize - 2; - g.setFont(myFontB); + //size = currentFontSize - 2; + //g.setFont(myFontB); - drawLimitedString(g, value, x, y + size + 3, width, 1); + drawLimitedString(g, value, x, y + fontSize + 3, width, 1); g.setFont(f); } - - /*if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - - drawLimitedString(g, REQ_TYPE_STR[reqType], x, y + size, width, 1); - - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - if (verified) { - if (satisfied) { - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.green); - g.drawLine(x+width-2, y-6+lineHeight, x+width-6, y-2+lineHeight); - g.drawLine(x+width-6, y-3+lineHeight, x+width-8, y-6+lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } else { - //g.drawString("acc", x + width - 10, y+height-10); - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.red); - g.drawLine(x+width-2, y-2+lineHeight, x+width-8, y-8+lineHeight); - g.drawLine(x+width-8, y-2+lineHeight, x+width-2, y-8+lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } - } - - g.setFont(myFont); - String texti = "Text"; - String s ; - int i; - size = lineHeight + currentFontSize; - - //ID - if (size < (height - 2)) { - drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0); - } - size += currentFontSize; - - //text - for(i=0; i<texts.length; i++) { - if (size < (height - 2)) { - s = texts[i]; - if (i == 0) { - s = texti + "=\"" + s; - } - if (i == (texts.length - 1)) { - s = s + "\""; - } - drawLimitedString(g, s, x + textX, y + size, width, 0); - } - size += currentFontSize; - - } - // Type and risk - if (size < (height - 2)) { - drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - if (size < (height - 2)) { - - drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0); - - size += currentFontSize; - if (size < (height - 2)) { - - if (reqType == SECURITY_REQ) { - drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0); - } - - if (reqType == SAFETY_REQ) { - drawLimitedString(g, "Violated action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - } - } - } - } - - - g.setFont(f);*/ } - + + /** + * editOndoubleClick: permits edition of the element on double click + * by simply calling adddiagramReference + * @param frame + * @param _x + * @param _y + * @return boolean true + * */ + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { addDiagramReference(frame); return true; @@ -338,28 +273,45 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI return editAttributes();*/ } - - - public void rescale(double scaleFactor){ - dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; - lineHeight = (int)(dlineHeight); - dlineHeight = dlineHeight - lineHeight; - - minHeight = lineHeight; - - super.rescale(scaleFactor); - } - - + /** + * Rescale: rescale the element with the help of a scaleFactor + * From abstract class TGScalableComponent + * @param scaleFactor + * + * */ + // Issue #31 +// @Override +// public void rescale(double scaleFactor){ +// dlineHeight = (lineLength + dlineHeight) / oldScaleFactor * scaleFactor; +// lineLength = (int)(dlineHeight); +// dlineHeight = dlineHeight - lineLength; +// +// minHeight = lineLength; +// +// super.rescale(scaleFactor); +// } + + /** + * isOnOnlyMe, Coming from Abstract Method From TGCWithInternalComponent (Abstract Class) + * @param x1 + * @param y1 + * @return TGComponent or null + * */ + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) return this; - } return null; } - - + /** + * addActionToPopupMenu + * @param componentMenu + * @param menuAL + * @param x + * @param y + * */ + @Override public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); @@ -370,6 +322,12 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI componentMenu.add(diagramReference); } + /** + * eventOnPopup + * @param e + * @return boolean true + * */ + @Override public boolean eventOnPopup(ActionEvent e) { // String s = e.getActionCommand(); @@ -382,6 +340,10 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI return true; } + /** + * addDiagramReference: permits to pop a new window??? + * @param frame + * */ public void addDiagramReference(JFrame frame) { JDialogManageListOfString jdmlos; Vector<String> ignored; // Must be built from non selected TMLTaskDiagramPanel or TMLCompPanel @@ -457,16 +419,23 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI public abstract void makeValidationInfos(AvatarMethodologyDiagramName dn); + /** + * hasAvatarMethodologyDiagramName + * @param s + * @return boolean denoting if the string s is in the tgcomponent list + * */ public boolean hasAvatarMethodologyDiagramName(String s) { - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i].getValue().compareTo(s) == 0) { + for (int i = 0; i < nbInternalTGComponent; i++) + if (tgcomponent[i].getValue().compareTo(s) == 0) return true; - } - } return false; } - + /** + * fillIgnoredSelectedFromInternalComponents + * @param ignored + * @param selected + * */ public void fillIgnoredSelectedFromInternalComponents(Vector<String> ignored, Vector<String>selected) { // Get from mgui the list of all diagrams with type depends from the subclass // If diagrams have the same name -> we do not see the difference @@ -513,11 +482,25 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI } public abstract boolean isAValidPanelType(TURTLEPanel panel); - + + /** + * Permits to know if tgc is an instance of AvatarMethodologyDiagramName + * @param tgc + * @return boolean + * */ + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof AvatarMethodologyDiagramName; } + /** + * addSwallowedTGComponent + * @param tgc + * @param x + * @param y + * @return boolean + * */ + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { tgc.setFather(this); addInternalComponent(tgc, 0); @@ -525,12 +508,22 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI return true; } + /** + * removeSwallowedTGComponent + * @param tgc + * */ + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } public abstract boolean makeCall(String diagramName, int index); + /** + * openDiagram + * @param tabName + * @return boolean + * */ protected boolean openDiagram(String tabName) { if (!tdp.getMGUI().selectMainTab(tabName)) { TraceManager.addDev("Diagram removed?"); @@ -539,12 +532,15 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI return true; } + /** + * giveInformation + * @param info + * + * */ protected void giveInformation(String info) { tdp.getMGUI().setStatusBarText(info); } - - /*public String getDiagramReferences() { return referenceElements; }*/ diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramToolbar.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramToolbar.java index 458f7828ae7c5ff26f0b2657bd11167404d073c4..dffc06435be1d35efc423bf232edb4a065d0e531 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramToolbar.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyDiagramToolbar.java @@ -63,7 +63,7 @@ public class AvatarMethodologyDiagramToolbar extends TToolBar { super(_mgui); } - + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -89,7 +89,7 @@ public class AvatarMethodologyDiagramToolbar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(!b); } - + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAnalysis.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAnalysis.java index 1f4a2511d3bf112c9613eb625665ca8da354bd73..be55883f7e3714e010314e042b3dfb4b56818fd6 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAnalysis.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAnalysis.java @@ -70,11 +70,11 @@ public class AvatarMethodologyReferenceToAnalysis extends AvatarMethodologyDiagr addTGConnectingPointsCommentTop(); } - + @Override public int getType() { return TGComponentManager.AVATARMETHODOLOGY_REF_ANALYSIS; } - + @Override public boolean isAValidPanelType(TURTLEPanel panel) { if (panel instanceof AvatarAnalysisPanel) { return true; @@ -82,11 +82,11 @@ public class AvatarMethodologyReferenceToAnalysis extends AvatarMethodologyDiagr return panel instanceof AttackTreePanel; } - + @Override public void makeValidationInfos(AvatarMethodologyDiagramName dn) { dn.setValidationsNumber(0); } - + @Override public boolean makeCall(String diagramName, int index) { return true; } diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAssumptions.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAssumptions.java index 726333ad14067d1c36707226d2c812f62e4434f0..9e4042771c3034db91132ab465bd835bcd24f618 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAssumptions.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToAssumptions.java @@ -69,20 +69,20 @@ public class AvatarMethodologyReferenceToAssumptions extends AvatarMethodologyDi addTGConnectingPointsCommentTop(); } - + @Override public int getType() { return TGComponentManager.AVATARMETHODOLOGY_REF_ASSUMPTIONS; } - + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof AvatarMADsPanel; } - + @Override public void makeValidationInfos(AvatarMethodologyDiagramName dn) { dn.setValidationsNumber(0); } - + @Override public boolean makeCall(String diagramName, int index) { return true; } diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToProperties.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToProperties.java index 6bfcef95ccab135a5527101f18124fae3ebe32cd..ae3066f2a2ed7020a7d4b9b0dd92aaa1351b4a09 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToProperties.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToProperties.java @@ -69,20 +69,24 @@ public class AvatarMethodologyReferenceToProperties extends AvatarMethodologyDia addTGConnectingPointsCommentTop(); } - + + @Override public int getType() { return TGComponentManager.AVATARMETHODOLOGY_REF_PROPERTIES; } - + + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof AvatarRequirementPanel; } - + + @Override public void makeValidationInfos(AvatarMethodologyDiagramName dn) { dn.setValidationsNumber(0); } - + + @Override public boolean makeCall(String diagramName, int index) { return true; } diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToPrototype.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToPrototype.java index de63bfa669ce1b6aac54bda27d4dcad3f6afd1e8..547115e705d6e82e9fd6a64760640dc33d4edbe8 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToPrototype.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToPrototype.java @@ -69,22 +69,22 @@ public class AvatarMethodologyReferenceToPrototype extends AvatarMethodologyDiag addTGConnectingPointsCommentTop(); } - + @Override public int getType() { return TGComponentManager.AVATARMETHODOLOGY_REF_PROTOTYPE; } - + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof AvatarDesignPanel; } - + @Override public void makeValidationInfos(AvatarMethodologyDiagramName dn) { dn.setValidationsNumber(1); dn.setValidationsInfo(0, AvatarMethodologyDiagramName.PROTO); } - + @Override public boolean makeCall(String diagramName, int index) { switch(index) { case 0: diff --git a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToRequirement.java b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToRequirement.java index 0256cc187fa62ee253484f54512574203deb8917..15d6d70adbc12c00ffad14f827a2e6f5d7be7d61 100755 --- a/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToRequirement.java +++ b/src/main/java/ui/avatarmethodology/AvatarMethodologyReferenceToRequirement.java @@ -71,20 +71,20 @@ public class AvatarMethodologyReferenceToRequirement extends AvatarMethodologyDi addTGConnectingPointsCommentTop(); } - + @Override public int getType() { return TGComponentManager.AVATARMETHODOLOGY_REF_REQUIREMENT; } - + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof AvatarRequirementPanel; } - + @Override public void makeValidationInfos(AvatarMethodologyDiagramName dn) { dn.setValidationsNumber(0); } - + @Override public boolean makeCall(String diagramName, int index) { return true; } diff --git a/src/main/java/ui/avatarpd/AvatarPDAlias.java b/src/main/java/ui/avatarpd/AvatarPDAlias.java index b84c78f44b1cabaa5881188b06f6c7c5049c4b5a..2323b8611da6b65807d7d310f0166ddd77e81dc5 100644 --- a/src/main/java/ui/avatarpd/AvatarPDAlias.java +++ b/src/main/java/ui/avatarpd/AvatarPDAlias.java @@ -56,25 +56,29 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDAlias extends TGCScalableWithInternalComponent implements ConstraintListInterface { - private int textY1 = 5; +// private int textY1 = 5; //private int textY2 = 30; public static final String[] STEREOTYPES = {"<<alias>>"}; protected String oldValue = ""; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 1; +// private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; +// private int textX = 1; public AvatarPDAlias(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(100* tdp.getZoom()); - height = (int)(40 * tdp.getZoom()); + //Issue #31 + width = 100; + height = 40; minWidth = 100; + textY = 5; + textX = 1; + initScaling(100, 40); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -104,112 +108,127 @@ public class AvatarPDAlias extends TGCScalableWithInternalComponent implements C value = "sig_al"; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic1078; } - public void internalDrawing(Graphics g) { - String ster; - ster = STEREOTYPES[0]; - Font f = g.getFont(); - Font fold = f; - - if (value != oldValue) { - setValue(value, g); - } - - 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, maxFontSize)); - int w0, w1, w2; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (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); - } - - } - - Color c = g.getColor(); + @Override + public void internalDrawing(Graphics g) + { + //rectangle + Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); - - g.setColor(ColorManager.AVATARPD_ALIAS); - g.fill3DRect(x+1, y+1, width-1, height-1, true); g.setColor(c); - - // Strings - int w; - if (displayText) { - f = f.deriveFont((float)currentFontSize); - Font f0 = g.getFont(); - - boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY1 * tdp.getZoom()))); - - if (cannotWriteAttack) { - w = g.getFontMetrics().stringWidth(value); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } else { - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - } - } - } else { - g.setFont(f.deriveFont(Font.BOLD)); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - int cumulated = 0; - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - cumulated = h; - } - g.setFont(f0); - w = g.getFontMetrics().stringWidth(value); - h = cumulated + currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } - } - } - - g.setFont(fold); - + + //Strings + String ster = STEREOTYPES[0]; + drawDoubleString(g, ster, value); } +// public void internalDrawing(Graphics g) { +// String ster; +// ster = STEREOTYPES[0]; +// Font f = g.getFont(); +// Font fold = f; +// +// if (value != oldValue) { +// setValue(value, g); +// } +// +// 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, maxFontSize)); +// int w0, w1, w2; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (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); +// } +// +// } +// +// Color c = g.getColor(); +// g.draw3DRect(x, y, width, height, true); +// +// +// g.setColor(ColorManager.AVATARPD_ALIAS); +// +// g.fill3DRect(x+1, y+1, width-1, height-1, true); +// g.setColor(c); +// +// // Strings +// int w; +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// Font f0 = g.getFont(); +// +// boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY * tdp.getZoom()))); +// +// if (cannotWriteAttack) { +// w = g.getFontMetrics().stringWidth(value); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } else { +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// } +// } +// } else { +// g.setFont(f.deriveFont(Font.BOLD)); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// int cumulated = 0; +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// cumulated = h; +// } +// g.setFont(f0); +// w = g.getFontMetrics().stringWidth(value); +// h = cumulated + currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } +// } +// } +// +// g.setFont(fold); +// +// } + public void setValue(String val, Graphics g) { oldValue = value; int w = g.getFontMetrics().stringWidth(value); @@ -224,10 +243,10 @@ public class AvatarPDAlias extends TGCScalableWithInternalComponent implements C } - + @Override public boolean editOndoubleClick(JFrame frame) { - String tmp; - boolean error = false; +// String tmp; +// boolean error = false; //String text = getName() + ": "; String s = (String)JOptionPane.showInputDialog(frame, "Alias=", @@ -251,6 +270,7 @@ public class AvatarPDAlias extends TGCScalableWithInternalComponent implements C return false; } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -259,17 +279,18 @@ public class AvatarPDAlias extends TGCScalableWithInternalComponent implements C return null; } + @Override public int getType() { return TGComponentManager.APD_ALIAS; } + @Override public String[] getConstraintList() { return STEREOTYPES; } + @Override public String getCurrentConstraint() { return value; } - - } diff --git a/src/main/java/ui/avatarpd/AvatarPDAttribute.java b/src/main/java/ui/avatarpd/AvatarPDAttribute.java index 1ef209eb33861319d282187fb3a0982400c350a6..f9d1d0baf43a31043bfdc0d1c1c5ef65b4cf8653 100644 --- a/src/main/java/ui/avatarpd/AvatarPDAttribute.java +++ b/src/main/java/ui/avatarpd/AvatarPDAttribute.java @@ -56,17 +56,17 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDAttribute extends AvatarPDToggle implements SwallowedTGComponent { - private int textY1 = 3; +// private int textY1 = 3; //private int textY2 = 3; //private int textX = 10; private String stereotype = "attribute"; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; +// private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; @@ -74,9 +74,12 @@ public class AvatarPDAttribute extends AvatarPDToggle implements SwallowedTGComp public AvatarPDAttribute(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(125* tdp.getZoom()); - height = (int)(50 * tdp.getZoom()); + //Issue #31 + width = 125; + height = 50; minWidth = 100; + textY = 3; + initScaling(125, 50); nbConnectingPoint = 12; connectingPoint = new TGConnectingPoint[12]; @@ -102,121 +105,141 @@ public class AvatarPDAttribute extends AvatarPDToggle implements SwallowedTGComp value = "attr01"; toggle = ""; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic702; } - public void internalDrawing(Graphics g) { - String ster; - ster = "<<" + stereotype + ">>"; - Font f = g.getFont(); - Font fold = f; - - if (valueChanged) { - setValueWidth(g); - } - - 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, maxFontSize)); - int w0, w1, w2; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (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); - } - - } - - Color c = g.getColor(); + @Override + public void internalDrawing(Graphics g) + { + //Rectangle and filling + Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); g.setColor(ColorManager.AVATARPD_ATTRIBUTE); - g.fill3DRect(x+1, y+1, width-1, toggleHeight-1, true); + g.fill3DRect(x+1, y+1, width-1, scale(toggleHeight-1), true); g.setColor(ColorManager.AVATARPD_SIGNAL); - g.fill3DRect(x+1, y+toggleHeight, width-1, height-toggleHeight, true); + g.fill3DRect(x+1, y + scale(toggleHeight), width-1, height-scale(toggleHeight), true); g.setColor(c); - - // Strings - int w; - if (displayText) { - f = f.deriveFont((float)currentFontSize); - Font f0 = g.getFont(); - - boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY1 * tdp.getZoom()))); - - if (cannotWriteAttack) { - w = g.getFontMetrics().stringWidth(value); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } else { - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - } - } - } else { - g.setFont(f.deriveFont(Font.BOLD)); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - int cumulated = 0; - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - cumulated = h; - } - g.setFont(f0); - w = g.getFontMetrics().stringWidth(value); - h = cumulated + currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } - String s = getFullToggle(); - w = g.getFontMetrics().stringWidth(s); - h = height-toggleDecY; - if ((w < (2*textX + width)) && (h < height)) { - g.setFont(f.deriveFont(Font.ITALIC)); - g.drawString(s, x + (width - w)/2, y + h); - } - - } - } - g.setFont(fold); - + //Strings + String ster = "<<" + stereotype + ">>"; + Font f = g.getFont(); + g.setFont(f.deriveFont(f.getSize() - 4)); + drawDoubleString(g, ster, value); + drawSingleString(g, getFullToggle(), getCenter(g, getFullToggle()), y + f.getSize() * 3 + scale(9)); } + +// public void internalDrawing(Graphics g) { +// String ster; +// ster = "<<" + stereotype + ">>"; +// Font f = g.getFont(); +// Font fold = f; +// +// if (valueChanged) { +// setValueWidth(g); +// } +// +// 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, maxFontSize)); +// int w0, w1, w2; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (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); +// } +// +// } +// +// Color c = g.getColor(); +// g.draw3DRect(x, y, width, height, true); +// g.setColor(ColorManager.AVATARPD_ATTRIBUTE); +// g.fill3DRect(x+1, y+1, width-1, toggleHeight-1, true); +// g.setColor(ColorManager.AVATARPD_SIGNAL); +// g.fill3DRect(x+1, y+toggleHeight, width-1, height-toggleHeight, true); +// g.setColor(c); +// +// // Strings +// int w; +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// Font f0 = g.getFont(); +// +// boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY * tdp.getZoom()))); +// +// if (cannotWriteAttack) { +// w = g.getFontMetrics().stringWidth(value); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } else { +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// } +// } +// } else { +// g.setFont(f.deriveFont(Font.BOLD)); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// int cumulated = 0; +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// cumulated = h; +// } +// g.setFont(f0); +// w = g.getFontMetrics().stringWidth(value); +// h = cumulated + currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } +// String s = getFullToggle(); +// w = g.getFontMetrics().stringWidth(s); +// h = height-toggleDecY; +// if ((w < (2*textX + width)) && (h < height)) { +// g.setFont(f.deriveFont(Font.ITALIC)); +// g.drawString(s, x + (width - w)/2, y + h); +// } +// +// } +// } +// +// g.setFont(fold); +// +// } - + @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarPDBlock)) { // @@ -226,7 +249,7 @@ public class AvatarPDAttribute extends AvatarPDToggle implements SwallowedTGComp } } - + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { //String text = getName() + ": "; @@ -255,6 +278,7 @@ public class AvatarPDAttribute extends AvatarPDToggle implements SwallowedTGComp } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -262,11 +286,13 @@ public class AvatarPDAttribute extends AvatarPDToggle implements SwallowedTGComp } return null; } - + + @Override public int getType() { return TGComponentManager.APD_ATTRIBUTE; } + @Override public int getDefaultConnector() { return TGComponentManager.APD_ATTRIBUTE_CONNECTOR; } diff --git a/src/main/java/ui/avatarpd/AvatarPDAttributeConnectingPoint.java b/src/main/java/ui/avatarpd/AvatarPDAttributeConnectingPoint.java index 7dcfaba4831f2fc3142121770fe6151adf40ff80..54f4132285a505deef8ce3e0061e93b56f73e3ae 100644 --- a/src/main/java/ui/avatarpd/AvatarPDAttributeConnectingPoint.java +++ b/src/main/java/ui/avatarpd/AvatarPDAttributeConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -53,14 +49,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 22/04/2010 * @author Ludovic APVRILLE */ -public class AvatarPDAttributeConnectingPoint extends TGConnectingPointWidthHeight { +public class AvatarPDAttributeConnectingPoint extends TGConnectingPointWidthHeight { public AvatarPDAttributeConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.APD_ATTRIBUTE_CONNECTOR; } - } diff --git a/src/main/java/ui/avatarpd/AvatarPDAttributeConnector.java b/src/main/java/ui/avatarpd/AvatarPDAttributeConnector.java index 7b7fc8efaeea33f8b234af9e77b9baa7daf5828a..29e0b10570f63193741fd680b2f77f0058edcd9b 100644 --- a/src/main/java/ui/avatarpd/AvatarPDAttributeConnector.java +++ b/src/main/java/ui/avatarpd/AvatarPDAttributeConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import myutil.GraphicLib; import ui.*; import ui.util.IconManager; @@ -58,22 +54,22 @@ import java.util.Vector; * @version 1.0 22/04/2010 * @author Ludovic APVRILLE */ -public class AvatarPDAttributeConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class AvatarPDAttributeConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 6; //square length - protected double oldScaleFactor; + //protected double oldScaleFactor; protected int fontSize = 12; - public AvatarPDAttributeConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; value = ""; editable = true; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); } + @Override 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); @@ -90,15 +86,15 @@ public class AvatarPDAttributeConnector extends TGConnectorWithCommentConnectio if (p == null) { // } else { - if (Point2D.distance(x1, y1, p.x, p.y) < GraphicLib.longueur * 1.5) { + if (Point2D.distance(x1, y1, p.x, p.y) < GraphicLib.longueur * 1.5) { // - if ((p.x != x1) || (p.y != y1)) { - g.drawLine(x1, y1, p.x, p.y); + if ((p.x != x1) || (p.y != y1)) { + g.drawLine(x1, y1, p.x, p.y); // + } + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, p.x, p.y, true); } - } else { - GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, p.x, p.y, true); - } } /*if (value.length() > 0) { @@ -110,7 +106,6 @@ public class AvatarPDAttributeConnector extends TGConnectorWithCommentConnectio g.drawString(value, x2-(cz/2), y2-(cz/2)-1); g.setFont(f); }*/ - } /*public boolean editOndoubleClick(JFrame frame) { @@ -135,34 +130,32 @@ public class AvatarPDAttributeConnector extends TGConnectorWithCommentConnectio return false; }*/ - + @Override public int getType() { return TGComponentManager.APD_ATTRIBUTE_CONNECTOR; } - - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } - - + // Issue #31 Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } } diff --git a/src/main/java/ui/avatarpd/AvatarPDAttributeSetting.java b/src/main/java/ui/avatarpd/AvatarPDAttributeSetting.java index 8bfd40ef15ba71cefd02bab98793e7ea085afb80..78fd570d39c49a994bebd3c7b9a965f7375568aa 100644 --- a/src/main/java/ui/avatarpd/AvatarPDAttributeSetting.java +++ b/src/main/java/ui/avatarpd/AvatarPDAttributeSetting.java @@ -56,25 +56,28 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDAttributeSetting extends AvatarPDToggle implements ConstraintListInterface { - private int textY1 = 3; + //private int textY1 = 3; //private int textY2 = 30; public static final String[] STEREOTYPES = {"<<setting>>"}; protected String oldValue = ""; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 1; + //private int maxFontSize = 12; +// private int minFontSize = 4; + //private int currentFontSize = -1; +// private boolean displayText = true; +// private int textX = 1; public AvatarPDAttributeSetting(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(125* tdp.getZoom()); - height = (int)(50 * tdp.getZoom()); + width = 125;//(int)(125* tdp.getZoom()); + height = 50;//(int)(50 * tdp.getZoom()); minWidth = 100; + textY = 3; + textX = 1; + initScaling(125, 50); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -104,122 +107,141 @@ public class AvatarPDAttributeSetting extends AvatarPDToggle implements Constrai value = "c = a + b"; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); + //currentFontSize = maxFontSize; + //oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic1078; } - public void internalDrawing(Graphics g) { - String ster; - ster = STEREOTYPES[0]; - Font f = g.getFont(); - Font fold = f; - - if (valueChanged) { - setValueWidth(g); - } - - 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, maxFontSize)); - int w0, w1, w2; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (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); - } - - } - - Color c = g.getColor(); + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); g.setColor(ColorManager.AVATARPD_ATTRIBUTE); - g.fill3DRect(x+1, y+1, width-1, toggleHeight-1, true); + g.fill3DRect(x+1, y+1, width-1, scale(toggleHeight - 1), true); g.setColor(ColorManager.AVATARPD_SIGNAL); - g.fill3DRect(x+1, y+toggleHeight, width-1, height-toggleHeight, true); + g.fill3DRect(x+1, y + scale(toggleHeight), width-1, height - scale(toggleHeight), true); g.setColor(c); - - // Strings - int w; - if (displayText) { - f = f.deriveFont((float)currentFontSize); - Font f0 = g.getFont(); - - boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY1 * tdp.getZoom()))); - - if (cannotWriteAttack) { - w = g.getFontMetrics().stringWidth(value); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } else { - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - } - } - } else { - g.setFont(f.deriveFont(Font.BOLD)); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - int cumulated = 0; - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - cumulated = h; - } - g.setFont(f0); - w = g.getFontMetrics().stringWidth(value); - h = cumulated + currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } - String s = getFullToggle(); - w = g.getFontMetrics().stringWidth(s); - h = height-toggleDecY; - if ((w < (2*textX + width)) && (h < height)) { - g.setFont(f.deriveFont(Font.ITALIC)); - g.drawString(s, x + (width - w)/2, y + h); - } - } - } - - g.setFont(fold); - + + //Strings + String ster = STEREOTYPES[0]; + Font f = g.getFont(); + drawDoubleString(g, ster, value); + drawSingleString(g, getFullToggle(), getCenter(g, getFullToggle()), y + f.getSize() * 3 + scale(9)); } - - + +// public void internalDrawing(Graphics g) { +// String ster; +// ster = STEREOTYPES[0]; +// Font f = g.getFont(); +// Font fold = f; +// +// if (valueChanged) { +// setValueWidth(g); +// } +// +// 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, maxFontSize)); +// int w0, w1, w2; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (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); +// } +// +// } +// +// Color c = g.getColor(); +// g.draw3DRect(x, y, width, height, true); +// g.setColor(ColorManager.AVATARPD_ATTRIBUTE); +// g.fill3DRect(x+1, y+1, width-1, toggleHeight-1, true); +// g.setColor(ColorManager.AVATARPD_SIGNAL); +// g.fill3DRect(x+1, y+toggleHeight, width-1, height-toggleHeight, true); +// g.setColor(c); +// +// // Strings +// int w; +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// Font f0 = g.getFont(); +// +// boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY * tdp.getZoom()))); +// +// if (cannotWriteAttack) { +// w = g.getFontMetrics().stringWidth(value); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } else { +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// } +// } +// } else { +// g.setFont(f.deriveFont(Font.BOLD)); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// int cumulated = 0; +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// cumulated = h; +// } +// g.setFont(f0); +// w = g.getFontMetrics().stringWidth(value); +// h = cumulated + currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } +// String s = getFullToggle(); +// w = g.getFontMetrics().stringWidth(s); +// h = height-toggleDecY; +// if ((w < (2*textX + width)) && (h < height)) { +// g.setFont(f.deriveFont(Font.ITALIC)); +// g.drawString(s, x + (width - w)/2, y + h); +// } +// } +// } +// +// g.setFont(fold); +// +// } + + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { - String tmp; - boolean error = false; + //String tmp; + //boolean error = false; //String text = getName() + ": "; if (_y < y + toggleHeight) { @@ -242,6 +264,7 @@ public class AvatarPDAttributeSetting extends AvatarPDToggle implements Constrai } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -250,14 +273,17 @@ public class AvatarPDAttributeSetting extends AvatarPDToggle implements Constrai return null; } + @Override public int getType() { return TGComponentManager.APD_ATTRIBUTE_SETTING; } + @Override public String[] getConstraintList() { return STEREOTYPES; } + @Override public String getCurrentConstraint() { return value; } diff --git a/src/main/java/ui/avatarpd/AvatarPDBlock.java b/src/main/java/ui/avatarpd/AvatarPDBlock.java index cd06ff9a8221a201f12e25e5d5956b8653a53ded..a7be04f652dfd4dc6900f16125e2c8670809661e 100644 --- a/src/main/java/ui/avatarpd/AvatarPDBlock.java +++ b/src/main/java/ui/avatarpd/AvatarPDBlock.java @@ -42,11 +42,13 @@ package ui.avatarpd; import myutil.GraphicLib; + import ui.*; import ui.util.IconManager; import javax.swing.*; import java.awt.*; +//import java.awt.image.ImageObserver;import myutil.TraceManager; import java.util.LinkedList; import java.util.Vector; @@ -59,22 +61,22 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent { - private int textY1 = 3; + //private int textY1 = 3; private String stereotype = "block"; - private int maxFontSize = 12; - private int minFontSize = 4; + //private int maxFontSize = 12; + //private int minFontSize = 4; private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 7; + //private boolean displayText = true; + //private int textX = 7; - private int limitName = -1; - private int limitAttr = -1; - private int limitMethod = -1; +// private int limitName = -1; +// private int limitAttr = -1; +// private int limitMethod = -1; // Icon private int iconSize = 15; - private boolean iconIsDrawn = false; +// private boolean iconIsDrawn = false; public String oldValue; @@ -82,10 +84,16 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S public AvatarPDBlock(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 200; + // Issue #31 + textY = 3; + textX = 7; minWidth = 5; minHeight = 2; + initScaling(250, 200); + + // width = 250; + // height = 200; + nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -122,273 +130,338 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S setValue(name); oldValue = value; - currentFontSize = maxFontSize; + //currentFontSize = maxFontSize; oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic700; actionOnAdd(); } + /** + * will get the position which represent the center of the box + * we are drawing. It will use the stringWidth so that the center is + * calculated in function of the string we want to draw. + * this function is used in internalDrawing + * @param g + * @param str + * @return + */ + - public void internalDrawing(Graphics g) { - String ster = "<<" + stereotype + ">>"; - Font f = g.getFont(); - Font fold = f; - - // - - 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, maxFontSize)); - int w0, w1, w2; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (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); - } - - } - - // - - Color c = g.getColor(); - + @Override + public void internalDrawing(Graphics g) + { + //Rectangle and filling + currentFontSize = g.getFont().getSize(); g.draw3DRect(x, y, width, height, true); - - //g.setColor(ColorManager.AVATAR_BLOCK); - Color avat = ColorManager.AVATAR_BLOCK; - int h; - h = 2* (currentFontSize + (int)(textY1 * tdp.getZoom())) + 2; - g.setColor(new Color(avat.getRed(), avat.getGreen(), avat.getBlue() + (getMyDepth() * 10))); - g.fill3DRect(x+1, y+1, width-1, Math.min(h, height)-1, true); - g.setColor(c); - - // Strings - int w; - h = 0; - if (displayText) { - f = f.deriveFont((float)currentFontSize); - Font f0 = g.getFont(); - g.setFont(f.deriveFont(Font.BOLD)); - - w = g.getFontMetrics().stringWidth(ster); - h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y +h); - } - g.setFont(f0); - w = g.getFontMetrics().stringWidth(value); - h = 2* (currentFontSize + (int)(textY1 * tdp.getZoom())); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } - limitName = y + h; - } else { - limitName = -1; - } - - g.setFont(fold); - - h = h +2; - if (h < height) { - //g.drawLine(x, y+h, x+width, y+h); - g.setColor(new Color(avat.getRed(), avat.getGreen(), avat.getBlue() + (getMyDepth() * 10))); - g.fill3DRect(x+1, y+h, width-1, height-1-h, true); - g.setColor(c); + int compartmentHeight = (currentFontSize + (2 * textY)) * 2; + if (compartmentHeight < height) { + Color savecurrColor = g.getColor(); + Color avatarColor = ColorManager.AVATAR_BLOCK; + g.setColor(new Color(avatarColor.getRed(), avatarColor.getGreen(), avatarColor.getBlue() + (getMyDepth() * 10))); + g.fill3DRect(x + 1, y + compartmentHeight, width - 1, height - compartmentHeight, true); + g.fill3DRect(x + 1, y + 1, width - 1, compartmentHeight - 1, true); + g.setColor(savecurrColor); } // Icon - if ((width>30) && (height > (iconSize + 2*textX))) { - iconIsDrawn = true; - g.drawImage(IconManager.img5100, x + width - iconSize - textX, y + textX, null); - } else { - iconIsDrawn = false; - } - - /*int cpt = h; - // Attributes - if (((AvatarBDPanel)tdp).areAttributesVisible()) { - limitAttr = -1; - int index = 0; - 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 = (TAttribute)(myAttributes.get(index)); - attr = a.toString(); - w = g.getFontMetrics().stringWidth(attr); - if ((w + (2 * textX) + 1) < width) { - g.drawString(attr, x + textX, y + cpt); - limitAttr = y + cpt; - } else { - attr = "..."; - w = g.getFontMetrics().stringWidth(attr); - if ((w + textX + 2) < width) { - g.drawString(attr, x + textX + 1, y + cpt); - limitAttr = y + cpt; - } else { - // skip attribute - cpt -= step; - } - } - index ++; - } - } else { - limitAttr = -1; - } - - // Methods - if (((AvatarBDPanel)tdp).areAttributesVisible()) { - limitMethod = -1; - if (myMethods.size() > 0) { - if (cpt < height) { - cpt += textY1; - g.drawLine(x, y+cpt, x+width, y+cpt); - cpt += textY1; - } - } - - int index = 0; - String method; - AvatarMethod am; - - 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 < myMethods.size()) { - cpt += step ; - if (cpt >= (height - textX)) { - break; - } - am = (AvatarMethod)(myMethods.get(index)); - method = "- " + am.toString(); - w = g.getFontMetrics().stringWidth(method); - if ((w + (2 * textX) + 1) < width) { - g.drawString(method, x + textX, y + cpt); - limitMethod = y + cpt; - } else { - method = "..."; - w = g.getFontMetrics().stringWidth(method); - if ((w + textX + 2) < width) { - g.drawString(method, x + textX + 1, y + cpt); - limitMethod = y + cpt; - } else { - // skip attribute - cpt -= step; - } - } - index ++; - } - } else { - limitMethod = -1; - } - - // Signals - if (((AvatarBDPanel)tdp).areAttributesVisible()) { - - if (mySignals.size() > 0) { - if (cpt < height) { - cpt += textY1; - g.drawLine(x, y+cpt, x+width, y+cpt); - cpt += textY1; - } - } - - int index = 0; - String signal; - AvatarSignal as; - - 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 < mySignals.size()) { - cpt += step ; - if (cpt >= (height - textX)) { - break; - } - as = (AvatarSignal)(mySignals.get(index)); - signal = as.toString(); - w = g.getFontMetrics().stringWidth(signal); - if ((w + (2 * textX) + 1) < width) { - g.drawString(signal, x + textX, y + cpt); - } else { - signal = "..."; - w = g.getFontMetrics().stringWidth(signal); - if ((w + textX + 2) < width) { - g.drawString(signal, x + textX + 1, y + cpt); - } else { - // skip attribute - cpt -= step; - } - } - index ++; - } - }*/ - - g.setFont(fold); - - /*int w = g.getFontMetrics().stringWidth(ster); + //int border = scale(5); + //g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize) - border, y + border, Color.yellow, null); + drawIcon(g, IconManager.img5100, iconSize); + //String Title + Stereotype + //Issue #31: isTextReadable and canTextgointheBox function are used to make sure the display is going to be correct Font f = g.getFont(); + int fontSize = f.getSize(); +// if (isTextReadable(g) && canTextGoInTheBox(g, fontSize, value, iconSize)) +// { +// g.setFont(f.deriveFont(Font.BOLD)); +// g.drawString(value, getCenterOfBox(g, value), y + currentFontSize); +// } g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(ster, x + (width - w)/2, y + textY1); - g.setFont(f); - w = g.getFontMetrics().stringWidth(value); - g.drawString(value, x + (width - w)/2, y + textY2);*/ - - // Icon - //g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + drawSingleString(g, value, getCenterOfBox(g, value), y + currentFontSize); + String ster ="<<stereotype>>"; + if (isTextReadable(g) && canTextGoInTheBox(g, fontSize, ster, 0)) + { + g.setFont(f.deriveFont(Font.PLAIN)); + //g.drawString(ster, getCenterOfBox(g, ster), y + currentFontSize * 2 + textY); + drawSingleString(g, ster, getCenterOfBox(g, ster), y + currentFontSize * 2 + textY); + } } - +// +// @Override +// public void internalDrawing(Graphics g) { +// //TraceManager.addDev("Hello this is AvatarPDBlock ---- "); +// String ster = "<<" + stereotype + ">>"; +// Font f = g.getFont(); +// Font fold = f; +// int currentFontSize = f.getSize(); +// if ( (!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 maxTextSize = Math.max(0, Math.min(height, maxFontSize)); +// int w0, w1, w2; +// //f = f.deriveFont((float)maxCurrentFontSize); +// //g.setFont(f); +// +// while(maxTextSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (2*textX))) { +// break; +// } +// maxTextSize--; +// f = f.deriveFont((float)maxTextSize); +// g.setFont(f); +// } +// currentFontSize = maxTextSize; +// f = f.deriveFont((float)maxTextSize); +// g.setFont(f); +// +// if (currentFontSize <minFontSize) { +// displayText = false; +// } else { +// displayText = true; +// f = f.deriveFont((float)currentFontSize); +// g.setFont(f); +// } +// +// } +// +// // +// +// Color c = g.getColor(); +// //contour rectangle +// g.draw3DRect(x, y, width, height, true); +// +// //g.setColor(ColorManager.AVATAR_BLOCK); +// Color avat = ColorManager.AVATAR_BLOCK; +// int compartmentHeight = 2 *( currentFontSize + textY )+ scale(2); +// //compartmentHeight = 2* (currentFontSize + (int)(textY * tdp.getZoom())) + 2; +// +// g.setColor(new Color(avat.getRed(), avat.getGreen(), avat.getBlue() + (getMyDepth() * 10))); +// g.fill3DRect(x+1, y+1, +// width-1, Math.min(compartmentHeight, height)-1, true); +// g.setColor(c); +// +// // Strings +// int w; +// compartmentHeight = displayText ? 0: compartmentHeight; +// if (displayText) { +// f = f.deriveFont((float)(currentFontSize)); +// Font f0 = g.getFont(); +// g.setFont(f.deriveFont(Font.BOLD)); +// +// //this part is the top text between << >> in an avatar PD diagrams +// w = g.getFontMetrics().stringWidth(ster); +// compartmentHeight = currentFontSize + textY; +// //compartmentHeight = currentFontSize + (int)(textY * tdp.getZoom()); //zoom i suppose +// +// if ((w < (2*textX + width)) && (compartmentHeight < height)) +// g.drawString(ster, x + (width - w)/2, y +compartmentHeight); +// +// // this part is the line just under the << >> +// //FIXME:this text zooms glitch, +// //when clicking on zoom the diagrams indeed zooms +// //but the text only take its zoomed form after the user click on the screen +// g.setFont(f0); +// w = g.getFontMetrics().stringWidth(value); +// // already done upper +// //compartmentHeight = 2 * (currentFontSize + (int)(textY * tdp.getZoom())); +// if ((w < (2*textX + width)) && (compartmentHeight < height)) { +// int middle = x + (width - w)/2; +// g.drawString(value, middle, y + compartmentHeight); +// } +// //limitName = y + compartmentHeight; +// } else +// //limitName = -1; +// +// +// //g.setFont(fold); +// +// compartmentHeight = compartmentHeight + scale(4); +// if (compartmentHeight < height) { +// //g.drawLine(x, y+h, x+width, y+h); +// g.setColor(new Color(avat.getRed(), avat.getGreen(), avat.getBlue() + (getMyDepth() * 10))); +// g.fill3DRect(x+1, y+compartmentHeight-2, width-1, height-1-compartmentHeight, true); +// g.setColor(c); +// } +// +// // Icon +// if ((width > scale(30)) && (height > (scale(iconSize) + 2*textX))) { +// //iconIsDrawn = true; +// g.drawImage( scale(IconManager.img5100), x + width - scale( iconSize + 3 ), y + scale( 3 ), Color.yellow, null); +// //g.drawImage(IconManager.img5100, x + width - iconSize - textX, y + textX, null); +// } else { +// //iconIsDrawn = false; +// } +// +// /*int cpt = h; +// // Attributes +// if (((AvatarBDPanel)tdp).areAttributesVisible()) { +// limitAttr = -1; +// int index = 0; +// 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 = (TAttribute)(myAttributes.get(index)); +// attr = a.toString(); +// w = g.getFontMetrics().stringWidth(attr); +// if ((w + (2 * textX) + 1) < width) { +// g.drawString(attr, x + textX, y + cpt); +// limitAttr = y + cpt; +// } else { +// attr = "..."; +// w = g.getFontMetrics().stringWidth(attr); +// if ((w + textX + 2) < width) { +// g.drawString(attr, x + textX + 1, y + cpt); +// limitAttr = y + cpt; +// } else { +// // skip attribute +// cpt -= step; +// } +// } +// index ++; +// } +// } else { +// limitAttr = -1; +// } +// +// // Methods +// if (((AvatarBDPanel)tdp).areAttributesVisible()) { +// limitMethod = -1; +// if (myMethods.size() > 0) { +// if (cpt < height) { +// cpt += textY1; +// g.drawLine(x, y+cpt, x+width, y+cpt); +// cpt += textY1; +// } +// } +// +// int index = 0; +// String method; +// AvatarMethod am; +// +// 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 < myMethods.size()) { +// cpt += step ; +// if (cpt >= (height - textX)) { +// break; +// } +// am = (AvatarMethod)(myMethods.get(index)); +// method = "- " + am.toString(); +// w = g.getFontMetrics().stringWidth(method); +// if ((w + (2 * textX) + 1) < width) { +// g.drawString(method, x + textX, y + cpt); +// limitMethod = y + cpt; +// } else { +// method = "..."; +// w = g.getFontMetrics().stringWidth(method); +// if ((w + textX + 2) < width) { +// g.drawString(method, x + textX + 1, y + cpt); +// limitMethod = y + cpt; +// } else { +// // skip attribute +// cpt -= step; +// } +// } +// index ++; +// } +// } else { +// limitMethod = -1; +// } +// +// // Signals +// if (((AvatarBDPanel)tdp).areAttributesVisible()) { +// +// if (mySignals.size() > 0) { +// if (cpt < height) { +// cpt += textY1; +// g.drawLine(x, y+cpt, x+width, y+cpt); +// cpt += textY1; +// } +// } +// +// int index = 0; +// String signal; +// AvatarSignal as; +// +// 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 < mySignals.size()) { +// cpt += step ; +// if (cpt >= (height - textX)) { +// break; +// } +// as = (AvatarSignal)(mySignals.get(index)); +// signal = as.toString(); +// w = g.getFontMetrics().stringWidth(signal); +// if ((w + (2 * textX) + 1) < width) { +// g.drawString(signal, x + textX, y + cpt); +// } else { +// signal = "..."; +// w = g.getFontMetrics().stringWidth(signal); +// if ((w + textX + 2) < width) { +// g.drawString(signal, x + textX + 1, y + cpt); +// } else { +// // skip attribute +// cpt -= step; +// } +// } +// index ++; +// } +// }*/ +// +// g.setFont(fold); +// +// /*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(value); +// g.drawString(value, x + (width - w)/2, y + textY2);*/ +// +// // Icon +// //g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); +// //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); +// } + + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -406,6 +479,7 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S return name; } + @Override public boolean editOndoubleClick(JFrame frame) { oldValue = value; @@ -448,9 +522,9 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S } } return false; - } - + + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { if (tgc instanceof AvatarPDBlock) { return true; @@ -464,11 +538,12 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S } - + @Override public int getType() { return TGComponentManager.APD_BLOCK; } + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { boolean swallowed = false; @@ -531,6 +606,7 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S return true; } + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeMyInternalComponent(tgc, false); } @@ -577,7 +653,7 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S } - + @Override public void hasBeenResized() { for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarPDBlock) { @@ -596,7 +672,7 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S } } - + @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarPDBlock)) { // Too large to fit in the father? -> resize it! @@ -663,7 +739,7 @@ public class AvatarPDBlock extends TGCScalableWithInternalComponent implements S } - + @Override public int getDefaultConnector() { return TGComponentManager.APD_COMPOSITION_CONNECTOR; } diff --git a/src/main/java/ui/avatarpd/AvatarPDBoolEq.java b/src/main/java/ui/avatarpd/AvatarPDBoolEq.java index 26425060b9b7475054d41d8d2a9b37e85edc7320..711fa8e6e8e1e1bf93de52bc3951f0c727e5b165 100644 --- a/src/main/java/ui/avatarpd/AvatarPDBoolEq.java +++ b/src/main/java/ui/avatarpd/AvatarPDBoolEq.java @@ -56,26 +56,29 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDBoolEq extends AvatarPDToggle implements ConstraintListInterface { - private int textY1 = 3; +// private int textY = 3; //private int textY2 = 30; public static final String[] STEREOTYPES = {"<<equation>>"}; protected String oldValue = ""; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; + //private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; public AvatarPDBoolEq(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(125* tdp.getZoom()); - height = (int)(50 * tdp.getZoom()); + width = 125;//(int)(125* tdp.getZoom()); + height = 50;//(int)(50 * tdp.getZoom()); minWidth = 100; + //Issue #31 + textY = 3; + initScaling(125, 50); nbConnectingPoint = 11; connectingPoint = new TGConnectingPoint[11]; @@ -105,122 +108,145 @@ public class AvatarPDBoolEq extends AvatarPDToggle implements ConstraintListInte decXToggle = (float)0.5; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic1078; } - public void internalDrawing(Graphics g) { - String ster; - ster = STEREOTYPES[0]; - Font f = g.getFont(); - Font fold = f; - - if (valueChanged) { - setValueWidth(g); - } - - 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, maxFontSize)); - int w0, w1, w2; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (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); - } - - } - - /*Color c = g.getColor(); - g.draw3DRect(x, y, width, height, true); - g.setColor(ColorManager.AVATARPD_ATTRIBUTE); - g.fill3DRect(x+1, y+1, width-1, height-1, true); - //g.fill3DRect(x+1, y+1, width-1, toggleHeight-1, true); - g.setColor(ColorManager.AVATARPD_SIGNAL); - g.fill3DRect(x+(int)(decXToggle*width)+1, y+toggleHeight, width-1-(int)(decXToggle*width), height-toggleHeight, true); - g.setColor(c);*/ - GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_ATTRIBUTE, g.getColor()); - GraphicLib.draw3DRoundRectangle(g, x+(int)(decXToggle*width), y+toggleHeight, width-1-(int)(decXToggle*width), height-toggleHeight, AvatarPDPanel.ARC, ColorManager.AVATARPD_SIGNAL, g.getColor()); - + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_ATTRIBUTE, g.getColor()); + GraphicLib.draw3DRoundRectangle(g, x + (int)(decXToggle*width), y + scale(toggleHeight), width-1-(int)(decXToggle*width), height-scale(toggleHeight), AvatarPDPanel.ARC, ColorManager.AVATARPD_SIGNAL, g.getColor()); - // Strings - int w; - if (displayText) { - f = f.deriveFont((float)currentFontSize); - Font f0 = g.getFont(); - - boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY1 * tdp.getZoom()))); - - if (cannotWriteAttack) { - w = g.getFontMetrics().stringWidth(value); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } else { - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - } - } - } else { - g.setFont(f.deriveFont(Font.BOLD)); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - int cumulated = 0; - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - cumulated = h; - } - g.setFont(f0); - w = g.getFontMetrics().stringWidth(value); - h = cumulated + currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } - String s = getFullToggle(); - w = g.getFontMetrics().stringWidth(s); - h = height-toggleDecY; - if ((w < (2*textX + width)) && (h < height)) { - g.setFont(f.deriveFont(Font.ITALIC)); - g.drawString(s, x + (int)(decXToggle*width) + (width - (int)(decXToggle*width) - w)/2, y + h); - } - } - } + //Strings + String ster = STEREOTYPES[0]; + Font f = g.getFont(); + int curH = f.getSize(); + drawDoubleString(g, ster, value); - g.setFont(fold); - + String s = getFullToggle(); + int strWidth = g.getFontMetrics().stringWidth(s); + curH = height-toggleDecY; + g.setFont(f.deriveFont(Font.ITALIC)); + drawSingleString(g, s, x + (int)(decXToggle*width) + (width - (int)(decXToggle*width) - strWidth)/2, y + curH); + } +// public void internalDrawing(Graphics g) { +// String ster; +// ster = STEREOTYPES[0]; +// Font f = g.getFont(); +// Font fold = f; +// +// if (valueChanged) { +// setValueWidth(g); +// } +// +// 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, maxFontSize)); +// int w0, w1, w2; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (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); +// } +// +// } +// +// /*Color c = g.getColor(); +// g.draw3DRect(x, y, width, height, true); +// g.setColor(ColorManager.AVATARPD_ATTRIBUTE); +// g.fill3DRect(x+1, y+1, width-1, height-1, true); +// //g.fill3DRect(x+1, y+1, width-1, toggleHeight-1, true); +// g.setColor(ColorManager.AVATARPD_SIGNAL); +// g.fill3DRect(x+(int)(decXToggle*width)+1, y+toggleHeight, width-1-(int)(decXToggle*width), height-toggleHeight, true); +// g.setColor(c);*/ +// GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_ATTRIBUTE, g.getColor()); +// GraphicLib.draw3DRoundRectangle(g, x+(int)(decXToggle*width), y+toggleHeight, width-1-(int)(decXToggle*width), height-toggleHeight, AvatarPDPanel.ARC, ColorManager.AVATARPD_SIGNAL, g.getColor()); +// +// +// // Strings +// int w; +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// Font f0 = g.getFont(); +// +// boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY * tdp.getZoom()))); +// +// if (cannotWriteAttack) { +// w = g.getFontMetrics().stringWidth(value); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } else { +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// } +// } +// } else { +// g.setFont(f.deriveFont(Font.BOLD)); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// int cumulated = 0; +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// cumulated = h; +// } +// g.setFont(f0); +// w = g.getFontMetrics().stringWidth(value); +// h = cumulated + currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } +// String s = getFullToggle(); +// w = g.getFontMetrics().stringWidth(s); +// h = height-toggleDecY; +// if ((w < (2*textX + width)) && (h < height)) { +// g.setFont(f.deriveFont(Font.ITALIC)); +// g.drawString(s, x + (int)(decXToggle*width) + (width - (int)(decXToggle*width) - w)/2, y + h); +// } +// } +// } +// +// g.setFont(fold); +// +// } +// + + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { //String text = getName() + ": "; @@ -247,8 +273,8 @@ public class AvatarPDBoolEq extends AvatarPDToggle implements ConstraintListInte } - + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -257,14 +283,17 @@ public class AvatarPDBoolEq extends AvatarPDToggle implements ConstraintListInte return null; } + @Override public int getType() { return TGComponentManager.APD_BOOLEQ; } - + + @Override public String[] getConstraintList() { return STEREOTYPES; } - + + @Override public String getCurrentConstraint() { return value; } diff --git a/src/main/java/ui/avatarpd/AvatarPDCompositionConnector.java b/src/main/java/ui/avatarpd/AvatarPDCompositionConnector.java index 8641f3511d9c34b4e0b8c4ae9f686a3f8c32e7c6..86e1fc9c097ffbb5adb8d6c7fb94be0c58ac53ea 100644 --- a/src/main/java/ui/avatarpd/AvatarPDCompositionConnector.java +++ b/src/main/java/ui/avatarpd/AvatarPDCompositionConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import ui.*; import ui.util.IconManager; @@ -55,14 +51,14 @@ import java.util.Vector; * @version 1.0 23/04/2010 * @author Ludovic APVRILLE */ -public class AvatarPDCompositionConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent{ +public class AvatarPDCompositionConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/{ protected int d = 20; protected int D = 26; //protected int widthValue, heightValue, maxWidthValue, h; protected Polygon p; protected int xp1, xp2, yp1, yp2; - protected double oldScaleFactor; - protected boolean rescaled; +// protected double oldScaleFactor; +// protected boolean rescaled; public AvatarPDCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { @@ -72,10 +68,11 @@ public class AvatarPDCompositionConnector extends TGConnectorWithCommentConnect value = "{info}"; editable = true; - oldScaleFactor = tdp.getZoom(); - rescaled = true; +// oldScaleFactor = tdp.getZoom(); +// rescaled = true; } + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { if ((p == null) || (rescaled) || (xp1 != x1) || (xp2 != x2) || (yp1 != y1) || (yp2 != y2)){ p = new Polygon(); @@ -83,7 +80,7 @@ public class AvatarPDCompositionConnector extends TGConnectorWithCommentConnect xp2 = x2; yp1 = y1; yp2 = y2; - Double alpha; + //Double alpha; int dd = (int)(d*tdp.getZoom()); int DD = (int)(D*tdp.getZoom()); @@ -166,6 +163,7 @@ public class AvatarPDCompositionConnector extends TGConnectorWithCommentConnect rescaled = false; } + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (p != null) { if (p.contains(x1, y1)) { @@ -175,36 +173,34 @@ public class AvatarPDCompositionConnector extends TGConnectorWithCommentConnect return null; } - - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - rescaled = true; - } +// Issue #31: Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// rescaled = true; +// } + @Override public int getType() { return TGComponentManager.APD_COMPOSITION_CONNECTOR; } - - - } diff --git a/src/main/java/ui/avatarpd/AvatarPDConnectingPoint.java b/src/main/java/ui/avatarpd/AvatarPDConnectingPoint.java index c8bcd98175711a7e19e0ffd1f68e564b22174cf7..0e52e46968b228519bb0bcc1353bc98ae1e853f2 100644 --- a/src/main/java/ui/avatarpd/AvatarPDConnectingPoint.java +++ b/src/main/java/ui/avatarpd/AvatarPDConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class AvatarPDConnectingPoint extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.APD_COMPOSITION_CONNECTOR; } - } diff --git a/src/main/java/ui/avatarpd/AvatarPDForbiddenSignalConnectingPoint.java b/src/main/java/ui/avatarpd/AvatarPDForbiddenSignalConnectingPoint.java index 2f06e437f50565313c19a8c05f86c4da552953b2..6e8a7e7e1fcb263a7911f109e92f1eb7c931a299 100644 --- a/src/main/java/ui/avatarpd/AvatarPDForbiddenSignalConnectingPoint.java +++ b/src/main/java/ui/avatarpd/AvatarPDForbiddenSignalConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class AvatarPDForbiddenSignalConnectingPoint extends TGConnectingPointWi super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.APD_SIGNAL_CONNECTOR; } - } diff --git a/src/main/java/ui/avatarpd/AvatarPDLogicalConstraint.java b/src/main/java/ui/avatarpd/AvatarPDLogicalConstraint.java index 2a1b3ac1f73767651b06bdb9e39133963f21dc38..5b5556fccf4c0b50e8fd0107baf033466394e4e2 100644 --- a/src/main/java/ui/avatarpd/AvatarPDLogicalConstraint.java +++ b/src/main/java/ui/avatarpd/AvatarPDLogicalConstraint.java @@ -57,25 +57,27 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDLogicalConstraint extends TGCScalableWithInternalComponent implements ConstraintListInterface { - private int textY1 = 5; + //private int textY1 = 5; //private int textY2 = 30; public static final String[] STEREOTYPES = {"<<LC>>", "<<LS>>"}; protected String oldValue = ""; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 1; +// private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; +// private int textX = 1; public AvatarPDLogicalConstraint(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(60* tdp.getZoom()); - height = (int)(100 * tdp.getZoom()); + width = 60; + height = 100; minWidth = 50; + textY = 5; + initScaling(60, 100); nbConnectingPoint = 20; connectingPoint = new TGConnectingPoint[20]; @@ -112,74 +114,97 @@ public class AvatarPDLogicalConstraint extends TGCScalableWithInternalComponent value = STEREOTYPES[0]; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic1078; } - - public void internalDrawing(Graphics g) { - - Font f = g.getFont(); - // Font fold = f; - - 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, maxFontSize)); - int w0; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - if (w0 < (width - (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); - } - - } - - GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_LOGICAL_CONSTRAINT, g.getColor()); - - /*Color c = g.getColor(); - g.draw3DRect(x, y, width, height, true); - - g.setColor(ColorManager.AVATARPD_TEMPORAL_CONSTRAINT); - g.fill3DRect(x+1, y+1, width-1, height-1, true); - g.setColor(c);*/ - - Font f0 = g.getFont(); - if (displayText) { - f = f.deriveFont((float)currentFontSize); - g.setFont(f.deriveFont(Font.BOLD)); - int w = g.getFontMetrics().stringWidth(value); - g.drawString(value, x + (width - w)/2, y + currentFontSize + (int)(textY1*tdp.getZoom())); - g.setFont(f0); - } - + + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_LOGICAL_CONSTRAINT, g.getColor()); + + //Issue #31: String + //int fontSize = g.getFont().getSize(); + Font f =g.getFont(); +// if (isTextReadable(g)) +// { +// int currentFontSize = f.getSize(); +// int strwidth = g.getFontMetrics().stringWidth(value); +// int center = x + (width - strwidth)/2; +// g.setFont(f.deriveFont(Font.BOLD)); +// g.drawString(value, center, y + scale(currentFontSize + 3)); +// g.setFont(f.deriveFont(Font.PLAIN)); +// } + g.setFont(f.deriveFont(Font.BOLD)); + drawSingleString(g, value, getCenter(g, value), y + f.getSize()); + g.setFont(f.deriveFont(Font.PLAIN)); } + +// public void internalDrawing(Graphics g) { +// +// Font f = g.getFont(); +//// Font fold = f; +// +// 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, maxFontSize)); +// int w0; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// if (w0 < (width - (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); +// } +// +// } +// +// GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_LOGICAL_CONSTRAINT, g.getColor()); +// +// /*Color c = g.getColor(); +// g.draw3DRect(x, y, width, height, true); +// +// g.setColor(ColorManager.AVATARPD_TEMPORAL_CONSTRAINT); +// g.fill3DRect(x+1, y+1, width-1, height-1, true); +// g.setColor(c);*/ +// +// Font f0 = g.getFont(); +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// g.setFont(f.deriveFont(Font.BOLD)); +// int w = g.getFontMetrics().stringWidth(value); +// g.drawString(value, x + (width - w)/2, y + currentFontSize + (int)(textY1*tdp.getZoom())); +// g.setFont(f0); +// } +// +// } diff --git a/src/main/java/ui/avatarpd/AvatarPDPanel.java b/src/main/java/ui/avatarpd/AvatarPDPanel.java index 09f0f6a1427cdb396d5fe58a48f83ba025c27007..820ecc9049c5729bc2a7ec79a5e7e47b977037a8 100644 --- a/src/main/java/ui/avatarpd/AvatarPDPanel.java +++ b/src/main/java/ui/avatarpd/AvatarPDPanel.java @@ -71,41 +71,52 @@ public class AvatarPDPanel extends TDiagramPanel implements TDPWithAttributes{ addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return true; } + @Override public boolean actionOnAdd(TGComponent tgc) { return false; - } + } + + @Override public boolean actionOnValueChanged(TGComponent tgc) { return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { return false; } + @Override public String getXMLHead() { return "<AvatarPDPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } + @Override public String getXMLTail() { return "</AvatarPDPanel>"; } + @Override public String getXMLSelectedHead() { return "<AvatarPDPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</AvatarPDPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<AvatarPDPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</AvatarPDPanelCopy>"; } @@ -119,7 +130,8 @@ public class AvatarPDPanel extends TDiagramPanel implements TDPWithAttributes{ } - + + @Override public boolean hasAutoConnect() { return false; } diff --git a/src/main/java/ui/avatarpd/AvatarPDProperty.java b/src/main/java/ui/avatarpd/AvatarPDProperty.java index 54c681a31415bbfeb6e6bbc90a1d9f3f2a589fac..1e063ce8b16e0fdde3b00233ccec6f1011be8a95 100644 --- a/src/main/java/ui/avatarpd/AvatarPDProperty.java +++ b/src/main/java/ui/avatarpd/AvatarPDProperty.java @@ -61,7 +61,7 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDProperty extends TGCScalableWithInternalComponent implements WithAttributes { - private int textY1 = 3; + //private int textY = 3; //private int textY2 = 3; //private int textX = 10; @@ -71,20 +71,23 @@ public class AvatarPDProperty extends TGCScalableWithInternalComponent implement private int kind = 0; //0: liveness, 1 reachability, 2 safety private boolean not = false; // Negation of property - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 2; - private int sizeBetweenNameAndLiveness = 6; +// private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; +// private int textX = 2; +// private int sizeBetweenNameAndLiveness = 6; public AvatarPDProperty(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); - + + //Issue #31 + textY = 5; width = 125; - height = (int)(55 * tdp.getZoom()); + height = 55; minWidth = 100; - + initScaling(125, 55); + nbConnectingPoint = 4; connectingPoint = new TGConnectingPoint[4]; @@ -101,132 +104,176 @@ public class AvatarPDProperty extends TGCScalableWithInternalComponent implement value = "prop01"; description = "blah blah blah"; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic702; } - - public void internalDrawing(Graphics g) { - String ster; - ster = "<<" + stereotype + ">>"; - Font f = g.getFont(); - Font fold = f; - - if (value != oldValue) { - setValue(value, g); - } - - 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, maxFontSize)); - int w0, w1, w2; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w1 = g.getFontMetrics().stringWidth(ster); - w2 = Math.min(w0, w1); - if (w2 < (width - (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); - } - - } - - /*Color c = g.getColor(); - g.draw3DRect(x, y, width, height, true); - - - g.setColor(ColorManager.AVATARPD_PROPERTY); - - g.fill3DRect(x+1, y+1, width-1, height-1, true); - g.setColor(c);*/ - GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_PROPERTY, g.getColor()); - - // Strings - int w; - if (displayText) { - f = f.deriveFont((float)currentFontSize); - Font f0 = g.getFont(); - - boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY1 * tdp.getZoom()))); - - if (cannotWriteAttack) { - w = g.getFontMetrics().stringWidth(value); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } else { - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - } - } - } else { - g.setFont(f.deriveFont(Font.BOLD)); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); - int cumulated = 0; - w = g.getFontMetrics().stringWidth(ster); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y + h); - cumulated = h; - } - g.setFont(f0); - w = g.getFontMetrics().stringWidth(value); - h = cumulated + currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); - } - - // Liveness - h+= currentFontSize + sizeBetweenNameAndLiveness; - String state; - if (kind == 0) { - state = "liveness"; - } else if (kind == 1) { - state = "reachability"; - } else { - state = "safety"; - } - if (not) { - state = "not " + state; - } - g.setFont(f.deriveFont(Font.ITALIC)); - w = g.getFontMetrics().stringWidth(state); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(state, x + (width - w)/2, y + h); - } - - } - } - - g.setFont(fold); - + +// private int getCenter(Graphics g, String str) +// { +// int w = g.getFontMetrics().stringWidth(str); +// return x + (width - w)/2; +// } + //Issue #31 + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_PROPERTY, g.getColor()); + + // Strings + String ster = "<<" + stereotype + ">>"; + Font f = g.getFont(); + int fontSize = f.getSize(); + //make sure to not return; if you want to add something after the string draw. + if (!isTextReadable(g)) + return; + + g.drawString(value, getCenter(g, value), y + fontSize * 2 + textY); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, getCenter(g, ster), y + fontSize); + g.setFont(f.deriveFont(Font.PLAIN)); + //drawDoubleString(g, value, ster); + // Liveness + + String state; + switch(kind) + { + case 0: + state="liveness"; + case 1: + state="reachability"; + default: + state="safety"; + } + if (not) + state = "not " + state; + g.setFont(f.deriveFont(Font.ITALIC)); + //g.drawString(state, getCenter(g, state), y + fontSize * 3 + textY*2); + drawSingleString(g, state, getCenter(g, state), y + fontSize * 3 + textY*2); + } +// public void internalDrawing(Graphics g) { +// String ster; +// ster = "<<" + stereotype + ">>"; +// Font f = g.getFont(); +// Font fold = f; +// +// if (value != oldValue) { +// setValue(value, g); +// } +// +// 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, maxFontSize)); +// int w0, w1, w2; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w1 = g.getFontMetrics().stringWidth(ster); +// w2 = Math.min(w0, w1); +// if (w2 < (width - (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); +// } +// +// } +// +// /*Color c = g.getColor(); +// g.draw3DRect(x, y, width, height, true); +// +// +// g.setColor(ColorManager.AVATARPD_PROPERTY); +// +// g.fill3DRect(x+1, y+1, width-1, height-1, true); +// g.setColor(c);*/ +// GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_PROPERTY, g.getColor()); +// +// // Strings +// int w; +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// Font f0 = g.getFont(); +// +// boolean cannotWriteAttack = (height < (2 * currentFontSize + (int)(textY * tdp.getZoom()))); +// +// if (cannotWriteAttack) { +// w = g.getFontMetrics().stringWidth(value); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } else { +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// } +// } +// } else { +// g.setFont(f.deriveFont(Font.BOLD)); +// int h = currentFontSize + (int)(textY * tdp.getZoom()); +// int cumulated = 0; +// w = g.getFontMetrics().stringWidth(ster); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(ster, x + (width - w)/2, y + h); +// cumulated = h; +// } +// g.setFont(f0); +// w = g.getFontMetrics().stringWidth(value); +// h = cumulated + currentFontSize + (int)(textY * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y + h); +// } +// +// // Liveness +// h+= currentFontSize + sizeBetweenNameAndLiveness; +// String state; +// if (kind == 0) { +// state = "liveness"; +// } else if (kind == 1) { +// state = "reachability"; +// } else { +// state = "safety"; +// } +// if (not) { +// state = "not " + state; +// } +// g.setFont(f.deriveFont(Font.ITALIC)); +// w = g.getFontMetrics().stringWidth(state); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(state, x + (width - w)/2, y + h); +// } +// +// } +// } +// +// g.setFont(fold); +// +// } public void setValue(String val, Graphics g) { oldValue = value; diff --git a/src/main/java/ui/avatarpd/AvatarPDPropertyConnectingPoint.java b/src/main/java/ui/avatarpd/AvatarPDPropertyConnectingPoint.java index 32091768e8a14128837f44ff1170be71bbc26586..4e436baa71b1298ae6b78d32cf70ae9d07e4b6c6 100644 --- a/src/main/java/ui/avatarpd/AvatarPDPropertyConnectingPoint.java +++ b/src/main/java/ui/avatarpd/AvatarPDPropertyConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class AvatarPDPropertyConnectingPoint extends TGConnectingPointWidthHeig super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.APD_PROPERTY_CONNECTOR; } - } diff --git a/src/main/java/ui/avatarpd/AvatarPDPropertyConnector.java b/src/main/java/ui/avatarpd/AvatarPDPropertyConnector.java index 8cf64a9c754803c983fbf5daa62430ee039d0d6a..13e0ca3fb11c18876d86e5386414dcd329cfc0e9 100644 --- a/src/main/java/ui/avatarpd/AvatarPDPropertyConnector.java +++ b/src/main/java/ui/avatarpd/AvatarPDPropertyConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import myutil.GraphicLib; import ui.*; import ui.util.IconManager; @@ -59,11 +55,11 @@ import java.util.Vector; * @version 1.0 22/04/2010 * @author Ludovic APVRILLE */ -public class AvatarPDPropertyConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class AvatarPDPropertyConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 10; //square length - protected double oldScaleFactor; + //protected double oldScaleFactor; protected int fontSize = 12; protected int l = 4; // cross length; @@ -72,12 +68,14 @@ public class AvatarPDPropertyConnector extends TGConnectorWithCommentConnection public AvatarPDPropertyConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; value = "reg"; editable = true; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); } + @Override 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); @@ -147,9 +145,9 @@ public class AvatarPDPropertyConnector extends TGConnectorWithCommentConnection g.drawString(value, x2-(cz/2), y2-(cz/2)-1); g.setFont(f); }*/ - } + @Override public boolean editOndoubleClick(JFrame frame) { // String oldValue = value; JDialogAvatarPropertyConnector jdapc = new JDialogAvatarPropertyConnector(frame, getValue().compareTo("not") == 0); @@ -170,38 +168,36 @@ public class AvatarPDPropertyConnector extends TGConnectorWithCommentConnection return true; } - + @Override public int getType() { return TGComponentManager.APD_PROPERTY_CONNECTOR; } - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } + // Issue #31: Now managed in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } public boolean isNegated() { return value.compareTo("not") == 0; } - - - } diff --git a/src/main/java/ui/avatarpd/AvatarPDPropertyRelation.java b/src/main/java/ui/avatarpd/AvatarPDPropertyRelation.java index 52ba15de4343ccbaf70880ccd4597a256a9a6b16..888b8a371dd07a10003bba4fffc26e66505394b6 100644 --- a/src/main/java/ui/avatarpd/AvatarPDPropertyRelation.java +++ b/src/main/java/ui/avatarpd/AvatarPDPropertyRelation.java @@ -57,25 +57,29 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDPropertyRelation extends TGCScalableWithInternalComponent implements ConstraintListInterface { - private int textY1 = 5; + //private int textY1 = 5; //private int textY2 = 30; public static final String[] STEREOTYPES = {"OR", "AND", "=>", "<=>"}; protected String oldValue = ""; - private int maxFontSize = 12; - private int minFontSize = 4; +// private int maxFontSize = 12; +// private int minFontSize = 4; private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 1; +// private boolean displayText = true; +// private int textX = 1; public AvatarPDPropertyRelation(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(80* tdp.getZoom()); - height = (int)(40 * tdp.getZoom()); + width = 80; + height = 40; minWidth = 75; + textY = 5; + textX = 1; + //Issue #31 + initScaling(80,40); nbConnectingPoint = 12; connectingPoint = new TGConnectingPoint[12]; @@ -114,75 +118,86 @@ public class AvatarPDPropertyRelation extends TGCScalableWithInternalComponent i value = "OR"; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic1078; } - - public void internalDrawing(Graphics g) { - - Font f = g.getFont(); - // Font fold = f; - - 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, maxFontSize)); - int w0; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - if (w0 < (width - (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); - } - - } - - /*Color c = g.getColor(); - g.draw3DRect(x, y, width, height, true); - - g.setColor(ColorManager.AVATARPD_PROPERTY_RELATION); - g.fill3DRect(x+1, y+1, width-1, height-1, true); - g.setColor(c);*/ - - GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_PROPERTY_RELATION, g.getColor()); - - - Font f0 = g.getFont(); - if (displayText) { - f = f.deriveFont((float)currentFontSize); - g.setFont(f.deriveFont(Font.BOLD)); - int w = g.getFontMetrics().stringWidth(value); - g.drawString(value, x + (width - w)/2, y + currentFontSize + (int)(textY1*tdp.getZoom())); - g.setFont(f0); - } - + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_PROPERTY_RELATION, g.getColor()); + + //String + if (!isTextReadable(g)) + return; + currentFontSize = g.getFont().getSize(); + g.drawString(value, getCenter(g, value), y + currentFontSize); } +// public void internalDrawing(Graphics g) { +// +// Font f = g.getFont(); +// // Font fold = f; +// +// 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, maxFontSize)); +// int w0; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// if (w0 < (width - (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); +// } +// +// } +// +// /*Color c = g.getColor(); +// g.draw3DRect(x, y, width, height, true); +// +// g.setColor(ColorManager.AVATARPD_PROPERTY_RELATION); +// g.fill3DRect(x+1, y+1, width-1, height-1, true); +// g.setColor(c);*/ +// +// GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_PROPERTY_RELATION, g.getColor()); +// +// +// Font f0 = g.getFont(); +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// g.setFont(f.deriveFont(Font.BOLD)); +// int w = g.getFontMetrics().stringWidth(value); +// g.drawString(value, x + (width - w)/2, y + currentFontSize + (int)(textY*tdp.getZoom())); +// g.setFont(f0); +// } +// +// } /* public void setValue(String val, Graphics g) { oldValue = value; diff --git a/src/main/java/ui/avatarpd/AvatarPDSignal.java b/src/main/java/ui/avatarpd/AvatarPDSignal.java index 33687d1cc1665767202c280fb757ace40aefa0de..b77ebe501d65b6c6a9d2e2b9748cd4c2678bccc4 100644 --- a/src/main/java/ui/avatarpd/AvatarPDSignal.java +++ b/src/main/java/ui/avatarpd/AvatarPDSignal.java @@ -56,26 +56,26 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDSignal extends TGCScalableWithInternalComponent implements SwallowedTGComponent { - private int textY1 = 3; - private int textY2 = 3; + //private int textY1 = 3; + //private int textY2 = 3; //private int textX = 10; protected String oldValue = ""; protected String description = ""; private String stereotype = "signal"; - private boolean isRootAttack = false; + //private boolean isRootAttack = false; private int maxFontSize = 12; - private int minFontSize = 4; + //private int minFontSize = 4; private int currentFontSize = -1; - private boolean displayText = true; + //private boolean displayText = true; private int textX = 2; public AvatarPDSignal(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(125* tdp.getZoom()); - height = (int)(40 * tdp.getZoom()); + width = 125;//(int)(125* tdp.getZoom()); + height = 40;//(int)(40 * tdp.getZoom()); minWidth = 100; nbConnectingPoint = 12; @@ -107,7 +107,36 @@ public class AvatarPDSignal extends TGCScalableWithInternalComponent implements myImageIcon = IconManager.imgic702; } + // Issue #31 + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + Filling + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + g.setColor(ColorManager.AVATARPD_SIGNAL); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + //Strings: Title and stereotype + currentFontSize = g.getFont().getSize(); + String ster = "<<" + stereotype + ">>"; + if (isTextReadable(g)) + { + g.setFont(g.getFont().deriveFont(Font.BOLD)); + g.drawString(ster, getCenterOfBox(g, ster), y + currentFontSize); + } + + if (isTextReadable(g)) + { + g.setFont(g.getFont().deriveFont(Font.PLAIN)); + g.drawString(value, getCenterOfBox(g, value), y + (currentFontSize * 2) + textX); + } + } + +/* + * @Override public void internalDrawing(Graphics g) { String ster; ster = "<<" + stereotype + ">>"; @@ -206,7 +235,7 @@ public class AvatarPDSignal extends TGCScalableWithInternalComponent implements g.setFont(fold); - } + }*/ public void setValue(String val, Graphics g) { oldValue = value; @@ -232,8 +261,8 @@ public class AvatarPDSignal extends TGCScalableWithInternalComponent implements public boolean editOndoubleClick(JFrame frame) { - String tmp; - boolean error = false; +// String tmp; +// boolean error = false; //String text = getName() + ": "; String s = (String)JOptionPane.showInputDialog(frame, "Signal name", diff --git a/src/main/java/ui/avatarpd/AvatarPDSignalConnectingPoint.java b/src/main/java/ui/avatarpd/AvatarPDSignalConnectingPoint.java index 2d5c4a39d2d9ae0b2e3e488a63bf67fd7835e1eb..f0be2f96988a076c7516e5c5a9f85bb78346cba1 100644 --- a/src/main/java/ui/avatarpd/AvatarPDSignalConnectingPoint.java +++ b/src/main/java/ui/avatarpd/AvatarPDSignalConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarpd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class AvatarPDSignalConnectingPoint extends TGConnectingPointWidthHeight super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.APD_SIGNAL_CONNECTOR; } - } diff --git a/src/main/java/ui/avatarpd/AvatarPDSignalConnector.java b/src/main/java/ui/avatarpd/AvatarPDSignalConnector.java index 45af9129011f103518b74959271ca6cf2d110272..963af295b5c009717aaaa159af8940714a1761b0 100644 --- a/src/main/java/ui/avatarpd/AvatarPDSignalConnector.java +++ b/src/main/java/ui/avatarpd/AvatarPDSignalConnector.java @@ -57,12 +57,12 @@ import java.util.Vector; * @version 1.0 22/04/2010 * @author Ludovic APVRILLE */ -public class AvatarPDSignalConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class AvatarPDSignalConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 6; //square length protected int l = 3; // cross length; - protected double oldScaleFactor; + //protected double oldScaleFactor; protected int fontSize = 12; @@ -71,9 +71,10 @@ public class AvatarPDSignalConnector extends TGConnectorWithCommentConnectionPo myImageIcon = IconManager.imgic202; value = ""; editable = true; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); } + @Override 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); @@ -163,34 +164,31 @@ public class AvatarPDSignalConnector extends TGConnectorWithCommentConnectionPo return false; }*/ - + @Override public int getType() { return TGComponentManager.APD_SIGNAL_CONNECTOR; } - - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } - - - +// Issue #31: Now in upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } } diff --git a/src/main/java/ui/avatarpd/AvatarPDTemporalConstraint.java b/src/main/java/ui/avatarpd/AvatarPDTemporalConstraint.java index bea0f6b7ffa904dea57fdf35bfbce301b495bf86..b6cfcf46c9671bf94029b9093bfe1965c4b938e9 100644 --- a/src/main/java/ui/avatarpd/AvatarPDTemporalConstraint.java +++ b/src/main/java/ui/avatarpd/AvatarPDTemporalConstraint.java @@ -56,25 +56,29 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarPDTemporalConstraint extends TGCScalableWithInternalComponent implements ConstraintListInterface { - private int textY1 = 5; +// private int textY1 = 5; //private int textY2 = 30; public static final String[] STEREOTYPES = {"<<TC>>"}; protected String oldValue = ""; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 1; +// private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; +// private int textX = 1; public AvatarPDTemporalConstraint(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(60* tdp.getZoom()); - height = (int)(100 * tdp.getZoom()); + //Issue #31 + width = 60; + height = 100; minWidth = 50; + textY = 5; + textX = 1; + initScaling(60, 100); nbConnectingPoint = 12; connectingPoint = new TGConnectingPoint[12]; @@ -103,91 +107,102 @@ public class AvatarPDTemporalConstraint extends TGCScalableWithInternalComponent value = "=0"; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic1078; } - public void internalDrawing(Graphics g) { - - Font f = g.getFont(); - Font fold = f; - - 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, maxFontSize)); - int w0; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - w0 = Math.max(w0, g.getFontMetrics().stringWidth(STEREOTYPES[0])); - if (w0 < (width - (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); - } - - } - - /*Color c = g.getColor(); - - g.setColor(ColorManager.AVATARPD_LOGICAL_CONSTRAINT); - //g.fill3DRect(x+1, y+1, width-1, height-1, true); - //Graphics2D graphics2 = (Graphics2D) g; - //RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(x, y, width, height, arc, arc); - //graphics2.draw(roundedRectangle); - //g.fillRoundRect(x, y, width, height, arc, arc); - //g.fill3DRect(x+arc, y+1, width-(2*arc), height-1, true); - //g.fill3DRect(x+1, y+arc, width-1, height-(2*arc), true); - g.fillRoundRect(x, y, width, height, AvatarPDPanel.ARC, AvatarPDPanel.ARC); - g.setColor(ColorManager.AVATARPD_LOGICAL_CONSTRAINT.brighter()); - g.drawLine(x+1, y+, x+1, y+height-(AvatarPDPanel.ARC/2)); - g.drawLine(x+(AvatarPDPanel.ARC/2), y+(AvatarPDPanel.ARC/2), x+1, y+height-(AvatarPDPanel.ARC/2)); - g.setColor(ColorManager.AVATARPD_LOGICAL_CONSTRAINT.darker()); - g.drawLine(x+width-1, y+(AvatarPDPanel.ARC/2), x+width-1, y+height-(AvatarPDPanel.ARC/2)); - g.setColor(c); - g.drawRoundRect(x, y, width, height, AvatarPDPanel.ARC, AvatarPDPanel.ARC);*/ - GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_TEMPORAL_CONSTRAINT, g.getColor()); - - - Font f0 = g.getFont(); - if (displayText) { - f = f.deriveFont((float)currentFontSize); - g.setFont(f.deriveFont(Font.BOLD)); - int w = g.getFontMetrics().stringWidth(STEREOTYPES[0]); - g.drawString(STEREOTYPES[0], x + (width - w)/2, y + currentFontSize + (int)(textY1*tdp.getZoom())); - g.setFont(f.deriveFont(Font.ITALIC)); - w = g.getFontMetrics().stringWidth(value); - g.drawString(value, x + (width - w)/2, y + (2*currentFontSize) + (int)(textY1*tdp.getZoom())); - g.setFont(f0); - } - + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_TEMPORAL_CONSTRAINT, g.getColor()); + + //strings + String ster = STEREOTYPES[0]; + drawDoubleString(g, ster, value); } +// public void internalDrawing(Graphics g) { +// +// Font f = g.getFont(); +//// Font fold = f; +// +// 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, maxFontSize)); +// int w0; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// w0 = Math.max(w0, g.getFontMetrics().stringWidth(STEREOTYPES[0])); +// if (w0 < (width - (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); +// } +// +// } +// +// /*Color c = g.getColor(); +// +// g.setColor(ColorManager.AVATARPD_LOGICAL_CONSTRAINT); +// //g.fill3DRect(x+1, y+1, width-1, height-1, true); +// //Graphics2D graphics2 = (Graphics2D) g; +// //RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(x, y, width, height, arc, arc); +// //graphics2.draw(roundedRectangle); +// //g.fillRoundRect(x, y, width, height, arc, arc); +// //g.fill3DRect(x+arc, y+1, width-(2*arc), height-1, true); +// //g.fill3DRect(x+1, y+arc, width-1, height-(2*arc), true); +// g.fillRoundRect(x, y, width, height, AvatarPDPanel.ARC, AvatarPDPanel.ARC); +// g.setColor(ColorManager.AVATARPD_LOGICAL_CONSTRAINT.brighter()); +// g.drawLine(x+1, y+, x+1, y+height-(AvatarPDPanel.ARC/2)); +// g.drawLine(x+(AvatarPDPanel.ARC/2), y+(AvatarPDPanel.ARC/2), x+1, y+height-(AvatarPDPanel.ARC/2)); +// g.setColor(ColorManager.AVATARPD_LOGICAL_CONSTRAINT.darker()); +// g.drawLine(x+width-1, y+(AvatarPDPanel.ARC/2), x+width-1, y+height-(AvatarPDPanel.ARC/2)); +// g.setColor(c); +// g.drawRoundRect(x, y, width, height, AvatarPDPanel.ARC, AvatarPDPanel.ARC);*/ +// GraphicLib.draw3DRoundRectangle(g, x, y, width, height, AvatarPDPanel.ARC, ColorManager.AVATARPD_TEMPORAL_CONSTRAINT, g.getColor()); +// +// +// Font f0 = g.getFont(); +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// g.setFont(f.deriveFont(Font.BOLD)); +// int w = g.getFontMetrics().stringWidth(STEREOTYPES[0]); +// g.drawString(STEREOTYPES[0], x + (width - w)/2, y + currentFontSize + (int)(textY*tdp.getZoom())); +// g.setFont(f.deriveFont(Font.ITALIC)); +// w = g.getFontMetrics().stringWidth(value); +// g.drawString(value, x + (width - w)/2, y + (2*currentFontSize) + (int)(textY*tdp.getZoom())); +// g.setFont(f0); +// } +// +// } + /* public void setValue(String val, Graphics g) { oldValue = value; int w = g.getFontMetrics().stringWidth(value); @@ -200,10 +215,8 @@ public class AvatarPDTemporalConstraint extends TGCScalableWithInternalComponent } // }*/ - - - + @Override public boolean editOndoubleClick(JFrame frame) { /*String tmp; boolean error = false; @@ -246,7 +259,8 @@ public class AvatarPDTemporalConstraint extends TGCScalableWithInternalComponent return false; } - + + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -254,15 +268,18 @@ public class AvatarPDTemporalConstraint extends TGCScalableWithInternalComponent } return null; } - + + @Override public int getType() { return TGComponentManager.APD_TEMPORAL_CONSTRAINT; } - + + @Override public String[] getConstraintList() { return STEREOTYPES; } - + + @Override public String getCurrentConstraint() { return value; } diff --git a/src/main/java/ui/avatarpd/AvatarPDToggle.java b/src/main/java/ui/avatarpd/AvatarPDToggle.java index 52c676d5eae134c597b9196107e26ed7efd36b21..47837c8a999fe7da8a8d3fac721096ce839b5535 100644 --- a/src/main/java/ui/avatarpd/AvatarPDToggle.java +++ b/src/main/java/ui/avatarpd/AvatarPDToggle.java @@ -105,6 +105,7 @@ public abstract class AvatarPDToggle extends TGCScalableWithInternalComponent { // } + @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarPDBlock)) { // @@ -140,7 +141,8 @@ public abstract class AvatarPDToggle extends TGCScalableWithInternalComponent { public void setToggle(String _toggle) { toggle = _toggle; } - + + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); diff --git a/src/main/java/ui/avatarpd/AvatarPDToolBar.java b/src/main/java/ui/avatarpd/AvatarPDToolBar.java index 3722e49d9ddbb5cef8c307b0d5981c3febb666f0..086a8237e915e5f2e41a40c5b23fe33940c1e740 100644 --- a/src/main/java/ui/avatarpd/AvatarPDToolBar.java +++ b/src/main/java/ui/avatarpd/AvatarPDToolBar.java @@ -64,7 +64,8 @@ public class AvatarPDToolBar extends TToolBar { super(_mgui); } - + + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -97,7 +98,8 @@ public class AvatarPDToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(!b); } - + + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/avatarrd/AvatarRDCompositionConnector.java b/src/main/java/ui/avatarrd/AvatarRDCompositionConnector.java index 0a73460b4faa5ba54eaa29ca2b69629ce88e333f..fe223981fdf806d528d4b4576eb86cbb363c452e 100644 --- a/src/main/java/ui/avatarrd/AvatarRDCompositionConnector.java +++ b/src/main/java/ui/avatarrd/AvatarRDCompositionConnector.java @@ -51,7 +51,7 @@ import java.util.Vector; /** * Class AvatarRDCompositionConnector - * Connector to be used in Avatar RD. Connects two requirements + * Connector to be used in Avatar RD (Requirement Diagram). Connects two requirements * Creation: 20/04/2010 * @version 1.0 20/04/2010 * @author Ludovic APVRILLE @@ -67,7 +67,7 @@ public class AvatarRDCompositionConnector extends TGConnectorWithCommentConnect myImageIcon = IconManager.imgic1012; } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); @@ -119,7 +119,7 @@ public class AvatarRDCompositionConnector extends TGConnectorWithCommentConnect } return null; }*/ - + @Override public int getType() { return TGComponentManager.AVATARRD_COMPOSITION_CONNECTOR; } diff --git a/src/main/java/ui/avatarrd/AvatarRDConnectingPointDerive.java b/src/main/java/ui/avatarrd/AvatarRDConnectingPointDerive.java index c967b3cc2cd35a8940cf7c0607cdfaff454d9cef..2d691a75a39457b043cbd614c992d92cc9c09b43 100755 --- a/src/main/java/ui/avatarrd/AvatarRDConnectingPointDerive.java +++ b/src/main/java/ui/avatarrd/AvatarRDConnectingPointDerive.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarrd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -61,6 +56,7 @@ public class AvatarRDConnectingPointDerive extends TGConnectingPointWidthHeight orientation = _orientation; } + @Override public boolean isCompatibleWith(int type) { // if (type == TGComponentManager.AVATARRD_DERIVE_CONNECTOR) { @@ -86,6 +82,4 @@ public class AvatarRDConnectingPointDerive extends TGConnectingPointWidthHeight // return false; } - - } diff --git a/src/main/java/ui/avatarrd/AvatarRDConnectingPointSatisfy.java b/src/main/java/ui/avatarrd/AvatarRDConnectingPointSatisfy.java index 6893027c8ce139ec50afc3c956c581a0292225a0..232859b02bd1f357512dd2b4bfc37e516baa47c1 100755 --- a/src/main/java/ui/avatarrd/AvatarRDConnectingPointSatisfy.java +++ b/src/main/java/ui/avatarrd/AvatarRDConnectingPointSatisfy.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarrd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -61,6 +56,7 @@ public class AvatarRDConnectingPointSatisfy extends TGConnectingPointWidthHeigh super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { // if (type == TGComponentManager.AVATARRD_SATISFY_CONNECTOR) { @@ -73,5 +69,4 @@ public class AvatarRDConnectingPointSatisfy extends TGConnectingPointWidthHeigh return false; } - } diff --git a/src/main/java/ui/avatarrd/AvatarRDConnectingPointVerify.java b/src/main/java/ui/avatarrd/AvatarRDConnectingPointVerify.java index eaacd158212a8f56a9edf7dd5cd7683c0a7bc281..272928aa9fb6b69ba3494bb79649aedcddd8fc9a 100755 --- a/src/main/java/ui/avatarrd/AvatarRDConnectingPointVerify.java +++ b/src/main/java/ui/avatarrd/AvatarRDConnectingPointVerify.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarrd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -54,7 +49,7 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 20/04/2010 * @author Ludovic APVRILLE */ -public class AvatarRDConnectingPointVerify extends TGConnectingPointWidthHeight { +public class AvatarRDConnectingPointVerify extends TGConnectingPointWidthHeight { public AvatarRDConnectingPointVerify(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h, int _orientation) { super(_container, _x, _y, _in, _out, _w, _h); @@ -65,6 +60,7 @@ public class AvatarRDConnectingPointVerify extends TGConnectingPointWidthHeight super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { // if (type == TGComponentManager.AVATARRD_VERIFY_CONNECTOR) { diff --git a/src/main/java/ui/avatarrd/AvatarRDCopyConnector.java b/src/main/java/ui/avatarrd/AvatarRDCopyConnector.java index 67a9b3fe50550621de7e281460713675245b2026..4e9acaae7a86885dd99c00c057dc53c7972f70d4 100755 --- a/src/main/java/ui/avatarrd/AvatarRDCopyConnector.java +++ b/src/main/java/ui/avatarrd/AvatarRDCopyConnector.java @@ -67,7 +67,7 @@ public class AvatarRDCopyConnector extends TGConnectorWithCommentConnectionPoin myImageIcon = IconManager.imgic1010; } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); @@ -84,10 +84,10 @@ public class AvatarRDCopyConnector extends TGConnectorWithCommentConnectionPoin w = g.getFontMetrics().stringWidth(value); h = g.getFontMetrics().getHeight(); - g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + drawSingleString(g, value, (x1 + x2 - w) / 2, (y1 + y2)/2); g.setFont(old); } - + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { return this; @@ -95,6 +95,7 @@ public class AvatarRDCopyConnector extends TGConnectorWithCommentConnectionPoin return null; } + @Override public int getType() { return TGComponentManager.AVATARRD_COPY_CONNECTOR; } diff --git a/src/main/java/ui/avatarrd/AvatarRDDeriveConnector.java b/src/main/java/ui/avatarrd/AvatarRDDeriveConnector.java index d583b4f7455bdd6ef1d02979ddd8e091bd7f779e..42d239a1fd10e3cead391fda3f8355e7cf86de1d 100755 --- a/src/main/java/ui/avatarrd/AvatarRDDeriveConnector.java +++ b/src/main/java/ui/avatarrd/AvatarRDDeriveConnector.java @@ -67,7 +67,7 @@ public class AvatarRDDeriveConnector extends TGConnectorWithCommentConnectionPo myImageIcon = IconManager.imgic1008; } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); @@ -84,17 +84,20 @@ public class AvatarRDDeriveConnector extends TGConnectorWithCommentConnectionPo w = g.getFontMetrics().stringWidth(value); h = g.getFontMetrics().getHeight(); - g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + drawSingleString(g, value, (x1 + x2 - w) / 2, (y1 + y2)/2); g.setFont(old); } - + + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { return this; } + return null; } - + + @Override public int getType() { return TGComponentManager.AVATARRD_DERIVE_CONNECTOR; } diff --git a/src/main/java/ui/avatarrd/AvatarRDElementReference.java b/src/main/java/ui/avatarrd/AvatarRDElementReference.java index bfd2280426b6a6bf4553b9b879495c04893a92df..abb979ec3a6badb888407a92f79f48c8c42e9a38 100644 --- a/src/main/java/ui/avatarrd/AvatarRDElementReference.java +++ b/src/main/java/ui/avatarrd/AvatarRDElementReference.java @@ -58,17 +58,17 @@ import java.awt.*; */ public class AvatarRDElementReference extends TGCScalableWithInternalComponent implements TGAutoAdjust { public String oldValue; - protected int textX = 5; - protected int textY = 22; +// protected int textX = 5; +// protected int textY = 22; protected int lineHeight = 30; private double dlineHeight = 0.0; //protected int startFontSize = 10; protected Graphics graphics; //protected int iconSize = 30; - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; +// private Font myFont, myFontB; +// private int maxFontSize = 30; + // private int minFontSize = 4; private int currentFontSize = -1; private boolean displayText = true; @@ -77,19 +77,24 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i protected String diagramText; private int iconSize = 18; - private boolean iconIsDrawn = false; +// private boolean iconIsDrawn = false; public AvatarRDElementReference(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); + //Issue #31 + minWidth = 10; + minHeight = lineHeight; + textX = 5; + textY = 22; initScaling(150, lineHeight); - oldScaleFactor = tdp.getZoom(); + +// oldScaleFactor = tdp.getZoom(); dlineHeight = lineHeight * oldScaleFactor; lineHeight = (int)dlineHeight; dlineHeight = dlineHeight - lineHeight; - minWidth = 10; - minHeight = lineHeight; + nbConnectingPoint = 12; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; @@ -111,7 +116,7 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i nbInternalTGComponent = 0; //tgcomponent = new TGComponent[nbInternalTGComponent]; - int h = 1; + //int h = 1; //TAttributeRequirement tgc0; //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); //tgcomponent[0] = tgc0; @@ -135,69 +140,100 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i actionOnAdd(); } - - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - int w, c; - int size; - - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; - - int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); - - g.drawLine(x, y+lineHeight, x+width, y+lineHeight); - g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); - g.fillRect(x+1, y+1, width-1, lineHeight-1); - g.setColor(ColorManager.AVATAR_BLOCK); - g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); - ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - drawLimitedString(g, ELEMENT_REFERENCE, x, y + size, width, 1); - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - /*g.setFont(myFont); - - size = lineHeight + currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - // Violated action - if (size < (height - 2)) { - drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - }*/ - g.setFont(f); + @Override + public void internalDrawing(Graphics g) + { + // Rectangle and Filling + g.drawRect(x, y, width, height); + + g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); + g.fillRect(x+1, y+1, width-1, lineHeight-1); + g.setColor(ColorManager.AVATAR_BLOCK); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + + // Check Text readability + if (!isTextReadable(g)) + return; + + // Icon + g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize) - scale(1), y + scale(3), Color.yellow, null); + + // Strings: <<Element ref>> and lossy or unlossy + Font font = g.getFont(); + int fontSize = font.getSize(); + g.setFont(font.deriveFont(Font.BOLD)); + drawLimitedString(g, ELEMENT_REFERENCE, x, y + fontSize, width, 1); + fontSize *=2; + g.setFont(font.deriveFont(Font.PLAIN)); + drawLimitedString(g, value, x, y + fontSize, width, 1); } - + + +// public void internalDrawing(Graphics g) { +// Font f = g.getFont(); +// //Font fold = f; +// //int w, c; +// int fontSize; +// +// if (!tdp.isScaled()) { +// graphics = g; +// } +// +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// // +// myFont = f.deriveFont((float)currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } +// +// displayText = currentFontSize >= minFontSize; +// +// int h = g.getFontMetrics().getHeight(); +// +// g.drawRect(x, y, width, height); +// +// g.drawLine(x, y+lineHeight, x+width, y+lineHeight); +// g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); +// g.fillRect(x+1, y+1, width-1, lineHeight-1); +// g.setColor(ColorManager.AVATAR_BLOCK); +// g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); +// ColorManager.setColor(g, getState(), 0); +// if ((lineHeight > 23) && (width > 23)){ +// g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 1), y + scale(3), Color.yellow, null); +// } +// +// if (displayText) { +// fontSize = currentFontSize - 2; +// g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); +// drawLimitedString(g, ELEMENT_REFERENCE, x, y + fontSize, width, 1); +// fontSize += currentFontSize; +// g.setFont(myFontB); +// w = g.getFontMetrics().stringWidth(value); +// drawLimitedString(g, value, x, y + fontSize, width, 1); +// +// } +// +// /*g.setFont(myFont); +// +// fontSize = lineHeight + currentFontSize; +// if (fontSize < (height - 2)) { +// drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + fontSize, width, 0); +// fontSize += currentFontSize; +// // Violated action +// if (fontSize < (height - 2)) { +// drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + fontSize, width, 0); +// } +// }*/ +// g.setFont(f); +// } + + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { oldValue = value; @@ -222,8 +258,8 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i } - int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; - minDesiredWidth = Math.max(size, minWidth); + int fontSize = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; + minDesiredWidth = Math.max(fontSize, minWidth); if (minDesiredWidth != width) { newSizeForSon(null); } @@ -239,7 +275,7 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i } - + @Override public void rescale(double scaleFactor){ dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); @@ -248,7 +284,7 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i super.rescale(scaleFactor); } - + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -256,17 +292,17 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i return null; } - + @Override public int getType() { return TGComponentManager.AVATARRD_ELEMENT_REFERENCE; } - + @Override public String toString() { String ret = getValue() + ELEMENT_REFERENCE; return ret; } - + @Override public void autoAdjust(int mode) { // @@ -280,7 +316,7 @@ public class AvatarRDElementReference extends TGCScalableWithInternalComponent i Font f2 = f.deriveFont((float)(currentFontSize - 2)); // Must find for both modes which width is desirable - String s0, s1; + String s0; //, s1; s0 = ELEMENT_REFERENCE; diff --git a/src/main/java/ui/avatarrd/AvatarRDPanel.java b/src/main/java/ui/avatarrd/AvatarRDPanel.java index a177712dde1b5f9c8e9ab3541fbd1e76832e4bd1..33429ad54f2e196e25bc82909bc00b731ef78a55 100755 --- a/src/main/java/ui/avatarrd/AvatarRDPanel.java +++ b/src/main/java/ui/avatarrd/AvatarRDPanel.java @@ -63,11 +63,13 @@ public class AvatarRDPanel extends TDiagramPanel implements TDPWithAttributes { addMouseListener(tdmm); addMouseMotionListener(tdmm);*/ } - + + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return true; } - + + @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -76,7 +78,8 @@ public class AvatarRDPanel extends TDiagramPanel implements TDPWithAttributes { }*/ return false; } - + + @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -86,34 +89,41 @@ public class AvatarRDPanel extends TDiagramPanel implements TDPWithAttributes { }*/ return false; } - + + @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); }*/ return false; } - + + @Override public String getXMLHead() { return "<AvatarRDPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } - + + @Override public String getXMLTail() { return "</AvatarRDPanel>"; } - + + @Override public String getXMLSelectedHead() { return "<AvatarRDPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - + + @Override public String getXMLSelectedTail() { return "</AvatarRDPanelCopy>"; } - + + @Override public String getXMLCloneHead() { return "<AvatarRDPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - + + @Override public String getXMLCloneTail() { return "</AvatarRDPanelCopy>"; } @@ -178,7 +188,8 @@ public class AvatarRDPanel extends TDiagramPanel implements TDPWithAttributes { return false; }*/ - + + @Override public void enhance() { autoAdjust(); } diff --git a/src/main/java/ui/avatarrd/AvatarRDProperty.java b/src/main/java/ui/avatarrd/AvatarRDProperty.java index 10d9e960a485ccfbe08d51632442962d880988f0..ade55894fc782996d6c00b5530c1e64c81a34c14 100755 --- a/src/main/java/ui/avatarrd/AvatarRDProperty.java +++ b/src/main/java/ui/avatarrd/AvatarRDProperty.java @@ -43,6 +43,7 @@ package ui.avatarrd; import myutil.GraphicLib; +//import myutil.TraceManager; import ui.*; import ui.util.IconManager; @@ -58,17 +59,17 @@ import java.awt.*; */ public class AvatarRDProperty extends TGCScalableWithInternalComponent implements TGAutoAdjust { public String oldValue; - protected int textX = 5; - protected int textY = 22; +// protected int textX = 5; +// protected int textY = 22; protected int lineHeight = 30; private double dlineHeight = 0.0; //protected int startFontSize = 10; protected Graphics graphics; - //protected int iconSize = 30; + - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; +// private Font myFont, myFontB; + //private int maxFontSize = 30; +// private int minFontSize = 4; private int currentFontSize = -1; private boolean displayText = true; @@ -78,12 +79,15 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement protected String violatedAction = "noAction"; private int iconSize = 18; - private boolean iconIsDrawn = false; + //private boolean iconIsDrawn = false; public AvatarRDProperty(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - + + textX = 5; + textY = 22; initScaling(150, lineHeight); + oldScaleFactor = tdp.getZoom(); dlineHeight = lineHeight * oldScaleFactor; lineHeight = (int)dlineHeight; @@ -112,7 +116,7 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement nbInternalTGComponent = 0; //tgcomponent = new TGComponent[nbInternalTGComponent]; - int h = 1; + //int h = 1; //TAttributeRequirement tgc0; //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); //tgcomponent[0] = tgc0; @@ -136,70 +140,99 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement actionOnAdd(); } - - - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - int w, c; - int size; - - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; - - int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); - - g.drawLine(x, y+lineHeight, x+width, y+lineHeight); - g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); - g.fillRect(x+1, y+1, width-1, lineHeight-1); - g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); - g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); - ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); - drawLimitedString(g, PROPERTY, x, y + size, width, 1); - size += currentFontSize; - g.setFont(myFontB); - w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - /*g.setFont(myFont); - - size = lineHeight + currentFontSize; - if (size < (height - 2)) { - drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); - size += currentFontSize; - // Violated action - if (size < (height - 2)) { - drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); - } - }*/ - g.setFont(f); + + //Issue #31 + @Override + public void internalDrawing(Graphics g) + { + //Rectangle + g.drawRect(x, y, width, height); + g.drawLine(x, y + lineHeight, x + width, y + lineHeight); + + //Filling + g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); + g.fillRect(x+1, y+1, width-1, lineHeight-1); + g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + + //Readability Check + if (!isTextReadable(g)) + return; + //Icon + g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize + 2), y + scale(3), Color.yellow, null); + + //Strings + Font font = g.getFont(); + currentFontSize = font.getSize(); + g.setFont(font.deriveFont(Font.BOLD)); + drawLimitedString(g, PROPERTY, x, y + currentFontSize , width, 1); + g.setFont(font.deriveFont(Font.PLAIN)); + drawLimitedString(g, value, x, y + currentFontSize * 2, width, 1); } - + + +// public void internalDrawing(Graphics g) { +// Font f = g.getFont(); +// +// //Font fold = f; FIXME: unused +// //int w, c; FIXME: unused +// if (!tdp.isScaled()) { +// graphics = g; +// } +// +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// myFont = f.deriveFont((float)currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) +// rescaled = false; +// } +// +// displayText = currentFontSize >= minFontSize; +// +// //int h = g.getFontMetrics().getHeight(); FIXME: unused ? +// +// g.drawRect(x, y, width, height); +// +// g.drawLine(x, y+lineHeight, x+width, y+lineHeight); +// g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); +// g.fillRect(x+1, y+1, width-1, lineHeight-1); +// g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); +// g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); +// ColorManager.setColor(g, getState(), 0); +// if ((lineHeight > 23) && (width > 23)){ +// g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); +// } +// +// int size; +// if (displayText) { +// //size = currentFontSize - 2; +// size = 50; +// g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); +// drawLimitedString(g, PROPERTY, x, y + size, width, 1); +// size += currentFontSize; +// g.setFont(myFontB); +// //w = g.getFontMetrics().stringWidth(value); FIXME: unused +// drawLimitedString(g, value, x, y + size, width, 1); +// +// } +// +// /*g.setFont(myFont); +// +// size = lineHeight + currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// // Violated action +// if (size < (height - 2)) { +// drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); +// } +// }*/ +// g.setFont(f); +// } + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { oldValue = value; @@ -272,7 +305,7 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement return true; }*/ - + @Override public void rescale(double scaleFactor){ dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); @@ -282,7 +315,7 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement super.rescale(scaleFactor); } - + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -294,7 +327,7 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement return value; } - + @Override public int getType() { return TGComponentManager.AVATARRD_PROPERTY; } @@ -322,12 +355,12 @@ public class AvatarRDProperty extends TGCScalableWithInternalComponent implement } return true; }*/ - + @Override public String toString() { String ret = getValue() + PROPERTY; return ret; } - + @Override public void autoAdjust(int mode) { // diff --git a/src/main/java/ui/avatarrd/AvatarRDRefineConnector.java b/src/main/java/ui/avatarrd/AvatarRDRefineConnector.java index a203b7cb6f1ae658c48b88e732bbc18d6ce900ad..760c896f3437ff0dc1f90c8e2bfd1eb1105af691 100755 --- a/src/main/java/ui/avatarrd/AvatarRDRefineConnector.java +++ b/src/main/java/ui/avatarrd/AvatarRDRefineConnector.java @@ -84,7 +84,7 @@ public class AvatarRDRefineConnector extends TGConnectorWithCommentConnectionPo w = g.getFontMetrics().stringWidth(value); h = g.getFontMetrics().getHeight(); - g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + drawSingleString(g, value, (x1 + x2 - w) / 2, (y1 + y2)/2); g.setFont(old); } diff --git a/src/main/java/ui/avatarrd/AvatarRDRequirement.java b/src/main/java/ui/avatarrd/AvatarRDRequirement.java index 2a8c4d218b40acc75e7fd15cf7351670086e8978..2db00f06bb816f2d3de3ddc7db1bbf1cd351044a 100755 --- a/src/main/java/ui/avatarrd/AvatarRDRequirement.java +++ b/src/main/java/ui/avatarrd/AvatarRDRequirement.java @@ -71,8 +71,8 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem public static int SIZE_LIMIT = 35; public String oldValue; - protected int textX = 5; - protected int textY = 22; + //protected int textX = 5; + //protected int textY = 22; protected int lineHeight = 30; private double dlineHeight = 0.0; //protected int reqType = 0; @@ -139,7 +139,13 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem public AvatarRDRequirement(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + //Issue #31 + textY = 22; + textX = 5; + minWidth = lineLength; + minHeight = 10; initScaling(200, 120); + oldScaleFactor = tdp.getZoom(); dlineHeight = lineHeight * oldScaleFactor; lineHeight = (int) dlineHeight; @@ -237,93 +243,59 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem public void makeValue() { texts = Conversion.wrapText(text); } + - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - // Font fold = f; - // int w, c; - int size; - - if (texts == null) { - makeValue(); - } - - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float) currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; - - // int h = g.getFontMetrics().getHeight(); - - g.drawRect(x, y, width, height); - - g.drawLine(x, y + lineHeight, x + width, y + lineHeight); - Color topColor = REQ_TYPE_COLOR.get(reqType); - if (topColor == null) { - //TraceManager.addDev("Swithing back to default Color for:" + REQ_TYPE_STR.get(reqType)); - topColor = ColorManager.AVATAR_REQUIREMENT_TOP; - } else { - //TraceManager.addDev("Using color: " + topColor.getRGB() + "for " +REQ_TYPE_STR.get(reqType)); - } - g.setColor(topColor); - g.fillRect(x + 1, y + 1, width - 1, lineHeight - 1); - g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); - g.fillRect(x + 1, y + 1 + lineHeight, width - 1, height - 1 - lineHeight); - ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)) { - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFont.deriveFont((float) (myFont.getSize() - 2))); - - drawLimitedString(g, "<<" + REQ_TYPE_STR.get(reqType) + ">>", x, y + size, width, 1); - - size += currentFontSize; - g.setFont(myFontB); - // w = g.getFontMetrics().stringWidth(value); - drawLimitedString(g, value, x, y + size, width, 1); - - } - - if (verified) { - if (satisfied) { - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.green); - g.drawLine(x + width - 2, y - 6 + lineHeight, x + width - 6, y - 2 + lineHeight); - g.drawLine(x + width - 6, y - 3 + lineHeight, x + width - 8, y - 6 + lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } else { - //g.drawString("acc", x + width - 10, y+height-10); - Color tmp = g.getColor(); - GraphicLib.setMediumStroke(g); - g.setColor(Color.red); - g.drawLine(x + width - 2, y - 2 + lineHeight, x + width - 8, y - 8 + lineHeight); - g.drawLine(x + width - 8, y - 2 + lineHeight, x + width - 2, y - 8 + lineHeight); - g.setColor(tmp); - GraphicLib.setNormalStroke(g); - } - } - - g.setFont(myFont); + @Override + public void internalDrawing(Graphics g) + { + // Rectangle and lines + g.drawRect(x, y, width, height); + g.drawLine(x, y + lineHeight, x + width, y + lineHeight); + + // Rectangle Filling + Color topColor = REQ_TYPE_COLOR.get(reqType); + if (topColor == null) + topColor = ColorManager.AVATAR_REQUIREMENT_TOP; + g.setColor(topColor); + g.fillRect(x + 1, y + 1, width - 1, lineHeight - 1); + g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); + g.fillRect(x + 1, y + 1 + lineHeight, width - 1, height - 1 - lineHeight); + ColorManager.setColor(g, getState(), 0); + + // check readability + if (!isTextReadable(g)) + return; + Font f = g.getFont(); + int size = f.getSize(); + + // TTool Icon + int borders = scale(3); + g.drawImage(scale(IconManager.img5100), x + width - scale(iconSize) - borders, y + borders, Color.yellow, null); + + //String + String req = "<<" + REQ_TYPE_STR.get(reqType) + ">>"; + if (!canTextGoInTheBox(g, size, req, iconSize)) + return; + g.setFont(f.deriveFont(Font.BOLD)); + drawLimitedString(g, req, x, y + size, width, 1); + + //g.setFont(myFontB); + if (!canTextGoInTheBox(g, size, value, iconSize)) + return; + Font iFont = f.deriveFont(Font.PLAIN); + g.setFont(iFont); + drawLimitedString(g, value, x, y + size * 2 + scale(2), width, 1); + + internalDrawingAux(g, size); + } + + //FIXME: need to make this function easier + private void internalDrawingAux(Graphics g, int size) + { String texti = "Text"; String s; int i; + currentFontSize = g.getFont().getSize(); size = lineHeight + currentFontSize; //ID @@ -382,12 +354,159 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem drawLimitedString(g, s, x + textX, y + size, width, 0); } size += currentFontSize; - } - - g.setFont(f); } +// public void internalDrawing(Graphics g) { +// Font f = g.getFont(); +// // Font fold = f; +// // int w, c; +// int size; +// +// if (texts == null) { +// makeValue(); +// } +// +// if (!tdp.isScaled()) { +// graphics = g; +// } +// +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// // +// myFont = f.deriveFont((float) currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } +// +// displayText = currentFontSize >= minFontSize; +// +// // int h = g.getFontMetrics().getHeight(); +// +// g.drawRect(x, y, width, height); +// +// g.drawLine(x, y + lineHeight, x + width, y + lineHeight); +// Color topColor = REQ_TYPE_COLOR.get(reqType); +// if (topColor == null) { +// //TraceManager.addDev("Swithing back to default Color for:" + REQ_TYPE_STR.get(reqType)); +// topColor = ColorManager.AVATAR_REQUIREMENT_TOP; +// } else { +// //TraceManager.addDev("Using color: " + topColor.getRGB() + "for " +REQ_TYPE_STR.get(reqType)); +// } +// g.setColor(topColor); +// g.fillRect(x + 1, y + 1, width - 1, lineHeight - 1); +// g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); +// g.fillRect(x + 1, y + 1 + lineHeight, width - 1, height - 1 - lineHeight); +// ColorManager.setColor(g, getState(), 0); +// if ((lineHeight > 23) && (width > 23)) { +// g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); +// } +// +// if (displayText) { +// size = currentFontSize - 2; +// g.setFont(myFont.deriveFont((float) (myFont.getSize() - 2))); +// +// drawLimitedString(g, "<<" + REQ_TYPE_STR.get(reqType) + ">>", x, y + size, width, 1); +// +// size += currentFontSize; +// g.setFont(myFontB); +// // w = g.getFontMetrics().stringWidth(value); +// drawLimitedString(g, value, x, y + size, width, 1); +// +// } +// +// if (verified) { +// if (satisfied) { +// Color tmp = g.getColor(); +// GraphicLib.setMediumStroke(g); +// g.setColor(Color.green); +// g.drawLine(x + width - 2, y - 6 + lineHeight, x + width - 6, y - 2 + lineHeight); +// g.drawLine(x + width - 6, y - 3 + lineHeight, x + width - 8, y - 6 + lineHeight); +// g.setColor(tmp); +// GraphicLib.setNormalStroke(g); +// } else { +// //g.drawString("acc", x + width - 10, y+height-10); +// Color tmp = g.getColor(); +// GraphicLib.setMediumStroke(g); +// g.setColor(Color.red); +// g.drawLine(x + width - 2, y - 2 + lineHeight, x + width - 8, y - 8 + lineHeight); +// g.drawLine(x + width - 8, y - 2 + lineHeight, x + width - 2, y - 8 + lineHeight); +// g.setColor(tmp); +// GraphicLib.setNormalStroke(g); +// } +// } +// +// g.setFont(myFont); +// String texti = "Text"; +// String s; +// int i; +// size = lineHeight + currentFontSize; +// +// //ID +// if (size < (height - 2)) { +// drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0); +// } +// size += currentFontSize; +// +// //text +// for (i = 0; i < texts.length; i++) { +// if (size < (height - 2)) { +// s = texts[i]; +// if (i == 0) { +// s = texti + "=\"" + s; +// } +// if (i == (texts.length - 1)) { +// s = s + "\""; +// } +// drawLimitedString(g, s, x + textX, y + size, width, 0); +// } +// size += currentFontSize; +// +// } +// // Type and risk +// if (size < (height - 2)) { +// drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// if (size < (height - 2)) { +// drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// if (size < (height - 2)) { +// +// drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// +// if (size < (height - 2)) { +// +// if (reqType == SECURITY_REQ) { +// drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// } +// +// if (reqType == SAFETY_REQ) { +// drawLimitedString(g, "State violating req.=\"" + violatedAction + "\"", x + textX, y + size, width, 0); +// size += currentFontSize; +// } +// } +// } +// } +// } +// +// // Extra attributes +// for (i = 0; i < extraParamIDs.size(); i++) { +// if (size < (height - 2)) { +// s = extraParamIDs.get(i) + ":" + extraParamValues.get(i); +// drawLimitedString(g, s, x + textX, y + size, width, 0); +// } +// size += currentFontSize; +// +// } +// +// g.setFont(f); +// } + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { // On the name ? oldValue = value; diff --git a/src/main/java/ui/avatarrd/AvatarRDRequirementReference.java b/src/main/java/ui/avatarrd/AvatarRDRequirementReference.java index 097eb93f908b9eb4c86300654b94ace5f03278f2..91405436869e7b96e11614d7b665870888554d45 100755 --- a/src/main/java/ui/avatarrd/AvatarRDRequirementReference.java +++ b/src/main/java/ui/avatarrd/AvatarRDRequirementReference.java @@ -39,26 +39,26 @@ package ui.avatarrd; - -import myutil.Conversion; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.util.Arrays; +//import java.util.LinkedList; +//import ui.window.JDialogIDAndStereotype; +//import ui.window.JDialogRequirement; +//import myutil.TraceManager; +//import org.w3c.dom.Element; +//import org.w3c.dom.Node; +//import org.w3c.dom.NodeList; +//import myutil.Conversion; import myutil.GraphicLib; -import myutil.TraceManager; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import ui.*; import ui.util.IconManager; import ui.window.JDialogChoiceSelection; -import ui.window.JDialogIDAndStereotype; -import ui.window.JDialogRequirement; - import javax.swing.*; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; + import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; + /** * Class AvatarRDRequirementReference @@ -73,8 +73,8 @@ public class AvatarRDRequirementReference extends TGCScalableWithInternalCompone public static String DEFAULT_REF = "UnsetReference"; public String oldValue; - protected int textX = 5; - protected int textY = 22; + //protected int textX = 5; +// protected int textY = 22; protected int lineHeight = 30; private double dlineHeight = 0.0; //protected int reqType = 0; @@ -98,16 +98,20 @@ public class AvatarRDRequirementReference extends TGCScalableWithInternalCompone public AvatarRDRequirementReference(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); - + + //Issue #31 + minWidth = 1; + minHeight = lineHeight; + textX = 5; + textY = 22; initScaling(200, 120); + + oldScaleFactor = tdp.getZoom(); dlineHeight = lineHeight * oldScaleFactor; lineHeight = (int) dlineHeight; dlineHeight = dlineHeight - lineHeight; - minWidth = 1; - minHeight = lineHeight; - nbConnectingPoint = 40; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.0, 0.25, TGConnectingPoint.WEST); diff --git a/src/main/java/ui/avatarrd/AvatarRDSatisfyConnector.java b/src/main/java/ui/avatarrd/AvatarRDSatisfyConnector.java index db2902ee059973c06b3db311702aa493a6b29d42..6229d37ffbc428dcf7b74d946efe440af40609cd 100755 --- a/src/main/java/ui/avatarrd/AvatarRDSatisfyConnector.java +++ b/src/main/java/ui/avatarrd/AvatarRDSatisfyConnector.java @@ -80,7 +80,7 @@ public class AvatarRDSatisfyConnector extends TGConnectorWithCommentConnectionP w = g.getFontMetrics().stringWidth(value); h = g.getFontMetrics().getHeight(); - g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + drawSingleString(g, value, (x1 + x2 - w) / 2, (y1 + y2)/2); g.setFont(old); } diff --git a/src/main/java/ui/avatarrd/AvatarRDVerifyConnector.java b/src/main/java/ui/avatarrd/AvatarRDVerifyConnector.java index 6e79d07b1873b652e253414951c4ad6c7b9dd686..07346d6ed6f19e5edaffff6a074ad86b4873a1d6 100755 --- a/src/main/java/ui/avatarrd/AvatarRDVerifyConnector.java +++ b/src/main/java/ui/avatarrd/AvatarRDVerifyConnector.java @@ -79,7 +79,7 @@ public class AvatarRDVerifyConnector extends TGConnectorWithCommentConnectionPo w = g.getFontMetrics().stringWidth(value); h = g.getFontMetrics().getHeight(); - g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + drawSingleString(g, value, (x1 + x2 - w) / 2, (y1 + y2)/2); g.setFont(old); } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDConnectingPoint.java b/src/main/java/ui/avatarsmd/AvatarSMDConnectingPoint.java index 1dd7c8ff10221e87bce7810f99f739a4b691b577..1a1937eaab08b8ee0857fd3dca592ec665a239b0 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDConnectingPoint.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDConnectingPoint.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.avatarsmd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -60,15 +55,8 @@ public class AvatarSMDConnectingPoint extends TGConnectingPointWidthHeight{ super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.AVATARSMD_CONNECTOR; } - } - - - - - - - diff --git a/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java b/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java index da260e9cb69575c3359a7b772615b57eb6419349..548289e75ba8f48aac9dc2d8184976ff907df67a 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java @@ -72,9 +72,9 @@ public class AvatarSMDExpireTimer extends AvatarSMDBasicCanBeDisabledComponent / protected int lineLength = 5; - protected int textX = 5; - - protected int textY = 15; +// protected int textX = 5; +// +// protected int textY = 15; protected int arc = 5; @@ -92,6 +92,9 @@ public class AvatarSMDExpireTimer extends AvatarSMDBasicCanBeDisabledComponent / width = 30; height = 20; minWidth = 30; + textX = 5; + textY = 15; + initScaling(30, 20); nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; @@ -192,7 +195,8 @@ public class AvatarSMDExpireTimer extends AvatarSMDBasicCanBeDisabledComponent / g.drawLine(x+width+hourglassSpace, y+height, x+width+hourglassSpace + hourglassWidth, y); //g.drawString("sig()", x+(width-w) / 2, y); - g.drawString(value, x + (width - w) / 2 + textX, y + textY); +// g.drawString(value, x + (width - w) / 2 + textX, y + textY); + drawSingleString(g, value, x + (width - w) / 2 + textX, y + textY); } @Override diff --git a/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java b/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java index 289727f7299a19725103e6378669b3cd4297d937..b96df028cd93decaf900142797253cb9a1bc338d 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java @@ -150,12 +150,15 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom String abbrev = this.value.substring (0, stringLength) + "..."; int w = this.tdp.stringWidth (graph, abbrev); if (w + 2*AvatarSMDLibraryFunctionCall.paddingHorizontal < this.width-2*linebreak) { - graph.drawString (abbrev, this.x + (this.width - w)/2, this.y + (this.height+h)/2); - break; +// graph.drawString (abbrev, this.x + (this.width - w)/2, this.y + (this.height+h)/2); + drawSingleString(graph, abbrev, this.x + (this.width - w)/2, this.y + (this.height+h)/2); + break; } } } else - graph.drawString (this.value, this.x + (this.width - stringWidth) / 2 , this.y + (this.height+h)/2); + drawSingleString(graph, this.value, this.x + (this.width - stringWidth) / 2 , this.y + (this.height+h)/2); +// graph.drawString (this.value, this.x + (this.width - stringWidth) / 2 , this.y + (this.height+h)/2); + } @Override diff --git a/src/main/java/ui/avatarsmd/AvatarSMDPanel.java b/src/main/java/ui/avatarsmd/AvatarSMDPanel.java index 34576d3c448c0745457099c7c46c79137d3d25e0..b9e9c97e6b4645a461b3dd5ef98d6e9579f33021 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDPanel.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDPanel.java @@ -65,45 +65,57 @@ public class AvatarSMDPanel extends TDiagramPanel implements TDPWithAttributes { attributesOn = NORMAL; } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return false; } + @Override public boolean actionOnAdd(TGComponent tgc) { return false; } + + @Override public boolean actionOnValueChanged(TGComponent tgc) { return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { return false; } + @Override public String getXMLHead() { return "<AVATARStateMachineDiagramPanel name=\"" + name + "\"" + sizeParam() + " >"; } + @Override public String getXMLTail() { return "</AVATARStateMachineDiagramPanel>"; } + @Override public String getXMLSelectedHead() { return "<AVATARStateMachineDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</AVATARStateMachineDiagramPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<AVATARStateMachineDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</AVATARStateMachineDiagramPanelCopy>"; } + public void makeGraphicalOptimizations() { // Segments of connector that mask components @@ -112,6 +124,7 @@ public class AvatarSMDPanel extends TDiagramPanel implements TDPWithAttributes { // Position correctly guards of choice } + @Override public void enhance() { //TraceManager.addDev("Enhance"); Vector<TGComponent> v = new Vector<TGComponent>(); @@ -191,7 +204,8 @@ public class AvatarSMDPanel extends TDiagramPanel implements TDPWithAttributes { componentList.add(tgc1); } } - + + @Override public boolean hasAutoConnect() { return true; } @@ -212,7 +226,8 @@ public class AvatarSMDPanel extends TDiagramPanel implements TDPWithAttributes { return list; } - + + @Override public void autoConnect(TGComponent added) { boolean cond = hasAutoConnect(); diff --git a/src/main/java/ui/avatarsmd/AvatarSMDRandom.java b/src/main/java/ui/avatarsmd/AvatarSMDRandom.java index 8d3c6c4aae5f04ad7caf096d67da5649ce12af60..89087aec7cdf922ee9692a47903253798f4e1fd7 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDRandom.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDRandom.java @@ -59,8 +59,8 @@ import java.awt.geom.Line2D; */ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected String valueRandom = ""; protected String variable; @@ -76,6 +76,9 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is width = 30; height = 20; minWidth = 30; + textX = 5; + textY = 15; + initScaling(30,20); nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; @@ -142,8 +145,9 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); //g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); - - g.drawString(valueRandom, x + (width - w) / 2 , y + textY); +// Issue #31: +// g.drawString(valueRandom, x + (width - w) / 2 , y + textY); + drawSingleString(g, valueRandom, getCenter(g, valueRandom), y + height - scale(5)); } @Override diff --git a/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java b/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java index b705e2a4c382fc40585864f40aa41471df5dc4d0..6711bb9f6cfa18a17b0be4d2daf2924ca3498865 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java @@ -77,11 +77,11 @@ import ui.window.JDialogAvatarSignal; */ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int linebreak = 10; - protected int textX1 = 2; +// protected int textX1 = 2; private Map<String, String> latencyVals; @@ -98,6 +98,9 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent width = 30; height = 20; minWidth = 30; + textX = 5; + textY = 15; + initScaling(30, 20); nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; @@ -125,7 +128,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent @Override public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value + textX1); + int w = g.getFontMetrics().stringWidth(value + textX); int w1 = Math.max(minWidth, w + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) { setCd(x + width/2 - w1/2, y); @@ -194,8 +197,10 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent } //g.drawString("sig()", x+(width-w) / 2, y); - g.drawString(value, x + linebreak + textX1, y + textY); - // + +// g.drawString(value, x + linebreak + textX, y + textY); + drawSingleString(g, value, x + linebreak + textX, y + textY); + // if (getCheckLatency()){ ConcurrentHashMap<String, String> latency =tdp.getMGUI().getLatencyVals(getAVATARID()); if (latency!=null){ @@ -207,7 +212,9 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent if (reference!=null){ if (reference instanceof AvatarRDRequirement){ AvatarRDRequirement refReq = (AvatarRDRequirement) reference; - g.drawString("ref: "+ refReq.getValue(), x, y+height1+textY); + //Issue #31 +// g.drawString("ref: "+ refReq.getValue(), x, y+height1+textY); + drawSingleString(g,"ref: "+ refReq.getValue(), x, y+height1+textY); } } } @@ -216,7 +223,9 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent int index=1; for (String s:latencyVals.keySet()){ int w = g.getFontMetrics().stringWidth(s); - g.drawString(s, x-latencyX-w+1, y-latencyY*index-2); +// g.drawString(s, x-latencyX-w+1, y-latencyY*index-2); + drawSingleString(g, s, x-latencyX-w+1, y-latencyY*index-2); + g.drawRect(x-latencyX-w, y-latencyY*index-textHeight, w+4, textHeight); g.drawLine(x,y,x-latencyX, y-latencyY*index); Color c = g.getColor(); @@ -311,7 +320,8 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent } } - g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); +// g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); + drawSingleString(g, latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); g.setColor(c); index++; } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java b/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java index 6eab76979e64f20b527b7d8fa475bd9095d2c9f3..35f0a9ea0a735c38ffea260e86c6d2aead164a30 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java @@ -70,8 +70,8 @@ import ui.window.JDialogAvatarTimer; */ public class AvatarSMDResetTimer extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int linebreak = 10; @@ -84,9 +84,13 @@ public class AvatarSMDResetTimer extends AvatarSMDBasicCanBeDisabledComponent /* public AvatarSMDResetTimer(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); + //Issue #31 width = 30; height = 20; minWidth = 30; + textX = 5; + textY = 15; + initScaling(30,20); nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; @@ -185,7 +189,8 @@ public class AvatarSMDResetTimer extends AvatarSMDBasicCanBeDisabledComponent /* g.drawLine(x+width+hourglassSpace, y+height, x+width+hourglassSpace + hourglassWidth, y); //g.drawString("sig()", x+(width-w) / 2, y); - g.drawString(value, x + (width - w) / 2 , y + textY); +// g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g, value, x + (width - w) / 2 , y + textY); } @Override diff --git a/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java b/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java index aefcf54dface93a33001f78b6cf39474a4137f4d..0182071c4f9d84412ccd6446fad4d71412b40643 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java @@ -76,8 +76,8 @@ import ui.window.JDialogAvatarSignal; */ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int linebreak = 10; @@ -96,6 +96,9 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* width = 30; height = 20; minWidth = 30; + textX = 5; + textY = 15; + initScaling(30,20); nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; @@ -191,7 +194,8 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* //g.drawString("sig()", x+(width-w) / 2, y); - g.drawString(value, x + (width - w) / 2 , y + textY); +// g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g, value, x + (width - w) / 2 , y + textY); //g.drawString("Reference " + reference, x-latencyX/2, y+latencyY/2); if (getCheckLatency()){ @@ -204,7 +208,8 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* if (reference!=null){ if (reference instanceof AvatarRDRequirement){ AvatarRDRequirement refReq = (AvatarRDRequirement) reference; - g.drawString("ref: "+ refReq.getValue(), x, y+height1+textY); +// g.drawString("ref: "+ refReq.getValue(), x, y+height1+textY); + drawSingleString(g, "ref: "+ refReq.getValue(), x, y+height1+textY); } } } @@ -309,7 +314,8 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* } } - g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); +// g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); + drawSingleString(g, latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); g.setColor(c); index++; } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java b/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java index d5915ffa4f2ec4fd11e375d407685bcede6759a0..4332f89b9eb796628de7e631edca08e6f7cd6415 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java @@ -70,8 +70,8 @@ import ui.window.JDialogAvatarTimer; */ public class AvatarSMDSetTimer extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int linebreak = 10; @@ -87,6 +87,9 @@ public class AvatarSMDSetTimer extends AvatarSMDBasicCanBeDisabledComponent /* I width = 30; height = 20; minWidth = 30; + textX = 5; + textY = 15; + initScaling(30,20); nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; @@ -186,7 +189,8 @@ public class AvatarSMDSetTimer extends AvatarSMDBasicCanBeDisabledComponent /* I g.drawLine(x+width+hourglassSpace, y+height, x+width+hourglassSpace + hourglassWidth, y); //g.drawString("sig()", x+(width-w) / 2, y); - g.drawString(value, x + (width - w) / 2 , y + textY); +// g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g, value, x + (width - w) / 2 , y + textY); } @Override diff --git a/src/main/java/ui/avatarsmd/AvatarSMDStartState.java b/src/main/java/ui/avatarsmd/AvatarSMDStartState.java index b815131fe67c80b6c8df60d045fa51279bbe0f27..b1ee6ff3217e1670f21ab6c78826d7e481bad7b5 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDStartState.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDStartState.java @@ -61,6 +61,7 @@ public class AvatarSMDStartState extends AvatarSMDBasicComponent implements Embe width = 15; height = 15; + initScaling(15, 15); nbConnectingPoint = 1; connectingPoint = new TGConnectingPoint[1]; @@ -80,7 +81,7 @@ public class AvatarSMDStartState extends AvatarSMDBasicComponent implements Embe @Override public void internalDrawing(Graphics g) { g.fillOval(x, y, width, height); - g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + g.drawLine(x+(width/2), y+height, x+(width/2), y + scale(lineLength) + height); } @Override diff --git a/src/main/java/ui/avatarsmd/AvatarSMDState.java b/src/main/java/ui/avatarsmd/AvatarSMDState.java index 1937354331848bef0495652b8d754a1583f5a812..686f389bea5f42d4dc6eceef23e6d5f172d97222 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDState.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDState.java @@ -68,13 +68,13 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements //private static String GLOBAL_CODE_INFO = "(global code)"; private static String ENTRY_CODE_INFO = "(entry code)"; - private int textY1 = 3; +// private int textY1 = 3; - private int maxFontSize = 12; - private int minFontSize = 4; - private int currentFontSize = -1; - private boolean displayText = true; - private int textX = 7; +// private int maxFontSize = 12; +// private int minFontSize = 4; +// private int currentFontSize = -1; +// private boolean displayText = true; +// private int textX = 7; //protected String [] globalCode; protected String [] entryCode; @@ -93,11 +93,13 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements public AvatarSMDState(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); - + textX = 7; + textY = 3; width = 100; height = 50; minWidth = 40; minHeight = 30; + initScaling(100, 50); nbConnectingPoint = 32; connectingPoint = new TGConnectingPoint[32]; @@ -160,8 +162,8 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements //name = "State"; oldValue = value; - currentFontSize = maxFontSize; - oldScaleFactor = tdp.getZoom(); +// currentFontSize = maxFontSize; +// oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic700; @@ -191,126 +193,159 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements mutexStates = null; } - @Override - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - - f = f.deriveFont(minFontSize); - // - - 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, maxFontSize)); - int w0;//, w1, w2; - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - // - while(maxCurrentFontSize > (minFontSize-1)) { - w0 = g.getFontMetrics().stringWidth(value); - if (w0 < (width - (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); - } - - } - - Color c = g.getColor(); - //g.setColor(ColorManager.AVATAR_STATE); - +// @Override + public void internalDrawing(Graphics g) + { + Font f = g.getFont(); + //Rectangle + Color c = g.getColor(); // Issue #69 - if ( isEnabled() ) { - Color avat = ColorManager.AVATAR_STATE; - g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); - } - else { - g.setColor( ColorManager.DISABLED_FILLING ); - } + if (isEnabled()) { + Color avat = ColorManager.AVATAR_STATE; + g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); + } + else { + g.setColor( ColorManager.DISABLED_FILLING ); + } g.fillRoundRect(x, y, width, height, 5, 5); g.setColor(c); g.drawRoundRect(x, y, width, height, 5, 5); + g.drawLine(x, y+ f.getSize() + 2, x+width, y+ f.getSize() + 2); - // Strings - int w; - int h = 0; - if (displayText) { - f = f.deriveFont((float)currentFontSize); - Font f0 = g.getFont(); - g.setFont(f.deriveFont(Font.BOLD)); - - w = g.getFontMetrics().stringWidth(value); - h = currentFontSize + (int)(textY1 * tdp.getZoom()); - if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y +h); - } - - - g.setColor(ColorManager.AVATAR_CODE); - int step = h + h; - /*if (hasGlobalCode()) { - w = g.getFontMetrics().stringWidth(GLOBAL_CODE_INFO); - if ((w < (2*textX + width)) && (step + 1 < height)) { - g.drawString(GLOBAL_CODE_INFO, x + (width - w)/2, y +step); - } - step = step + h; - }*/ - if (hasEntryCode()) { - w = g.getFontMetrics().stringWidth(ENTRY_CODE_INFO); - if ((w < (2*textX + width)) && (step + 1 < height)) { - g.drawString(ENTRY_CODE_INFO, x + (width - w)/2, y +step); - } - step = step + h; - } - g.setColor(c); - - - g.setFont(f0); - } - - g.setFont(fold); - - h = h +2; - if (h < height) { - g.drawLine(x, y+h, x+width, y+h); - } - - // Icon - - g.setFont(fold); - - /*if ((mutexStates != null) && (state == TGState.POINTER_ON_ME)){ - String s = "Mutually exclusive states:\n"; - for(AvatarSMDState st: mutexStates) { - s += st.getTDiagramPanel().getName() + "/" + st.getStateName() + "\n"; - } - drawAttributes(g, s); - }*/ - - drawSecurityInformation(g); + //Strings + g.setFont(f.deriveFont(Font.BOLD)); + drawSingleString(g, value, getCenter(g, value), y + f.getSize()); + + g.setFont(f.deriveFont(Font.PLAIN)); + g.setColor(ColorManager.AVATAR_CODE); + drawSingleString(g, ENTRY_CODE_INFO, getCenter(g, ENTRY_CODE_INFO), y + f.getSize() * 2 + scale(3)); + g.setColor(c); + + //Security information + drawSecurityInformation(g); } + +// //@Override +// public void internalDrawin(Graphics g) { +// Font f = g.getFont(); +// Font fold = f; +// +// f = f.deriveFont(minFontSize); +// // +// +// 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, maxFontSize)); +// int w0;//, w1, w2; +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// // +// while(maxCurrentFontSize > (minFontSize-1)) { +// w0 = g.getFontMetrics().stringWidth(value); +// if (w0 < (width - (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); +// } +// +// } +// +// Color c = g.getColor(); +// //g.setColor(ColorManager.AVATAR_STATE); +// +// // Issue #69 +// if ( isEnabled() ) { +// Color avat = ColorManager.AVATAR_STATE; +// g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); +// } +// else { +// g.setColor( ColorManager.DISABLED_FILLING ); +// } +// +// g.fillRoundRect(x, y, width, height, 5, 5); +// g.setColor(c); +// g.drawRoundRect(x, y, width, height, 5, 5); +// +// // Strings +// int w; +// int h = 0; +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// Font f0 = g.getFont(); +// g.setFont(f.deriveFont(Font.BOLD)); +// +// w = g.getFontMetrics().stringWidth(value); +// h = currentFontSize + (int)(textY1 * tdp.getZoom()); +// if ((w < (2*textX + width)) && (h < height)) { +// g.drawString(value, x + (width - w)/2, y +h); +// } +// +// +// g.setColor(ColorManager.AVATAR_CODE); +// int step = h + h; +// /*if (hasGlobalCode()) { +// w = g.getFontMetrics().stringWidth(GLOBAL_CODE_INFO); +// if ((w < (2*textX + width)) && (step + 1 < height)) { +// g.drawString(GLOBAL_CODE_INFO, x + (width - w)/2, y +step); +// } +// step = step + h; +// }*/ +// if (hasEntryCode()) { +// w = g.getFontMetrics().stringWidth(ENTRY_CODE_INFO); +// if ((w < (2*textX + width)) && (step + 1 < height)) { +// g.drawString(ENTRY_CODE_INFO, x + (width - w)/2, y +step); +// } +// step = step + h; +// } +// g.setColor(c); +// +// +// g.setFont(f0); +// } +// +// g.setFont(fold); +// +// h = h +2; +// if (h < height) { +// g.drawLine(x, y+h, x+width, y+h); +// } +// +// // Icon +// +// g.setFont(fold); +// +// /*if ((mutexStates != null) && (state == TGState.POINTER_ON_ME)){ +// String s = "Mutually exclusive states:\n"; +// for(AvatarSMDState st: mutexStates) { +// s += st.getTDiagramPanel().getName() + "/" + st.getStateName() + "\n"; +// } +// drawAttributes(g, s); +// }*/ +// +// drawSecurityInformation(g); +// } private void drawSecurityInformation(Graphics g) { if (securityInformation > 0) { @@ -611,6 +646,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return (nbInternalTGComponent > 0); } + @Override public String getAttributes() { if (mutexStates == null) { return null; diff --git a/src/main/java/ui/avatarsmd/AvatarSMDStopState.java b/src/main/java/ui/avatarsmd/AvatarSMDStopState.java index 7f755ed2e10956a6b75ccea8cdafb082fe9b98b3..f38d9393c068e7b75fdf5a9e44e7ebc37082cbea 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDStopState.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDStopState.java @@ -79,14 +79,15 @@ public class AvatarSMDStopState extends AvatarSMDBasicComponent implements Embed myImageIcon = IconManager.imgic210; } + @Override public void internalDrawing(Graphics g) { ColorManager.setColor(g, state, 0); - g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); + g.fillOval(x + (width - scale(internalCircleSize))/2, y + (height - scale(internalCircleSize))/2, scale(internalCircleSize), scale(internalCircleSize)); g.drawOval(x, y, width, height); - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y, x+(width/2), y - scale(lineLength)); } - - + + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -94,6 +95,7 @@ public class AvatarSMDStopState extends AvatarSMDBasicComponent implements Embed return null; } + @Override public int getType() { return TGComponentManager.AVATARSMD_STOP_STATE; } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java b/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java index e774c907fe4baafaf95335efd483724872be494c..352b6877d3c28c72f89137a2664bd9f575e043d0 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java @@ -80,9 +80,13 @@ public class AvatarSMDToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.actions[TGUIAction.ACT_TOGGLE_AVATAR_ID].setEnabled(b); diff --git a/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java b/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java index fb13095b3a00e0150a728b335b852c7ed17a8c19..cd960b46c3826060df2a8cbb132666fdaa1eaa08 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java @@ -905,6 +905,7 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme // return ret; // } + @Override public String getAttributes() { String attr = ""; if ( !guard.isNull()) diff --git a/src/main/java/ui/cd/TClassDiagramToolBar.java b/src/main/java/ui/cd/TClassDiagramToolBar.java index 655b003820294cee163f545e1678541a8d6c118a..9076fcc859ccdf090c6dee88bab3579162b3144a 100755 --- a/src/main/java/ui/cd/TClassDiagramToolBar.java +++ b/src/main/java/ui/cd/TClassDiagramToolBar.java @@ -85,9 +85,13 @@ public class TClassDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_RTLOTOS_RG].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/cd/TGConnectingPointAssociation.java b/src/main/java/ui/cd/TGConnectingPointAssociation.java index 54881c9c4f2943fbf752d24d8bdc4cf6b3b6efb0..1f98730c5541c7792e045891572e8ef1daea0718 100755 --- a/src/main/java/ui/cd/TGConnectingPointAssociation.java +++ b/src/main/java/ui/cd/TGConnectingPointAssociation.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.cd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointTwoFathers; @@ -53,14 +49,14 @@ import ui.TGConnectingPointTwoFathers; * @version 1.0 20/12/2003 * @author Ludovic APVRILLE */ -public class TGConnectingPointAssociation extends TGConnectingPointTwoFathers{ +public class TGConnectingPointAssociation extends TGConnectingPointTwoFathers{ public TGConnectingPointAssociation(CDElement _container1, CDElement _container2, int _x, int _y, boolean _in, boolean _out) { super(_container1, _container2, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_ATTRIBUTE; } - } diff --git a/src/main/java/ui/cd/TGConnectingPointCompositionOperator.java b/src/main/java/ui/cd/TGConnectingPointCompositionOperator.java index 3e4f882ed587ef717d0e82762df0fc111f38a892..d85442c6cc00c02453526501f3c7400e0ac23599 100755 --- a/src/main/java/ui/cd/TGConnectingPointCompositionOperator.java +++ b/src/main/java/ui/cd/TGConnectingPointCompositionOperator.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.cd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPoint; @@ -53,21 +49,14 @@ import ui.TGConnectingPoint; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TGConnectingPointCompositionOperator extends TGConnectingPoint{ +public class TGConnectingPointCompositionOperator extends TGConnectingPoint { public TGConnectingPointCompositionOperator(CDElement _container1, int _x, int _y, boolean _in, boolean _out) { super(_container1, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_ATTRIBUTE; } - } - - - - - - - diff --git a/src/main/java/ui/cd/TGConnectorAssociation.java b/src/main/java/ui/cd/TGConnectorAssociation.java index adca6bc46b7f0d5544c2e4c015bd31daaf58ab02..c511912ead957fd01351438cdd0dece0afeff070 100755 --- a/src/main/java/ui/cd/TGConnectorAssociation.java +++ b/src/main/java/ui/cd/TGConnectorAssociation.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.cd; import ui.*; @@ -47,9 +44,6 @@ import ui.util.IconManager; import java.awt.*; import java.util.Vector; -//import java.awt.geom.*; -//import myutil.*; - /** * Class TGConnectorAssociation * Association to be used in class diagram. Connects two TClasses. diff --git a/src/main/java/ui/dd/TDeploymentDiagramToolBar.java b/src/main/java/ui/dd/TDeploymentDiagramToolBar.java index 5b2379b81c2f840508086da5b76ed665eb3ee929..ec1aa888fadb4b56e09605b43c744aad08681ac1 100755 --- a/src/main/java/ui/dd/TDeploymentDiagramToolBar.java +++ b/src/main/java/ui/dd/TDeploymentDiagramToolBar.java @@ -73,9 +73,13 @@ public class TDeploymentDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.TDD_NODE].setEnabled(b); mgui.actions[TGUIAction.TDD_ARTIFACT].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/dd/TGConnectingPointDD.java b/src/main/java/ui/dd/TGConnectingPointDD.java index c5c5280a172dd4250d4db5b1ec656a5a8575340c..bb832f32386d3edf007dc78e47e8782d5edb42ac 100755 --- a/src/main/java/ui/dd/TGConnectingPointDD.java +++ b/src/main/java/ui/dd/TGConnectingPointDD.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.dd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -53,14 +49,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 02/05/2005 * @author Ludovic APVRILLE */ -public class TGConnectingPointDD extends TGConnectingPointWidthHeight{ +public class TGConnectingPointDD extends TGConnectingPointWidthHeight{ public TGConnectingPointDD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_NODE_DD; } - } diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyConnectingPoint.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyConnectingPoint.java index 8eb16dbcbcdf76064671c0750e66be772fc8c2cc..5c7a14bc163f3d8fedaea19c49e4e9a8cb662e48 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyConnectingPoint.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyConnectingPoint.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.diplodocusmethodology; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -61,12 +56,8 @@ public class DiplodocusMethodologyConnectingPoint extends TGConnectingPointWidt orientation = _orientation; } + @Override public boolean isCompatibleWith(int type) { - return type == TGComponentManager.DIPLODOCUSMETHODOLOGY_CONNECTOR; - - } - - -} \ No newline at end of file +} diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java index c381c69cc52f2b7c3ca7ae78ee50a9b19dd96c78..22840b4b7e6a3eccf68c0ce350e28e01f691caa2 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java @@ -65,7 +65,6 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal public final static int X_MARGIN = 5; public final static int Y_MARGIN = 3; - protected final static int SIM_TRACE_APP_DIPLO = 0; protected final static int SIM_ANIM_APP_DIPLO = 7; protected final static int UPP_APP_DIPLO = 1; @@ -107,6 +106,10 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal public DiplodocusMethodologyDiagramName(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); + minWidth = 10; + minHeight = lineLength; + initScaling(10, 10); + nbConnectingPoint = 0; minWidth = 10; nbInternalTGComponent = 0; @@ -117,14 +120,90 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal name = "value "; + myImageIcon = IconManager.imgic302; + } + + //Issue #31: Factorisation with isTextReadable included into a new function: drawSingleString + @Override + public void internalDrawing(Graphics g) + { +// if (!isTextReadable(g)) +// return; + // Strings + String textDiagramRef = value; + Font f = g.getFont(); + //g.drawString(textDiagramRef, x, y); + drawSingleString(g, textDiagramRef, x, y); + //validation and their strings + GestionOfValidations(g, f); + } + + private void setFontStyleWhenPointerIsOnMe(Graphics g, int fontStyle, boolean pointerOnMe, Font font, int index) { + if (pointerOnMe && indexOnMe == index) + g.setFont(font.deriveFont(fontStyle)); + } + + private void GestionOfValidations(Graphics g, Font f) { + if (validations == null) { + if (getFather() instanceof DiplodocusMethodologyDiagramReference) { + ((DiplodocusMethodologyDiagramReference)(getFather())).makeValidationInfos(this); + } + } + + if ((validations != null) && (valMinX == null)) { + valMinX = new int[validations.length]; + valMaxX = new int[validations.length]; + } + int widthText = g.getFontMetrics().stringWidth(value); + int widthFather = getFather().getWidth(); + int curWidth = Math.max(width, myWidth); + int currentMaxWidthX = widthFather + x - 2 * (X_MARGIN); + int saveCurrentMaxX = currentMaxWidthX; + boolean oneWritten = false; + int saveWidth = 0; + g.setFont(f.deriveFont(Font.ITALIC)); + boolean pointerIsOnMe = tdp.componentPointed() == this ? true : false; + + if ((validations != null) & (validations.length >0)) { + for (int i = validations.length-1; i >= 0; i--) { + saveWidth = g.getFontMetrics().stringWidth(SHORT_ACTION_NAMES[validations[i]]); + + if ((currentMaxWidthX - saveWidth) > (x + widthText)) { +// if ((onMe && indexOnMe == i)) { +// g.setFont(f.deriveFont(Font.BOLD)); +// } Issue #31 + setFontStyleWhenPointerIsOnMe(g, Font.BOLD, pointerIsOnMe, f, i); + //g.drawString(SHORT_ACTION_NAMES[validations[i]], currentMaxWidthX - saveWidth, y); + drawSingleString(g, SHORT_ACTION_NAMES[validations[i]], currentMaxWidthX - saveWidth, y); + + g.setFont(f.deriveFont(Font.ITALIC)); + valMinX[i] = currentMaxWidthX - saveWidth; + valMaxX[i] = currentMaxWidthX; + oneWritten = true; + currentMaxWidthX = currentMaxWidthX - saveWidth - 5; + } else + break; + } + } + g.setFont(f); - initScaling(10, 10); - + if (oneWritten) { + makeScale(g, saveCurrentMaxX - x); + } else { + makeScale(g, widthText); + } + // Issue #31: Same as in Avatar Diagram Name: rectangle size error on zoom +// if (onMe) +// g.drawRect(x-2, y-12, myWidth+4, 15); + if (pointerIsOnMe) + g.drawRect(x - 2, y - scale(15), curWidth + 4, scale(15)); + + } - myImageIcon = IconManager.imgic302; - } + /* + @Override public void internalDrawing(Graphics g) { boolean onMe = false; @@ -132,13 +211,13 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal onMe = true; } - if (getFather() == null) { - return; - } - - if ((y+Y_MARGIN) > (getFather().getY()+getFather().getHeight())) { - return; - } + if (getFather() == null) { + return; + } + + if ((y+Y_MARGIN) > (getFather().getY()+getFather().getHeight())) { + return; + } //TraceManager.addDev("Internal drawing ..."); @@ -175,17 +254,17 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal valMaxX = new int[validations.length]; } - /*if (validations == null) { - TraceManager.addDev("null validation"); - } else { - TraceManager.addDev("Validation size=" + validations.length); - }*/ +// if (validations == null) { +// TraceManager.addDev("null validation"); +// } else { +// TraceManager.addDev("Validation size=" + validations.length); +// } currentMaxX = wf + x - 2*(X_MARGIN); saveCurrentMaxX = currentMaxX; if (wf < w+(2*X_MARGIN)) { - makeScale(g, w+(2*X_MARGIN)); + makeScale(g, w + (2 * X_MARGIN)); return; } @@ -224,14 +303,12 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal } else { makeScale(g, w); } - + // Issue #31: Same as in Avatar Diagram Name: rectangle size error on zoom +// if (onMe) +// g.drawRect(x-2, y-12, myWidth+4, 15); if (onMe) - g.drawRect(x-2, y-12, myWidth+4, 15); - - return; - - - } + g.drawRect(x - 2, y - scale(15), myWidth + 4, scale(15)); + }*/ private void makeScale(Graphics g, int _size) { if (!tdp.isScaled()) { @@ -240,7 +317,7 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal } } - + @Override public TGComponent isOnMe(int _x, int _y) { int oldIndex = indexOnMe; if (GraphicLib.isInRectangle(_x, _y, x, y - height, Math.max(myWidth, minWidth), myHeight)) { @@ -270,7 +347,8 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal } return null; } - + + @Override public boolean editOndoubleClick(JFrame frame) { if (indexOnMe == -1) { @@ -292,11 +370,12 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal return true; } - + @Override public int getType() { return TGComponentManager.DIPLODODUSMETHODOLOGY_DIAGRAM_NAME; } - + + @Override public int getDefaultConnector() { return TGComponentManager.DIPLODOCUSMETHODOLOGY_CONNECTOR; } @@ -308,7 +387,8 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal public void setValidationsInfo(int _index, int _val) { validations[_index] = _val; } - + + @Override public void rescale(double scaleFactor){ if ((valMinX != null) && (valMinX.length > 0)) { diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramPanel.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramPanel.java index c61235565be7a402075d8dfd49b3505e6669069f..168d7b3d069eea308e6e3f31ae3258195336bd60 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramPanel.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramPanel.java @@ -61,10 +61,12 @@ public class DiplodocusMethodologyDiagramPanel extends TDiagramPanel implements addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return true; } - + + @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -73,7 +75,8 @@ public class DiplodocusMethodologyDiagramPanel extends TDiagramPanel implements }*/ return false; } - + + @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -83,34 +86,41 @@ public class DiplodocusMethodologyDiagramPanel extends TDiagramPanel implements }*/ return false; } - + + @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); }*/ return false; } - + + @Override public String getXMLHead() { return "<DiplodocusMethodologyDiagramPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } - + + @Override public String getXMLTail() { return "</DiplodocusMethodologyDiagramPanel>"; } - + + @Override public String getXMLSelectedHead() { return "<DiplodocusMethodologyDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - + + @Override public String getXMLSelectedTail() { return "</DiplodocusMethodologyDiagramPanelCopy>"; } - + + @Override public String getXMLCloneHead() { return "<DiplodocusMethodologyDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - + + @Override public String getXMLCloneTail() { return "</DiplodocusMethodologyDiagramPanelCopy>"; } @@ -119,7 +129,8 @@ public class DiplodocusMethodologyDiagramPanel extends TDiagramPanel implements public void makePostLoadingProcessing() throws MalformedModelingException { } - + + @Override public void enhance() { autoAdjust(); } diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java index d8b46d1ff1f0068430a6ca807d5a559319a54b14..e8ae3747a2143b12f2b4443a08a6e733c2e14559 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.diplodocusmethodology; - import myutil.GraphicLib; import myutil.TraceManager; import ui.*; @@ -65,21 +61,23 @@ import java.util.Vector; */ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableWithInternalComponent implements SwallowTGComponent { public String oldValue; - protected int textX = 5; - protected int textY = 22; - protected int lineHeight = 30; - protected double dlineHeight = 0.0; + + // +// protected int textX = 5; +// protected int textY = 22; +// protected int lineHeight = 30; +// protected double dlineHeight = 0.0; //protected int reqType = 0; // 0: normal, 1: formal, 2: security //protected int startFontSize = 10; - protected Graphics graphics; - protected int iconSize = 30; + //protected Graphics graphics; + private static final int ICON_SIZE = 30; protected Font myFont, myFontB; protected int maxFontSize = 30; protected int minFontSize = 4; - protected int currentFontSize = -1; - protected boolean displayText = true; + //protected int currentFontSize = -1; + //protected boolean displayText = true; protected int typeOfReference; @@ -94,23 +92,22 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW protected JMenuItem diagramReference; - - - // Icon - //private int iconSize = 18; - //private boolean iconIsDrawn = false; - public DiplodocusMethodologyDiagramReference(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - initScaling(200, 120); - oldScaleFactor = tdp.getZoom(); - dlineHeight = lineHeight * oldScaleFactor; - lineHeight = (int)dlineHeight; - dlineHeight = dlineHeight - lineHeight; + // Issue #31 + lineLength = 30; + textX = 5; + textY = 22; + minHeight = lineLength; - minWidth = 10; - minHeight = lineHeight; + initScaling(200, 120); + + // Issue #31 +// oldScaleFactor = tdp.getZoom(); +// dlineHeight = lineHeight * oldScaleFactor; +// lineHeight = (int)dlineHeight; +// dlineHeight = dlineHeight - lineHeight; addTGConnectingPointsCommentTop(); @@ -128,41 +125,40 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW userResizable = true; multieditable = true; - - oldValue = value; myImageIcon = IconManager.imgic5006; - actionOnAdd(); } - + @Override public void internalDrawing(Graphics g) { Font f = g.getFont(); // Font fold = f; // int w, c; - int size; + // int size; value = TYPE_STR[typeOfReference]; - if (!tdp.isScaled()) { - graphics = g; - } - - if (((rescaled) && (!tdp.isScaled())) || myFont == null) { - currentFontSize = tdp.getFontSize(); - // - myFont = f.deriveFont((float)currentFontSize); - myFontB = myFont.deriveFont(Font.BOLD); - - if (rescaled) { - rescaled = false; - } - } - - displayText = currentFontSize >= minFontSize; +// if (!tdp.isScaled()) { +// graphics = g; +// } + + // Issue #31 The font is already managed when drawing the panel +// if (((rescaled) && (!tdp.isScaled())) || myFont == null) { +// currentFontSize = tdp.getFontSize(); +// // +// myFont = f.deriveFont((float)currentFontSize); +// myFontB = myFont.deriveFont(Font.BOLD); +// +// if (rescaled) { +// rescaled = false; +// } +// } + + final int fontSize = g.getFont().getSize(); + //displayText = fontSize /*currentFontSize*/ >= minFontSize; // int h = g.getFontMetrics().getHeight(); @@ -177,17 +173,22 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW //g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); //g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); ColorManager.setColor(g, getState(), 0); - if ((lineHeight > 23) && (width > 23)){ - g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); - } - - if (displayText) { - size = currentFontSize - 2; - g.setFont(myFontB); - - drawLimitedString(g, value, x, y + size + 3, width, 1); - g.setFont(f); - } + //if ((lineLength > 23) && (width > 23)){ + if (!isTextReadable(g)) + return; + // Issue #31 + g.drawImage( scale( IconManager.img5100 ), x + width - scale( ICON_SIZE + 1 ), y + scale( 3 ), Color.yellow, null); + //} + + + // size = currentFontSize - 2; + // g.setFont(myFontB); + + //drawLimitedString(g, value, x, y + fontSize + 1 /*size + 3*/, width, 1); + drawSingleLimitedString(g, value, x, y + fontSize + 1 /*size + 3*/, width, 1); + + g.setFont(f); + /*if (displayText) { size = currentFontSize - 2; @@ -280,6 +281,7 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW g.setFont(f);*/ } + @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { addDiagramReference(frame); return true; @@ -339,18 +341,18 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW } - - public void rescale(double scaleFactor){ - dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; - lineHeight = (int)(dlineHeight); - dlineHeight = dlineHeight - lineHeight; - - minHeight = lineHeight; - - super.rescale(scaleFactor); - } - - + // Issue #31 +// public void rescale(double scaleFactor){ +// dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; +// lineHeight = (int)(dlineHeight); +// dlineHeight = dlineHeight - lineHeight; +// +// minHeight = lineHeight; +// +// super.rescale(scaleFactor); +// } + + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -358,8 +360,7 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW return null; } - - + @Override public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); @@ -370,6 +371,7 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW componentMenu.add(diagramReference); } + @Override public boolean eventOnPopup(ActionEvent e) { //String s = e.getActionCommand(); @@ -463,15 +465,14 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW return false; } - public void fillIgnoredSelectedFromInternalComponents(Vector<String> ignored, Vector<String>selected) { // Get from mgui the list of all diagrams with type depends from the subclass // If diagrams have the same name -> we do not see the difference TURTLEPanel tp; - Vector tabs = getTDiagramPanel().getMGUI().getTabs(); - for(Object o: tabs) { - tp = (TURTLEPanel)o; + Vector<TURTLEPanel> tabs = getTDiagramPanel().getMGUI().getTabs(); + for(TURTLEPanel o: tabs) { + tp = o; if (isAValidPanelType(tp)) { ignored.add(getTDiagramPanel().getMGUI().getTitleAt(tp)); } @@ -511,10 +512,12 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW public abstract boolean isAValidPanelType(TURTLEPanel panel); + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof DiplodocusMethodologyDiagramName; } + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { tgc.setFather(this); addInternalComponent(tgc, 0); @@ -522,6 +525,7 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW return true; } + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } @@ -539,11 +543,4 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW protected void giveInformation(String info) { tdp.getMGUI().setStatusBarText(info); } - - - - /*public String getDiagramReferences() { - return referenceElements; - }*/ - } diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java index a0a07e012901a1a92aa67d41331e59f96ae043b5..aad40b81d5aa51d82883cdc32df6c540eb1a7003 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java @@ -72,16 +72,16 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc } - + @Override public int getType() { return TGComponentManager.DIPLODODUSMETHODOLOGY_REF_APPLICATION; } - + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return (panel instanceof TMLDesignPanel) || (panel instanceof TMLComponentDesignPanel); } - + @Override public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { dn.setValidationsNumber(5); dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM_ANIM_APP_DIPLO); @@ -91,7 +91,8 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc dn.setValidationsInfo(3, DiplodocusMethodologyDiagramName.PROVERIF_DIPLO); dn.setValidationsInfo(4, DiplodocusMethodologyDiagramName.TML_APP_DIPLO); } - + + @Override public boolean makeCall(String diagramName, int index) { String tmp; @@ -175,9 +176,4 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc return true; } - - - - - } diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java index 96a42af251804c47bb4d4a0ffe57dc3bdd85d5dd..afa769635a6d884103a87ce72477691c7bda4d7e 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java @@ -70,25 +70,26 @@ public class DiplodocusMethodologyDiagramReferenceToArchitecture extends Diplodo } - + @Override public int getType() { return TGComponentManager.DIPLODODUSMETHODOLOGY_REF_ARCHITECTURE; } + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof TMLArchiPanel; } + @Override public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { dn.setValidationsNumber(0); } + @Override public boolean makeCall(String diagramName, int index) { return true; } - - } diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToCP.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToCP.java index b309eec8314003c2c85ecd0b24b66dace767046a..9fa64689b18199c4f5afba391a32e37416c2b1b0 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToCP.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToCP.java @@ -71,20 +71,24 @@ public class DiplodocusMethodologyDiagramReferenceToCP extends DiplodocusMethodo } + @Override public int getType() { return TGComponentManager.DIPLODODUSMETHODOLOGY_REF_CP; } + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof TMLCommunicationPatternPanel; } + @Override public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { dn.setValidationsNumber(0); } + @Override public boolean makeCall(String diagramName, int index) { return true; } diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java index 903b036d93867c08a3b02ad32945b61dd2c95c0e..bdbcc9dfbe76b0ef649b39ba54d08efce5c20ac0 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java @@ -74,16 +74,16 @@ public class DiplodocusMethodologyDiagramReferenceToMapping extends DiplodocusMe } - + @Override public int getType() { return TGComponentManager.DIPLODODUSMETHODOLOGY_REF_MAPPING; } - + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof TMLArchiPanel; } - + @Override public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { dn.setValidationsNumber(4); dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM_ANIM_MAPPING_DIPLO); @@ -91,7 +91,7 @@ public class DiplodocusMethodologyDiagramReferenceToMapping extends DiplodocusMe dn.setValidationsInfo(2, DiplodocusMethodologyDiagramName.FV_MAPPING_DIPLO); dn.setValidationsInfo(3, DiplodocusMethodologyDiagramName.TML_MAPPING_DIPLO); } - + @Override public boolean makeCall(String diagramName, int index) { String tmp; diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java index dc56aab28942d789c354f79ef9033f8d3b830416..ec02141fd7ad70dccbfcc46e851f87a7728e32c4 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java @@ -69,20 +69,20 @@ public class DiplodocusMethodologyDiagramReferenceToRequirement extends Diplodoc addTGConnectingPointsCommentTop(); } - + @Override public int getType() { return TGComponentManager.DIPLODODUSMETHODOLOGY_REF_REQUIREMENT; } - + @Override public boolean isAValidPanelType(TURTLEPanel panel) { return panel instanceof AvatarRequirementPanel; } - + @Override public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { dn.setValidationsNumber(0); } - + @Override public boolean makeCall(String diagramName, int index) { return true; } diff --git a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramToolbar.java b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramToolbar.java index df678ddc5b961fab1212f428acf2525aa0e685d9..7c58c5e10a59c85db4dc69694d922b4951105ec6 100755 --- a/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramToolbar.java +++ b/src/main/java/ui/diplodocusmethodology/DiplodocusMethodologyDiagramToolbar.java @@ -62,7 +62,7 @@ public class DiplodocusMethodologyDiagramToolbar extends TToolBar { super(_mgui); } - + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -88,7 +88,7 @@ public class DiplodocusMethodologyDiagramToolbar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(!b); } - + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/directedgraph/JFrameLatencyDetailedAnalysis.java b/src/main/java/ui/directedgraph/JFrameLatencyDetailedAnalysis.java index 4e05eb82f3fbd448e2bb191ff02ce14b45af9a70..797e1dd0a97161a119f9bde3c92c7d817d799122 100644 --- a/src/main/java/ui/directedgraph/JFrameLatencyDetailedAnalysis.java +++ b/src/main/java/ui/directedgraph/JFrameLatencyDetailedAnalysis.java @@ -39,7 +39,6 @@ package ui.directedgraph; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; @@ -52,13 +51,10 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.io.InputStream; import java.lang.Thread.State; import java.util.List; import java.util.Vector; @@ -73,7 +69,6 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.JTextArea; @@ -84,40 +79,29 @@ import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; +//import javax.swing.table.DefaultTableModel; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.jgrapht.Graph; -import org.jgrapht.ext.JGraphXAdapter; import org.jgrapht.graph.DefaultDirectedGraph; import org.jgrapht.graph.DefaultEdge; import org.jgrapht.io.EdgeProvider; import org.jgrapht.io.ExportException; import org.jgrapht.io.GraphMLImporter; import org.jgrapht.io.ImportException; -import org.jgrapht.io.SimpleGraphMLImporter; import org.jgrapht.io.VertexProvider; import org.xml.sax.SAXException; -import com.mxgraph.layout.hierarchical.mxHierarchicalLayout; -import com.mxgraph.swing.mxGraphComponent; - import common.ConfigurationTTool; import common.SpecConfigTTool; import myutil.GraphicLib; import myutil.ScrolledJTextArea; import tmltranslator.TMLMapping; import ui.ColorManager; -import ui.MainGUI; -import ui.SimulationTrace; import ui.TGComponent; import ui.TMLComponentDesignPanel; -import ui.interactivesimulation.InteractiveSimulationActions; -import ui.interactivesimulation.JFrameCompareSimulationTraces; -import ui.interactivesimulation.SaveCommandsToolBar; import ui.interactivesimulation.SimulationTransaction; import ui.interactivesimulation.SimulationTransactionParser; @@ -132,11 +116,11 @@ import ui.interactivesimulation.SimulationTransactionParser; public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListener, Runnable, MouseListener, ItemListener, ChangeListener { - private JButton saveGraph, viewGraph; +// private JButton saveGraph, viewGraph; protected JTextArea jta; protected JScrollPane jsp; - private JTabbedPane commandTab, resultTab, resultTabDetailed; - private JPanel loadxml, commands, jp01, jp02, activities, graphAnalysisResult, jp03, jp04, jp05, graphAnalysisResultDetailed; + private JTabbedPane commandTab, resultTab;/*, resultTabDetailed;*/ + private JPanel loadxml, commands, jp01, jp02, /*activities,*/ graphAnalysisResult, jp03, jp04, jp05; //,graphAnalysisResultDetailed; protected JButton buttonClose, buttonShowDGraph, buttonSaveDGraph, buttonBrowse, buttonDetailedAnalysis; protected JTextField saveDirName; @@ -145,7 +129,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe private JComboBox<String> tasksDropDownCombo1 = new JComboBox<String>(); private JComboBox<String> tasksDropDownCombo2 = new JComboBox<String>(); - private JComboBox<Object> tracesCombo1, tracesCombo2; +// private JComboBox<Object> tracesCombo1, tracesCombo2; protected SaveGraphToolBar sgtb; @@ -154,7 +138,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe private String[] columnNames = new String[5]; private String[] columnMinMaxNames = new String[5]; - private String[] columnByTaskNames = new String[4]; +// private String[] columnByTaskNames = new String[4]; private Object[][] dataDetailedByTask; private Object[][] dataDetailedMinMax; @@ -165,13 +149,13 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe private DirectedGraphTranslator dgraph; - private JScrollPane scrollPane11, scrollPane12, scrollPane13; + private JScrollPane scrollPane11, scrollPane12;//, scrollPane13; - private GridBagLayout gridbag01; - private GridBagConstraints c01; +// private GridBagLayout gridbag01; +// private GridBagConstraints c01; private Thread t; - @SuppressWarnings("deprecation") +// @SuppressWarnings("deprecation") public JFrameLatencyDetailedAnalysis(TMLMapping<TGComponent> tmap, List<TMLComponentDesignPanel> cpanels) { super("Latency Detailed Analysis"); initActions(); @@ -215,9 +199,9 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe // mainpanel.add(jp, BorderLayout.NORTH); - GridBagLayout gridbag02 = new GridBagLayout(); +// GridBagLayout gridbag02 = new GridBagLayout(); - GridBagLayout gridbag03 = new GridBagLayout(); +// GridBagLayout gridbag03 = new GridBagLayout(); commands = new JPanel(new BorderLayout()); commands.setBorder(new javax.swing.border.TitledBorder("load/Save")); @@ -233,7 +217,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe framePanel.add(commands, mainConstraint); - GridBagLayout gridbag05 = new GridBagLayout(); +// GridBagLayout gridbag05 = new GridBagLayout(); graphAnalysisResult = new JPanel(new BorderLayout()); graphAnalysisResult.setBorder(new javax.swing.border.TitledBorder("Latency Detailed Analysis ")); @@ -718,7 +702,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe tableData = dgraph.latencyDetailedAnalysis(task1, task2, transFile1); - DefaultTableModel model = new DefaultTableModel(); +// DefaultTableModel model = new DefaultTableModel(); table11.removeAll(); @@ -732,7 +716,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe int row = table11.getSelectedRow(); Thread t = new Thread() { public void run() { - JFrameLatencyDetailedPopup rowPopup = new JFrameLatencyDetailedPopup(dgraph, row, true); + /* JFrameLatencyDetailedPopup rowPopup =*/ new JFrameLatencyDetailedPopup(dgraph, row, true); } }; @@ -747,7 +731,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe tableData2 = dgraph.latencyMinMaxAnalysis(task1, task2, transFile1); - DefaultTableModel model2 = new DefaultTableModel(); +// DefaultTableModel model2 = new DefaultTableModel(); table12.removeAll(); @@ -760,7 +744,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe int row = table12.getSelectedRow(); Thread t = new Thread() { public void run() { - JFrameLatencyDetailedPopup rowPopup = new JFrameLatencyDetailedPopup(dgraph, row, false); + /*JFrameLatencyDetailedPopup rowPopup = */new JFrameLatencyDetailedPopup(dgraph, row, false); } }; diff --git a/src/main/java/ui/ebrdd/EBRDDToolBar.java b/src/main/java/ui/ebrdd/EBRDDToolBar.java index 57f7b47f81117b6bbf9fa2159620acc483c9d129..6fe9e38c4166a8354283a79943f98a316a40cd35 100755 --- a/src/main/java/ui/ebrdd/EBRDDToolBar.java +++ b/src/main/java/ui/ebrdd/EBRDDToolBar.java @@ -80,9 +80,13 @@ public class EBRDDToolBar extends TToolBar { mgui.actions[TGUIAction.EBRDD_ERB].setEnabled(b); mgui.actions[TGUIAction.EBRDD_VARIABLE_DECLARATION].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(!b); diff --git a/src/main/java/ui/ebrdd/TGConnectingPointEBRDD.java b/src/main/java/ui/ebrdd/TGConnectingPointEBRDD.java index 03174fd1cdc222cc2d0fd9aa16a5e50c47cb246f..d9b2e84fb700245944b63f11fd42681d8c20255a 100755 --- a/src/main/java/ui/ebrdd/TGConnectingPointEBRDD.java +++ b/src/main/java/ui/ebrdd/TGConnectingPointEBRDD.java @@ -35,14 +35,9 @@ * 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.ebrdd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -54,21 +49,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 08/09/2009 * @author Ludovic APVRILLE */ -public class TGConnectingPointEBRDD extends TGConnectingPointWidthHeight{ +public class TGConnectingPointEBRDD extends TGConnectingPointWidthHeight{ public TGConnectingPointEBRDD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_EBRDD; } - } - - - - - - - diff --git a/src/main/java/ui/ebrdd/TGConnectingPointEBRDDERC.java b/src/main/java/ui/ebrdd/TGConnectingPointEBRDDERC.java index 6b2e53d95654a8187e6176828979acf18312455c..fe66a93331425eb2d99081e1be88654e93a97a68 100755 --- a/src/main/java/ui/ebrdd/TGConnectingPointEBRDDERC.java +++ b/src/main/java/ui/ebrdd/TGConnectingPointEBRDDERC.java @@ -35,14 +35,9 @@ * 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.ebrdd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -54,21 +49,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 09/09/2009 * @author Ludovic APVRILLE */ -public class TGConnectingPointEBRDDERC extends TGConnectingPointWidthHeight{ +public class TGConnectingPointEBRDDERC extends TGConnectingPointWidthHeight { public TGConnectingPointEBRDDERC(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_EBRDD_ERC; } - } - - - - - - - diff --git a/src/main/java/ui/eln/ELNConnectingPoint.java b/src/main/java/ui/eln/ELNConnectingPoint.java index be3b97a1069ef524dae0b52835219e2c3a09b050..31e3edea68fbfadc35eb8ffb445fbcc2ec25d4e8 100644 --- a/src/main/java/ui/eln/ELNConnectingPoint.java +++ b/src/main/java/ui/eln/ELNConnectingPoint.java @@ -60,10 +60,12 @@ public class ELNConnectingPoint extends TGConnectingPointWidthHeight { name = _name; } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.ELN_CONNECTOR; } + @Override public String getName() { return name; } @@ -71,4 +73,4 @@ public class ELNConnectingPoint extends TGConnectingPointWidthHeight { public void setName(String _name) { name = _name; } -} \ No newline at end of file +} diff --git a/src/main/java/ui/eln/ELNConnector.java b/src/main/java/ui/eln/ELNConnector.java index d15fa72874add4ba68e04c562d8f613ec571155c..640788bb73b371000f09e6e9a73a47d9b33e4f5a 100644 --- a/src/main/java/ui/eln/ELNConnector.java +++ b/src/main/java/ui/eln/ELNConnector.java @@ -42,8 +42,17 @@ import ui.*; import ui.eln.sca_eln_sca_tdf.*; import ui.util.IconManager; import ui.window.JDialogELNConnector; -import java.awt.*; -import java.util.*; + +import java.awt.BasicStroke; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Stroke; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + import javax.swing.JFrame; import myutil.GraphicLib; @@ -55,8 +64,8 @@ import myutil.GraphicLib; * @author Irina Kit Yan LEE */ -public class ELNConnector extends TGConnector implements ScalableTGComponent { - protected double oldScaleFactor; +public class ELNConnector extends TGConnector /* Issue #31 implements ScalableTGComponent*/ { + //protected double oldScaleFactor; public ELNConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); @@ -64,7 +73,7 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent { myImageIcon = IconManager.imgic202; value = ""; editable = false; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); p1 = _p1; p2 = _p2; @@ -78,12 +87,14 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent { return p2; } + @Override public boolean editOndoubleClick(JFrame frame) { JDialogELNConnector jde = new JDialogELNConnector(this); jde.setVisible(true); return true; } + @Override protected void drawLastSegment(Graphics gr, int x1, int y1, int x2, int y2) { Graphics2D g = (Graphics2D) gr; @@ -262,30 +273,31 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent { } return ""; } - - public void rescale(double scaleFactor) { - int xx, yy; - - for (int i = 0; i < nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - 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); - } - oldScaleFactor = scaleFactor; - } +// Issue #31: Now moved in upper class +// public void rescale(double scaleFactor) { +// int xx, yy; +// +// for (int i = 0; i < nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// 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); +// } +// oldScaleFactor = scaleFactor; +// } + @Override public int getType() { return TGComponentManager.ELN_CONNECTOR; } - public java.util.List<ELNMidPortTerminal> getAllMidPortTerminal() { - java.util.List<ELNMidPortTerminal> list = new ArrayList<ELNMidPortTerminal>(); + public List<ELNMidPortTerminal> getAllMidPortTerminal() { + List<ELNMidPortTerminal> list = new ArrayList<ELNMidPortTerminal>(); for (int i = 0; i < nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof ELNMidPortTerminal) { list.add((ELNMidPortTerminal) (tgcomponent[i])); diff --git a/src/main/java/ui/eln/ELNDiagramToolBar.java b/src/main/java/ui/eln/ELNDiagramToolBar.java index f8cd9289a4baab5701f977d45f7d2100e69c3251..20086b57fcd4a29c6c3ab1cc856aecac6d7155c3 100644 --- a/src/main/java/ui/eln/ELNDiagramToolBar.java +++ b/src/main/java/ui/eln/ELNDiagramToolBar.java @@ -101,7 +101,11 @@ public class ELNDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/ftd/FTDBlock.java b/src/main/java/ui/ftd/FTDBlock.java index db749aacee7ab64136a657d600fe7032c3bc59ec..b7d1fa44af4890c033656283ea662985e79bc3c5 100644 --- a/src/main/java/ui/ftd/FTDBlock.java +++ b/src/main/java/ui/ftd/FTDBlock.java @@ -58,24 +58,27 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public class FTDBlock extends TGCScalableWithInternalComponent implements SwallowTGComponent { - private int textY1 = 3; +// private int textY1 = 3; private String stereotype = "block"; private int maxFontSize = 12; private int minFontSize = 4; private int currentFontSize = -1; private boolean displayText = true; - private int textX = 1; +// private int textX = 1; public FTDBlock(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); - + + textY = 3; + textX = 1; width = 250; height = 200; minWidth = 5; minHeight = 2; - + initScaling(250, 200); + nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -114,8 +117,42 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo myImageIcon = IconManager.imgic700; } + + public void internalDrawing(Graphics g) + { + //Rectangle + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); - public void internalDrawing(Graphics g) { + g.setColor(ColorManager.FTD_BLOCK); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + //Strings + String ster = "<<" + stereotype + ">>"; + Font f = g.getFont(); + Font f0 = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + + int w = g.getFontMetrics().stringWidth(ster); + int h = f.getSize(); + if ((w < (2*textX + width)) && (h < height)) { + g.drawString(ster, x + (width - w)/2, y +h); + } + g.setFont(f0); + w = g.getFontMetrics().stringWidth(value); + h = 2 * f.getSize(); + if ((w < (2*textX + width)) && (h < height)) { + drawSingleString(g, value, x + (width - w)/2, y + h); + } + + // Icon + g.drawImage(scale(IconManager.imgic1100.getImage()), x + scale(4), y + scale(4), null); + //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + //@Override + public void internalDrawin(Graphics g) { String ster = "<<" + stereotype + ">>"; Font f = g.getFont(); Font fold = f; @@ -179,15 +216,15 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo g.setFont(f.deriveFont(Font.BOLD)); w = g.getFontMetrics().stringWidth(ster); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); + int h = currentFontSize + (int)(textY * tdp.getZoom()); if ((w < (2*textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w)/2, y +h); + drawSingleString(g, ster, x + (width - w)/2, y +h); } g.setFont(f0); w = g.getFontMetrics().stringWidth(value); - h = 2* (currentFontSize + (int)(textY1 * tdp.getZoom())); + h = 2* (currentFontSize + (int)(textY * tdp.getZoom())); if ((w < (2*textX + width)) && (h < height)) { - g.drawString(value, x + (width - w)/2, y + h); + drawSingleString(g, value, x + (width - w)/2, y + h); } } @@ -204,7 +241,8 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo //g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); } - + + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -221,7 +259,8 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo public String getNodeName() { return name; } - + + @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = value; @@ -267,16 +306,19 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo return false; } - + + @Override public int getType() { return TGComponentManager.FTD_BLOCK; } - + + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof FTDFault; } - + + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { if (tgc instanceof FTDFault) { tgc.setFather(this); @@ -304,7 +346,8 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo return false; } - + + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } @@ -319,7 +362,8 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo } return v; } - + + @Override public void hasBeenResized() { for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof FTDFault) { @@ -328,7 +372,8 @@ public class FTDBlock extends TGCScalableWithInternalComponent implements Swallo } } - + + @Override public int getDefaultConnector() { return TGComponentManager.FTD_COMPOSITION_CONNECTOR; } diff --git a/src/main/java/ui/ftd/FTDCompositionConnectingPoint.java b/src/main/java/ui/ftd/FTDCompositionConnectingPoint.java index af9abada7120b08cfa7c997a87c2489b03e571b1..1c4683bf5234d94f8d65610bb9562f9dd900ff80 100644 --- a/src/main/java/ui/ftd/FTDCompositionConnectingPoint.java +++ b/src/main/java/ui/ftd/FTDCompositionConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ftd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -53,14 +49,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 14/12/2017 * @author Ludovic APVRILLE */ -public class FTDCompositionConnectingPoint extends TGConnectingPointWidthHeight { +public class FTDCompositionConnectingPoint extends TGConnectingPointWidthHeight { public FTDCompositionConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.FTD_COMPOSITION_CONNECTOR; } - } diff --git a/src/main/java/ui/ftd/FTDCompositionConnector.java b/src/main/java/ui/ftd/FTDCompositionConnector.java index 38ecf3843baedd3844f057bed03739aefff299ba..e5ea8ed29d6fec3e24dbe4acc8c5f7e2c5cbb7b6 100644 --- a/src/main/java/ui/ftd/FTDCompositionConnector.java +++ b/src/main/java/ui/ftd/FTDCompositionConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ftd; - import ui.*; import ui.util.IconManager; @@ -55,14 +51,14 @@ import java.util.Vector; * @version 1.0 14/12/2017 * @author Ludovic APVRILLE */ -public class FTDCompositionConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent{ +public class FTDCompositionConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { protected int d = 20; protected int D = 26; //protected int widthValue, heightValue, maxWidthValue, h; protected Polygon p; protected int xp1, xp2, yp1, yp2; - protected double oldScaleFactor; - protected boolean rescaled; +// protected double oldScaleFactor; +// protected boolean rescaled; public FTDCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { @@ -70,10 +66,11 @@ public class FTDCompositionConnector extends TGConnectorWithCommentConnectionPo myImageIcon = IconManager.imgic202; value = "{info}"; editable = true; - oldScaleFactor = tdp.getZoom(); - rescaled = true; +// oldScaleFactor = tdp.getZoom(); +// rescaled = true; } + @Override 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); @@ -86,7 +83,7 @@ public class FTDCompositionConnector extends TGConnectorWithCommentConnectionPo xp2 = x2; yp1 = y1; yp2 = y2; - Double alpha; + // Double alpha; int dd = (int)(d*tdp.getZoom()); int DD = (int)(D*tdp.getZoom()); @@ -169,6 +166,7 @@ public class FTDCompositionConnector extends TGConnectorWithCommentConnectionPo rescaled = false; } + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (p != null) { if (p.contains(x1, y1)) { @@ -178,36 +176,34 @@ public class FTDCompositionConnector extends TGConnectorWithCommentConnectionPo return null; } - - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - rescaled = true; - } - - +// Issue #31: Now moved to upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// rescaled = true; +// } + + @Override public int getType() { return TGComponentManager.FTD_COMPOSITION_CONNECTOR; } - - - } + diff --git a/src/main/java/ui/ftd/FTDConstraint.java b/src/main/java/ui/ftd/FTDConstraint.java index d00214ea616184eb351a1aec2bd61b27a3518514..bf4e417cc107d65182a06d77055c06f4fdc7694e 100644 --- a/src/main/java/ui/ftd/FTDConstraint.java +++ b/src/main/java/ui/ftd/FTDConstraint.java @@ -62,7 +62,7 @@ import java.awt.*; * @version 1.0 14/12/2017 */ public class FTDConstraint extends TGCScalableWithInternalComponent implements SwallowedTGComponent, ConstraintListInterface { - private int textY1 = 5; +// private int textY1 = 5; //private int textY2 = 30; public static final String[] STEREOTYPES = {"<<OR>>", "<<XOR>>", "<<AND>>", "<<NOT>>", "<<SEQUENCE>>", "<<AFTER>>", @@ -88,10 +88,12 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S public FTDConstraint(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int) (150 * tdp.getZoom()); - height = (int) (50 * tdp.getZoom()); + width = 150; //(int) (150 * tdp.getZoom()); + height = 50; //(int) (50 * tdp.getZoom()); minWidth = 100; - + textY = 5; + initScaling(150,50); + nbConnectingPoint = 12; connectingPoint = new TGConnectingPoint[12]; @@ -123,24 +125,25 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S myImageIcon = IconManager.imgic1078; } + @Override public void internalDrawing(Graphics g) { Font f = g.getFont(); // Font fold = f; - if (currentFontSize == -1) { - currentFontSize = f.getSize(); - } - - if ((rescaled) && (!tdp.isScaled())) { +// if (currentFontSize == -1) { +// currentFontSize = f.getSize(); +// } - rescaled = false; - - float scale = (float) (f.getSize() * tdp.getZoom()); - scale = Math.min(maxFontSize, scale); - currentFontSize = (int) scale; - displayText = !(scale < minFontSize); - } +// if ((rescaled) && (!tdp.isScaled())) { +// +// rescaled = false; +// +// float scale = (float) (f.getSize() * tdp.getZoom()); +// scale = Math.min(maxFontSize, scale); +// currentFontSize = (int) scale; +// displayText = !(scale < minFontSize); +// } Color c = g.getColor(); //g.draw3DRect(x, y, width, height, true); @@ -153,9 +156,9 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S //g.fill3DRect(x+1, y+1, width-1, height-1, true); g.setColor(c); - - if (height > (IconManager.iconSize * 2 + 10)) { - g.drawImage(ICONS[index], this.x + this.width - IconManager.iconSize * 2 - 6, this.y + 10, null); + int border_space_icon = scale(5); + if (height >= (scale(IconManager.iconSize * 2 + border_space_icon))) { + g.drawImage(scale(ICONS[index]), this.x + this.width - scale(IconManager.iconSize *2 + border_space_icon ), this.y + border_space_icon, null); } Font f0 = g.getFont(); @@ -163,16 +166,16 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S f = f.deriveFont(currentFontSize); g.setFont(f.deriveFont(Font.BOLD)); int w = g.getFontMetrics().stringWidth(value); - g.drawString(value, x + (width - w) / 2, y + currentFontSize + (int) (textY1 * tdp.getZoom())); + drawSingleString(g,value, x + (width - w) / 2, y + currentFontSize + textY); g.setFont(f0.deriveFont(f0.getSize() - 2).deriveFont(Font.ITALIC)); w = g.getFontMetrics().stringWidth(equation); if (w >= width) { w = g.getFontMetrics().stringWidth("..."); - g.drawString("...", x + (width - w) / 2, y + (2 * currentFontSize) + (int) (textY1 * tdp.getZoom())); + drawSingleString(g,"...", x + (width - w) / 2, y + (2 * currentFontSize) + textY); } else { - g.drawString(equation, x + (width - w) / 2, y + (2 * currentFontSize) + (int) (textY1 * tdp.getZoom())); + drawSingleString(g,equation, x + (width - w) / 2, y + (2 * currentFontSize) + textY); } g.setFont(f0); } @@ -195,6 +198,7 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S }*/ + @Override public boolean editOndoubleClick(JFrame frame) { // String tmp; // boolean error = false; @@ -224,6 +228,7 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S return true; } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -232,14 +237,17 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S return null; } + @Override public int getType() { return TGComponentManager.FTD_CONSTRAINT; } + @Override public String[] getConstraintList() { return STEREOTYPES; } + @Override public String getCurrentConstraint() { return value; } @@ -280,6 +288,7 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S return (value.compareTo(STEREOTYPES[7]) == 0); } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info equation=\"" + GTURTLEModeling.transformString(getEquation())); @@ -334,6 +343,7 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements S } } + @Override public void resizeWithFather() { if ((father != null) && (father instanceof FTDBlock)) { // diff --git a/src/main/java/ui/ftd/FTDCountermeasure.java b/src/main/java/ui/ftd/FTDCountermeasure.java index 8bee69defccfb34611b5f42f2e8516a38e6990fe..f994f1333a747707521bff6e72f7cbf96cdd29a9 100644 --- a/src/main/java/ui/ftd/FTDCountermeasure.java +++ b/src/main/java/ui/ftd/FTDCountermeasure.java @@ -60,7 +60,7 @@ import java.awt.*; * @version 1.0 14/12/2017 */ public class FTDCountermeasure extends TGCScalableWithInternalComponent implements SwallowedTGComponent, WithAttributes { - private int textY1 = 3; +// private int textY1 = 3; // private int textY2 = 3; // private static int arc = 7; @@ -77,7 +77,7 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen private static int minFontSize = 4; private int currentFontSize = -1; private boolean displayText = true; - private int textX = 10; +// private int textX = 10; public FTDCountermeasure(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); @@ -85,6 +85,9 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen width = 125; height = (int) (40 * tdp.getZoom()); minWidth = 100; + textY = 3; + textX = 10; + initScaling(125,40); nbConnectingPoint = 12; connectingPoint = new TGConnectingPoint[12]; @@ -116,6 +119,7 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen myImageIcon = IconManager.imgic702; } + @Override public void internalDrawing(Graphics g) { String ster = "<<" + stereotype + ">>"; Font f = g.getFont(); @@ -126,9 +130,9 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen } - if (currentFontSize == -1) { - currentFontSize = f.getSize(); - } +// if (currentFontSize == -1) { +// currentFontSize = f.getSize(); +// } if ((rescaled) && (!tdp.isScaled())) { rescaled = false; @@ -162,22 +166,22 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen g.setFont(f); //Font f0 = g.getFont(); - boolean cannotWriteAttack = (height < (2 * currentFontSize + (int) (textY1 * tdp.getZoom()))); + boolean cannotWriteAttack = (height < (2 * currentFontSize + (int) (textY * tdp.getZoom()))); //TraceManager.addDev("Zoom=" + tdp.getZoom() + " Cannot write attack=" + cannotWriteAttack + "Font=" + f0); if (cannotWriteAttack) { w = g.getFontMetrics().stringWidth(value); - int h = currentFontSize + (int) (textY1 * tdp.getZoom()); + int h = currentFontSize + (int) (textY * tdp.getZoom()); if ((w < (2 * textX + width)) && (h < height)) { - g.drawString(value, x + (width - w) / 2, y + h); + drawSingleString(g, value, x + (width - w) / 2, y + h); } else { w = g.getFontMetrics().stringWidth(ster); if ((w < (2 * textX + width)) && (h < height)) { - g.drawString(ster, x + (width - w) / 2, y + h); + drawSingleString( g, ster, x + (width - w) / 2, y + h); } } } else { g.setFont(f.deriveFont(Font.BOLD)); - int h = currentFontSize + (int) (textY1 * tdp.getZoom()); + int h = currentFontSize + (int) (textY * tdp.getZoom()); int cumulated = 0; w = g.getFontMetrics().stringWidth(ster); if ((w < (2 * textX + width)) && (h < height)) { @@ -186,12 +190,12 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen } g.setFont(f); w = g.getFontMetrics().stringWidth(value); - h = cumulated + currentFontSize + (int) (textY1 * tdp.getZoom()); + h = cumulated + currentFontSize + (int) (textY * tdp.getZoom()); if ((w < (2 * textX + width)) && (h < height)) { //TraceManager.addDev("Drawing value=" + value); - g.drawString(value, x + (width - w) / 2, y + h); + drawSingleString(g, value, x + (width - w) / 2, y + h); } else { - g.drawString(value, x + (width - w) / 2, y + h); + drawSingleString(g, value, x + (width - w) / 2, y + h); //TraceManager.addDev("--------------------------------------------------- Cannot draw value=" + value); //TraceManager.addDev("w=" + w + " val=" + (2*textX + width) + "h=" + h + " height=" + height + " zoom=" + tdp.getZoom() + " Font=" + f0); } @@ -248,6 +252,7 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen // } + @Override public void resizeWithFather() { if ((father != null) && (father instanceof FTDBlock)) { // @@ -258,6 +263,7 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen } + @Override public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; @@ -300,6 +306,7 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen return !error; } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { Polygon p = getMyPolygon(); if (p.contains(x1, y1)) { @@ -308,6 +315,7 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen return null; } + @Override public int getType() { return TGComponentManager.FTD_COUNTERMEASURE; } @@ -324,6 +332,7 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen return value; } + @Override public String getAttributes() { String s = "Description = " + description + "\n"; s += "Id=" + getId(); @@ -375,12 +384,14 @@ public class FTDCountermeasure extends TGCScalableWithInternalComponent implemen makeValue(); } + @Override public void wasUnswallowed() { setFather(null); TDiagramPanel tdp = getTDiagramPanel(); setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); diff --git a/src/main/java/ui/ftd/FTDCountermeasureConnectingPoint.java b/src/main/java/ui/ftd/FTDCountermeasureConnectingPoint.java index 6e12228299fdf6ec0344592ae1dceb768bab0b28..bbcdf70b196f8a2f514dd7f82cb67461ffd27ba2 100644 --- a/src/main/java/ui/ftd/FTDCountermeasureConnectingPoint.java +++ b/src/main/java/ui/ftd/FTDCountermeasureConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ftd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class FTDCountermeasureConnectingPoint extends TGConnectingPointWidthHei super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.FTD_COUNTERMEASURE_CONNECTOR; } - } diff --git a/src/main/java/ui/ftd/FTDCountermeasureConnector.java b/src/main/java/ui/ftd/FTDCountermeasureConnector.java index cfadc573a68a9270d55440b4565e8d79981e1e7a..e2dc28e658b10920466ce9523ce715f24892e013 100644 --- a/src/main/java/ui/ftd/FTDCountermeasureConnector.java +++ b/src/main/java/ui/ftd/FTDCountermeasureConnector.java @@ -36,22 +36,20 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ftd; +import java.awt.Graphics; +import java.awt.Point; +import java.util.Vector; -import myutil.Conversion; import myutil.GraphicLib; -import ui.*; +import ui.TDiagramPanel; +import ui.TGComponent; +import ui.TGComponentManager; +import ui.TGConnectingPoint; +import ui.TGConnectorWithCommentConnectionPoints; import ui.util.IconManager; -import javax.swing.*; -import java.awt.*; -import java.awt.geom.Point2D; -import java.util.Vector; - /** * Class FTDCountermeasureConnector * Connector used in Fault Tree Diagrams @@ -59,11 +57,11 @@ import java.util.Vector; * @version 1.0 14/12/2017 * @author Ludovic APVRILLE */ -public class FTDCountermeasureConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class FTDCountermeasureConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 5; //square length - protected double oldScaleFactor; + //protected double oldScaleFactor; protected int fontSize = 12; @@ -72,48 +70,44 @@ public class FTDCountermeasureConnector extends TGConnectorWithCommentConnectio myImageIcon = IconManager.imgic202; value = ""; editable = true; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ GraphicLib.dashedLine(g, x1, y1, x2, y2); - } + @Override protected void drawMiddleSegment(Graphics g, int x1, int y1, int x2, int y2) { GraphicLib.dashedLine(g, x1, y1, x2, y2); } + @Override public int getType() { return TGComponentManager.FTD_COUNTERMEASURE_CONNECTOR; } - - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } - - - - - +// Issue #31: Moved to upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } } diff --git a/src/main/java/ui/ftd/FTDFault.java b/src/main/java/ui/ftd/FTDFault.java index a69774d8e24ddd56dc68a9fcc80fa75b13a463b2..f64972c7d1fd05ac9e919857f576769848c84486 100644 --- a/src/main/java/ui/ftd/FTDFault.java +++ b/src/main/java/ui/ftd/FTDFault.java @@ -61,7 +61,7 @@ import java.awt.*; public class FTDFault extends TGCScalableWithInternalComponent implements SwallowedTGComponent, WithAttributes, CheckableAccessibility/*, Issue #69 CanBeDisabled*/ { public static double DEFAULT_PROBABILITY = 0.5; - private int textY1 = 3; +// private int textY1 = 3; // private int textY2 = 3; // private static int arc = 7; @@ -84,9 +84,11 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); width = 125; - height = (int)(40 * tdp.getZoom()); + height = 40; //(int)(40 * tdp.getZoom()); minWidth = 100; - + textY = 3; //issue 31 + initScaling(125, 40); + nbConnectingPoint = 24; connectingPoint = new TGConnectingPoint[24]; @@ -146,9 +148,9 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo } - if (currentFontSize == -1) { - currentFontSize = f.getSize(); - } +// if (currentFontSize == -1) { +// currentFontSize = f.getSize(); +// } if ((rescaled) && (!tdp.isScaled())) { rescaled = false; @@ -195,11 +197,11 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo g.setFont(f); //Font f0 = g.getFont(); - boolean cannotWriteFault = (height < (2 * currentFontSize + (int)(textY1 * tdp.getZoom()))); + boolean cannotWriteFault = (height < (2 * currentFontSize + (int)(textY * tdp.getZoom()))); //TraceManager.addDev("Zoom=" + tdp.getZoom() + " Cannot write attack=" + cannotWriteAttack + "Font=" + f0); if (cannotWriteFault) { w = g.getFontMetrics().stringWidth(value); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); + int h = currentFontSize + (int)(textY * tdp.getZoom()); if ((w < (2*textX + width)) && (h < height)) { g.drawString(value, x + (width - w)/2, y + h); } else { @@ -210,7 +212,7 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo } } else { g.setFont(f.deriveFont(Font.BOLD)); - int h = currentFontSize + (int)(textY1 * tdp.getZoom()); + int h = currentFontSize + (int)(textY * tdp.getZoom()); int cumulated = 0; w = g.getFontMetrics().stringWidth(ster); if ((w < (2*textX + width)) && (h < height)) { @@ -219,7 +221,7 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo } g.setFont(f); w = g.getFontMetrics().stringWidth(value); - h = cumulated + currentFontSize + (int)(textY1 * tdp.getZoom()); + h = cumulated + currentFontSize + (int)(textY * tdp.getZoom()); if ((w < (2*textX + width)) && (h < height)) { //TraceManager.addDev("Drawing value=" + value); g.drawString(value, x + (width - w)/2, y + h); diff --git a/src/main/java/ui/ftd/FTDFaultConnectingPoint.java b/src/main/java/ui/ftd/FTDFaultConnectingPoint.java index c1c26d9f8c7f3e0464c1ef18f4f70280af050978..9d2aa792573f8f08eccd18d2524e55fb50d9955d 100644 --- a/src/main/java/ui/ftd/FTDFaultConnectingPoint.java +++ b/src/main/java/ui/ftd/FTDFaultConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ftd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -59,8 +55,8 @@ public class FTDFaultConnectingPoint extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.FTD_FAULT_CONNECTOR; } - } diff --git a/src/main/java/ui/ftd/FTDFaultConnector.java b/src/main/java/ui/ftd/FTDFaultConnector.java index cc24f0a3a2f4ed54ed818e0e860fc9f6f0606f1b..99b9731ff830193c6f630e18944b08a4e6d36f3b 100644 --- a/src/main/java/ui/ftd/FTDFaultConnector.java +++ b/src/main/java/ui/ftd/FTDFaultConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ftd; - import myutil.Conversion; import myutil.GraphicLib; import ui.*; @@ -59,11 +55,11 @@ import java.util.Vector; * @version 1.0 14/12/2017 * @author Ludovic APVRILLE */ -public class FTDFaultConnector extends TGConnectorWithCommentConnectionPoints implements ScalableTGComponent { +public class FTDFaultConnector extends TGConnectorWithCommentConnectionPoints /* Issue #31 implements ScalableTGComponent*/ { //protected int arrowLength = 10; //protected int widthValue, heightValue, maxWidthValue, h; protected int c = 5; //square length - protected double oldScaleFactor; + //protected double oldScaleFactor; protected int fontSize = 12; @@ -72,9 +68,10 @@ public class FTDFaultConnector extends TGConnectorWithCommentConnectionPoints i myImageIcon = IconManager.imgic202; value = ""; editable = true; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); } + @Override 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); @@ -137,9 +134,9 @@ public class FTDFaultConnector extends TGConnectorWithCommentConnectionPoints i g.fillRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz);*/ Point p = new Point(x2, y2); - if (p == null) { - // - } else { +// if (p == null) { +// // +// } else { if (Point2D.distance(x1, y1, p.x, p.y) < GraphicLib.longueur * 1.5) { // if ((p.x != x1) || (p.y != y1)) { @@ -149,7 +146,7 @@ public class FTDFaultConnector extends TGConnectorWithCommentConnectionPoints i } else { GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, p.x, p.y, true); } - } + // } if (value.length() > 0) { Font f = g.getFont(); @@ -163,6 +160,7 @@ public class FTDFaultConnector extends TGConnectorWithCommentConnectionPoints i } + @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = value; String text = getName() + "Connector"; @@ -185,36 +183,31 @@ public class FTDFaultConnector extends TGConnectorWithCommentConnectionPoints i return false; } - + @Override public int getType() { return TGComponentManager.FTD_FAULT_CONNECTOR; } - - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } - - - - - +// Issue #31: Moved to upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } } diff --git a/src/main/java/ui/ftd/FaultTreeDiagramPanel.java b/src/main/java/ui/ftd/FaultTreeDiagramPanel.java index c9e1393320ee028e6fa8c8c1436e76b467932578..76add2313cc41257b9efb0721f3ec8fe445e20a3 100644 --- a/src/main/java/ui/ftd/FaultTreeDiagramPanel.java +++ b/src/main/java/ui/ftd/FaultTreeDiagramPanel.java @@ -66,42 +66,53 @@ public class FaultTreeDiagramPanel extends TDiagramPanel implements TDPWithAttri public FaultTreeDiagramPanel(MainGUI mgui, TToolBar _ttb) { super(mgui, _ttb); } - + + @Override public boolean actionOnDoubleClick(TGComponent tgc) { return true; } + @Override public boolean actionOnAdd(TGComponent tgc) { return false; } + + @Override public boolean actionOnValueChanged(TGComponent tgc) { return false; } - + + @Override public boolean actionOnRemove(TGComponent tgc) { return false; } - + + @Override public String getXMLHead() { return "<FaultTreeDiagramPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } - + + @Override public String getXMLTail() { return "</FaultTreeDiagramPanel>"; } - + + @Override public String getXMLSelectedHead() { return "<FaultTreeDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - + + @Override public String getXMLSelectedTail() { return "</FaultTreeDiagramPanelCopy>"; } - + + @Override public String getXMLCloneHead() { return "<FaultTreeDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - + + @Override public String getXMLCloneTail() { return "</FaultTreeDiagramPanelCopy>"; } @@ -130,7 +141,8 @@ public class FaultTreeDiagramPanel extends TDiagramPanel implements TDPWithAttri return list; } - + + @Override public boolean hasAutoConnect() { return false; } diff --git a/src/main/java/ui/ftd/FaultTreeDiagramToolbar.java b/src/main/java/ui/ftd/FaultTreeDiagramToolbar.java index 40eaa5118a5b7923ea411676fc802166c20d2d55..ab71a6f9c241dab3e9146bf2347cf51d29d8e054 100644 --- a/src/main/java/ui/ftd/FaultTreeDiagramToolbar.java +++ b/src/main/java/ui/ftd/FaultTreeDiagramToolbar.java @@ -63,7 +63,8 @@ public class FaultTreeDiagramToolbar extends TToolBar { super(_mgui); } - + + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -91,7 +92,8 @@ public class FaultTreeDiagramToolbar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); } - + + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/iod/InteractionOverviewDiagramToolBar.java b/src/main/java/ui/iod/InteractionOverviewDiagramToolBar.java index 5ab07f2d5ebf7085e628bbee67f8dcac2420cf37..3d6ea50d57c6ce28cecf57b57b37cf86184947fe 100755 --- a/src/main/java/ui/iod/InteractionOverviewDiagramToolBar.java +++ b/src/main/java/ui/iod/InteractionOverviewDiagramToolBar.java @@ -81,9 +81,13 @@ public class InteractionOverviewDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.IOD_JUNCTION].setEnabled(b); mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/ncdd/NCDiagramToolBar.java b/src/main/java/ui/ncdd/NCDiagramToolBar.java index e863eeecb0cf79485ad4d7adf7059f8e7715526b..fd3dc8c3c89ba4b9f33b60957a105a5ea0164c9a 100755 --- a/src/main/java/ui/ncdd/NCDiagramToolBar.java +++ b/src/main/java/ui/ncdd/NCDiagramToolBar.java @@ -76,9 +76,13 @@ public class NCDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.NCDD_ROUTE_ARTIFACT].setEnabled(b); mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); diff --git a/src/main/java/ui/ncdd/NCNodeConnectingPoint.java b/src/main/java/ui/ncdd/NCNodeConnectingPoint.java index 6e5d67f9d764c038e07aab78ae18df3144c9ccdf..47f04a3842d6ff93bd189d9580a7ce2a8e228b66 100755 --- a/src/main/java/ui/ncdd/NCNodeConnectingPoint.java +++ b/src/main/java/ui/ncdd/NCNodeConnectingPoint.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ncdd; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -53,14 +49,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 18/11/2008 * @author Ludovic APVRILLE */ -public class NCNodeConnectingPoint extends TGConnectingPointWidthHeight{ +public class NCNodeConnectingPoint extends TGConnectingPointWidthHeight{ public NCNodeConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_NODE_NC; } - } diff --git a/src/main/java/ui/osad/TURTLEOSActivityDiagramToolBar.java b/src/main/java/ui/osad/TURTLEOSActivityDiagramToolBar.java index 804c23d385695310de6bad487035278e987fb28c..ca33b3a22c35045949a4b538bd2a2d65a5ec4cfe 100755 --- a/src/main/java/ui/osad/TURTLEOSActivityDiagramToolBar.java +++ b/src/main/java/ui/osad/TURTLEOSActivityDiagramToolBar.java @@ -73,9 +73,13 @@ public class TURTLEOSActivityDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.TOSAD_TIME_INTERVAL].setEnabled(b); mgui.actions[TGUIAction.TOSAD_INT_TIME_INTERVAL].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/oscd/TGConnectingPointTOSClasses.java b/src/main/java/ui/oscd/TGConnectingPointTOSClasses.java index d38373170794577000d757e9864976ceff7c2809..3859987465437492758de603e8ff2743ce794710 100755 --- a/src/main/java/ui/oscd/TGConnectingPointTOSClasses.java +++ b/src/main/java/ui/oscd/TGConnectingPointTOSClasses.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.oscd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; diff --git a/src/main/java/ui/oscd/TGConnectingPointTOSCompositionOperator.java b/src/main/java/ui/oscd/TGConnectingPointTOSCompositionOperator.java index 1f33cc7476a4ca9753a864c8c832129a8f161ba5..89c75834c0c8768f587edafd3cf739036b1150ef 100755 --- a/src/main/java/ui/oscd/TGConnectingPointTOSCompositionOperator.java +++ b/src/main/java/ui/oscd/TGConnectingPointTOSCompositionOperator.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.oscd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPoint; @@ -54,14 +49,14 @@ import ui.TGConnectingPoint; * @version 1.0 06/10/2006 * @author Ludovic APVRILLE */ -public class TGConnectingPointTOSCompositionOperator extends TGConnectingPoint{ +public class TGConnectingPointTOSCompositionOperator extends TGConnectingPoint { public TGConnectingPointTOSCompositionOperator(CDElement _container1, int _x, int _y, boolean _in, boolean _out) { super(_container1, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.TOS_CONNECTOR_ATTRIBUTE; } - -} \ No newline at end of file +} diff --git a/src/main/java/ui/oscd/TURTLEOSClassDiagramToolBar.java b/src/main/java/ui/oscd/TURTLEOSClassDiagramToolBar.java index 3debac93456e3123a04d5a6029f7cd95563f7656..86e3cd0649051f892999f33649322cfb5b30a107 100755 --- a/src/main/java/ui/oscd/TURTLEOSClassDiagramToolBar.java +++ b/src/main/java/ui/oscd/TURTLEOSClassDiagramToolBar.java @@ -85,9 +85,13 @@ public class TURTLEOSClassDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_TOGGLE_GATES].setEnabled(b); mgui.actions[TGUIAction.ACT_TOGGLE_SYNCHRO].setEnabled(b);*/ - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/procsd/ProactiveCSDToolBar.java b/src/main/java/ui/procsd/ProactiveCSDToolBar.java index 51835c20e640662e0275850a9a4fbeaed098d4b6..ed07b3a32cb1b56e00c03fd95d46ddf56c062e9d 100755 --- a/src/main/java/ui/procsd/ProactiveCSDToolBar.java +++ b/src/main/java/ui/procsd/ProactiveCSDToolBar.java @@ -85,9 +85,13 @@ public class ProactiveCSDToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/procsd/TGConnectingPointAssociationProCSD.java b/src/main/java/ui/procsd/TGConnectingPointAssociationProCSD.java index aeded1950296d3529279596e993a98054813132a..aec7d931a72b12016715d50f11628c4ef356a5a5 100755 --- a/src/main/java/ui/procsd/TGConnectingPointAssociationProCSD.java +++ b/src/main/java/ui/procsd/TGConnectingPointAssociationProCSD.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.procsd; -//import java.awt.*; - import ui.CDElement; import ui.TGConnectingPointTwoFathers; @@ -59,6 +54,7 @@ public class TGConnectingPointAssociationProCSD extends TGConnectingPointTwoFat super(_container1, _container2, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { //A link is not compatible with an interface. By Solange //if (type == TGComponentManager.CONNECTOR_ATTRIBUTE) { @@ -66,5 +62,4 @@ public class TGConnectingPointAssociationProCSD extends TGConnectingPointTwoFat //} return false; } - } diff --git a/src/main/java/ui/procsd/TGConnectingPointPROCSDInterface.java b/src/main/java/ui/procsd/TGConnectingPointPROCSDInterface.java index ce7d93fc1bf049e4be02b87aad425ba3da93db72..3ccf7f416958b8d31daf5c3d2a6d06b3d499b470 100644 --- a/src/main/java/ui/procsd/TGConnectingPointPROCSDInterface.java +++ b/src/main/java/ui/procsd/TGConnectingPointPROCSDInterface.java @@ -36,8 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - package ui.procsd; import ui.CDElement; @@ -46,20 +44,16 @@ import ui.cd.TGConnectingPointCompositionOperator; public class TGConnectingPointPROCSDInterface extends TGConnectingPointCompositionOperator { - public TGConnectingPointPROCSDInterface(CDElement _container1, int _x, int _y, boolean _in, boolean _out) { super(_container1, _x, _y, _in, _out); } - + @Override public boolean isCompatibleWith(int type) { if (type == TGComponentManager.CONNECTOR_ATTRIBUTE) { return true; } return type == TGComponentManager.CONNECTOR_PROCSD_PORT_INTERFACE; - - } - } diff --git a/src/main/java/ui/prosmd/ProactiveSMDToolBar.java b/src/main/java/ui/prosmd/ProactiveSMDToolBar.java index 6d64e073b9a529500aebc9cc418402c5ba8ec5b2..e892a566716db47942a5ac45bf23ef6966b2e709 100755 --- a/src/main/java/ui/prosmd/ProactiveSMDToolBar.java +++ b/src/main/java/ui/prosmd/ProactiveSMDToolBar.java @@ -91,9 +91,13 @@ public class ProactiveSMDToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/prosmd/TGConnectingPointProSMD.java b/src/main/java/ui/prosmd/TGConnectingPointProSMD.java index b99bcff4f3392c58bd86924e463dc35b8bef1b36..395c4eafd247cc0b74374060331f023b1bcf2f43 100755 --- a/src/main/java/ui/prosmd/TGConnectingPointProSMD.java +++ b/src/main/java/ui/prosmd/TGConnectingPointProSMD.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.prosmd; import ui.CDElement; @@ -58,15 +55,8 @@ public class TGConnectingPointProSMD extends TGConnectingPointWidthHeight{ super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_PROSMD; } - } - - - - - - - diff --git a/src/main/java/ui/req/TGConnectingPointDerive.java b/src/main/java/ui/req/TGConnectingPointDerive.java index bc999c2d184cd650b32c5d44a9f58f625aa66fa7..c4dba0fb9c29d69b3e380f8de1b4dd8cea59c936 100755 --- a/src/main/java/ui/req/TGConnectingPointDerive.java +++ b/src/main/java/ui/req/TGConnectingPointDerive.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.req; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -61,6 +56,7 @@ public class TGConnectingPointDerive extends TGConnectingPointWidthHeight { orientation = _orientation; } + @Override public boolean isCompatibleWith(int type) { // if (type == TGComponentManager.CONNECTOR_DERIVE_REQ) { @@ -80,4 +76,4 @@ public class TGConnectingPointDerive extends TGConnectingPointWidthHeight { // return false; } -} \ No newline at end of file +} diff --git a/src/main/java/ui/req/TGConnectingPointVerify.java b/src/main/java/ui/req/TGConnectingPointVerify.java index 3525000a63c9e8c1904ff4268009ac6705464c27..838cb97601f2205d084f997a21df209ce1e21682 100755 --- a/src/main/java/ui/req/TGConnectingPointVerify.java +++ b/src/main/java/ui/req/TGConnectingPointVerify.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.req; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -54,7 +49,7 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 30/05/2006 * @author Ludovic APVRILLE */ -public class TGConnectingPointVerify extends TGConnectingPointWidthHeight { +public class TGConnectingPointVerify extends TGConnectingPointWidthHeight { public TGConnectingPointVerify(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h, int _orientation) { super(_container, _x, _y, _in, _out, _w, _h); @@ -65,6 +60,7 @@ public class TGConnectingPointVerify extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { // if (type == TGComponentManager.CONNECTOR_VERIFY_REQ) { diff --git a/src/main/java/ui/sd/SDAbsoluteTimeConstraint.java b/src/main/java/ui/sd/SDAbsoluteTimeConstraint.java index de95114a9f8dc54418de87dc15dae84827ee15ed..dd7a9922651f7e8778ac8cb4bac2c6a12691979b 100755 --- a/src/main/java/ui/sd/SDAbsoluteTimeConstraint.java +++ b/src/main/java/ui/sd/SDAbsoluteTimeConstraint.java @@ -90,7 +90,7 @@ public class SDAbsoluteTimeConstraint extends TGCWithoutInternalComponent implem widthValue = g.getFontMetrics().stringWidth(value); heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, x-widthValue-2, y); + drawSingleString(g, value, x-widthValue-2, y); g.drawLine(x, y, x+width, y); } diff --git a/src/main/java/ui/sd/SDActionState.java b/src/main/java/ui/sd/SDActionState.java index aadb5786023bfa69d45761fc199d9047df432fdb..8e43332d97f1431ba98f673e3f2891d4e4b433d7 100755 --- a/src/main/java/ui/sd/SDActionState.java +++ b/src/main/java/ui/sd/SDActionState.java @@ -56,8 +56,8 @@ import java.awt.*; */ public class SDActionState extends TGCOneLineText implements SwallowedTGComponent { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int w; //w1; @@ -67,6 +67,9 @@ public class SDActionState extends TGCOneLineText implements SwallowedTGComponen width = 30; height = 20; minWidth = 30; + textX = 5; + textY = 15; + initScaling(30,20); nbConnectingPoint = 0; addTGConnectingPointsCommentMiddle(); @@ -89,7 +92,7 @@ public class SDActionState extends TGCOneLineText implements SwallowedTGComponen } g.drawRoundRect(x - width/2, y, width, height, arc, arc); - g.drawString(value, x - w / 2 , y + textY); + drawSingleString(g, value, x - width/2 + textX , y + textY); } public TGComponent isOnMe(int _x, int _y) { diff --git a/src/main/java/ui/sd/SDGuard.java b/src/main/java/ui/sd/SDGuard.java index 41400ba50782c56da4d80557f12676dc6beb59c7..6e147805b2c03fc806f458a4d79c6fc716c3891b 100755 --- a/src/main/java/ui/sd/SDGuard.java +++ b/src/main/java/ui/sd/SDGuard.java @@ -96,7 +96,7 @@ public class SDGuard extends TGCOneLineText implements SwallowedTGComponent { g.drawLine(x+width/2, y, x+width/2-lineLength, y); g.drawLine(x+width/2, y+height, x+width/2-lineLength, y+height); - g.drawString(value, x - w / 2 , y + textY); + drawSingleString(g, value, x - w / 2 , y + textY); } public TGComponent isOnMe(int _x, int _y) { diff --git a/src/main/java/ui/sd/SDInstance.java b/src/main/java/ui/sd/SDInstance.java index fa43367c142fdc33fce07ff67b263b91c9f2aeb4..acd5c38de3f5ee1eff0168cddd048b846fbef2b0 100755 --- a/src/main/java/ui/sd/SDInstance.java +++ b/src/main/java/ui/sd/SDInstance.java @@ -110,7 +110,7 @@ public class SDInstance extends TGCWithInternalComponent implements SwallowTGCom wText = g.getFontMetrics().stringWidth(name); hText = g.getFontMetrics().getHeight(); } - g.drawString( name, x - (wText / 2) + width/2, y - 3 ); + drawSingleString(g, name, x - (wText / 2) + width/2, y - 3 ); g.drawLine(x - (wText / 2) + width/2, y-2, x + (wText / 2) + width/2, y-2); g.drawLine(x+(width/2), y, x+(width/2), y +height); diff --git a/src/main/java/ui/sd/SDTimeInterval.java b/src/main/java/ui/sd/SDTimeInterval.java index 38d38a13ad773b2e2de5ced2bb7914ef863bd3ec..5339d6ae6088ecd85534f7c75b87ebb74874e4dd 100755 --- a/src/main/java/ui/sd/SDTimeInterval.java +++ b/src/main/java/ui/sd/SDTimeInterval.java @@ -92,7 +92,7 @@ public class SDTimeInterval extends TGCTimeInterval implements SwallowedTGCompon //g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); //w = g.getFontMetrics().stringWidth(value); - g.drawString(value, x + textX, y + textY); + drawSingleString(g, value, x + textX, y + textY); if (!tdp.isScaled()) { wtext = g.getFontMetrics().stringWidth(value); diff --git a/src/main/java/ui/sd/SDTimerCancellation.java b/src/main/java/ui/sd/SDTimerCancellation.java index 4b970811cd3730b23604cf19d8766e22e3196bfc..77d015eaf3db216119435930dd90b3a5be9b70c6 100755 --- a/src/main/java/ui/sd/SDTimerCancellation.java +++ b/src/main/java/ui/sd/SDTimerCancellation.java @@ -92,7 +92,7 @@ public class SDTimerCancellation extends TGCWithoutInternalComponent implements heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, x+width, y+height/2+3); + drawSingleString(g, value, x+width, y+height/2+3); g.drawLine(x, y, x+width, y+height); //g.drawLine(x, y, x+width, y); diff --git a/src/main/java/ui/sd/SDTimerExpiration.java b/src/main/java/ui/sd/SDTimerExpiration.java index 3822577b8800d4272b0c7a49c764536971f0e440..037c69d0b41e06e043b51269edbbd6baa2b3d3ec 100755 --- a/src/main/java/ui/sd/SDTimerExpiration.java +++ b/src/main/java/ui/sd/SDTimerExpiration.java @@ -91,7 +91,7 @@ public class SDTimerExpiration extends TGCWithoutInternalComponent implements Sw heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, x+width, y+height/2+3); + drawSingleString(g, value, x+width, y+height/2+3); g.drawLine(x, y, x+width, y+height); g.drawLine(x, y, x+width, y); diff --git a/src/main/java/ui/sd/SDTimerSetting.java b/src/main/java/ui/sd/SDTimerSetting.java index adae175872d86ae553a745ad031b8f89e242a4b2..a59b805131e6ea6e103fd2859dfc6d399e8539bb 100755 --- a/src/main/java/ui/sd/SDTimerSetting.java +++ b/src/main/java/ui/sd/SDTimerSetting.java @@ -93,7 +93,7 @@ public class SDTimerSetting extends TGCWithoutInternalComponent implements Swall heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, x+width, y+height/2+3); + drawSingleString(g, value, x+width, y+height/2+3); g.drawLine(x, y, x+width, y+height); g.drawLine(x, y, x+width, y); diff --git a/src/main/java/ui/sd/SequenceDiagramToolBar.java b/src/main/java/ui/sd/SequenceDiagramToolBar.java index 8aa4eec3d9d740b638215bd3322650739353d216..a69b7029b9d0f4cf0f5ac4ccc13e0e0b9c28e05c 100755 --- a/src/main/java/ui/sd/SequenceDiagramToolBar.java +++ b/src/main/java/ui/sd/SequenceDiagramToolBar.java @@ -84,9 +84,13 @@ public class SequenceDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.SD_RELATIVE_TIME_CONSTRAINT_CONNECTOR].setEnabled(b); mgui.actions[TGUIAction.SD_ALIGN_INSTANCES].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/sd/TGConnectingPointMessageSD.java b/src/main/java/ui/sd/TGConnectingPointMessageSD.java index 4d970120c07e0af381dc6768581f8b2fb115f01b..ff3a912ba7f0141f79226d0bc5be237150e88b62 100755 --- a/src/main/java/ui/sd/TGConnectingPointMessageSD.java +++ b/src/main/java/ui/sd/TGConnectingPointMessageSD.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.sd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPoint; @@ -54,12 +49,13 @@ import ui.TGConnectingPoint; * @version 1.0 06/10/2004 * @author Ludovic APVRILLE */ -public class TGConnectingPointMessageSD extends TGConnectingPoint{ +public class TGConnectingPointMessageSD extends TGConnectingPoint { public TGConnectingPointMessageSD(CDElement _container, int _x, int _y, boolean _in, boolean _out) { super(_container, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { // if ((type == TGComponentManager.CONNECTOR_MESSAGE_ASYNC_SD) || (type == TGComponentManager.CONNECTOR_MESSAGE_SYNC_SD)) { @@ -69,5 +65,4 @@ public class TGConnectingPointMessageSD extends TGConnectingPoint{ // return false; } - -} \ No newline at end of file +} diff --git a/src/main/java/ui/sd/TGConnectorMessageAsyncOrSyncSD.java b/src/main/java/ui/sd/TGConnectorMessageAsyncOrSyncSD.java index ef84b8fb2542ace4bb41802bdc137fa37c89fa74..157d1a332fbe695fbb285899b64dff36fc7c667c 100755 --- a/src/main/java/ui/sd/TGConnectorMessageAsyncOrSyncSD.java +++ b/src/main/java/ui/sd/TGConnectorMessageAsyncOrSyncSD.java @@ -86,7 +86,7 @@ public class TGConnectorMessageAsyncOrSyncSD extends TGConnectorMessageSD { heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); + drawSingleString(g, value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); } else { if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -99,8 +99,8 @@ public class TGConnectorMessageAsyncOrSyncSD extends TGConnectorMessageSD { heightValue = g.getFontMetrics().getHeight(); } - //g.drawString(value, (p1.getX() + p2.getX()) / 2, ((p1.getY() + p2.getY()) / 2) - 5); - g.drawString(value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); + //drawSingleString(g, value, (p1.getX() + p2.getX()) / 2, ((p1.getY() + p2.getY()) / 2) - 5); + drawSingleString(g, value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); } } diff --git a/src/main/java/ui/sd/TGConnectorMessageAsyncSD.java b/src/main/java/ui/sd/TGConnectorMessageAsyncSD.java index c5281cdd905b735685a2e962e7e581a56edb5e50..0d80bea043eba9dfb88037b137aff441108979cf 100755 --- a/src/main/java/ui/sd/TGConnectorMessageAsyncSD.java +++ b/src/main/java/ui/sd/TGConnectorMessageAsyncSD.java @@ -83,7 +83,7 @@ public class TGConnectorMessageAsyncSD extends TGConnectorMessageSD { heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); + drawSingleString(g, value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); } public int getType() { diff --git a/src/main/java/ui/sd/TGConnectorMessageSyncSD.java b/src/main/java/ui/sd/TGConnectorMessageSyncSD.java index 70d60cc206e65af9139b42cab7cbafb477ca6d3d..d57c4b8d85826a3f4d9dcbc7772ce2aacd9dd12e 100755 --- a/src/main/java/ui/sd/TGConnectorMessageSyncSD.java +++ b/src/main/java/ui/sd/TGConnectorMessageSyncSD.java @@ -79,7 +79,7 @@ public class TGConnectorMessageSyncSD extends TGConnectorMessageSD { } //g.drawString(value, (p1.getX() + p2.getX()) / 2, ((p1.getY() + p2.getY()) / 2) - 5); - g.drawString(value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); + drawSingleString(g, value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); } public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { diff --git a/src/main/java/ui/sd/TGConnectorRelativeTimeSD.java b/src/main/java/ui/sd/TGConnectorRelativeTimeSD.java index 60fe671558c5ae9efbb13e0952ee107540cb7c8f..be369938e36b64ae4b97b9ebe65ad756db305fa4 100755 --- a/src/main/java/ui/sd/TGConnectorRelativeTimeSD.java +++ b/src/main/java/ui/sd/TGConnectorRelativeTimeSD.java @@ -87,7 +87,7 @@ public class TGConnectorRelativeTimeSD extends TGConnector { heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, ((p1.getX() + p2.getX()) / 2) - widthValue - 2, ((p1.getY() + p2.getY()) / 2)); + drawSingleString(g, value, ((p1.getX() + p2.getX()) / 2) - widthValue - 2, ((p1.getY() + p2.getY()) / 2)); } public TGComponent extraIsOnOnlyMe(int x1, int y1) { diff --git a/src/main/java/ui/sd2/SDActionState.java b/src/main/java/ui/sd2/SDActionState.java index b0359d179f31a1face5091c2e91dde3a58c74e73..86f8b378fb712fc0ed34909cf71971df587ce31c 100755 --- a/src/main/java/ui/sd2/SDActionState.java +++ b/src/main/java/ui/sd2/SDActionState.java @@ -56,19 +56,22 @@ import java.awt.*; */ public class SDActionState extends TGCScalableOneLineText implements SwallowedTGComponent { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int w; //w1; public SDActionState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(30 * tdp.getZoom()); - height = (int)(20 * tdp.getZoom()); - minWidth = (int)(30 * tdp.getZoom()); - oldScaleFactor = tdp.getZoom(); - + width = 30; //(int)(30 * tdp.getZoom()); + height = 20; //(int)(20 * tdp.getZoom()); + minWidth = 30; //(int)(30 * tdp.getZoom()); +// oldScaleFactor = tdp.getZoom(); + textX = 5; + textY = 15; + initScaling(30, 20); + nbConnectingPoint = 0; addTGConnectingPointsCommentMiddle(); @@ -91,7 +94,7 @@ public class SDActionState extends TGCScalableOneLineText implements SwallowedTG } g.drawRoundRect(x - width/2, y, width, height, arc, arc); - g.drawString(value, x - w / 2 , y + (int)(textY*tdp.getZoom())); + drawSingleString(g, value, x - width / 2 , y + textY); } public TGComponent isOnMe(int _x, int _y) { diff --git a/src/main/java/ui/sd2/SequenceDiagramPanel.java b/src/main/java/ui/sd2/SequenceDiagramPanel.java index 1c199c31dca1f6c446d7395a6b163193afbcb918..cff705664081bffcc2d3f20a72091d02cfd8efbc 100755 --- a/src/main/java/ui/sd2/SequenceDiagramPanel.java +++ b/src/main/java/ui/sd2/SequenceDiagramPanel.java @@ -65,6 +65,7 @@ public class SequenceDiagramPanel extends TDiagramPanel { addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { // /*if (tgc instanceof TCDTClass) { @@ -85,6 +86,7 @@ public class SequenceDiagramPanel extends TDiagramPanel { return false; } + @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -97,6 +99,7 @@ public class SequenceDiagramPanel extends TDiagramPanel { return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -108,6 +111,7 @@ public class SequenceDiagramPanel extends TDiagramPanel { return false; } + @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); @@ -116,26 +120,32 @@ public class SequenceDiagramPanel extends TDiagramPanel { return false; } + @Override public String getXMLHead() { return "<SequenceDiagramPanelZV name=\"" + name + "\"" + sizeParam() + " >"; } + @Override public String getXMLTail() { return "</SequenceDiagramPanelZV>"; } + @Override public String getXMLSelectedHead() { return "<SequenceDiagramPanelZVCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</SequenceDiagramPanelZVCopy>"; } + @Override public String getXMLCloneHead() { return "<SequenceDiagramPanelZVCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</SequenceDiagramPanelZVCopy>"; } @@ -219,6 +229,7 @@ public class SequenceDiagramPanel extends TDiagramPanel { return null; } + @Override public TGComponent getSecondTGComponent(TGConnector tgco) { TGComponent tmp; TGComponent tmp1; diff --git a/src/main/java/ui/sd2/TGConnectingPointMessageSD.java b/src/main/java/ui/sd2/TGConnectingPointMessageSD.java index c22702e74a9bb43aabad19f88b5079342f117432..f256ac99cb3fb5cfe3443b41c7f178ca95d0d181 100755 --- a/src/main/java/ui/sd2/TGConnectingPointMessageSD.java +++ b/src/main/java/ui/sd2/TGConnectingPointMessageSD.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.sd2; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -60,6 +55,7 @@ public class TGConnectingPointMessageSD extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { //TraceManager.addDev("is compatible with " + type); if ((type == TGComponentManager.CONNECTOR_MESSAGE_ASYNC_SDZV) || (type == TGComponentManager.CONNECTOR_MESSAGE_SYNC_SDZV)) { @@ -70,5 +66,4 @@ public class TGConnectingPointMessageSD extends TGConnectingPointWidthHeight { // return false; } - } diff --git a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java index dbda02b22ea6f4752ef578914dd3e2afb248f155..daae9a0cd48d2880ab7b8199748bfe7919e675d5 100644 --- a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java +++ b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java @@ -59,9 +59,6 @@ public class SysCAMSComponentTaskDiagramToolBar extends TToolBar { } protected void setActive(boolean b) { - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); - mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); mgui.actions[TGUIAction.CAMS_BLOCK_TDF].setEnabled(b); @@ -79,7 +76,10 @@ public class SysCAMSComponentTaskDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); mgui.updateZoomInfo(); } diff --git a/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java b/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java index 9246b51a02718c232eeea18a018452ffa3eb9cf9..55d297917e30ff7bf270b8883b51e03548cf00f6 100644 --- a/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java +++ b/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java @@ -58,7 +58,8 @@ public class SysCAMSPortConnectingPoint extends TGConnectingPointWidthHeight { super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CAMS_CONNECTOR; } -} \ No newline at end of file +} diff --git a/src/main/java/ui/syscams/SysCAMSPortConnector.java b/src/main/java/ui/syscams/SysCAMSPortConnector.java index ca2f7828ccf83bfe9f8c0085989cdda708dc97e2..d05e16def34f164ffdcec84ad743cd676c55853c 100644 --- a/src/main/java/ui/syscams/SysCAMSPortConnector.java +++ b/src/main/java/ui/syscams/SysCAMSPortConnector.java @@ -57,8 +57,8 @@ import myutil.GraphicLib; * @author Irina Kit Yan LEE */ -public class SysCAMSPortConnector extends TGConnector implements ScalableTGComponent, SpecificActionAfterAdd, SpecificActionAfterMove { - protected double oldScaleFactor; +public class SysCAMSPortConnector extends TGConnector implements /* Issue #31 ScalableTGComponent,*/ SpecificActionAfterAdd, SpecificActionAfterMove { + //protected double oldScaleFactor; public SysCAMSPortConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); @@ -66,7 +66,7 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo myImageIcon = IconManager.imgic202; value = ""; editable = true; - oldScaleFactor = tdp.getZoom(); + //oldScaleFactor = tdp.getZoom(); p1 = _p1; p2 = _p2; @@ -80,12 +80,14 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo return p2; } + @Override public boolean editOndoubleClick(JFrame frame) { JDialogSysCAMSConnector jde = new JDialogSysCAMSConnector(this); jde.setVisible(true); return true; } + @Override protected void drawLastSegment(Graphics gr, int x1, int y1, int x2, int y2) { Graphics2D g = (Graphics2D) gr; @@ -153,24 +155,25 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo } catch (Exception e) { } } - - public void rescale(double scaleFactor) { - int xx, yy; - - for (int i = 0; i < nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - 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); - } - oldScaleFactor = scaleFactor; - } - +// Issue #31: Moved to upper class +// public void rescale(double scaleFactor) { +// int xx, yy; +// +// for (int i = 0; i < nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// 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); +// } +// oldScaleFactor = scaleFactor; +// } + + @Override public int getType() { return TGComponentManager.CAMS_CONNECTOR; } diff --git a/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyConnectingPoint.java b/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyConnectingPoint.java index ca97414e14e2484c43b1c5a24bab7c69abe4d7cb..2a83bd3c3ea814f7451964b620fc0d7baac29484 100755 --- a/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyConnectingPoint.java +++ b/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyConnectingPoint.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.sysmlsecmethodology; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -54,19 +49,15 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 26/01/2016 * @author Ludovic APVRILLE */ -public class SysmlsecMethodologyConnectingPoint extends TGConnectingPointWidthHeight { +public class SysmlsecMethodologyConnectingPoint extends TGConnectingPointWidthHeight { public SysmlsecMethodologyConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h, int _orientation) { super(_container, _x, _y, _in, _out, _w, _h); orientation = _orientation; } + @Override public boolean isCompatibleWith(int type) { - return type == TGComponentManager.SYSMLSEC_METHODOLOGY_CONNECTOR; - - } - - } diff --git a/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramName.java b/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramName.java index e91b4539c6d542272cc109840c9b1dc88a56a806..8eec092876fa88fe0fca974ecd541209bbc0fe1e 100755 --- a/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramName.java +++ b/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramName.java @@ -175,7 +175,7 @@ public class SysmlsecMethodologyDiagramName extends TGCScalableWithoutInternalCo } widthAppli = g.getFontMetrics().stringWidth(val); curWidth = Math.max(widthAppli, curWidth); - g.drawString(val, x, y); + drawSingleString(g, val, x, y); g.setFont(f); if (validations == null) { @@ -223,7 +223,7 @@ public class SysmlsecMethodologyDiagramName extends TGCScalableWithoutInternalCo if ((onMe && indexOnMe == i)) { g.setFont(f.deriveFont(Font.BOLD)); } - g.drawString(SHORT_ACTION_NAMES[validations[i]], currentMaxX - w1, y); + drawSingleString(g, SHORT_ACTION_NAMES[validations[i]], currentMaxX - w1, y); g.setFont(f.deriveFont(Font.ITALIC)); valMinX[i] = currentMaxX-w1; valMaxX[i] = currentMaxX; diff --git a/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramReference.java b/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramReference.java index f600a62538369f6fedcbae06795720ebeff0dd96..912071c94ebb132647c8903dbe6263442d82c60f 100755 --- a/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramReference.java +++ b/src/main/java/ui/sysmlsecmethodology/SysmlsecMethodologyDiagramReference.java @@ -221,7 +221,7 @@ public abstract class SysmlsecMethodologyDiagramReference extends TGCScalableWit g.setColor(tmp); GraphicLib.setNormalStroke(g); } else { - //g.drawString("acc", x + width - 10, y+height-10); + //drawSingleString(g, "acc", x + width - 10, y+height-10); Color tmp = g.getColor(); GraphicLib.setMediumStroke(g); g.setColor(Color.red); diff --git a/src/main/java/ui/tmlad/TGConnectorTMLAD.java b/src/main/java/ui/tmlad/TGConnectorTMLAD.java index 35955d3d254f9431278c572aff4451a787b45746..1b3fef016a2f5b8e532cc132e961cc3dab939fbf 100755 --- a/src/main/java/ui/tmlad/TGConnectorTMLAD.java +++ b/src/main/java/ui/tmlad/TGConnectorTMLAD.java @@ -56,7 +56,7 @@ import java.util.Vector; */ public class TGConnectorTMLAD extends TADConnector /* Issue #69 TGConnector*/ { - protected int arrowLength = 10; + //protected int arrowLength = 10; public TGConnectorTMLAD(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); @@ -69,7 +69,7 @@ public class TGConnectorTMLAD extends TADConnector /* Issue #69 TGConnector*/ { 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); + GraphicLib.arrowWithLine(g, 1, 0, scale( 10 ), x1, y1, x2, y2, true); } } diff --git a/src/main/java/ui/tmlad/TMLADActionState.java b/src/main/java/ui/tmlad/TMLADActionState.java index a216f7d0454b47ce6a819814f67940bcfe3a7503..ec856478e2cbb0d89c82fc9b5c2a7bd025fb3e10 100755 --- a/src/main/java/ui/tmlad/TMLADActionState.java +++ b/src/main/java/ui/tmlad/TMLADActionState.java @@ -64,6 +64,8 @@ import ui.ad.TADActionState; * @author Ludovic APVRILLE */ public class TMLADActionState extends TADActionState/* Issue #69 TGCOneLineText */implements PreJavaCode, PostJavaCode, CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + + // Issue #31 // protected int lineLength = 5; // protected int textX = 5; // protected int textY = 15; @@ -102,23 +104,25 @@ public class TMLADActionState extends TADActionState/* Issue #69 TGCOneLineText } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) /*& (!tdp.isScaled())*/) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateAction > 0) { Color c = g.getColor(); switch(stateAction) { - case ErrorHighlight.OK: - g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); - break; - default: - g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + case ErrorHighlight.OK: + g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); } g.fillRoundRect(x, y, width, height, arc, arc); g.setColor(c); @@ -128,7 +132,7 @@ public class TMLADActionState extends TADActionState/* Issue #69 TGCOneLineText g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g,value, x + (width - w) / 2 , y + textY); } // public TGComponent isOnMe(int _x, int _y) { diff --git a/src/main/java/ui/tmlad/TMLADChoice.java b/src/main/java/ui/tmlad/TMLADChoice.java index c2f1175b4bf8fe8966880b691ae749a43b9cfcce..24e43bad657e45a43223d216a27b8a73c8e986eb 100755 --- a/src/main/java/ui/tmlad/TMLADChoice.java +++ b/src/main/java/ui/tmlad/TMLADChoice.java @@ -55,6 +55,8 @@ import ui.ad.TADChoice; * @author Ludovic APVRILLE */ public class TMLADChoice extends TADChoice /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + + // Issue #31 // private int lineLength = 10; // private int lineOutLength = 25; // private int textX1, textY1, textX2, textY2, textX3, textY3; @@ -117,9 +119,9 @@ public class TMLADChoice extends TADChoice /* Issue #69 TGCWithInternalComponent nbConnectingPoint = 4; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[ 0 ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ 1 ] = new TGConnectingPointTMLAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[ 2 ] = new TGConnectingPointTMLAD(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[ 3 ] = new TGConnectingPointTMLAD(this, 0, lineOutLength, false, true, 0.5, 1.0); + connectingPoint[ 1 ] = new TGConnectingPointTMLAD(this, -OUT_LINE_LENGTH, 0, false, true, 0.0, 0.5); + connectingPoint[ 2 ] = new TGConnectingPointTMLAD(this, OUT_LINE_LENGTH, 0, false, true, 1.0, 0.5); + connectingPoint[ 3 ] = new TGConnectingPointTMLAD(this, 0, OUT_LINE_LENGTH, false, true, 0.5, 1.0); } // public void internalDrawing(Graphics g) { diff --git a/src/main/java/ui/tmlad/TMLADDecrypt.java b/src/main/java/ui/tmlad/TMLADDecrypt.java index 09c37ac7b23a6c6bd2dd073b906f32bce059de58..fef8c18a8bd8ee0d0ef9fa7ec9a73158bffc3452 100755 --- a/src/main/java/ui/tmlad/TMLADDecrypt.java +++ b/src/main/java/ui/tmlad/TMLADDecrypt.java @@ -36,23 +36,35 @@ * knowledge of the CeCILL license and that you accept its terms. */ - package ui.tmlad; -import myutil.GraphicLib; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.geom.Line2D; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFrame; + import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import ui.*; + +import myutil.GraphicLib; +import ui.AllowedBreakpoint; +import ui.BasicErrorHighlight; +import ui.ColorManager; +import ui.EmbeddedComment; +import ui.ErrorHighlight; +import ui.MalformedModelingException; +import ui.TDiagramPanel; +import ui.TGComponent; +import ui.TGComponentManager; +import ui.TGConnectingPoint; import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogMultiString; -import javax.swing.*; -import java.awt.*; -import java.awt.geom.Line2D; -import java.util.ArrayList; - /** * Class TMLADDecrypt * Create decryption. To be used in TML activity diagrams @@ -62,27 +74,32 @@ import java.util.ArrayList; * @version 1.0 21/11/2005 */ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 5; + + // Issue #31 +// private int lineLength = 5; // private int textX, textY; - private int ilength = 20; - private int ex = 5; - private int lineLength1 = 2; +// private int ilength = 20; +// private int ex = 5; +// private int lineLength1;// = 2; + private static final int MARGIN = 5; + private static final int DEC_SYMBOL_MARGIN_Y = 6; + public String securityContext = ""; protected int stateOfError = 0; // Not yet checked public TMLADDecrypt(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 15; - height = 35; -// textX = width + 5; -// textY = height/2 + 5; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, +lineLength + ex, false, true, 0.5, 1.0); - + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, +lineLength + MARGIN, false, true, 0.5, 1.0); +// width = 15; +// height = 35; +// textX = width + 5; +// textY = height/2 + 5; + initScaling( 15, 35 ); moveable = true; editable = true; @@ -94,7 +111,9 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { + final int scaledMargin = scale( MARGIN ); + if (stateOfError > 0) { Color c = g.getColor(); switch (stateOfError) { @@ -106,31 +125,27 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } g.fillRect(x, y, width, height); int[] xP = new int[]{x, x + width, x + width / 2}; - int[] yP = new int[]{y + height, y + height, y + height + ex}; + int[] yP = new int[]{y + height, y + height, y + height + scaledMargin }; g.fillPolygon(xP, yP, 3); g.setColor(c); } g.drawLine(x, y, x + width, y); g.drawLine(x, y, x, y + height); g.drawLine(x + width, y, x + width, y + height); - g.drawLine(x, y + height, x + width / 2, y + height + ex); - g.drawLine(x + width / 2, y + height + ex, x + width, y + height); + g.drawLine(x, y + height, x + width / 2, y + height + scaledMargin); + g.drawLine(x + width / 2, y + height + scaledMargin, x + width, y + height); g.drawLine(x + (width / 2), y, x + (width / 2), y - lineLength); - g.drawLine(x + (width / 2), y + height + ex, x + (width / 2), y + lineLength + height + ex); - - g.drawLine(x + (width / 2) - lineLength1, y + (height - ilength) / 2, x + (width / 2) - lineLength1, y + (height + ilength) / 2); - g.drawArc(x - ex, y + ex, width, height - 2 * ex, 270, 180); - -/* - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) + lineLength1, y+(height-ilength)/2); + g.drawLine(x + (width / 2), y + height + scaledMargin, x + (width / 2), y + lineLength + height + scaledMargin); + // D + final int xPosOffset = (int) (width / 3 ); + final int scaledSymbolMarginY = scale( DEC_SYMBOL_MARGIN_Y ); + g.drawLine(x + xPosOffset, y + scaledSymbolMarginY, x + xPosOffset, y + height - scaledSymbolMarginY ); + g.drawArc(x - scaledMargin, y + scaledMargin, width, height - 2 * scaledMargin, 270, 180); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2 + ilength, x + (width/2) + lineLength1, y+(height-ilength)/2 + ilength); - - g.drawLine(x + (width/2)+ lineLength1, y+(height-ilength)/2, x + (width/2)+ lineLength1, y+(height+ilength)/2); -*/ - g.drawImage(IconManager.imgic7000.getImage(), x - 22, y + height / 2, null); - g.drawString("sec:" + securityContext, x + 3 * width / 2, y + height / 2); + g.drawImage( scale( IconManager.imgic7000.getImage() ), x - scale( 22 ), y + height / 2, null ); + + drawSingleString(g,"sec:" + securityContext, x + 3 * width / 2, y + height / 2); } @Override @@ -140,7 +155,7 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T labels[0] = "Security Pattern"; values[0] = securityContext; - ArrayList<String[]> help = new ArrayList<String[]>(); + List<String[]> help = new ArrayList<String[]>(); help.add(tdp.getMGUI().getCurrentCryptoConfig()); //JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples); JDialogMultiString jdms = new JDialogMultiString(frame, "Setting Decryption", 1, labels, values, help); @@ -185,14 +200,10 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { - // try { - NodeList nli; Node n1, n2; Element elt; -// int k; -// String s; for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); diff --git a/src/main/java/ui/tmlad/TMLADDelay.java b/src/main/java/ui/tmlad/TMLADDelay.java index 1ab0518c6b6571836b392046a0e70a2de55531d8..2d422174f573ecedaa30e5d57075135a66d72f10 100755 --- a/src/main/java/ui/tmlad/TMLADDelay.java +++ b/src/main/java/ui/tmlad/TMLADDelay.java @@ -54,8 +54,10 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 5; - private int textX, textY; + + // Issue #31 +// private int lineLength = 5; + //private int textX, textY; // private int ilength = 10; // private int lineLength1 = 2; @@ -63,16 +65,18 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi public TMLADDelay(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 10; - height = 30; - textX = width + 5; - textY = height/2 + 5; - + + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); +// width = 10; +// height = 30; + initScaling( 10, 30 ); + + textX = width + scale( 5 ); + textY = height/2 + scale( 5 ); nbInternalTGComponent = 1; tgcomponent = new TGComponent[nbInternalTGComponent]; @@ -97,7 +101,7 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { diff --git a/src/main/java/ui/tmlad/TMLADDelayInterval.java b/src/main/java/ui/tmlad/TMLADDelayInterval.java index 8581ff199153b7053fcf12b4d345d89e1069fbd6..ed472c9001f6887784f794f639462fbccaf55d90 100755 --- a/src/main/java/ui/tmlad/TMLADDelayInterval.java +++ b/src/main/java/ui/tmlad/TMLADDelayInterval.java @@ -54,27 +54,33 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 5; - private int textX, textY; + + // Issue #31 +// private int lineLength = 5; + //private int textX, textY; // private int ilength = 10; // private int lineLength1 = 2; - private int incrementY = 3; - private int segment = 4; +// private int incrementY = 3; +// private int segment = 4; + private static final int INCREMENT_Y = 3; + private static final int NB_SEGMENTS = 4; protected int stateOfError = 0; // Not yet checked public TMLADDelayInterval(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 10; - height = 30; - textX = width + 5; - textY = height/2 + 5; - + + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); +// width = 10; +// height = 30; + initScaling( 10, 30 ); + + textX = width + scale( 5 ); + textY = height/2 + scale( 5 ); nbInternalTGComponent = 1; tgcomponent = new TGComponent[nbInternalTGComponent]; @@ -98,7 +104,7 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { @@ -116,15 +122,17 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - int y1 = y + 4; - int x1 = x + 2; - int width1 = width - 4; + int y1 = y + scale( 4 ); + int x1 = x + scale( 2 ); + int width1 = width - scale( 4 ); + + final int scaledIncrementY = scale( INCREMENT_Y ); - for (int i=0; i<segment; i++) { - g.drawLine(x1, y1, x1+width1, y1+incrementY); - y1 += incrementY; - g.drawLine(x1+width1, y1, x1, y1+incrementY); - y1 += incrementY; + for (int i = 0; i < NB_SEGMENTS; i++ ) { + g.drawLine( x1, y1, x1 + width1, y1 + scaledIncrementY ); + y1 += scaledIncrementY; + g.drawLine( x1 + width1, y1, x1, y1 + scaledIncrementY ); + y1 += scaledIncrementY; } } diff --git a/src/main/java/ui/tmlad/TMLADEncrypt.java b/src/main/java/ui/tmlad/TMLADEncrypt.java index f3fac8dc34d48549623c0e285519c9390824ec0a..d48589f61c6034f6506325a416768d81a5a3c273 100755 --- a/src/main/java/ui/tmlad/TMLADEncrypt.java +++ b/src/main/java/ui/tmlad/TMLADEncrypt.java @@ -61,12 +61,21 @@ import java.awt.geom.Line2D; * @version 1.0 21/11/2005 */ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 5; + + // Issue #31 +// private int lineLength = 5; // private int textX, textY; - private int ex = 5; - private int textHeight = 8; - private int ilength = 12; - private int lineLength1 = 3; +// private int ex = 5; +// private int textHeight = 8; +// +// private double dlength = 12; +// private double dlineLength1 = 3; + + private static final int MARGIN = 5; + private static final int ENC_SYMBOL_HEIGHT = 12; + private static final int ENC_SYMBOL_MARGIN = 3; + private static final int SEC_ICON_HIGHT = 8; + public String type = ""; public String message_overhead = ""; public String size = ""; @@ -82,16 +91,16 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T public TMLADEncrypt(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 15; - height = 35; - // textX = width + 5; -// textY = height/2 + 5; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, +lineLength + ex, false, true, 0.5, 1.0); - + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, +lineLength + MARGIN, false, true, 0.5, 1.0); +// width = 15; +// height = 35; + // textX = width + 5; +// textY = height/2 + 5; + initScaling( 15, 35 ); moveable = true; editable = true; @@ -103,7 +112,9 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { + final int scaledMargin = scale( MARGIN ); + if (stateOfError > 0) { Color c = g.getColor(); switch (stateOfError) { @@ -115,77 +126,89 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } g.fillRect(x, y, width, height); int[] xP = new int[]{x, x + width, x + width / 2}; - int[] yP = new int[]{y + height, y + height, y + height + ex}; + int[] yP = new int[]{ y + height, y + height, y + height + scaledMargin }; g.fillPolygon(xP, yP, 3); g.setColor(c); } + g.drawLine(x, y, x + width, y); g.drawLine(x, y, x, y + height); g.drawLine(x + width, y, x + width, y + height); - g.drawLine(x, y + height, x + width / 2, y + height + ex); - g.drawLine(x + width / 2, y + height + ex, x + width, y + height); + + g.drawLine(x, y + height, x + width / 2, y + height + scaledMargin ); + g.drawLine(x + width / 2, y + height + scaledMargin, x + width, y + height); g.drawLine(x + (width / 2), y, x + (width / 2), y - lineLength); - g.drawLine(x + (width / 2), y + height + ex, x + (width / 2), y + lineLength + height + ex); + g.drawLine(x + (width / 2), y + height + scaledMargin, x + (width / 2), y + lineLength + height + scaledMargin); + // Issue #31 + final int scaledSymbolHeight = scale( ENC_SYMBOL_HEIGHT ); + final int scaledSymbolMargin = scale( ENC_SYMBOL_MARGIN ); + if (type.equals("Symmetric Encryption")) { //S - g.drawLine(x + ex, y + (height - ilength) / 4, x + width - ex, y + (height - ilength) / 4); - g.drawLine(x + ex, y + (height - ilength) / 4 + ilength, x + width - ex, y + (height - ilength) / 4 + ilength); - g.drawLine(x + ex, y + (height - ilength) / 4 + ilength / 2, x + width - ex, y + (height - ilength) / 4 + ilength / 2); - g.drawLine(x + ex, y + (height - ilength) / 4, x + ex, y + (height - ilength) / 4 + ilength / 2); - g.drawLine(x + width - ex, y + (height - ilength) / 4 + ilength / 2, x + width - ex, y + (height - ilength) / 4 + ilength); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4, x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2); + g.drawLine(x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight); //E - g.drawLine(x + ex, y + (height - ilength) / 4 + height / 2 - ex / 2, x + width - ex, y + (height - ilength) / 4 + height / 2 - ex / 2); - g.drawLine(x + ex, y + (height - ilength) / 4 + ilength + height / 2 - ex / 2, x + width - ex, y + (height - ilength) / 4 + ilength + height / 2 - ex / 2); - g.drawLine(x + ex, y + (height - ilength) / 4 + ilength / 2 + height / 2 - ex / 2, x + width - ex, y + (height - ilength) / 4 + ilength / 2 + height / 2 - ex / 2); - g.drawLine(x + ex, y + (height - ilength) / 4 + height / 2 - ex / 2, x + ex, y + (height - ilength) / 4 + ilength + height / 2 - ex / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + height / 2 - scaledMargin / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + height / 2 - scaledMargin / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight + height / 2 - scaledMargin / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight + height / 2 - scaledMargin / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2 + height / 2 - scaledMargin / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2 + height / 2 - scaledMargin / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + height / 2 - scaledMargin / 2, x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight + height / 2 - scaledMargin / 2); } else if (type.equals("Asymmetric Encryption")) { //A - g.drawLine(x + (width / 2), y + (height - ilength) / 4, x + ex, y + (height - ilength) / 4 + ilength); - g.drawLine(x + (width / 2), y + (height - ilength) / 4, x + (width) - ex, y + (height - ilength) / 4 + ilength); - g.drawLine(x + 3 * ex / 2, y + (height - ilength) / 4 + ilength / 2 + ex / 2, x + width - 3 * ex / 2, y + (height - ilength) / 4 + ilength / 2 + ex / 2); + g.drawLine(x + (width / 2), y + (height - scaledSymbolHeight) / 4, x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight); + g.drawLine(x + (width / 2), y + (height - scaledSymbolHeight) / 4, x + (width) - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight); + g.drawLine(x + 3 * scaledMargin / 2, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2 + scaledMargin / 2, x + width - 3 * scaledMargin / 2, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2 + scaledMargin / 2); //E - g.drawLine(x + ex, y + (height - ilength) / 4 + height / 2 - ex / 2, x + width - ex, y + (height - ilength) / 4 + height / 2 - ex / 2); - g.drawLine(x + ex, y + (height - ilength) / 4 + ilength + height / 2 - ex / 2, x + width - ex, y + (height - ilength) / 4 + ilength + height / 2 - ex / 2); - g.drawLine(x + ex, y + (height - ilength) / 4 + ilength / 2 + height / 2 - ex / 2, x + width - ex, y + (height - ilength) / 4 + ilength / 2 + height / 2 - ex / 2); - g.drawLine(x + ex, y + (height - ilength) / 4 + height / 2 - ex / 2, x + ex, y + (height - ilength) / 4 + ilength + height / 2 - ex / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + height / 2 - scaledMargin / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + height / 2 - scaledMargin / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight + height / 2 - scaledMargin / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight + height / 2 - scaledMargin / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2 + height / 2 - scaledMargin / 2, x + width - scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight / 2 + height / 2 - scaledMargin / 2); + g.drawLine(x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + height / 2 - scaledMargin / 2, x + scaledMargin, y + (height - scaledSymbolHeight) / 4 + scaledSymbolHeight + height / 2 - scaledMargin / 2); } else if (type.equals("Nonce")) { //N - g.drawLine(x + (width / 2) - lineLength1, y + (height - ilength) / 2, x + (width / 2) - lineLength1, y + (height - ilength) / 2 + ilength); - g.drawLine(x + (width / 2) + lineLength1, y + (height - ilength) / 2, x + (width / 2) + lineLength1, y + (height - ilength) / 2 + ilength); - g.drawLine(x + (width / 2) - lineLength1, y + (height - ilength) / 2, x + (width / 2) + lineLength1, y + (height - ilength) / 2 + ilength); + g.drawLine(x + (width / 2) - scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2, x + (width / 2) - scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + (width / 2) + scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2, x + (width / 2) + scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + (width / 2) - scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2, x + (width / 2) + scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); } else if (type.equals("MAC")) { //M - g.drawLine(x + ex / 2 + 1, y + (height - ilength) / 2, x + ex / 2 + 1, y + (height - ilength) / 2 + ilength); - g.drawLine(x + width - ex / 2 - 1, y + (height - ilength) / 2, x + width - ex / 2 - 1, y + (height - ilength) / 2 + ilength); - g.drawLine(x + ex / 2 + 1, y + (height - ilength) / 2, x + width / 2, y + (height - ilength) / 2 + ilength); - g.drawLine(x + width - ex / 2 - 1, y + (height - ilength) / 2, x + width / 2, y + (height - ilength) / 2 + ilength); + g.drawLine(x + scaledMargin / 2 + 1, y + (height - scaledSymbolHeight) / 2, x + scaledMargin / 2 + 1, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + width - scaledMargin / 2 - 1, y + (height - scaledSymbolHeight) / 2, x + width - scaledMargin / 2 - 1, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + scaledMargin / 2 + 1, y + (height - scaledSymbolHeight) / 2, x + width / 2, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + width - scaledMargin / 2 - 1, y + (height - scaledSymbolHeight) / 2, x + width / 2, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); } else if (type.equals("Hash")) { - g.drawLine(x + (width / 2) - lineLength1, y + (height - ilength) / 2, x + (width / 2) - lineLength1, y + (height - ilength) / 2 + ilength); - g.drawLine(x + (width / 2) + lineLength1, y + (height - ilength) / 2, x + (width / 2) + lineLength1, y + (height - ilength) / 2 + ilength); - g.drawLine(x + (width / 2) - lineLength1, y + (height - ilength) / 2 + ilength / 2, x + (width / 2) + lineLength1, y + (height - ilength) / 2 + ilength / 2); + //H + g.drawLine(x + (width / 2) - scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2, x + (width / 2) - scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + (width / 2) + scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2, x + (width / 2) + scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + (width / 2) - scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight / 2, x + (width / 2) + scaledSymbolMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight / 2); } else if (type.equals("Advanced")) { //A - g.drawLine(x + (width / 2), y + (height - ilength) / 2, x + ex, y + (height - ilength) / 2 + ilength); - g.drawLine(x + (width / 2), y + (height - ilength) / 2, x + (width) - ex, y + (height - ilength) / 2 + ilength); - g.drawLine(x + 3 * ex / 2, y + (height - ilength) / 2 + ilength / 2 + ex / 2, x + width - 3 * ex / 2, y + (height - ilength) / 2 + ilength / 2 + ex / 2); + g.drawLine(x + (width / 2), y + (height - scaledSymbolHeight) / 2, x + scaledMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + (width / 2), y + (height - scaledSymbolHeight) / 2, x + (width) - scaledMargin, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight); + g.drawLine(x + 3 * scaledMargin / 2, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight / 2 + scaledMargin / 2, x + width - 3 * scaledMargin / 2, y + (height - scaledSymbolHeight) / 2 + scaledSymbolHeight / 2 + scaledMargin / 2); } + //Draw security pattern - g.drawString("sec:" + securityContext, x + 3 * width / 2, y + height / 2); + drawSingleString(g,"sec:" + securityContext, x + 3 * width / 2, y + height / 2); + + final int scaledSecIconHeight = scale( SEC_ICON_HIGHT ); + //Draw nonce if it exists if (!nonce.isEmpty()) { - g.drawString("nonce:" + nonce, x + 3 * width / 2, y + height / 2 + textHeight); + drawSingleString(g,"nonce:" + nonce, x + 3 * width / 2, y + height / 2 + scaledSecIconHeight ); } + //Draw key if it exists if (!key.isEmpty()) { - g.drawString("key:" + key, x + 3 * width / 2, y + height / 2 + 2 * textHeight); + drawSingleString(g,"key:" + key, x + 3 * width / 2, y + height / 2 + 2 * scaledSecIconHeight ); } - g.drawImage(IconManager.imgic7000.getImage(), x - 22, y + height / 2, null); + + g.drawImage( scale( IconManager.imgic7000.getImage() ), x - scale( 22 ), y + height / 2, null ); } @Override public boolean editOndoubleClick(JFrame frame) { - //JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples);] String[] values = new String[]{securityContext, type, message_overhead, encTime, size, nonce, formula, decTime, key, algorithm}; String[] nonces = tdp.getMGUI().getAllNonce(); String[] keys = tdp.getMGUI().getAllKeys().toArray(new String[0]); diff --git a/src/main/java/ui/tmlad/TMLADExecC.java b/src/main/java/ui/tmlad/TMLADExecC.java index c7be2687dd657920ed6b6ac0e6c01318711eb433..21765db6b9601f3c95a7c22782379a8569bc90df 100755 --- a/src/main/java/ui/tmlad/TMLADExecC.java +++ b/src/main/java/ui/tmlad/TMLADExecC.java @@ -38,13 +38,17 @@ package ui.tmlad; -import myutil.GraphicLib; -import ui.*; -import ui.ad.TADComponentWithSubcomponents; -import ui.util.IconManager; +import java.awt.Graphics; -import java.awt.*; -import java.awt.geom.Line2D; +import ui.AllowedBreakpoint; +import ui.BasicErrorHighlight; +import ui.CDElement; +import ui.EmbeddedComment; +import ui.TDiagramPanel; +import ui.TGComponent; +import ui.TGComponentManager; +import ui.ad.TADExec; +import ui.ad.TGConnectingPointAD; /** * Class TMLADExecC @@ -53,86 +57,104 @@ import java.awt.geom.Line2D; * @version 1.0 21/05/2008 * @author Ludovic APVRILLE */ -public class TMLADExecC extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 5; - private int textX, textY; - private int ilength = 10; - private int lineLength1 = 2; - - protected int stateOfError = 0; // Not yet checked +public class TMLADExecC extends TADExec /* Issue #31TADComponentWithSubcomponents *//* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + + // Issue #31 + //private int lineLength = 5; + //private int textX, textY; + +// private int ilength;// = 10; +// private int lineLength1;// = 2; +// +// protected int stateOfError = 0; // Not yet checked public TMLADExecC(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 10; - height = 30; - textX = width + 5; - textY = height/2 + 5; - - nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[2]; - connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); - - nbInternalTGComponent = 1; - tgcomponent = new TGComponent[nbInternalTGComponent]; - - TGCOneLineText tgc = new TGCOneLineText(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); - tgc.setValue("execc value"); - tgc.setName("value of the delay"); - tgcomponent[0] = tgc; - - moveable = true; - editable = false; - removable = true; + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp, "execc value", "value of the delay" ); + + // Issue #31 +// width = 10; +// height = 30; +// initSize( 10, 30 ); +// ilength = scale( 10 ); +// lineLength1 = scale( 2 ); +// textX = width + scale( 5 ); +// textY = height/2 + scale( 5 ); +// +// nbConnectingPoint = 2; +// connectingPoint = new TGConnectingPoint[2]; +// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); +// +// nbInternalTGComponent = 1; +// tgcomponent = new TGComponent[nbInternalTGComponent]; +// +// TGCOneLineText tgc = new TGCOneLineText(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); +// tgc.setValue("execc value"); +// tgc.setName("value of the delay"); +// tgcomponent[0] = tgc; +// +// moveable = true; +// editable = false; +// removable = true; name = "execC"; - myImageIcon = IconManager.imgic214; - } - - @Override - public void internalDrawing(Graphics g) { - if (stateOfError > 0) { - Color c = g.getColor(); - switch(stateOfError) { - case ErrorHighlight.OK: - g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); - break; - default: - g.setColor(ColorManager.UNKNOWN_BOX_ACTION); - } - g.fillRect(x, y, width, height); - g.setColor(c); - } - g.drawRect(x, y, width, height); - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); - g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) + lineLength1, y+(height-ilength)/2); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2 + ilength, x + (width/2) + lineLength1, y+(height-ilength)/2 + ilength); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2)- lineLength1, y+(height+ilength)/2); - } - - @Override - public TGComponent isOnOnlyMe(int x1, int y1) { - if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { - return this; - } - - if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { - return this; - } - - return null; - } - - public String getDelayValue() { - return tgcomponent[0].getValue(); - } - - public void setDelayValue(String value) { - tgcomponent[0].setValue(value); +// myImageIcon = IconManager.imgic214; } +// +// @Override +// public void internalDrawing(Graphics g) { +// if (stateOfError > 0) { +// Color c = g.getColor(); +// switch(stateOfError) { +// case ErrorHighlight.OK: +// g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); +// break; +// default: +// g.setColor(ColorManager.UNKNOWN_BOX_ACTION); +// } +// +// g.fillRect(x, y, width, height); +// g.setColor(c); +// } +// +// final int scaledLineLength1 = scale( lineLength1 ); +// final int scaledIlength1 = scale( ilength ); +// +// g.drawRect(x, y, width, height); +// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); +// g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); +// +// // - +// g.drawLine(x + (width/2) - scaledLineLength1, y+(height-scaledIlength1)/2, x + (width/2) + scaledLineLength1, y+(height-scaledIlength1)/2); +// +// // | +// g.drawLine(x + (width/2) - scaledLineLength1, y+(height-scaledIlength1)/2, x + (width/2)- scaledLineLength1, y+(height+scaledIlength1)/2); +// +// // - +// g.drawLine(x + (width/2) - scaledLineLength1, y+(height-scaledIlength1)/2 + scaledIlength1, x + (width/2) + scaledLineLength1, y+(height-scaledIlength1)/2 + scaledIlength1); +// } +// +// @Override +// public TGComponent isOnOnlyMe(int x1, int y1) { +// if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { +// return this; +// } +// +// if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { +// return this; +// } +// +// return null; +// } +// +// public String getDelayValue() { +// return tgcomponent[0].getValue(); +// } +// +// public void setDelayValue(String value) { +// tgcomponent[0].setValue(value); +// } @Override public int getType() { @@ -143,9 +165,29 @@ public class TMLADExecC extends TADComponentWithSubcomponents /* Issue #69 TGCWi public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - - @Override - public void setStateAction(int _stateAction) { - stateOfError = _stateAction; +// +// @Override +// public void setStateAction(int _stateAction) { +// stateOfError = _stateAction; +// } + + @Override + protected TGConnectingPointAD createConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, + double _w, double _h) { + return new TGConnectingPointTMLAD( _container, _x, _y, _in, _out, _w, _h ); + } + + @Override + protected void drawInternalSymbol( Graphics g, + int symbolWidth, + int symbolHeight ) { + // - + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2); + + // | + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2, x + (width/2)- symbolWidth, y+(height+symbolHeight)/2); + + // - + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2 + symbolHeight, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2 + symbolHeight); } } diff --git a/src/main/java/ui/tmlad/TMLADExecCInterval.java b/src/main/java/ui/tmlad/TMLADExecCInterval.java index bf07c7eafebfad4b5f9e7dbb541b9cb3b648fae4..47f32563ead9e0895277cbc8275d630b2036d9d5 100755 --- a/src/main/java/ui/tmlad/TMLADExecCInterval.java +++ b/src/main/java/ui/tmlad/TMLADExecCInterval.java @@ -38,13 +38,15 @@ package ui.tmlad; -import myutil.GraphicLib; -import ui.*; -import ui.ad.TADComponentWithSubcomponents; -import ui.util.IconManager; +import java.awt.Graphics; -import java.awt.*; -import java.awt.geom.Line2D; +import ui.CDElement; +import ui.TDiagramPanel; +import ui.TGCTimeInterval; +import ui.TGComponent; +import ui.TGComponentManager; +import ui.ad.TADExec; +import ui.ad.TGConnectingPointAD; /** * Class TMLADExecCInterval @@ -53,93 +55,112 @@ import java.awt.geom.Line2D; * @version 1.0 21/05/2008 * @author Ludovic APVRILLE */ -public class TMLADExecCInterval extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 5; - private int textX, textY; - private int ilength = 10; - private int lineLength1 = 2; - - protected int stateOfError = 0; // Not yet checked +public class TMLADExecCInterval extends TADExec /* Issue #31 TADComponentWithSubcomponents *//* Issue #69 TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight*/ { + + // Issue #31 + //private int lineLength = 5; + //private int textX, textY; +// private int ilength;// = 10; +// private int lineLength1;// = 2; +// +// protected int stateOfError = 0; // Not yet checked public TMLADExecCInterval(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 10; - height = 30; - textX = width + 5; - textY = height/2 + 5; - - nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[2]; - connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); - - nbInternalTGComponent = 1; - tgcomponent = new TGComponent[nbInternalTGComponent]; - - TGCTimeInterval tgc = new TGCTimeInterval(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); - tgc.setValue(""); - tgc.setName("value of the time interval"); - tgcomponent[0] = tgc; + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp, "", "value of the time interval" ); - moveable = true; - editable = false; - removable = true; + // Issue #31 +// width = 10; +// height = 30; +// initSize( 10, 30 ); +// ilength = scale( 10 ); +// lineLength1 = scale( 2 ); +// textX = width + scale( 5 ); +// textY = height/2 + scale( 5 ); +// +// nbConnectingPoint = 2; +// connectingPoint = new TGConnectingPoint[2]; +// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); +// +// nbInternalTGComponent = 1; +// tgcomponent = new TGComponent[nbInternalTGComponent]; +// +// TGCTimeInterval tgc = new TGCTimeInterval(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); +// tgc.setValue(""); +// tgc.setName("value of the time interval"); +// tgcomponent[0] = tgc; +// +// moveable = true; +// editable = false; +// removable = true; name = "execIInterval"; - myImageIcon = IconManager.imgic214; +// myImageIcon = IconManager.imgic214; } - + @Override - public void internalDrawing(Graphics g) { - if (stateOfError > 0) { - Color c = g.getColor(); - switch(stateOfError) { - case ErrorHighlight.OK: - g.setColor(ColorManager.EXEC); - break; - default: - g.setColor(ColorManager.UNKNOWN_BOX_ACTION); - } - g.fillRect(x, y, width, height); - g.setColor(c); - } - g.drawRect(x, y, width, height); - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); - g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) + lineLength1, y+(height-ilength)/2); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2 + ilength, x + (width/2) + lineLength1, y+(height-ilength)/2 + ilength); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) - lineLength1, y+(height+ilength)/2); + protected TGCTimeInterval createInternalComponent() { + return new TGCTimeInterval(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, tdp); } - @Override - public TGComponent isOnOnlyMe(int x1, int y1) { - if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { - return this; - } - - if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { - return this; - } - - return null; + protected TGCTimeInterval getTimeInterval() { + return (TGCTimeInterval) tgcomponent[0]; } +// @Override +// public void internalDrawing(Graphics g) { +// if (stateOfError > 0) { +// Color c = g.getColor(); +// switch(stateOfError) { +// case ErrorHighlight.OK: +// g.setColor(ColorManager.EXEC); +// break; +// default: +// g.setColor(ColorManager.UNKNOWN_BOX_ACTION); +// } +// g.fillRect(x, y, width, height); +// g.setColor(c); +// } +// g.drawRect(x, y, width, height); +// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); +// g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); +// +// // Issue #31 +// final int scaledLineLength1 = scale( lineLength1 ); +// final int scaledIlength1 = scale( ilength ); +// g.drawLine(x + (width/2) - scaledLineLength1, y+(height-scaledIlength1)/2, x + (width/2) + scaledLineLength1, y+(height-scaledIlength1)/2); +// g.drawLine(x + (width/2) - scaledLineLength1, y+(height-scaledIlength1)/2 + scaledIlength1, x + (width/2) + scaledLineLength1, y+(height-scaledIlength1)/2 + scaledIlength1); +// g.drawLine(x + (width/2) - scaledLineLength1, y+(height-scaledIlength1)/2, x + (width/2) - scaledLineLength1, y+(height+scaledIlength1)/2); +// } +// +// @Override +// public TGComponent isOnOnlyMe(int x1, int y1) { +// if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { +// return this; +// } +// +// if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { +// return this; +// } +// +// return null; +// } + public String getMinDelayValue() { - return ((TGCTimeInterval)(tgcomponent[0])).getMinDelay(); + return getTimeInterval().getMinDelay(); } public String getMaxDelayValue() { - return ((TGCTimeInterval)(tgcomponent[0])).getMaxDelay(); + return getTimeInterval().getMaxDelay(); } public void setMinValue(String val) { - ((TGCTimeInterval)(tgcomponent[0])).setMinDelay(val); + getTimeInterval().setMinDelay(val); } public void setMaxValue(String val) { - ((TGCTimeInterval)(tgcomponent[0])).setMaxDelay(val); + getTimeInterval().setMaxDelay(val); } @Override @@ -151,9 +172,29 @@ public class TMLADExecCInterval extends TADComponentWithSubcomponents /* Issue # public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - - @Override - public void setStateAction(int _stateAction) { - stateOfError = _stateAction; +// +// @Override +// public void setStateAction(int _stateAction) { +// stateOfError = _stateAction; +// } + + @Override + protected TGConnectingPointAD createConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, + double _w, double _h) { + return new TGConnectingPointTMLAD( _container, _x, _y, _in, _out, _w, _h ); + } + + @Override + protected void drawInternalSymbol( Graphics g, + int symbolWidth, + int symbolHeight ) { + // - + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2); + + // | + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2, x + (width/2)- symbolWidth, y+(height+symbolHeight)/2); + + // - + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2 + symbolHeight, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2 + symbolHeight); } } diff --git a/src/main/java/ui/tmlad/TMLADExecI.java b/src/main/java/ui/tmlad/TMLADExecI.java index 024b0c57605c721713c0afe1e10b36e62a3dc7f5..b9abd4033a56b08bb0d060c8635f44d1f5595782 100755 --- a/src/main/java/ui/tmlad/TMLADExecI.java +++ b/src/main/java/ui/tmlad/TMLADExecI.java @@ -38,13 +38,14 @@ package ui.tmlad; -import myutil.GraphicLib; -import ui.*; -import ui.ad.TADComponentWithSubcomponents; -import ui.util.IconManager; +import java.awt.Graphics; -import java.awt.*; -import java.awt.geom.Line2D; +import ui.CDElement; +import ui.TDiagramPanel; +import ui.TGComponent; +import ui.TGComponentManager; +import ui.ad.TADExec; +import ui.ad.TGConnectingPointAD; /** * Class TMLADExecI @@ -53,86 +54,92 @@ import java.awt.geom.Line2D; * @version 1.0 21/11/2005 * @author Ludovic APVRILLE */ -public class TMLADExecI extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, CheckableLatency, BasicErrorHighlight { - private int lineLength = 5; - private int textX, textY; - private int ilength = 10; - private int lineLength1 = 2; +public class TMLADExecI extends TADExec /* Issue #69 TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, CheckableLatency, BasicErrorHighlight*/ { + + // Issue #31 +// private int lineLength = 5; + // private int textX, textY; +// private int ilength;// = 10; +// private int lineLength1;// = 2; - protected int stateOfError = 0; // Not yet checked +// protected int stateOfError = 0; // Not yet checked public TMLADExecI(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 10; - height = 30; - textX = width + 5; - textY = height/2 + 5; - - nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[2]; - connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp, "execi value", "value of the delay" ); - nbInternalTGComponent = 1; - tgcomponent = new TGComponent[nbInternalTGComponent]; - - TGCOneLineText tgc = new TGCOneLineText(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); - tgc.setValue("execi value"); - tgc.setName("value of the delay"); - tgcomponent[0] = tgc; - - moveable = true; - editable = false; - removable = true; + // Issue #31 +// width = 10; +// height = 30; +// initSize( 10, 30 ); +// textX = width + scale( 5 ); +// textY = height/2 + scale( 5 ); +// ilength = scale( 10 ); +// lineLength1 = scale( ) +// +// nbConnectingPoint = 2; +// connectingPoint = new TGConnectingPoint[2]; +// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); +// +// nbInternalTGComponent = 1; +// tgcomponent = new TGComponent[nbInternalTGComponent]; +// +// TGCOneLineText tgc = new TGCOneLineText(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); +// tgc.setValue("execi value"); +// tgc.setName("value of the delay"); +// tgcomponent[0] = tgc; +// +// moveable = true; +// editable = false; +// removable = true; name = "execI"; - myImageIcon = IconManager.imgic214; + // myImageIcon = IconManager.imgic214; } +// +// @Override +// public void internalDrawing(Graphics g) { +// if (stateOfError > 0) { +// Color c = g.getColor(); +// switch(stateOfError) { +// case ErrorHighlight.OK: +// g.setColor(ColorManager.EXEC); +// break; +// default: +// g.setColor(ColorManager.UNKNOWN_BOX_ACTION); +// } +// g.fillRect(x, y, width, height); +// g.setColor(c); +// } +// g.drawRect(x, y, width, height); +// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); +// g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); +// g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) + lineLength1, y+(height-ilength)/2); +// g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2 + ilength, x + (width/2) + lineLength1, y+(height-ilength)/2 + ilength); +// g.drawLine(x + (width/2), y+(height-ilength)/2, x + (width/2), y+(height+ilength)/2); +// } - @Override - public void internalDrawing(Graphics g) { - if (stateOfError > 0) { - Color c = g.getColor(); - switch(stateOfError) { - case ErrorHighlight.OK: - g.setColor(ColorManager.EXEC); - break; - default: - g.setColor(ColorManager.UNKNOWN_BOX_ACTION); - } - g.fillRect(x, y, width, height); - g.setColor(c); - } - g.drawRect(x, y, width, height); - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); - g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) + lineLength1, y+(height-ilength)/2); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2 + ilength, x + (width/2) + lineLength1, y+(height-ilength)/2 + ilength); - g.drawLine(x + (width/2), y+(height-ilength)/2, x + (width/2), y+(height+ilength)/2); - } - - @Override - public TGComponent isOnOnlyMe(int x1, int y1) { - if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { - return this; - } - - if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { - return this; - } - - return null; - } - - public String getDelayValue() { - return tgcomponent[0].getValue(); - } - - public void setDelayValue(String value) { - tgcomponent[0].setValue(value); - } +// @Override +// public TGComponent isOnOnlyMe(int x1, int y1) { +// if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { +// return this; +// } +// +// if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { +// return this; +// } +// +// return null; +// } +// +// public String getDelayValue() { +// return tgcomponent[0].getValue(); +// } +// +// public void setDelayValue(String value) { +// tgcomponent[0].setValue(value); +// } @Override public int getType() { @@ -143,9 +150,24 @@ public class TMLADExecI extends TADComponentWithSubcomponents /* Issue #69 TGCWi public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - - @Override - public void setStateAction(int _stateAction) { - stateOfError = _stateAction; +// +// @Override +// public void setStateAction(int _stateAction) { +// stateOfError = _stateAction; +// } + + @Override + protected TGConnectingPointAD createConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, + double _w, double _h) { + return new TGConnectingPointTMLAD( _container, _x, _y, _in, _out, _w, _h ); + } + + @Override + protected void drawInternalSymbol( Graphics g, + int symbolWidth, + int symbolHeight ) { + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2); + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2 + symbolHeight, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2 + symbolHeight); + g.drawLine(x + (width/2), y+(height-symbolHeight)/2, x + (width/2), y+(height+symbolHeight)/2); } } diff --git a/src/main/java/ui/tmlad/TMLADExecIInterval.java b/src/main/java/ui/tmlad/TMLADExecIInterval.java index 49c6b1546867e49a1c55c881509aec503ff0ddd9..04385a3b6e0942bc494d64b14b62cd48fe3066ee 100755 --- a/src/main/java/ui/tmlad/TMLADExecIInterval.java +++ b/src/main/java/ui/tmlad/TMLADExecIInterval.java @@ -38,13 +38,15 @@ package ui.tmlad; -import myutil.GraphicLib; -import ui.*; -import ui.ad.TADComponentWithSubcomponents; -import ui.util.IconManager; +import java.awt.Graphics; -import java.awt.*; -import java.awt.geom.Line2D; +import ui.CDElement; +import ui.TDiagramPanel; +import ui.TGCTimeInterval; +import ui.TGComponent; +import ui.TGComponentManager; +import ui.ad.TADExec; +import ui.ad.TGConnectingPointAD; /** * Class TMLADExecIInterval @@ -53,93 +55,106 @@ import java.awt.geom.Line2D; * @version 1.0 02/12/2005 * @author Ludovic APVRILLE */ -public class TMLADExecIInterval extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent */ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 5; - private int textX, textY; - private int ilength = 10; - private int lineLength1 = 2; - - protected int stateOfError = 0; // Not yet checked +public class TMLADExecIInterval extends TADExec /* Issue #31 TADComponentWithSubcomponents *//* Issue #69 TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight*/ { + + // Issue #31 +// private int lineLength = 5; + // private int textX, textY; +// private int ilength = 10; +// private int lineLength1 = 2; +// +// protected int stateOfError = 0; // Not yet checked public TMLADExecIInterval(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 10; - height = 30; - textX = width + 5; - textY = height/2 + 5; - - nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[2]; - connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); - - nbInternalTGComponent = 1; - tgcomponent = new TGComponent[nbInternalTGComponent]; - - TGCTimeInterval tgc = new TGCTimeInterval(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); - tgc.setValue(""); - tgc.setName("value of the time interval"); - tgcomponent[0] = tgc; - - moveable = true; - editable = false; - removable = true; + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp, "", "value of the time interval" ); + + // Issue #31 +// width = 10; +// height = 30; +// initSize( 10, 30 ); +// textX = width + scale( 5 ); +// textY = height/2 + scale( 5 ); +// +// nbConnectingPoint = 2; +// connectingPoint = new TGConnectingPoint[2]; +// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); +// +// nbInternalTGComponent = 1; +// tgcomponent = new TGComponent[nbInternalTGComponent]; +// +// TGCTimeInterval tgc = new TGCTimeInterval(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); +// tgc.setValue(""); +// tgc.setName("value of the time interval"); +// tgcomponent[0] = tgc; +// +// moveable = true; +// editable = false; +// removable = true; name = "execIInterval"; - myImageIcon = IconManager.imgic214; +// myImageIcon = IconManager.imgic214; } - + @Override - public void internalDrawing(Graphics g) { - if (stateOfError > 0) { - Color c = g.getColor(); - switch(stateOfError) { - case ErrorHighlight.OK: - g.setColor(ColorManager.EXEC); - break; - default: - g.setColor(ColorManager.UNKNOWN_BOX_ACTION); - } - g.fillRect(x, y, width, height); - g.setColor(c); - } - g.drawRect(x, y, width, height); - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); - g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) + lineLength1, y+(height-ilength)/2); - g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2 + ilength, x + (width/2) + lineLength1, y+(height-ilength)/2 + ilength); - g.drawLine(x + (width/2), y+(height-ilength)/2, x + (width/2), y+(height+ilength)/2); + protected TGCTimeInterval createInternalComponent() { + return new TGCTimeInterval(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, tdp); } - @Override - public TGComponent isOnOnlyMe(int x1, int y1) { - if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { - return this; - } - - if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { - return this; - } - - return null; + protected TGCTimeInterval getTimeInterval() { + return (TGCTimeInterval) tgcomponent[0]; } +// +// @Override +// public void internalDrawing(Graphics g) { +// if (stateOfError > 0) { +// Color c = g.getColor(); +// switch(stateOfError) { +// case ErrorHighlight.OK: +// g.setColor(ColorManager.EXEC); +// break; +// default: +// g.setColor(ColorManager.UNKNOWN_BOX_ACTION); +// } +// g.fillRect(x, y, width, height); +// g.setColor(c); +// } +// g.drawRect(x, y, width, height); +// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); +// g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); +// g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) + lineLength1, y+(height-ilength)/2); +// g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2 + ilength, x + (width/2) + lineLength1, y+(height-ilength)/2 + ilength); +// g.drawLine(x + (width/2), y+(height-ilength)/2, x + (width/2), y+(height+ilength)/2); +// } + +// @Override +// public TGComponent isOnOnlyMe(int x1, int y1) { +// if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { +// return this; +// } +// +// if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { +// return this; +// } +// +// return null; +// } public String getMinDelayValue() { - return ((TGCTimeInterval)(tgcomponent[0])).getMinDelay(); + return getTimeInterval().getMinDelay(); } public String getMaxDelayValue() { - return ((TGCTimeInterval)(tgcomponent[0])).getMaxDelay(); + return getTimeInterval().getMaxDelay(); } public void setMinValue(String val) { - ((TGCTimeInterval)(tgcomponent[0])).setMinDelay(val); + getTimeInterval().setMinDelay(val); } public void setMaxValue(String val) { - ((TGCTimeInterval)(tgcomponent[0])).setMaxDelay(val); + getTimeInterval().setMaxDelay(val); } @Override @@ -151,9 +166,22 @@ public class TMLADExecIInterval extends TADComponentWithSubcomponents /* Issue # public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - - @Override - public void setStateAction(int _stateAction) { - stateOfError = _stateAction; +// +// @Override +// public void setStateAction(int _stateAction) { +// stateOfError = _stateAction; +// } + + @Override + protected TGConnectingPointAD createConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, + double _w, double _h) { + return new TGConnectingPointTMLAD( _container, _x, _y, _in, _out, _w, _h ); + } + + @Override + protected void drawInternalSymbol(Graphics g, int symbolWidth, int symbolHeight) { + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2); + g.drawLine(x + (width/2) - symbolWidth, y+(height-symbolHeight)/2 + symbolHeight, x + (width/2) + symbolWidth, y+(height-symbolHeight)/2 + symbolHeight); + g.drawLine(x + (width/2), y+(height-symbolHeight)/2, x + (width/2), y+(height+symbolHeight)/2); } } diff --git a/src/main/java/ui/tmlad/TMLADForEverLoop.java b/src/main/java/ui/tmlad/TMLADForEverLoop.java index a59a009886c6c686b298f12d51eb4b02e1b3ff7d..5dfc173cab88e7d66bf02049990ddb167ce54062 100755 --- a/src/main/java/ui/tmlad/TMLADForEverLoop.java +++ b/src/main/java/ui/tmlad/TMLADForEverLoop.java @@ -60,6 +60,8 @@ import ui.ad.TADForLoop; * @author Ludovic APVRILLE */ public class TMLADForEverLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + + // Issue #31 // protected int lineLength = 5; // protected int textX = 5; // protected int textY = 15; @@ -74,10 +76,10 @@ public class TMLADForEverLoop extends TADForLoop /* Issue #69 TGCWithoutInternal // height = 20; // minWidth = 30; - nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[2]; - connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop +// nbConnectingPoint = 2; +// connectingPoint = new TGConnectingPoint[2]; +// connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop //connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp // moveable = true; @@ -91,14 +93,24 @@ public class TMLADForEverLoop extends TADForLoop /* Issue #69 TGCWithoutInternal } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + protected void createConnectingPoints() { + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop + } + + @Override + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateOfError > 0) { Color c = g.getColor(); @@ -116,9 +128,9 @@ public class TMLADForEverLoop extends TADForLoop /* Issue #69 TGCWithoutInternal g.drawRoundRect(x, y, width, height, arc, arc); g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); //g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); + //g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); - g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g,value, x + (width - w) / 2 , y + textY); } /*public boolean editOndoubleClick(JFrame frame) { diff --git a/src/main/java/ui/tmlad/TMLADForLoop.java b/src/main/java/ui/tmlad/TMLADForLoop.java index 75e89fcb6ccc172803358b7d42af2e7dedad1763..c489092b8f6000bd9fc10bf8e1e71eefae3ff72b 100755 --- a/src/main/java/ui/tmlad/TMLADForLoop.java +++ b/src/main/java/ui/tmlad/TMLADForLoop.java @@ -75,6 +75,8 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp // private final static String EXIT_LOOP = "exit loop"; // // + + // Issue #31 // protected int lineLength = 5; // protected int textX = 5; // protected int textY = 15; @@ -93,11 +95,11 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp // height = 20; // minWidth = 30; - nbConnectingPoint = 3; - connectingPoint = new TGConnectingPoint[3]; - connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop - connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp +// nbConnectingPoint = 3; +// connectingPoint = new TGConnectingPoint[3]; +// connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop +// connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp // // moveable = true; // editable = true; @@ -111,14 +113,25 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + protected void createConnectingPoints() { + nbConnectingPoint = 3; + connectingPoint = new TGConnectingPoint[3]; + connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop + connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp + } + + @Override + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } if ( isEnabled() && stateOfError > 0 ) { Color c = g.getColor(); @@ -138,12 +151,14 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); //g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); - g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g,value, x + (width - w) / 2 , y + textY); // Info on loops - g.drawString(IN_LOOP, x+width+2, y+height/2); + drawSingleString(g,IN_LOOP, x+width+2, y+height/2); //int wTmp = g.getFontMetrics().stringWidth(EXIT_LOOP); - g.drawString(EXIT_LOOP, x+width/2+2, y+height+10); + + // Issue #31 + drawSingleString(g,EXIT_LOOP, (int) (x+width/2+ 2 * oldScaleFactor), (int) (y+height+ scale( 10 ) ) ); } @Override diff --git a/src/main/java/ui/tmlad/TMLADForStaticLoop.java b/src/main/java/ui/tmlad/TMLADForStaticLoop.java index 5f38637077528baa1aec8360ebf6aaf79672fcc0..c80b41d83d15c3761f06019c7036d3301bfb1ae0 100755 --- a/src/main/java/ui/tmlad/TMLADForStaticLoop.java +++ b/src/main/java/ui/tmlad/TMLADForStaticLoop.java @@ -58,6 +58,8 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern // private final static String IN_LOOP = "inside loop"; // private final static String EXIT_LOOP = "exit loop"; // + + // Issue #31 // protected int lineLength = 5; // protected int textX = 5; // protected int textY = 15; @@ -72,12 +74,12 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern // width = 30; // height = 20; // minWidth = 30; - - nbConnectingPoint = 3; - connectingPoint = new TGConnectingPoint[3]; - connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop - connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp +// +// nbConnectingPoint = 3; +// connectingPoint = new TGConnectingPoint[3]; +// connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop +// connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp // moveable = true; // editable = true; @@ -89,23 +91,33 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern // myImageIcon = IconManager.imgic912; } + @Override + protected void createConnectingPoints() { + nbConnectingPoint = 3; + connectingPoint = new TGConnectingPoint[3]; + connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop + connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp + } + private void makeValueLoop() { valueLoop = "Loop " + value + " times"; } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (valueLoop.length() == 0) { makeValueLoop(); } - - int w = g.getFontMetrics().stringWidth(valueLoop); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + + // Issue #31 + final int w = checkWidth( g, valueLoop );//g.getFontMetrics().stringWidth(valueLoop); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateOfError > 0) { Color c = g.getColor(); @@ -125,12 +137,11 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); //g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); - g.drawString(valueLoop, x + (width - w) / 2 , y + textY); + drawSingleString(g,valueLoop, x + (width - w) / 2 , y + textY); - //info on loops - g.drawString(IN_LOOP, x+width+2, y+height/2); - g.drawString(EXIT_LOOP, x+width/2+2, y+height+10); - + //info on loops + drawSingleString(g,IN_LOOP, x+width+2, y+height/2); + drawSingleString(g,EXIT_LOOP, x+width/2+2, y+height+ scale( 10 ) ); } @Override diff --git a/src/main/java/ui/tmlad/TMLADNotifiedEvent.java b/src/main/java/ui/tmlad/TMLADNotifiedEvent.java index 174ae7f50293825ebb3c860cc224936ad96626a7..0250d106b9ed999bd40ab387bcf1242e37fa7274 100755 --- a/src/main/java/ui/tmlad/TMLADNotifiedEvent.java +++ b/src/main/java/ui/tmlad/TMLADNotifiedEvent.java @@ -59,11 +59,15 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue #69TGCWithoutInternalComponent */ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int linebreak = 10; - protected int textX1 = 2; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; + //protected int linebreak = 10; +// private int textX1; +// private double dtextX1; + protected String eventName = "evt"; protected String result = "x"; @@ -73,14 +77,15 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue public TMLADNotifiedEvent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = 30; moveable = true; editable = true; @@ -93,15 +98,16 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 3 * textX); - if ((w1 != width) && (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } - + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g ); // g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 3 * textX); +// if ((w1 != width) && (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateOfError > 0) { Color c = g.getColor(); @@ -142,8 +148,8 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue g.drawLine(x, y, x+linebreak, y+height/2); g.drawLine(x, y+height, x+linebreak, y+height/2); - g.drawString("evt", x+(width-w) / 2, y); - g.drawString(value, x + linebreak + textX1, y + textY); + drawSingleString(g,"evt", x+(width-w) / 2, y); + drawSingleString(g,value, x + linebreak + scale( 2 ), y + textY); } @Override @@ -263,6 +269,7 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue return TGComponentManager.CONNECTOR_TMLAD; } + @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } diff --git a/src/main/java/ui/tmlad/TMLADRandom.java b/src/main/java/ui/tmlad/TMLADRandom.java index e7cad443daf0ebad38d6d32a58a08c2d5ccd84cd..f022cabfd15969888dedc57d91cab5daa93926a4 100755 --- a/src/main/java/ui/tmlad/TMLADRandom.java +++ b/src/main/java/ui/tmlad/TMLADRandom.java @@ -59,10 +59,12 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent */implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; protected String valueRandom = ""; protected String variable; protected String minValue; @@ -74,14 +76,15 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG public TMLADRandom(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = scale( 30 ); moveable = true; editable = true; @@ -100,18 +103,19 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (valueRandom.length() == 0) { makeValue(); } - - int w = g.getFontMetrics().stringWidth(valueRandom); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + + // Issue #31 + final int w = checkWidth( g, valueRandom );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateOfError > 0) { Color c = g.getColor(); @@ -131,7 +135,7 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); //g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); - g.drawString(valueRandom, x + (width - w) / 2 , y + textY); + drawSingleString(g,valueRandom, x + (width - w) / 2 , y + textY); } @Override diff --git a/src/main/java/ui/tmlad/TMLADReadChannel.java b/src/main/java/ui/tmlad/TMLADReadChannel.java index 0e4ec24024cbc7581e7e30876891dc4e86e2189f..7ecda12ce803777efbe26913038785012c754b79 100755 --- a/src/main/java/ui/tmlad/TMLADReadChannel.java +++ b/src/main/java/ui/tmlad/TMLADReadChannel.java @@ -81,12 +81,14 @@ import ui.window.TabInfo; */ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private Map<String, String> latencyVals; - protected int lineLength = 5; - protected int textX = 5; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; protected int textX0 = 2; - protected int textY0 = 0; + //protected int textY0 = 0; protected int textY1 = 15; - protected int linebreak = 10; + // protected int linebreak = 10; protected int decSec = 4; @@ -113,14 +115,16 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # public TMLADReadChannel(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = scale( 30 ); + textY = 0; moveable = true; editable = true; @@ -143,14 +147,16 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width / 2 - w1 / 2, y); - width = w1; - //updateConnectingPoints(); - } + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width / 2 - w1 / 2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateOfError > 0) { Color c = g.getColor(); @@ -191,18 +197,18 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # g.drawLine(x, y, x + linebreak, y + height / 2); g.drawLine(x, y + height, x + linebreak, y + height / 2); if (isAttacker) { - g.drawString("attack", x + (width - w) / 2, y + textY0); + drawSingleString(g,"attack", x + (width - w) / 2, y + textY); // Issue #31 } else { - g.drawString("chl", x + (width - w) / 2, y + textY0); + drawSingleString(g,"chl", x + (width - w) / 2, y + textY); // Issue #31 } - g.drawString(value, x + linebreak + textX0, y + textY1); + drawSingleString(g,value, x + linebreak + scale( textX0 ), y + scale( textY1 ) ); // Issue #31 if (!securityContext.equals("")) { c = g.getColor(); if (!isEncForm){ g.setColor(Color.RED); } - g.drawString("sec:" + securityContext, x + 3 * width / 4, y + height + textY1 - decSec); + drawSingleString(g,"sec:" + securityContext, x + 3 * width / 4, y + height + textY1 - decSec); g.setColor(c); } drawReachabilityInformation(g); @@ -220,10 +226,16 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # int index = 1; for (String s : latencyVals.keySet()) { int w = g.getFontMetrics().stringWidth(s); - g.drawString(s, x - latencyX - w + 1, y - latencyY * index - 2); + + // Issue #31 + latencyX = scale( latencyX ); + latencyY = scale( latencyY ); + textHeight = scale( textHeight ); + + drawSingleString(g,s, x - latencyX - w + 1, y - latencyY * index - 2); g.drawRect(x - latencyX - w, y - latencyY * index - textHeight, w + 4, textHeight); g.drawLine(x, y, x - latencyX, y - latencyY * index); - g.drawString(latencyVals.get(s), x - latencyX / 2, y - latencyY * index / 2); + drawSingleString(g,latencyVals.get(s), x - latencyX / 2, y - latencyY * index / 2); index++; } } @@ -243,15 +255,15 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # return; } - GraphicLib.arrowWithLine(g, 1, 0, 10, x - 30, y - 3, x - 15, y - 3, true); - g.drawOval(x - 11, y - 10, 7, 9); + GraphicLib.arrowWithLine(g, 1, 0, 10, x - scale( 30 ), y - scale( 3 ), x - scale( 15 ), y - scale( 3 ), true); // Issue #31 + g.drawOval(x - scale( 11 ), y - scale( 10 ), scale( 7 ), scale( 9 )); // Issue #31 g.setColor(c1); - g.fillRect(x - 12, y - 7, 9, 7); + g.fillRect(x - scale( 12 ), y - scale( 7 ), scale( 9 ), scale( 7 )); // Issue #31 g.setColor(c); - g.drawRect(x - 12, y - 7, 9, 7); + g.drawRect(x - scale( 12 ), y - scale( 7 ), scale( 9 ), scale( 7 )); // Issue #31 if (reachabilityInformation == NOT_REACHABLE) { - g.drawLine(x - 14, y - 9, x - 1, y + 3); - g.drawLine(x - 14, y + 3, x - 1, y - 9); + g.drawLine(x - scale( 14 ), y - scale( 9 ), x - scale( 1 ), y + scale( 3 )); // Issue #31 + g.drawLine(x - scale( 14 ), y + scale( 3 ), x - scale( 1 ), y - scale( 9 )); // Issue #31 } } } diff --git a/src/main/java/ui/tmlad/TMLADReadRequestArg.java b/src/main/java/ui/tmlad/TMLADReadRequestArg.java index 89a6fd960122b7adea9cf65d68f1c0ddcbc10132..0559dce75517e9562fb6a4e1fd1e5de2a8015fdb 100755 --- a/src/main/java/ui/tmlad/TMLADReadRequestArg.java +++ b/src/main/java/ui/tmlad/TMLADReadRequestArg.java @@ -59,10 +59,12 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; int nParam = 5; protected String [] params = new String[nParam]; @@ -70,15 +72,18 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu public TMLADReadRequestArg(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 30; - height = 20; - minWidth = 30; - + + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp +// width = 30; +// height = 20; + minWidth = scale( 30 ); + + // Issue #31 + initScaling( 30, 20 ); for(int i=0; i<nParam; i++) { params[i] = ""; @@ -96,7 +101,7 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu public void makeValue() { boolean first = true; - value = "getReqArg ("; + value = "getReqArg("; for(int i=0; i<nParam; i++) { if (params[i].length() > 0) { if (!first) { @@ -151,18 +156,19 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (value.length() == 0) { makeValue(); } - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } Color c = g.getColor(); if (stateOfError > 0) { @@ -184,7 +190,7 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); //g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); - g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g,value, x + (width - w) / 2 , y + textY); } @Override diff --git a/src/main/java/ui/tmlad/TMLADSelectEvt.java b/src/main/java/ui/tmlad/TMLADSelectEvt.java index 693b65b5838544a27d216404b4c2d65f3c4afb4e..8f0ae61bdc78faa7dfa0b6051d00719a85bc6951 100755 --- a/src/main/java/ui/tmlad/TMLADSelectEvt.java +++ b/src/main/java/ui/tmlad/TMLADSelectEvt.java @@ -54,17 +54,35 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private int lineLength = 10; - private int lineOutLength = 25; + + // Issue #31 +// private int lineLength = 10; //private int textX1, textY1, textX2, textY2, textX3, textY3; +// private int lineOutLength;// = 25; + + protected static final int OUT_LINE_LENGTH = 25; protected int stateOfError = 0; // Not yet checked public TMLADSelectEvt(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 30; + // Issue #31 + nbConnectingPoint = 10; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, -OUT_LINE_LENGTH, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new TGConnectingPointTMLAD(this, OUT_LINE_LENGTH, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, OUT_LINE_LENGTH, false, true, 0.5, 1.0); + connectingPoint[4] = new TGConnectingPointTMLAD(this, -OUT_LINE_LENGTH, 0, false, true, 0.0, 0.5); + connectingPoint[5] = new TGConnectingPointTMLAD(this, OUT_LINE_LENGTH, 0, false, true, 1.0, 0.5); + connectingPoint[6] = new TGConnectingPointTMLAD(this, 0, OUT_LINE_LENGTH, false, true, 0.5, 1.0); + connectingPoint[7] = new TGConnectingPointTMLAD(this, -OUT_LINE_LENGTH, 0, false, true, 0.0, 0.5); + connectingPoint[8] = new TGConnectingPointTMLAD(this, OUT_LINE_LENGTH, 0, false, true, 1.0, 0.5); + connectingPoint[9] = new TGConnectingPointTMLAD(this, 0, OUT_LINE_LENGTH, false, true, 0.5, 1.0); +// width = 30; +// height = 30; + initScaling( 30, 30 ); /*textX1 = -lineOutLength; textY1 = height/2 - 5; textX2 = width + 5; @@ -72,19 +90,6 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 textX3 = width /2 + 5; textY3 = height + 15;*/ - nbConnectingPoint = 10; - connectingPoint = new TGConnectingPoint[nbConnectingPoint]; - connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[2] = new TGConnectingPointTMLAD(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, lineOutLength, false, true, 0.5, 1.0); - connectingPoint[4] = new TGConnectingPointTMLAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[5] = new TGConnectingPointTMLAD(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[6] = new TGConnectingPointTMLAD(this, 0, lineOutLength, false, true, 0.5, 1.0); - connectingPoint[7] = new TGConnectingPointTMLAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[8] = new TGConnectingPointTMLAD(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[9] = new TGConnectingPointTMLAD(this, 0, lineOutLength, false, true, 0.5, 1.0); - moveable = true; editable = false; removable = true; @@ -95,7 +100,7 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { @@ -117,13 +122,15 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 g.drawLine(x + width/2, y, x, y + height/2); g.drawLine(x + width, y + height/2, x + width/2, y + height); + // Issue #31 + final int scaledLineOutLength = scale( OUT_LINE_LENGTH ); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); - g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); - g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); - g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); + g.drawLine(x, y + height/2, x-scaledLineOutLength, y + height/2); // Issue #31 + g.drawLine(x + width, y + height/2, x+ width + scaledLineOutLength, y + height/2); // Issue #31 + g.drawLine(x+(width/2), y + height, x+(width/2), y + height + scaledLineOutLength); // Issue #31 - //g.drawString("select", x, y + height/2 - 5); - g.drawString("evt", x+7, y + height/2 + 3); + drawSingleString(g,"evt", x + scale( 5 ), y + height/2 + scale( 3 ) ); // Issue #31 } @Override @@ -132,15 +139,18 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 return this; } - if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { + // Issue #31 + final int scaledLineOutLength = scale( OUT_LINE_LENGTH ); + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + scaledLineOutLength, _x, _y)) < distanceSelected) { // Issue #31 return this; } - if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + scaledLineOutLength, y + height/2, _x, _y)) < distanceSelected) { // Issue #31 return this; } - if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-scaledLineOutLength, y + height/2, _x, _y)) < distanceSelected) { // Issue #31 return this; } diff --git a/src/main/java/ui/tmlad/TMLADSendEvent.java b/src/main/java/ui/tmlad/TMLADSendEvent.java index 9715bc12867b78b620b0a303d7daba12a4c615b3..03b0a2a3c022cb275c685193a2ffc64fa59a1b0b 100755 --- a/src/main/java/ui/tmlad/TMLADSendEvent.java +++ b/src/main/java/ui/tmlad/TMLADSendEvent.java @@ -76,13 +76,15 @@ import ui.window.JDialogMultiString; * @version 1.0 21/11/2005 */ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; - protected int linebreak = 10; - protected String eventName = "evt"; + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; +// protected int linebreak = 10; + + private String eventName = "evt"; int nParam = 5; protected String[] params = new String[nParam]; @@ -97,14 +99,15 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements public TMLADSendEvent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = scale( 30 ); for (int i = 0; i < nParam; i++) { params[i] = ""; @@ -117,19 +120,20 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements name = "send event"; makeValue(); - myImageIcon = IconManager.imgic904; } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width / 2 - w1 / 2, y); - width = w1; //updateConnectingPoints(); - } - + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ( w1 > width & !tdp.isScaled() ) { +// setCd(x - (w1 - width) / 2 , y); +// width = w1; //updateConnectingPoints(); +// } // Issue #69 if ( isEnabled() && stateOfError > 0) { @@ -150,7 +154,6 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements //g.drawRoundRect(x, y, width, height, arc, arc); Color c = g.getColor(); - // g.drawLine(x + (width / 2), y, x + (width / 2), y - lineLength); g.drawLine(x + (width / 2), y + height, x + (width / 2), y + lineLength + height); @@ -183,8 +186,8 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements g.drawLine(x + width - linebreak, y + height, x + width, y + height / 2); - g.drawString("evt", x + (width - w) / 2, y); - g.drawString(value, x + (width - w) / 2, y + textY); + drawSingleString(g,"evt", x + (width - w) / 2, y); + drawSingleString(g,value, x + (width - w) / 2, y + textY); drawReachabilityInformation(g); } @@ -214,7 +217,7 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements } } - // @Override + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -241,8 +244,8 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements } } - value += ")"; + value += ")"; } public String getEventName() { @@ -254,7 +257,6 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements makeValue(); } - public String getParamValue(int i) { return params[i]; } diff --git a/src/main/java/ui/tmlad/TMLADSendRequest.java b/src/main/java/ui/tmlad/TMLADSendRequest.java index 8bb62a0d90b6f78aca0583f55df0d55ce4de5240..f3adac6e147ef62a9f9f55434eedfeda9e032170 100755 --- a/src/main/java/ui/tmlad/TMLADSendRequest.java +++ b/src/main/java/ui/tmlad/TMLADSendRequest.java @@ -63,11 +63,13 @@ import java.util.List; * @author Ludovic APVRILLE */ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue #69TGCWithoutInternalComponent*/ implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; - protected int linebreak = 10; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; +// protected int linebreak = 10; protected String requestName = "req"; int nParam = 5; @@ -84,14 +86,18 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # public TMLADSendRequest(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = scale( 30 ); + + // Issue #31 + //textX = 5; for(int i=0; i<nParam; i++) { params[i] = ""; @@ -109,17 +115,20 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ( w1 > width & !tdp.isScaled() ) { +// setCd(x - (w1 - width) / 2 , y); +// width = w1; +// //updateConnectingPoints(); +// } //g.drawRoundRect(x, y, width, height, arc, arc); - if (stateOfError > 0) { + // Issue #69 + if ( isEnabled() && stateOfError > 0 ) { Color c = g.getColor(); switch(stateOfError) { case ErrorHighlight.OK: @@ -140,7 +149,12 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # int height1 = height; int width1 = width; Color c = g.getColor(); - g.setColor(ColorManager.TML_PORT_REQUEST); + + // Issue #69 + if ( isEnabled() ) { + g.setColor(ColorManager.TML_PORT_REQUEST); + } + g.drawLine(x1, y1, x1+width1-linebreak, y1); g.drawLine(x1, y1+height1, x1+width1-linebreak, y1+height1); g.drawLine(x1, y1, x1, y1+height1); @@ -156,8 +170,8 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # g.drawLine(x+width-linebreak, y, x+width, y+height/2); g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); - g.drawString("req", x+(width-w) / 2, y); - g.drawString(value, x + (width - w) / 2 , y + textY); + drawSingleString(g,"req", x+(width-w) / 2, y); + drawSingleString(g,value, x + (width - w) / 2 , y + textY); drawReachabilityInformation(g); } @@ -213,8 +227,8 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # } } - value += ")"; + value += ")"; } public String getRequestName() { diff --git a/src/main/java/ui/tmlad/TMLADSequence.java b/src/main/java/ui/tmlad/TMLADSequence.java index c29c9d814cfccf780f8bfe8d908b9a5b1c6cdb34..891e16975c0d8ef8fe38f6710200293151400294 100755 --- a/src/main/java/ui/tmlad/TMLADSequence.java +++ b/src/main/java/ui/tmlad/TMLADSequence.java @@ -54,6 +54,8 @@ import ui.ad.TADSequence; * @author Ludovic APVRILLE */ public class TMLADSequence extends TADSequence /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint { + + // Issue #31 // private int lineLength = 0; //private int textX, textY; diff --git a/src/main/java/ui/tmlad/TMLADStartState.java b/src/main/java/ui/tmlad/TMLADStartState.java index 0fa07b1319dba0045d4045d4c243ef2490af8de7..2489bc5d6d81fb2fd975c78d629048ac0c4e9f32 100755 --- a/src/main/java/ui/tmlad/TMLADStartState.java +++ b/src/main/java/ui/tmlad/TMLADStartState.java @@ -53,7 +53,9 @@ import ui.ad.TADStartState; * @author Ludovic APVRILLE */ public class TMLADStartState extends TADStartState /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment{ - private int lineLength = 5; + + // Issue #31 + //private int lineLength = 5; public TMLADStartState(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); diff --git a/src/main/java/ui/tmlad/TMLADUnorderedSequence.java b/src/main/java/ui/tmlad/TMLADUnorderedSequence.java index 0df1f8d927889b4f42d3fbfa40adae92cadd6289..eba2d9ff369e5a712982f701dece6340b639718b 100755 --- a/src/main/java/ui/tmlad/TMLADUnorderedSequence.java +++ b/src/main/java/ui/tmlad/TMLADUnorderedSequence.java @@ -54,6 +54,7 @@ import ui.ad.TADSequence; * @author Ludovic APVRILLE */ public class TMLADUnorderedSequence extends TADSequence/* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint { + // private int lineLength = 0; // private int textX, textY; diff --git a/src/main/java/ui/tmlad/TMLADWaitEvent.java b/src/main/java/ui/tmlad/TMLADWaitEvent.java index ae17151b2df4d2d5f186a09c4251719384ba35a8..f4fe2504e16c26a08e382701f83698c4d711998a 100755 --- a/src/main/java/ui/tmlad/TMLADWaitEvent.java +++ b/src/main/java/ui/tmlad/TMLADWaitEvent.java @@ -63,11 +63,13 @@ import java.util.List; * @author Ludovic APVRILLE */ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int linebreak = 10; - protected int textX1 = 2; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; + // protected int linebreak = 10; + //protected int textX1 = 2; protected String eventName = "evt"; int nParam = 5; @@ -84,14 +86,15 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 public TMLADWaitEvent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = scale( 30 ); for(int i=0; i<nParam; i++) { params[i] = ""; @@ -109,14 +112,16 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } // Issue #69 if ( isEnabled() && stateOfError > 0) { @@ -163,8 +168,8 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 g.drawLine(x, y, x+linebreak, y+height/2); g.drawLine(x, y+height, x+linebreak, y+height/2); - g.drawString("evt", x+(width-w) / 2, y); - g.drawString(value, x + linebreak + textX1, y + textY); + drawSingleString(g,"evt", x+(width-w) / 2, y); + drawSingleString(g,value, x + linebreak + scale( 2 ), y + textY); drawReachabilityInformation(g); } diff --git a/src/main/java/ui/tmlad/TMLADWriteChannel.java b/src/main/java/ui/tmlad/TMLADWriteChannel.java index f38f4dedba2a5f34977fa37aef4c0b706938c9b3..7f5e2eb8a7a32bc7f69679bbb24dbdd048ba9168 100755 --- a/src/main/java/ui/tmlad/TMLADWriteChannel.java +++ b/src/main/java/ui/tmlad/TMLADWriteChannel.java @@ -81,12 +81,14 @@ import ui.window.TabInfo; * @version 1.0 17/11/2005 */ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; - protected int linebreak = 10; - protected int decSec = 4; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; +// protected int linebreak = 10; + //protected int decSec = 4; private Map<String, String> latencyVals; @@ -113,15 +115,15 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue public TMLADWriteChannel(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; - - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); +// width = 30; +// height = 20; + initScaling( 30, 20 ); + minWidth = scale( 30 ); moveable = true; editable = true; @@ -139,14 +141,16 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue } @Override - public void internalDrawing(Graphics g) { - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width / 2 - w1 / 2, y); - width = w1; - //updateConnectingPoints(); - } + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width / 2 - w1 / 2, y); +// width = w1; +// //updateConnectingPoints(); +// } //g.drawRoundRect(x, y, width, height, arc, arc); if (stateOfError > 0) { @@ -187,17 +191,17 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue g.drawLine(x + width - linebreak, y, x + width, y + height / 2); g.drawLine(x + width - linebreak, y + height, x + width, y + height / 2); if (isAttacker) { - g.drawString("attack", x + (width - w) / 2, y); + drawSingleString(g,"attack", x + (width - w) / 2, y); } else { - g.drawString("chl", x + (width - w) / 2, y); + drawSingleString(g,"chl", x + (width - w) / 2, y); } - g.drawString(value, x + (width - w) / 2, y + textY); + drawSingleString(g,value, x + (width - w) / 2, y + textY); if (!securityContext.equals("")) { c = g.getColor(); if (!isEncForm){ g.setColor(Color.RED); } - g.drawString("sec:" + securityContext, x + 3 * width / 4, y + height + textY - decSec); + drawSingleString(g,"sec:" + securityContext, x + 3 * width / 4, y + height + textY - scale( 4 ) ); g.setColor(c); } @@ -209,6 +213,7 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue drawLatencyInformation(g); } } + drawReachabilityInformation(g); } @@ -216,21 +221,20 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue int index = 1; for (String s : latencyVals.keySet()) { int w = g.getFontMetrics().stringWidth(s); - g.drawString(s, x - latencyX - w + 1, y - latencyY * index - 2); + drawSingleString(g,s, x - latencyX - w + 1, y - latencyY * index - 2); g.drawRect(x - latencyX - w, y - latencyY * index - textHeight, w + 4, textHeight); g.drawLine(x, y, x - latencyX, y - latencyY * index); - g.drawString(latencyVals.get(s), x - latencyX / 2, y - latencyY * index / 2); + drawSingleString(g,latencyVals.get(s), x - latencyX / 2, y - latencyY * index / 2); index++; } } - public void addLatency(String name, String num) { - latencyVals.put(name, num); - } +// public void addLatency(String name, String num) { +// latencyVals.put(name, num); +// } private void drawReachabilityInformation(Graphics g) { if (reachabilityInformation > 0) { - Color c = g.getColor(); Color c1; switch (reachabilityInformation) { diff --git a/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java b/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java index 7319744e9592d0b0f863cff18d59d06ae0bd2947..3edc345492d2c47f2c698d4fd51bd434500bc1e0 100755 --- a/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java +++ b/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java @@ -85,9 +85,9 @@ public class TMLActivityDiagramPanel extends TDiagramPanel { public boolean actionOnRemove(TGComponent tgc) { return false; } - + public String getXMLHead() { - return "<TMLActivityDiagramPanel name=\"" + name + "\"" + sizeParam() + " >"; + return "<TMLActivityDiagramPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } public String getXMLTail() { diff --git a/src/main/java/ui/tmlad/TMLActivityDiagramToolBar.java b/src/main/java/ui/tmlad/TMLActivityDiagramToolBar.java index 72d625d857802e5abbbb82a17fe2ce67e9ee804d..f3cb3c410213708c0aaa6e7677325fed733f3686 100755 --- a/src/main/java/ui/tmlad/TMLActivityDiagramToolBar.java +++ b/src/main/java/ui/tmlad/TMLActivityDiagramToolBar.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlad; import ui.MainGUI; @@ -47,9 +44,6 @@ import ui.TToolBar; import javax.swing.*; -//import java.awt.*; -//import java.awt.event.*; - /** * Class TMLActivityDiagramToolBar * Toolbar associated with TML activity diagrams @@ -64,6 +58,7 @@ public class TMLActivityDiagramToolBar extends TToolBar { super(_mgui); } + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.TMLAD_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); @@ -101,9 +96,13 @@ public class TMLActivityDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_TOGGLE_INTERNAL_COMMENT].setEnabled(b); mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled( b ); + mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled( b ); + mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); diff --git a/src/main/java/ui/tmlcd/TGConnectingPointTMLAssociation.java b/src/main/java/ui/tmlcd/TGConnectingPointTMLAssociation.java index bea46c0d6c8ff995ad87d423fb62363816395c7b..6bd3e8bc2cb970e82fe1b460c6e99cec869a5f73 100755 --- a/src/main/java/ui/tmlcd/TGConnectingPointTMLAssociation.java +++ b/src/main/java/ui/tmlcd/TGConnectingPointTMLAssociation.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointTwoFathers; @@ -54,14 +49,14 @@ import ui.TGConnectingPointTwoFathers; * @version 1.0 28/10/2005 * @author Ludovic APVRILLE */ -public class TGConnectingPointTMLAssociation extends TGConnectingPointTwoFathers{ +public class TGConnectingPointTMLAssociation extends TGConnectingPointTwoFathers { public TGConnectingPointTMLAssociation(CDElement _container1, CDElement _container2, int _x, int _y, boolean _in, boolean _out) { super(_container1, _container2, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_TML_COMPOSITION_OPERATOR; } - } diff --git a/src/main/java/ui/tmlcd/TGConnectingPointTMLCompositionOperator.java b/src/main/java/ui/tmlcd/TGConnectingPointTMLCompositionOperator.java index 08467f809d5ca3a50912524539bf4cce98bf4a51..ee94b9d0bee08ed920e54a6422c6369806226dc5 100755 --- a/src/main/java/ui/tmlcd/TGConnectingPointTMLCompositionOperator.java +++ b/src/main/java/ui/tmlcd/TGConnectingPointTMLCompositionOperator.java @@ -36,13 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcd; -//import java.awt.*; - import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPoint; @@ -54,21 +49,14 @@ import ui.TGConnectingPoint; * @version 1.0 28/10/2005 * @author Ludovic APVRILLE */ -public class TGConnectingPointTMLCompositionOperator extends TGConnectingPoint{ +public class TGConnectingPointTMLCompositionOperator extends TGConnectingPoint { public TGConnectingPointTMLCompositionOperator(CDElement _container1, int _x, int _y, boolean _in, boolean _out) { super(_container1, _x, _y, _in, _out); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_TML_COMPOSITION_OPERATOR; } - } - - - - - - - diff --git a/src/main/java/ui/tmlcd/TGConnectorTMLAssociationNav.java b/src/main/java/ui/tmlcd/TGConnectorTMLAssociationNav.java index 7bddc3d32128ffb4c4b5982acd5b53ac45f28013..e5aebcebb528c0be0ee24df4ffe748321aa3c410 100755 --- a/src/main/java/ui/tmlcd/TGConnectorTMLAssociationNav.java +++ b/src/main/java/ui/tmlcd/TGConnectorTMLAssociationNav.java @@ -84,26 +84,27 @@ public class TGConnectorTMLAssociationNav extends TGConnector { myImageIcon = IconManager.imgic106; } + @Override public void internalDrawing(Graphics g) { TMLTaskDiagramPanel tmltdp = (TMLTaskDiagramPanel)tdp; if (!tmltdp.areAllVisible()) { if (!tmltdp.connectedToVisible(this)) return; } - super.internalDrawing(g); +// super.internalDrawing(g); super.internalDrawing(g); } + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ GraphicLib.arrowWithLine(g, 1, 1, arrowLength, x1, y1, x2, y2, false); } + @Override public int getType() { return TGComponentManager.CONNECTOR_TML_ASSOCIATION_NAV; } - - public void setP1(TGConnectingPoint p) { p1 = p; if (nbConnectingPoint > 0) { @@ -118,10 +119,7 @@ public class TGConnectorTMLAssociationNav extends TGConnector { } } - public void pointHasBeenRemoved(TGCPointOfConnector tgc) { - - int i, index = 0; TGConnectingPointTwoFathers cp1, cp2; @@ -202,6 +200,7 @@ public class TGConnectorTMLAssociationNav extends TGConnector { return null; } + @Override public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem reverse = new JMenuItem("Reverse"); @@ -209,14 +208,14 @@ public class TGConnectorTMLAssociationNav extends TGConnector { componentMenu.add(reverse); } + @Override public boolean eventOnPopup(ActionEvent e) { reverse(); return true; } + @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TML_COMPOSITION_OPERATOR; + return TGComponentManager.CONNECTOR_TML_COMPOSITION_OPERATOR; } - - } diff --git a/src/main/java/ui/tmlcd/TGConnectorTMLCompositionOperator.java b/src/main/java/ui/tmlcd/TGConnectorTMLCompositionOperator.java index 7c1b7126ccd071d636a1a58d957411a5412db271..e4b8a4f4fef58d7faf8bd6bf4516b897cdc7dcf0 100755 --- a/src/main/java/ui/tmlcd/TGConnectorTMLCompositionOperator.java +++ b/src/main/java/ui/tmlcd/TGConnectorTMLCompositionOperator.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcd; import myutil.GraphicLib; @@ -48,8 +45,6 @@ import ui.util.IconManager; import java.awt.*; import java.util.Vector; -//import java.awt.geom.*; - /** * Class TGConnectorTMLCompositionOperator * Connects an association to a TML composition operator. To be used in TML task diagram. @@ -64,25 +59,29 @@ public class TGConnectorTMLCompositionOperator extends TGConnector { myImageIcon = IconManager.imgic108; } + @Override public void internalDrawing(Graphics g) { TMLTaskDiagramPanel tmltdp = (TMLTaskDiagramPanel)tdp; if (!tmltdp.areAllVisible()) { if (!tmltdp.connectedToVisible(this)) return; } + super.internalDrawing(g); } + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ GraphicLib.dashedLine(g, x1, y1, x2, y2); } + @Override protected void drawMiddleSegment(Graphics g, int x1, int y1, int x2, int y2) { GraphicLib.dashedLine(g, x1, y1, x2, y2); } + @Override public int getType() { return TGComponentManager.CONNECTOR_TML_COMPOSITION_OPERATOR; } - } diff --git a/src/main/java/ui/tmlcd/TMLAttributeBox.java b/src/main/java/ui/tmlcd/TMLAttributeBox.java index 63f5d190843e5fa181ad493c5fe0bcdaa2a91b8e..0be11393e1d6f7044b6ea0688d072fca1b8054a5 100755 --- a/src/main/java/ui/tmlcd/TMLAttributeBox.java +++ b/src/main/java/ui/tmlcd/TMLAttributeBox.java @@ -164,10 +164,10 @@ public class TMLAttributeBox extends TGCWithoutInternalComponent { TAttribute a; for(int i=0; i<myAttributes.size(); i++) { a = myAttributes.get (i); - g.drawString(a.toString(), x + textX, y + textY + i* h); + drawSingleString(g,a.toString(), x + textX, y + textY + i* h); } } else if (myAttributes.size() >0) { - g.drawString("...", x + textX, y + textY); + drawSingleString(g,"...", x + textX, y + textY); } } diff --git a/src/main/java/ui/tmlcd/TMLChannelOperator.java b/src/main/java/ui/tmlcd/TMLChannelOperator.java index 671d105828d60b1437a4394542b4b2d5caf1c134..260782fe3435543c3ca722730b4091c6c786622a 100755 --- a/src/main/java/ui/tmlcd/TMLChannelOperator.java +++ b/src/main/java/ui/tmlcd/TMLChannelOperator.java @@ -81,7 +81,7 @@ public class TMLChannelOperator extends TMLCompositionOperator { //g.drawImage(IconManager.img8, x + width - 20, y + 3, ColorManager.COMPOSITION_OPERATOR, null); ColorManager.setColor(g, getState(), 0); g.setFont((g.getFont()).deriveFont(Font.BOLD)); - g.drawString(value, x + textX, y + textY); + drawSingleString(g,value, x + textX, y + textY); g.setFont((g.getFont()).deriveFont(Font.PLAIN)); } } diff --git a/src/main/java/ui/tmlcd/TMLChannelProperties.java b/src/main/java/ui/tmlcd/TMLChannelProperties.java index 798d6c28b717d7a8b3bd9f06f8dd823805f2cb41..f0cf78e933341f1f7730e2c86720bf86b6c029fc 100755 --- a/src/main/java/ui/tmlcd/TMLChannelProperties.java +++ b/src/main/java/ui/tmlcd/TMLChannelProperties.java @@ -100,7 +100,7 @@ public class TMLChannelProperties extends TGCWithoutInternalComponent { ColorManager.setColor(g, getState(), 0); // h = g.getFontMetrics().getHeight(); - g.drawString(value, x, y + h); + drawSingleString(g,value, x, y + h); if (!tdp.isScaled()) { width = g.getFontMetrics().stringWidth(value); diff --git a/src/main/java/ui/tmlcd/TMLCompositionOperator.java b/src/main/java/ui/tmlcd/TMLCompositionOperator.java index 22a7586cb62fe48d67e1ec209a29d30d2d171724..3bb1d9d48efa21f390767eb83563352dbdd0e7f7 100755 --- a/src/main/java/ui/tmlcd/TMLCompositionOperator.java +++ b/src/main/java/ui/tmlcd/TMLCompositionOperator.java @@ -80,6 +80,7 @@ public abstract class TMLCompositionOperator extends TGCWithInternalComponent { actionOnAdd(); } + @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); //g.setColor(ColorManager.COMPOSITION_OPERATOR); @@ -90,10 +91,10 @@ public abstract class TMLCompositionOperator extends TGCWithInternalComponent { g.setFont((g.getFont()).deriveFont(Font.BOLD)); g.drawString(value, x + textX, y + textY); g.setFont((g.getFont()).deriveFont(Font.PLAIN)); - } - public TGComponent isOnOnlyMe(int x1, int y1) { + @Override + public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; } @@ -101,13 +102,6 @@ public abstract class TMLCompositionOperator extends TGCWithInternalComponent { } public abstract boolean isToggledVisible(); - public abstract Color getMyColor(); - + + public abstract Color getMyColor(); } - - - - - - - diff --git a/src/main/java/ui/tmlcd/TMLEventOperator.java b/src/main/java/ui/tmlcd/TMLEventOperator.java index 5f8a11bc9f4eef699f436964d3c4d2ea11d15e89..92e6463eb2d753843dc1dcbc697595897694f239 100755 --- a/src/main/java/ui/tmlcd/TMLEventOperator.java +++ b/src/main/java/ui/tmlcd/TMLEventOperator.java @@ -73,6 +73,7 @@ public class TMLEventOperator extends TMLCompositionOperator { myImageIcon = IconManager.imgic800; } + @Override public void internalDrawing(Graphics g) { if (((TMLTaskDiagramPanel)(tdp)).areEventsVisible()) { g.drawRect(x, y, width, height); @@ -81,7 +82,7 @@ public class TMLEventOperator extends TMLCompositionOperator { //g.drawImage(IconManager.img8, x + width - 20, y + 3, ColorManager.COMPOSITION_OPERATOR, null); ColorManager.setColor(g, getState(), 0); g.setFont((g.getFont()).deriveFont(Font.BOLD)); - g.drawString(value, x + textX, y + textY); + drawSingleString(g,value, x + textX, y + textY); g.setFont((g.getFont()).deriveFont(Font.PLAIN)); } } @@ -122,6 +123,7 @@ public class TMLEventOperator extends TMLCompositionOperator { return ColorManager.TML_PORT_EVENT; } + @Override public int getType() { return TGComponentManager.TMLTD_EVENT_OPERATOR; } diff --git a/src/main/java/ui/tmlcd/TMLEventProperties.java b/src/main/java/ui/tmlcd/TMLEventProperties.java index ceda021d7dac1a75c8f28ef04337d3598ed96b2e..dee00aad3b5bc58066ce142cc25f849de5afdfdd 100755 --- a/src/main/java/ui/tmlcd/TMLEventProperties.java +++ b/src/main/java/ui/tmlcd/TMLEventProperties.java @@ -96,7 +96,7 @@ public class TMLEventProperties extends TGCWithoutInternalComponent { ColorManager.setColor(g, getState(), 0); // h = g.getFontMetrics().getHeight(); - g.drawString(valueOCL, x, y + h); + drawSingleString(g,valueOCL, x, y + h); if (!tdp.isScaled()) { width = g.getFontMetrics().stringWidth(valueOCL); diff --git a/src/main/java/ui/tmlcd/TMLOperationBox.java b/src/main/java/ui/tmlcd/TMLOperationBox.java index 8f157b7dcefee9a4d549e220ca0751e94ed08f0c..0f804a3792bffe597619fb84659ee1f08072d52b 100755 --- a/src/main/java/ui/tmlcd/TMLOperationBox.java +++ b/src/main/java/ui/tmlcd/TMLOperationBox.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcd; import myutil.GraphicLib; @@ -86,16 +83,18 @@ public class TMLOperationBox extends TGCWithoutInternalComponent { myImageIcon = IconManager.imgic122; } - public void internalDrawing(Graphics g) { + @Override + protected void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.setColor(ColorManager.OPERATION_BOX); g.fillRect(x+1, y+1, width-1, height-1); ColorManager.setColor(g, getState(), 0); if (value.length() > 0) { - g.drawString(value, x + textX, y + textY); + drawSingleString(g,value, x + textX, y + textY); } } + @Override public boolean editOndoubleClick(JFrame frame) { oldValue = value; String text = getName() + ": "; @@ -112,7 +111,7 @@ public class TMLOperationBox extends TGCWithoutInternalComponent { return false; } - + @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -120,15 +119,8 @@ public class TMLOperationBox extends TGCWithoutInternalComponent { return null; } + @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TML_ASSOCIATION_NAV; } - } - - - - - - - diff --git a/src/main/java/ui/tmlcd/TMLRequestOperator.java b/src/main/java/ui/tmlcd/TMLRequestOperator.java index 851cb6de4ce50f3ea29139aadbd35067e0ed4e28..07c6305de9993151b36bded18f0f887042d76c65 100755 --- a/src/main/java/ui/tmlcd/TMLRequestOperator.java +++ b/src/main/java/ui/tmlcd/TMLRequestOperator.java @@ -81,7 +81,7 @@ public class TMLRequestOperator extends TMLCompositionOperator { //g.drawImage(IconManager.img8, x + width - 20, y + 3, ColorManager.COMPOSITION_OPERATOR, null); ColorManager.setColor(g, getState(), 0); g.setFont((g.getFont()).deriveFont(Font.BOLD)); - g.drawString(value, x + textX, y + textY); + drawSingleString(g,value, x + textX, y + textY); g.setFont((g.getFont()).deriveFont(Font.PLAIN)); } } diff --git a/src/main/java/ui/tmlcd/TMLRequestProperties.java b/src/main/java/ui/tmlcd/TMLRequestProperties.java index 2dcff2167df8b09a0485ba2358da15a04b938911..f026dbb026a8be3c9868b851bc85571b3cc0cab1 100755 --- a/src/main/java/ui/tmlcd/TMLRequestProperties.java +++ b/src/main/java/ui/tmlcd/TMLRequestProperties.java @@ -94,7 +94,7 @@ public class TMLRequestProperties extends TGCWithoutInternalComponent { ColorManager.setColor(g, getState(), 0); // h = g.getFontMetrics().getHeight(); - g.drawString(valueOCL, x, y + h); + drawSingleString(g,valueOCL, x, y + h); if (!tdp.isScaled()) { width = g.getFontMetrics().stringWidth(valueOCL); diff --git a/src/main/java/ui/tmlcd/TMLTaskDiagramPanel.java b/src/main/java/ui/tmlcd/TMLTaskDiagramPanel.java index 32dda85a9e3abdded249001e7815dd9b2ece6360..88d96a9043343e65bd09e312e5a8fa196a132bc6 100755 --- a/src/main/java/ui/tmlcd/TMLTaskDiagramPanel.java +++ b/src/main/java/ui/tmlcd/TMLTaskDiagramPanel.java @@ -36,16 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcd; - import org.w3c.dom.Element; import ui.*; import ui.tmldd.TMLArchiDiagramPanel; +import java.util.List; import java.util.ArrayList; import java.util.Iterator; @@ -65,6 +62,7 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { // if (tgc instanceof TMLTaskOperator) { @@ -79,6 +77,7 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return false; } + @Override public boolean actionOnAdd(TGComponent tgc) { // if (tgc instanceof TMLTaskOperator) { @@ -96,6 +95,7 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { if (tgc instanceof TMLTaskOperator) { TMLTaskOperator tgcc = (TMLTaskOperator)(tgc); @@ -106,6 +106,7 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return false; } + @Override public boolean actionOnValueChanged(TGComponent tgc) { if (tgc instanceof TMLTaskOperator) { return actionOnDoubleClick(tgc); @@ -113,37 +114,41 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return false; } + @Override public String getXMLHead() { return "<TMLTaskDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() +" >"; } + @Override public String getXMLTail() { return "</TMLTaskDiagramPanel>"; } + @Override public String getXMLSelectedHead() { return "<TMLTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</TMLTaskDiagramPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<TMLTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</TMLTaskDiagramPanelCopy>"; } - - + @Override public boolean areAttributesVisible() { return attributesVisible; } - public boolean areChannelVisible() { return synchroVisible; } @@ -152,7 +157,6 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { attributesVisible = b; } - public void setChannelVisible(boolean b) { channelVisible = b; } @@ -366,13 +370,13 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { } } - public ArrayList<String> getAllTMLTaskNames(String _topname) { + public List<String> getAllTMLTaskNames(String _topname) { TGComponent tgc; - Iterator iterator = componentList.listIterator(); - ArrayList<String> list = new ArrayList<String>(); + Iterator<TGComponent> iterator = componentList.listIterator(); + List<String> list = new ArrayList<String>(); while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); + tgc = iterator.next(); if (tgc instanceof TMLTaskOperator) { list.add(_topname + "::" + ((TMLTaskOperator)tgc).getTaskName()); } @@ -381,15 +385,15 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return list; } - public ArrayList<String> getAllTMLCommunicationNames(String _topname) { + public List<String> getAllTMLCommunicationNames(String _topname) { TGComponent tgc; - Iterator iterator = componentList.listIterator(); - ArrayList<String> list = new ArrayList<String>(); + Iterator<TGComponent> iterator = componentList.listIterator(); + List<String> list = new ArrayList<String>(); String name = ""; String type = ""; while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); + tgc = iterator.next(); if (tgc instanceof TMLCompositionOperator) { if (tgc instanceof TMLEventOperator) { name = ((TMLEventOperator)tgc).getEventName(); @@ -411,19 +415,19 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return list; } - public ArrayList<String> getAllTMLChannelNames( String _topname ) { + public List<String> getAllTMLChannelNames( String _topname ) { TGComponent tgc; - Iterator iterator = componentList.listIterator(); - ArrayList<String> list = new ArrayList<String>(); + Iterator<TGComponent> iterator = componentList.listIterator(); + List<String> list = new ArrayList<String>(); String name = ""; - String type = ""; + //String type = ""; while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); + tgc = iterator.next(); if (tgc instanceof TMLCompositionOperator) { if (tgc instanceof TMLChannelOperator) { name = ((TMLChannelOperator)tgc).getChannelName(); - type = "Channel"; + // type = "Channel"; } list.add(_topname + "::" + name ); } @@ -432,30 +436,33 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return list; } - public ArrayList<String> getAllTMLEventNames( String _topname ) { + public List<String> getAllTMLEventNames( String _topname ) { TGComponent tgc; - Iterator iterator = componentList.listIterator(); - ArrayList<String> list = new ArrayList<String>(); + Iterator<TGComponent> iterator = componentList.listIterator(); + List<String> list = new ArrayList<String>(); String name = ""; String type = ""; while( iterator.hasNext() ) { - tgc = (TGComponent)( iterator.next() ); - if (tgc instanceof TMLCompositionOperator) { - if (tgc instanceof TMLEventOperator) { - name = ((TMLEventOperator)tgc).getEventName(); - type = "Event"; - } - list.add( _topname + "::" + name + " (" + type + ")" ); - } + tgc = iterator.next(); + + if (tgc instanceof TMLCompositionOperator) { + if (tgc instanceof TMLEventOperator) { + name = ((TMLEventOperator)tgc).getEventName(); + type = "Event"; + } + + list.add( _topname + "::" + name + " (" + type + ")" ); + } } - return list; + + return list; } - public ArrayList<String> getAllNonMappedTMLTaskNames(String _topName, TMLArchiDiagramPanel _tadp, boolean ref, String _name) { + public List<String> getAllNonMappedTMLTaskNames(String _topName, TMLArchiDiagramPanel _tadp, boolean ref, String _name) { TGComponent tgc; - Iterator iterator = componentList.listIterator(); - ArrayList<String> list = new ArrayList<String>(); + Iterator<TGComponent> iterator = componentList.listIterator(); + List<String> list = new ArrayList<String>(); String name; while(iterator.hasNext()) { @@ -477,8 +484,8 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { public TMLTaskOperator getTaskByName(String _name) { TGComponent tgc; - Iterator iterator = componentList.listIterator(); - ArrayList<String> list = new ArrayList<String>(); + Iterator<TGComponent> iterator = componentList.listIterator(); + //List<String> list = new ArrayList<String>(); while(iterator.hasNext()) { tgc = (TGComponent)(iterator.next()); @@ -491,5 +498,4 @@ public class TMLTaskDiagramPanel extends TDiagramPanel { return null; } - } diff --git a/src/main/java/ui/tmlcd/TMLTaskDiagramToolBar.java b/src/main/java/ui/tmlcd/TMLTaskDiagramToolBar.java index 759869c4f719d85e112754ea96436141b8b0ac37..ca8be4973e95eb1d67f8135a5a6492399a16c3c2 100755 --- a/src/main/java/ui/tmlcd/TMLTaskDiagramToolBar.java +++ b/src/main/java/ui/tmlcd/TMLTaskDiagramToolBar.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcd; import ui.MainGUI; @@ -59,7 +56,6 @@ public class TMLTaskDiagramToolBar extends TToolBar { public TMLTaskDiagramToolBar(MainGUI _mgui) { super(_mgui); - } protected void setActive(boolean b) { @@ -76,9 +72,16 @@ public class TMLTaskDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ACT_TOGGLE_REQUESTS].setEnabled(b); mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); + +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); @@ -123,27 +126,20 @@ public class TMLTaskDiagramToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.TMLTD_REQ]); button.addMouseListener(mgui.mouseHandler); - this.addSeparator(); + this.addSeparator(); - button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_CHANNELS]); - button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_CHANNELS]); + button.addMouseListener(mgui.mouseHandler); - button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_EVENTS]); - button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_EVENTS]); + button.addMouseListener(mgui.mouseHandler); - button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_REQUESTS]); - button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_REQUESTS]); + button.addMouseListener(mgui.mouseHandler); - this.addSeparator(); + this.addSeparator(); button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]); button.addMouseListener(mgui.mouseHandler); - } - } // Class - - - - - diff --git a/src/main/java/ui/tmlcd/TMLTaskOperator.java b/src/main/java/ui/tmlcd/TMLTaskOperator.java index 57d3134b734628fa457b2b3fe9b9a697dbbff864..7cd165bbf1a6eda678c077b7da5f767c0ad240a5 100755 --- a/src/main/java/ui/tmlcd/TMLTaskOperator.java +++ b/src/main/java/ui/tmlcd/TMLTaskOperator.java @@ -183,7 +183,7 @@ public class TMLTaskOperator extends TGCWithInternalComponent implements TMLTask return w; }*/ - + @Override public void internalDrawing(Graphics g) { if (!tdp.isScaled()) { graphics = g; @@ -199,17 +199,18 @@ public class TMLTaskOperator extends TGCWithInternalComponent implements TMLTask // ColorManager.setColor(g, getState(), 0); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + textX, y + textY); + drawSingleString(g,value, x + textX, y + textY); g.setFont(f); if (exit) { g.setFont(f.deriveFont((float)exitFontSize)); int w = g.getFontMetrics().stringWidth(EXIT_STRING); - g.drawString(EXIT_STRING, x + width - w - 5, y + textY + exitFontSize); + drawSingleString(g,EXIT_STRING, x + width - w - 5, y + textY + exitFontSize); g.setFont(f); } } + @Override public boolean editOndoubleClick(JFrame frame) { oldValue = value; diff --git a/src/main/java/ui/tmlcompd/TMLCChannelFacility.java b/src/main/java/ui/tmlcompd/TMLCChannelFacility.java index 5f537a0621759c1427d8b652bf6dc183b19ffcc6..a548e74cfeea59d5ce65ab0136252ad5d0bb0a83 100755 --- a/src/main/java/ui/tmlcompd/TMLCChannelFacility.java +++ b/src/main/java/ui/tmlcompd/TMLCChannelFacility.java @@ -74,6 +74,7 @@ public abstract class TMLCChannelFacility extends TGCScalableWithInternalCompone userResizable = false; } + @Override public TGComponent isOnOnlyMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -157,7 +158,8 @@ public abstract class TMLCChannelFacility extends TGCScalableWithInternalCompone conflictMessage = _msg; calculatePortColor(); } - + + @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_PORT_TMLC; } diff --git a/src/main/java/ui/tmlcompd/TMLCChannelOutPort.java b/src/main/java/ui/tmlcompd/TMLCChannelOutPort.java index c01174e4061e608bc75775a832fdcae1f3f8d78e..be40949c5d671695b7aa289d657aac2fc0ce5bfe 100755 --- a/src/main/java/ui/tmlcompd/TMLCChannelOutPort.java +++ b/src/main/java/ui/tmlcompd/TMLCChannelOutPort.java @@ -64,11 +64,12 @@ public class TMLCChannelOutPort extends TMLCPrimitivePort { //myImageIcon = IconManager.imgic700; } - + @Override public void drawParticularity(Graphics g) { } - + + @Override public int getType() { return TGComponentManager.TMLCTD_COPORT; } diff --git a/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java b/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java index 406f8523882bbc3a7366ce50d541a6604393ca2b..b7fb28a96f6e7f366ee135606bf8bc1b057f639b 100755 --- a/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java +++ b/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java @@ -62,10 +62,10 @@ import java.util.ListIterator; * @author Ludovic APVRILLE */ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, HiddenInternalComponents { - private int maxFontSize = 20; - private int minFontSize = 4; +// private int maxFontSize = 20; +// private int minFontSize = 4; private int currentFontSize = -1; - private boolean displayText = true; +// private boolean displayText = true; // private int spacePt = 3; private Color myColor; private int iconSize = 17; @@ -113,93 +113,124 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } @Override - public void internalDrawing(Graphics g) { - int w; - int c; - Font f = g.getFont(); - Font fold = f; - //FontMetrics fm = g.getFontMetrics(); - - if (myColor == null) { + public void internalDrawing(Graphics g) + { + //Color choosing + if (myColor == null) { if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) { myColor = Color.white; } else { - myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200); - } - } - - 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)) { - f = f.deriveFont((float)maxCurrentFontSize); - g.setFont(f); - w = g.getFontMetrics().stringWidth(value); - //w = fm.stringWidth(value); - c = width - iconSize - (2 * textX); - // - if (w < c) { - break; - } - maxCurrentFontSize --; - + myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200); } - currentFontSize = maxCurrentFontSize; - - displayText = currentFontSize >= minFontSize; } - - // Zoom is assumed to be computed - Color col = g.getColor(); + + //Rectangle & filling + Color col = 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(col); } - - // 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); - } else { - g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); - } - } - - g.setFont(fold); - - // Icon - if ((width>30) && (height > (iconSize + 2*textX))) { - g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); - } + + //Strings + Font f = g.getFont(); + currentFontSize = f.getSize(); + if (canTextGoInTheBox(g, currentFontSize, value, iconSize + textX)) + drawSingleString(g, value, getCenter(g, value), y + currentFontSize + textX); + + //Icon + drawImageWithCheck(g, IconManager.imgic1200.getImage(), x + width - scale(iconSize) - textX, y + textX); } + + // @Override +// public void internalDrawin(Graphics g) { +// int w; +// int c; +// Font f = g.getFont(); +// Font fold = f; +// //FontMetrics fm = g.getFontMetrics(); +// +// if (myColor == null) { +// if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) { +// myColor = Color.white; +// } else { +// myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200); +// } +// } +// +// 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)) { +// f = f.deriveFont((float)maxCurrentFontSize); +// g.setFont(f); +// w = g.getFontMetrics().stringWidth(value); +// //w = fm.stringWidth(value); +// c = width - iconSize - (2 * textX); +// // +// if (w < c) { +// break; +// } +// maxCurrentFontSize --; +// +// } +// currentFontSize = maxCurrentFontSize; +// +// displayText = currentFontSize >= minFontSize; +// } +// +// // Zoom is assumed to be computed +// Color col = 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(col); +// } +// +// // Font size +// if (displayText) { +// f = f.deriveFont((float)currentFontSize); +// g.setFont(f); +// w = g.getFontMetrics().stringWidth(value); +// +// if (!(w < (width - 2 * (iconSize + textX)))) { +// drawSingleString(g, value, x + textX + 1, y + currentFontSize + textX); +// } else { +// drawSingleString(g, value, x + (width - w)/2, y + currentFontSize + textX); +// } +// } +// +// g.setFont(fold); +// +// // Icon +// if ((width>30) && (height > (iconSize + 2*textX))) { +// g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); +// } +// } - @Override - public void rescale(double scaleFactor){ - dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; - textX = (int)(dtextX); - dtextX = dtextX - textX; - - super.rescale(scaleFactor); - } +// @Override +// public void rescale(double scaleFactor){ +// dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; +// textX = (int)(dtextX); +// dtextX = dtextX - textX; +// +// super.rescale(scaleFactor); +// } @Override public TGComponent isOnOnlyMe(int _x, int _y) { diff --git a/src/main/java/ui/tmlcompd/TMLCCompositePort.java b/src/main/java/ui/tmlcompd/TMLCCompositePort.java index 50f0cb31c5e14784ad57a49dddb34eaf577b5e69..e3cf69c0017a00a62a13d9f85d723cd953b05484 100755 --- a/src/main/java/ui/tmlcompd/TMLCCompositePort.java +++ b/src/main/java/ui/tmlcompd/TMLCCompositePort.java @@ -102,6 +102,7 @@ public class TMLCCompositePort extends TMLCChannelFacility implements SwallowedT myImageIcon = IconManager.imgic1204; } + @Override public void internalDrawing(Graphics g) { if ((x != oldx) | (oldy != y)) { // Component has moved! diff --git a/src/main/java/ui/tmlcompd/TMLCFork.java b/src/main/java/ui/tmlcompd/TMLCFork.java index bec725d3c15548bb92fb2826dcc3f3ada573e6d0..730e15758c93ea0e9f2f501c9ca3414d355b56f4 100755 --- a/src/main/java/ui/tmlcompd/TMLCFork.java +++ b/src/main/java/ui/tmlcompd/TMLCFork.java @@ -96,12 +96,9 @@ public class TMLCFork extends TMLCChannelFacility implements WithAttributes { myImageIcon = IconManager.imgic1204; } - - - + @Override public void internalDrawing(Graphics g) { - - radius = width / 2; + radius = width / 2; if (rescaled) { rescaled = false; diff --git a/src/main/java/ui/tmlcompd/TMLCJoin.java b/src/main/java/ui/tmlcompd/TMLCJoin.java index 84ee822a3d28cff967b737a80d5064116f9a290c..6d77eb73f2e849e33cc837885560f7c109ef138b 100755 --- a/src/main/java/ui/tmlcompd/TMLCJoin.java +++ b/src/main/java/ui/tmlcompd/TMLCJoin.java @@ -98,7 +98,7 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes { myImageIcon = IconManager.imgic1204; } - + @Override public void internalDrawing(Graphics g) { radius = width / 2; @@ -106,18 +106,13 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes { if (rescaled) { rescaled = false; } - calculatePortColor(); - - // Draw arrow showing the connection if necessary //if (outp != null ){ // //} - - // Zoom is assumed to be computed Color c = g.getColor(); //g.drawRect(x, y, width, height); @@ -145,10 +140,11 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes { g.drawString(value, x+radius-(w/2), y+radius+(currentFontSize/2));*/ } - + + @Override public boolean editOndoubleClick(JFrame frame) { if (isChannel) { - String oldValue = value; +// String oldValue = value; String[] labels = new String[1]; labels[0] = "Nb of samples (positive int): "; String[] values = new String[1]; @@ -197,6 +193,8 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes { + + @Override public int getType() { return TGComponentManager.TMLCTD_JOIN; } diff --git a/src/main/java/ui/tmlcompd/TMLCPortConnectingPoint.java b/src/main/java/ui/tmlcompd/TMLCPortConnectingPoint.java index 3fe548814863585f111ce9b3a9b798baf23b7d08..bdedb5ed5eae68ca07e0a259f86c540f7558fb7d 100755 --- a/src/main/java/ui/tmlcompd/TMLCPortConnectingPoint.java +++ b/src/main/java/ui/tmlcompd/TMLCPortConnectingPoint.java @@ -61,6 +61,7 @@ public class TMLCPortConnectingPoint extends TGConnectingPointWidthHeight{ super(_container, _x, _y, _in, _out, _w, _h); } + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_PORT_TMLC; } diff --git a/src/main/java/ui/tmlcompd/TMLCPortConnector.java b/src/main/java/ui/tmlcompd/TMLCPortConnector.java index dd705454dba2738e9f066df6b8b960a933088652..ff96719282514655e932297189c08cc996eac3b2 100755 --- a/src/main/java/ui/tmlcompd/TMLCPortConnector.java +++ b/src/main/java/ui/tmlcompd/TMLCPortConnector.java @@ -36,12 +36,8 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcompd; - import ui.*; import ui.util.IconManager; @@ -55,14 +51,14 @@ import java.util.Vector; * @version 1.0 12/03/2008 * @author Ludovic APVRILLE */ -public class TMLCPortConnector extends TGConnector implements ScalableTGComponent, SpecificActionAfterAdd, SpecificActionAfterMove{ +public class TMLCPortConnector extends TGConnector implements /* Issue #31 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 double oldScaleFactor; //protected TGConnectingPoint oldp1, oldp2; @@ -72,7 +68,7 @@ public class TMLCPortConnector extends TGConnector implements ScalableTGCompone value = "Connector between ports"; editable = false; - oldScaleFactor = tdp.getZoom(); + // oldScaleFactor = tdp.getZoom(); //oldp1 = null; //oldp2 = null; @@ -97,6 +93,7 @@ public class TMLCPortConnector extends TGConnector implements ScalableTGCompone return true; }*/ + @Override 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)) { @@ -132,7 +129,7 @@ public class TMLCPortConnector extends TGConnector implements ScalableTGCompone 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); + drawSingleString(g,name1, (x1 + x2 - w)/2, (y1 + y2)/2); g.setFont(fold); } } @@ -149,40 +146,42 @@ public class TMLCPortConnector extends TGConnector implements ScalableTGCompone // GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); //} } - - public void rescale(double scaleFactor){ - // - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - // - 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); - - // - } - - oldScaleFactor = scaleFactor; - } - - +// Issue #31: Moved to upper class +// public void rescale(double scaleFactor){ +// // +// int xx, yy; +// +// for(int i=0; i<nbInternalTGComponent; i++) { +// xx = tgcomponent[i].getX(); +// yy = tgcomponent[i].getY(); +// // +// 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); +// +// // +// } +// +// oldScaleFactor = scaleFactor; +// } + + @Override public int getType() { return TGComponentManager.CONNECTOR_PORT_TMLC; } + @Override public void specificActionAfterAdd() { // ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); } + @Override public void specificActionAfterMove() { // ((TMLComponentTaskDiagramPanel)tdp).updatePorts(); @@ -264,5 +263,4 @@ public class TMLCPortConnector extends TGConnector implements ScalableTGCompone public String getAttributes() { return "Priority = " + priority; }*/ - } diff --git a/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java b/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java index b64401e7d2d1404a070e781b349889a2c74d1627..3a50d364b620dbe9b92cf0c953ca141d1337754e 100755 --- a/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java +++ b/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java @@ -1,4 +1,3 @@ - /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille * * ludovic.apvrille AT enst.fr @@ -37,11 +36,11 @@ * knowledge of the CeCILL license and that you accept its terms. */ - package ui.tmlcompd; import myutil.GraphicLib; import myutil.TraceManager; + import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -52,8 +51,8 @@ import ui.window.JDialogAttribute; import javax.swing.*; import java.awt.*; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import java.util.Vector; /** @@ -65,15 +64,18 @@ import java.util.Vector; * @version 1.0 12/03/2008 */ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, WithAttributes { - private int maxFontSize = 14; - private int minFontSize = 4; + // #FIXME Debugging + //private int maxFontSize = 14; + //private int minFontSize = 4; private int currentFontSize = -1; - private boolean displayText = true; + + //private boolean displayText = true; // private int spacePt = 3; private Color myColor; private boolean isAttacker = false; private boolean isDaemon = false; + // Icon private int iconSize = 15; private boolean iconIsDrawn = false; @@ -82,9 +84,11 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp // private boolean attributesAreDrawn = false; //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; + protected List<TAttribute> myAttributes; + + // Issue #31 +// private int textX = 15; // border for ports +// private double dtextX = 0.0; private String operation = ""; @@ -93,15 +97,19 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp public TMLCPrimitiveComponent(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); + // Issue #31 + //minWidth = 1; + //minHeight = 1; + minWidth = 150; + minHeight = 100; + initScaling(200, 150); - oldScaleFactor = tdp.getZoom(); - dtextX = textX * oldScaleFactor; - textX = (int) dtextX; - dtextX = dtextX - textX; - - minWidth = 1; - minHeight = 1; + // Issue #31 +// oldScaleFactor = tdp.getZoom(); +// dtextX = textX * oldScaleFactor; +// textX = (int) dtextX; +// dtextX = dtextX - textX; nbConnectingPoint = 0; @@ -115,7 +123,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp removable = true; userResizable = true; - value = tdp.findTMLPrimitiveComponentName("Function"); + value = tdp.findTMLPrimitiveComponentName("TMLComp_"); oldValue = value; setName("Primitive component"); @@ -125,7 +133,82 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp actionOnAdd(); } - + + private Color choosingColor() + { + if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) + return Color.white; + else + return new Color(201, 243, 188 - (getMyDepth() * 10), 200); + } + +// private boolean canTextGoInTheBox(Graphics g, int fontSize, String text) +// { +// int txtWidth = g.getFontMetrics().stringWidth(text) + (textX * 2); +// int spaceTakenByIcon = iconSize + textX; +// return (fontSize + (textY * 2) < height) // enough space in height +// && (txtWidth + spaceTakenByIcon < width) // enough space in width +// ; +// } + /** + * Function which is drawing the box, the text and icon + * Issue #31: Fixed zoom on texts and icon + made sure that if the text can't go into the box is does not get drawn + * @param g + */ + @Override + public void internalDrawing(Graphics g) + { + //rectangle + Filling color + Color c = g.getColor(); + myColor = choosingColor(); + g.drawRect(x, y, width, height); + g.setColor(myColor); + g.fill3DRect(x, y, width, height, true); + g.setColor(c); + + //String + int stringWidth = g.getFontMetrics().stringWidth(value); + int centerOfBox = (width - stringWidth) / 2; + Font f = g.getFont(); + currentFontSize = f.getSize(); + if (canTextGoInTheBox(g, currentFontSize, value, iconSize)) + { + //put title in bold before drawing then set back to normal after + g.setFont(f.deriveFont(Font.BOLD)); +// drawSingleString(g,value, x + centerOfBox, y + currentFontSize + textY); + drawSingleString(g, value, x + centerOfBox, y + currentFontSize + textY); + g.setFont(f); + } + + // Scaled ICON drawing + g.drawImage(scale(IconManager.imgic1200.getImage()), x + width - iconSize - textX, y + textX, null); + if (isAttacker) + g.drawImage(scale(IconManager.imgic7008.getImage()), x + width - 2 * iconSize - textX, y + 2 * textX, null); + + // Attributes printing + if (tdp.areAttributesVisible()) + { + //spaces permits the attributes to not override each other + int spaces = currentFontSize + textY * 2; + TAttribute attribute; + String attributeStr; + for (int i = 0; i < myAttributes.size(); i++) + { + attribute = myAttributes.get(i); + spaces += currentFontSize; + attributeStr = attribute.toString(); + if (canTextGoInTheBox(g, spaces, attributeStr, iconSize)) + { + drawSingleString(g,attributeStr, x + textX, y + spaces); + drawVerification(g, x + textX, y + spaces, attribute.getConfidentialityVerification()); + } + else // if we could not display some attributes it will show a ... + drawSingleString(g,"...", x + textX, y + height - 15); + } + } + } +/* + @Override public void internalDrawing(Graphics g) { int w; Font f = g.getFont(); @@ -190,10 +273,11 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp 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); + drawSingleString(g,value, x + textX + 1, y + currentFontSize + textX); } else { - g.drawString(value, x + (width - w) / 2, y + currentFontSize + textX); + drawSingleString(g,value, x + (width - w) / 2, y + currentFontSize + textX); } } @@ -201,16 +285,12 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp if ((width > 30) && (height > (iconSize + 2 * textX))) { iconIsDrawn = true; g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); - if (isAttacker) { - g.drawImage(IconManager.imgic7008.getImage(), x + width - 2 * iconSize - textX, y + 2 * textX, null); - } - if (isDaemon) { - g.drawImage(IconManager.imgic5116.getImage(), x + 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()) { @@ -236,13 +316,13 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp attr = a.toString(); w = g.getFontMetrics().stringWidth(attr); if ((w + (2 * textX) + 1) < width) { - g.drawString(attr, x + textX, y + cpt); + drawSingleString(g,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); + drawSingleString(g,attr, x + textX + 1, y + cpt); } else { // skip attribute cpt -= step; @@ -253,8 +333,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp } g.setFont(fold); - - } + }*/ public void drawVerification(Graphics g, int x, int y, int checkConfStatus) { Color c = g.getColor(); @@ -274,18 +353,19 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp 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); - } +// Issue #31 +// @Override +// public void rescale(double scaleFactor) { +// dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; +// textX = (int) (dtextX); +// dtextX = dtextX - textX; +// +// super.rescale(scaleFactor); +// } + @Override public TGComponent isOnOnlyMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -293,26 +373,27 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp return null; } - public boolean isAttacker() { return isAttacker; } + public boolean isDaemon() { return isDaemon; } - + + @Override 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)) { + if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, scale(iconSize), scale(iconSize))) { tdp.getMouseManager().setSelection(-1, -1); tdp.selectTab(getValue()); return true; } } - // On the name ? + // On the name ? /*if ((displayText) && (_y <= (y + currentFontSize + textX))) { //TraceManager.addDev("Edit on double click x=" + _x + " y=" + _y); oldValue = value; @@ -357,7 +438,8 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp String oldName = getValue(); oldValue = getValue(); - JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, + + JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting attributes of " + value, "Attribute", operation, isDaemon, getValue()); setJDialogOptions(jda); // jda.setSize(650, 375); @@ -451,6 +533,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp return ((TMLComponentTaskDiagramPanel) (tdp)).getRecordNamed(this, _nameOfRecord); } + @Override public int getType() { return TGComponentManager.TMLCTD_PCOMPONENT; } @@ -464,12 +547,10 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp setFather(null); TDiagramPanel tdp = getTDiagramPanel(); setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); - } public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof TMLCPrimitivePort; - } public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { @@ -496,7 +577,6 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp removeInternalComponent(tgc); } - /*public Vector getArtifactList() { Vector v = new Vector(); for(int i=0; i<nbInternalTGComponent; i++) { @@ -507,6 +587,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp return v; }*/ + @Override public void hasBeenResized() { rescaled = true; for (int i = 0; i < nbInternalTGComponent; i++) { @@ -520,8 +601,9 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp } } + @Override public void resizeWithFather() { - if ((father != null) && (father instanceof TMLCCompositeComponent)) { + if (/*(father != null) && (*/father instanceof TMLCCompositeComponent ) { // Too large to fit in the father? -> resize it! resizeToFatherSize(); @@ -530,6 +612,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp } } + @Override public int getChildCount() { return myAttributes.size() + nbInternalTGComponent + 1; } @@ -564,6 +647,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp return -1; } + @Override protected String translateExtraParam() { TAttribute a; //TraceManager.addDev("Loading extra params of " + value); @@ -669,40 +753,41 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp } } - public int getCurrentFontSize() { - return currentFontSize; - } + // Issue #31 +// public int getCurrentFontSize() { +// return currentFontSize; +// } - public java.util.List<TAttribute> getAttributeList() { + public List<TAttribute> getAttributeList() { return myAttributes; } - public java.util.List<TMLCPrimitivePort> getAllChannelsOriginPorts() { + public List<TMLCPrimitivePort> getAllChannelsOriginPorts() { return getAllPorts(0, true); } - public java.util.List<TMLCPrimitivePort> getAllChannelsDestinationPorts() { + public List<TMLCPrimitivePort> getAllChannelsDestinationPorts() { return getAllPorts(0, false); } - public java.util.List<TMLCPrimitivePort> getAllEventsOriginPorts() { + public List<TMLCPrimitivePort> getAllEventsOriginPorts() { return getAllPorts(1, true); } - public java.util.List<TMLCPrimitivePort> getAllEventsDestinationPorts() { + public List<TMLCPrimitivePort> getAllEventsDestinationPorts() { return getAllPorts(1, false); } - public java.util.List<TMLCPrimitivePort> getAllRequestsDestinationPorts() { + public List<TMLCPrimitivePort> getAllRequestsDestinationPorts() { return getAllPorts(2, false); } - public java.util.List<TMLCPrimitivePort> getAllRequestsOriginPorts() { + public List<TMLCPrimitivePort> getAllRequestsOriginPorts() { return getAllPorts(2, true); } - public java.util.List<TMLCPrimitivePort> getAllPorts(int _type, boolean _isOrigin) { - java.util.List<TMLCPrimitivePort> ret = new LinkedList<TMLCPrimitivePort>(); + public List<TMLCPrimitivePort> getAllPorts(int _type, boolean _isOrigin) { + List<TMLCPrimitivePort> ret = new LinkedList<TMLCPrimitivePort>(); TMLCPrimitivePort port; //TraceManager.addDev("Type = " + _type + " isOrigin=" + _isOrigin); @@ -721,8 +806,8 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp return ret; } - public java.util.List<TMLCPrimitivePort> getAllInternalPrimitivePorts() { - java.util.List<TMLCPrimitivePort> list = new ArrayList<TMLCPrimitivePort>(); + public List<TMLCPrimitivePort> getAllInternalPrimitivePorts() { + List<TMLCPrimitivePort> list = new ArrayList<TMLCPrimitivePort>(); for (int i = 0; i < nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLCPrimitivePort) { list.add((TMLCPrimitivePort) (tgcomponent[i])); diff --git a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java index 9d4119d8f7b4bcba5916503eb57ee01477a14402..dba962380ff59d4a51628d627e250014bc01aae0 100755 --- a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java +++ b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java @@ -1,4 +1,4 @@ -/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille * * ludovic.apvrille AT enst.fr * @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlcompd; import myutil.GraphicLib; @@ -130,7 +127,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent protected int lossPercentage; protected int maxNbOfLoss; //-1 means no max - // Security Verification + //Security Verification public int checkConfStatus; public int checkSecConfStatus; @@ -212,6 +209,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent return myColor; } + @Override public void internalDrawing(Graphics g) { if ((x != oldx) | (oldy != y)) { // Component has moved! @@ -353,22 +351,23 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent TGComponent tgc = getFather(); int ft = 10; if ((tgc != null) && (tgc instanceof TMLCPrimitiveComponent)) { - ft = ((TMLCPrimitiveComponent)tgc).getCurrentFontSize(); + ft = g.getFont().getSize();// Issue #31 ((TMLCPrimitiveComponent)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); - } - + // Issue #31: The commName was not zooming + //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))) { + // drawSingleString(g,commName, x, y-1); + //} + //drawSingleString(g,commName, x, y -1); + drawSingleString(g, commName, x, y -1); if (checkConf && isOrigin){ drawConfVerification(g); } @@ -385,7 +384,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent public void drawAuthVerification(Graphics g){ - g.drawString(secName, x-xc*2/3, y+yc*2/3); + drawSingleString(g,secName, x-xc*2/3, y+yc*2/3); Color c = g.getColor(); Color c1; Color c2; @@ -423,8 +422,8 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent g.setColor(c); g.drawPolygon(xps, yps,3); g.drawPolygon(xpw, ypw, 3); - g.drawString("S", x-authxoffset+1, y+yc+authyoffset); - g.drawString("W", x-authxoffset+authlockwidth/2, y+yc+authovalheight); + drawSingleString(g,"S", x-authxoffset+1, y+yc+authyoffset); + drawSingleString(g,"W", x-authxoffset+authlockwidth/2, y+yc+authovalheight); if (checkStrongAuthStatus ==3){ g.drawLine(x-authxoffset, y+authyoffset*3/2, x-authxoffset/2, y+authyoffset+yc); g.drawLine(x-authxoffset, y+authyoffset+yc, x-authxoffset/2, y+authyoffset*3/2); @@ -454,7 +453,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent default: return; } - g.drawString(mappingName, x-conflockwidth*2, y-conflockheight); + drawSingleString(g,mappingName, x-conflockwidth*2, y-conflockheight); g.drawOval(x-confovalwidth*2, y, confovalwidth, confovalheight); g.setColor(c1); g.fillRect(x-conflockwidth*3/2, y+conflockheight/2, conflockwidth, conflockheight); @@ -480,7 +479,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent default: return; } - g.drawString(secName, x-conflockwidth*2, y+conflockheight*3); + drawSingleString(g,secName, x-conflockwidth*2, y+conflockheight*3); g.drawOval(x-confovalwidth*2, y+confyoffset, confovalwidth, confovalheight); g.setColor(c1); g.fillRect(x-conflockwidth*3/2, y+conflockheight/2+confyoffset, conflockwidth, conflockheight); @@ -538,7 +537,8 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent ((TMLCPortConnectingPoint)(connectingPoint[i])).setH(h0); } } - + + @Override public TGComponent isOnOnlyMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -554,11 +554,13 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent //public abstract int getType(); - + + @Override public void wasSwallowed() { myColor = null; } - + + @Override public void wasUnswallowed() { myColor = null; setFather(null); @@ -566,7 +568,8 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } - + + @Override public void resizeWithFather() { // if ((father != null) && (father instanceof TMLCPrimitiveComponent)) { @@ -579,7 +582,8 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent oldy = -1; } } - + + @Override public boolean editOndoubleClick(JFrame frame) { // //String oldValue = valueOCL; @@ -603,12 +607,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent } } - JDialogTMLCompositePort jda = new JDialogTMLCompositePort(commName, typep, list[0], list[1], list[2], list[3], - list[4], isOrigin, isFinite, isBlocking, - ""+maxSamples, ""+widthSamples, isLossy, lossPercentage, maxNbOfLoss, - frame, "Port properties", - otherTypes, dataFlowType, associatedEvent, isPrex, isPostex, checkConf, checkAuth, reference, refs, - vc); + JDialogTMLCompositePort jda = new JDialogTMLCompositePort(commName, typep, list[0], list[1], list[2], list[3], list[4], isOrigin, isFinite, isBlocking, ""+maxSamples, ""+widthSamples, isLossy, lossPercentage, maxNbOfLoss, frame, "Port properties", otherTypes, dataFlowType, associatedEvent, isPrex, isPostex, checkConf, checkAuth, reference, refs, vc); // jda.setSize(350, 700); GraphicLib.centerOnParent(jda, 350, 700 ); // jda.show(); // blocked until dialog has been closed @@ -754,7 +753,8 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent } } - + + @Override protected String translateExtraParam() { TType a; //String val = ""; @@ -911,7 +911,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent vc = Integer.decode(elt.getAttribute("vc")); } catch (Exception e) { vc = 0; - } + } } @@ -980,16 +980,16 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent public void setParam(int index, TType t){ list[index] = t; } - + + @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_PORT_TMLC; } - public int getVC() { return vc; } - - + + @Override public String getAttributes() { String attr = ""; if (isOrigin()) { diff --git a/src/main/java/ui/tmlcompd/TMLCRecordComponent.java b/src/main/java/ui/tmlcompd/TMLCRecordComponent.java index e1495f6f8818585f6883c89ee78d08c06edbb5ad..5ba5b992b9a8606c6c7f5a147722b567a34c8a15 100755 --- a/src/main/java/ui/tmlcompd/TMLCRecordComponent.java +++ b/src/main/java/ui/tmlcompd/TMLCRecordComponent.java @@ -178,9 +178,9 @@ public class TMLCRecordComponent extends TGCScalableWithInternalComponent implem g.setFont(f); w = g.getFontMetrics().stringWidth(value); if (w > (width - 2 * (iconSize + textX))) { - g.drawString(value, x + textX + 1, y + currentFontSize + textX); + drawSingleString(g,value, x + textX + 1, y + currentFontSize + textX); } else { - g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); + drawSingleString(g,value, x + (width - w)/2, y + currentFontSize + textX); } } @@ -217,12 +217,12 @@ public class TMLCRecordComponent extends TGCScalableWithInternalComponent implem attr = a.toString(); w = g.getFontMetrics().stringWidth(attr); if ((w + (2 * textX) + 1) < width) { - g.drawString(attr, x + textX, y + cpt); + drawSingleString(g,attr, x + textX, y + cpt); } else { attr = "..."; w = g.getFontMetrics().stringWidth(attr); if ((w + textX + 2) < width) { - g.drawString(attr, x + textX + 1, y + cpt); + drawSingleString(g,attr, x + textX + 1, y + cpt); } else { // skip attribute cpt -= step; diff --git a/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java b/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java index 0eb38b932ddf50c25e66100810f2c6dc572a4ace..274654aa4809519f5759a7645a14e79be8742b23 100755 --- a/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java +++ b/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java @@ -220,9 +220,9 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone w = g.getFontMetrics().stringWidth(value); //TraceManager.addDev("Display text: Font size=" + currentFontSize + " w=" + w + " value=" + value); if (!(w < (width - 2 * (iconSize + textX)))) { - g.drawString(value, x + textX + 1, y + currentFontSize + textX); + drawSingleString(g,value, x + textX + 1, y + currentFontSize + textX); } else { - g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); + drawSingleString(g,value, x + (width - w)/2, y + currentFontSize + textX); } } diff --git a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java index 3c410b2478ff76e7e00d790355c84701234b3cf4..8c1788c1961a1736909e0b5a286d79a05b4581a8 100755 --- a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java +++ b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java @@ -593,7 +593,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi public String getXMLCloneTail() { return "</TMLComponentTaskDiagramPanelCopy>"; } - + @Override public boolean areAttributesVisible() { return attributesVisible; } diff --git a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java index 06896e70ee0758881de6b11c260ad6eee0b11198..bbbf01f100b97617571e26b87ed38758ae8c684f 100755 --- a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java +++ b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java @@ -62,6 +62,7 @@ public class TMLComponentTaskDiagramToolBar extends TToolBar { } + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); @@ -91,6 +92,7 @@ public class TMLComponentTaskDiagramToolBar extends TToolBar { } + @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java b/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java index 7e071398c9304250562b91732f80dc2701b2950c..1066dc00b9463c7a3c7677520c1cab051a2dc3d1 100755 --- a/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java +++ b/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java @@ -57,12 +57,6 @@ public class TGConnectingPointTMLCP extends TGConnectingPointWidthHeight{ @Override public boolean isCompatibleWith(int type) { - // - if (type == TGComponentManager.CONNECTOR_TMLCP) { - // - return true; - } - // - return false; + return type == TGComponentManager.CONNECTOR_TMLCP; } } diff --git a/src/main/java/ui/tmlcp/TGConnectorTMLCP.java b/src/main/java/ui/tmlcp/TGConnectorTMLCP.java index 4bcca5ef6284ce4f394d8e69446cdf295a867831..65b3673ee324ceac27722690dbcef03309d5dacc 100755 --- a/src/main/java/ui/tmlcp/TGConnectorTMLCP.java +++ b/src/main/java/ui/tmlcp/TGConnectorTMLCP.java @@ -55,8 +55,11 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public class TGConnectorTMLCP extends TADConnector /* Issue #69 TGConnector*/ { - protected int arrowLength = 10; - protected String guard = ""; + + // Issue #31 + //protected int arrowLength = 10; + + protected String guard = ""; public TGConnectorTMLCP(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); diff --git a/src/main/java/ui/tmlcp/TMLCPChoice.java b/src/main/java/ui/tmlcp/TMLCPChoice.java index 9e9ea5db9759211e30342b9ca5b60b8331ff4759..24658693c2a5a1283d659f80833bbfca108c24ef 100755 --- a/src/main/java/ui/tmlcp/TMLCPChoice.java +++ b/src/main/java/ui/tmlcp/TMLCPChoice.java @@ -116,9 +116,9 @@ public class TMLCPChoice extends TADChoice /* Issue #69 TGCWithInternalComponent nbConnectingPoint = 4; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLCP(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[2] = new TGConnectingPointTMLCP(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, lineOutLength, false, true, 0.5, 1.0); + connectingPoint[1] = new TGConnectingPointTMLCP(this, -OUT_LINE_LENGTH, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new TGConnectingPointTMLCP(this, OUT_LINE_LENGTH, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, OUT_LINE_LENGTH, false, true, 0.5, 1.0); } // // public void internalDrawing(Graphics g) { diff --git a/src/main/java/ui/tmlcp/TMLCPForLoop.java b/src/main/java/ui/tmlcp/TMLCPForLoop.java index 5a2e19156d237684c8a5f34a9e278e14cdfad72c..3ea8368315663cc312e9387c8f9fb6f45792d73c 100755 --- a/src/main/java/ui/tmlcp/TMLCPForLoop.java +++ b/src/main/java/ui/tmlcp/TMLCPForLoop.java @@ -88,11 +88,11 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp // height = 20; // minWidth = 30; - nbConnectingPoint = 3; - connectingPoint = new TGConnectingPoint[3]; - connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 1.0, 0.45); // loop - connectingPoint[2] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp +// nbConnectingPoint = 3; +// connectingPoint = new TGConnectingPoint[3]; +// connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); +// connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 1.0, 0.45); // loop +// connectingPoint[2] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp // moveable = true; // editable = true; @@ -106,14 +106,25 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp } @Override - public void internalDrawing(Graphics g) { - final int textWidth = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, textWidth + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width / 2 - w1 / 2, y); - width = w1; - //updateConnectingPoints(); - } + protected void createConnectingPoints() { + nbConnectingPoint = 3; + connectingPoint = new TGConnectingPoint[3]; + connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 1.0, 0.45); // loop + connectingPoint[2] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp + } + + @Override + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int textWidth = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, textWidth + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width / 2 - w1 / 2, y); +// width = w1; +// //updateConnectingPoints(); +// } if (stateOfError > 0) { Color c = g.getColor(); @@ -131,9 +142,11 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp g.drawRoundRect(x, y, width, height, arc, arc); g.drawLine(x + (width / 2), y, x + (width / 2), y - lineLength); g.drawLine(x + (width / 2), y + height, x + (width / 2), y + lineLength + height); - g.drawLine(x + width, y + height / 2, x + width + lineLength, y + height / 2); + + // Issue #31 Useless line + //g.drawLine(x + width, y + height / 2, x + width + lineLength, y + height / 2); - g.drawString(value, x + (width - textWidth) / 2, y + textY); + drawSingleString(g,value, x + (width - textWidth) / 2, y + textY); } @Override diff --git a/src/main/java/ui/tmlcp/TMLCPFork.java b/src/main/java/ui/tmlcp/TMLCPFork.java index 1d8f840e0ed7b875f5f6e2993823e05d904720e8..3a7b0adcd94c340fa6ba84931868d6524c15f125 100755 --- a/src/main/java/ui/tmlcp/TMLCPFork.java +++ b/src/main/java/ui/tmlcp/TMLCPFork.java @@ -59,7 +59,7 @@ import ui.util.IconManager; */ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGCWithoutInternalComponent*/ { - private int lineLength = 0; + //private int lineLength = 0; private static int instanceCounter = 0; private int counter = 0; //private int textX, textY; @@ -67,12 +67,7 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC public TMLCPFork(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 150; - height = 5; - - //textX = width - 10; - //textY = height - 8; - + // Issue #31 nbConnectingPoint = 6; connectingPoint = new TGConnectingPoint[6]; connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.167, 1.0); @@ -81,6 +76,13 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.667, 1.0); connectingPoint[4] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.833, 1.0); connectingPoint[5] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); + + initScaling( 150, 5 ); +// width = 150; +// height = 5; + + //textX = width - 10; + //textY = height - 8; addTGConnectingPointsComment(); @@ -98,7 +100,7 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } diff --git a/src/main/java/ui/tmlcp/TMLCPJoin.java b/src/main/java/ui/tmlcp/TMLCPJoin.java index 341f896cde57bc4c08d38b91565f367f4cb59474..7b8ba1ea07c824a3982f53af04e4c2cbe7da3425 100755 --- a/src/main/java/ui/tmlcp/TMLCPJoin.java +++ b/src/main/java/ui/tmlcp/TMLCPJoin.java @@ -57,20 +57,16 @@ import ui.util.IconManager; */ public class TMLCPJoin extends TGCWithoutInternalComponent{ - private int lineLength = 0; + // Issue #31 +// private int lineLength = 0; private static int instanceCounter = 0; private int counter = 0; //private int textX, textY; public TMLCPJoin(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 150; - height = 5; - - //textX = width - 10; - //textY = height - 8; + // Issue #31 nbConnectingPoint = 6; connectingPoint = new TGConnectingPoint[6]; connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.167, 0.0); @@ -79,6 +75,10 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{ connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.667, 0.0); connectingPoint[4] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.833, 0.0); connectingPoint[5] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); + + initScaling( 150, 5 ); +// width = 150; +// height = 5; addTGConnectingPointsComment(); @@ -96,7 +96,7 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{ } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } diff --git a/src/main/java/ui/tmlcp/TMLCPPanel.java b/src/main/java/ui/tmlcp/TMLCPPanel.java index cb458388ddd31668b754b4cc3f9cc31631b3e29b..6c4f3b706421ffc897d4b7ef031a9131530c0cf4 100755 --- a/src/main/java/ui/tmlcp/TMLCPPanel.java +++ b/src/main/java/ui/tmlcp/TMLCPPanel.java @@ -54,7 +54,6 @@ public class TMLCPPanel extends TDiagramPanel { public TMLCPPanel(MainGUI mgui, TToolBar _ttb) { super(mgui, _ttb); - } @Override @@ -108,8 +107,8 @@ public class TMLCPPanel extends TDiagramPanel { } @Override - public String getXMLHead() { - return "<CommunicationPatternDiagramPanel name=\"" + name + "\"" + sizeParam() + " >"; + public String getXMLHead() { // Issue #31 + return "<CommunicationPatternDiagramPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; // Issue #31 } @Override @@ -189,7 +188,7 @@ public class TMLCPPanel extends TDiagramPanel { return null; }*/ - public void makePostLoadingProcessing() throws MalformedModelingException { + //public void makePostLoadingProcessing() throws MalformedModelingException { // TGComponent tgc; /*for(int i=0; i<componentList.size(); i++) { @@ -198,7 +197,7 @@ public class TMLCPPanel extends TDiagramPanel { ((TCDTObject)tgc).postLoadingProcessing(); } }*/ - } + //} public boolean isTMLCPSDCreated(String name) { return mgui.isTMLCPSDCreated(tp, name); @@ -227,7 +226,8 @@ public class TMLCPPanel extends TDiagramPanel { //mgui.changeMade(mgui.getSequenceDiagramPanel(name), TDiagramPanel.NEW_COMPONENT); return b; } - + + @Override public void enhance() { // Vector<TGComponent> v = new Vector<>(); diff --git a/src/main/java/ui/tmlcp/TMLCPRefAD.java b/src/main/java/ui/tmlcp/TMLCPRefAD.java index 5e07d716018dd43b9402c9b5ebbfcd8d6a1c8cef..5f9ed6688d9fc7d645a11b2520118ddbb00d234e 100755 --- a/src/main/java/ui/tmlcp/TMLCPRefAD.java +++ b/src/main/java/ui/tmlcp/TMLCPRefAD.java @@ -58,23 +58,28 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE, Andrea ENRICI */ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; public TMLCPRefAD(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 35; - minWidth = 70; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); + initScaling( 30, 35 ); +// width = 30; +// height = 35; + minWidth = scale( 70 ); + textX = scale( 5 ); + addTGConnectingPointsComment(); moveable = true; @@ -88,15 +93,16 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { } @Override - public void internalDrawing(Graphics g) { - //int w2 = g.getFontMetrics().stringWidth("ref"); - int w = g.getFontMetrics().stringWidth(value) /*+ w2*/; - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } Color c = g.getColor(); g.setColor(ColorManager.IOD_REFERENCE); @@ -105,17 +111,22 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { g.drawRect(x, y, width, height); - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawString(name, x + (width - w) / 2, y + textY + 15); - g.drawString("ad", x+3, y+12); - g.drawLine(x, y+15, x+15, y+15); - g.drawLine(x+25, y, x+25, y+8); - g.drawLine(x+15, y+15, x+25, y+8); - - + final int offset = scale( 15 ); + drawSingleString(g,name, x + (width - w) / 2, y + textY + offset /* 15 Issue #31 */ ); + + // Issue #31 + final int adOffsetX = scale( 3 ); + final int adOffsetY = scale( 12 ); + drawSingleString(g,"ad", x + adOffsetX /*3*/, y + adOffsetY ); + g.drawLine(x, y + offset /*15*/, x + offset /* 15 */, y+ offset /*15 Issue #31 */); + + final int adBoxOffsetX = scale( 25 ); + final int adBoxOffsetY = scale( 8 ); + g.drawLine(x + adBoxOffsetX /*25*/, y, x + adBoxOffsetX /*25*/, y + adBoxOffsetY /*8*/); + g.drawLine(x+ offset /*15*/, y+ offset /*15*/, x + adBoxOffsetX /*25*/, y + adBoxOffsetY /*8*/ ); } @Override @@ -135,7 +146,6 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { return value; } - @Override public int getType() { return TGComponentManager.TMLCP_REF_CP; diff --git a/src/main/java/ui/tmlcp/TMLCPRefSD.java b/src/main/java/ui/tmlcp/TMLCPRefSD.java index dc6bb9e8469ffe7fc6f6b911a8aa3e1fc8179d92..5d803e27122f8d29ea2c944a3bc385935a64e1ed 100755 --- a/src/main/java/ui/tmlcp/TMLCPRefSD.java +++ b/src/main/java/ui/tmlcp/TMLCPRefSD.java @@ -66,10 +66,12 @@ import ui.util.IconManager; * @author Ludovic APVRILLE */ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; // private TMLSDPanel refToSD; // private TGConnectorTMLCP[] connectors = new TGConnectorTMLCP[2]; //private int index = 0; @@ -77,14 +79,17 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { public TMLCPRefSD(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 35; - minWidth = 70; - + // Issue #31 nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); + + textX = 5; +// width = 30; +// height = 35; + initScaling( 30, 35 ); + minWidth = 70; addTGConnectingPointsComment(); @@ -99,15 +104,16 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { } @Override - public void internalDrawing(Graphics g) { - //int w2 = g.getFontMetrics().stringWidth("ref"); - int w = g.getFontMetrics().stringWidth(value) /*+ w2*/; - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) & (!tdp.isScaled())) { - setCd(x + width/2 - w1/2, y); - width = w1; - //updateConnectingPoints(); - } + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );// g.getFontMetrics().stringWidth(value) /*+ w2*/; +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) & (!tdp.isScaled())) { +// setCd(x + width/2 - w1/2, y); +// width = w1; +// //updateConnectingPoints(); +// } Color c = g.getColor(); g.setColor(ColorManager.SD_REFERENCE); @@ -118,11 +124,18 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); - g.drawString(name, x + (width - w) / 2, y + textY + 15); - g.drawString("sd", x+3, y+12); - g.drawLine(x, y+15, x+15, y+15); - g.drawLine(x+25, y, x+25, y+8); - g.drawLine(x+15, y+15, x+25, y+8); + final int offsetDefault = scale( 15 ); + drawSingleString(g,name, x + (width - w) / 2, y + textY + offsetDefault /*15*/); + + final int sdOffsetX = scale( 3 ); + final int sdOffsetY = scale( 12 ); + drawSingleString(g,"sd", x + sdOffsetX /*3*/, y + sdOffsetY /*12*/); + g.drawLine(x, y + offsetDefault /*15*/, x + offsetDefault /*15*/, y + offsetDefault /*15*/); + + final int sdBoxOffsetX = scale( 25 ); + final int sdBoxOffsetY = scale( 8 ); + g.drawLine(x + sdBoxOffsetX /*25*/, y, x + sdBoxOffsetX /*25*/, y + sdBoxOffsetY /*8*/); + g.drawLine(x + offsetDefault /*15*/, y + offsetDefault /*15*/, x + sdBoxOffsetX /*25*/, y + sdBoxOffsetY /*8*/); } @Override @@ -179,7 +192,7 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLCP; + return TGComponentManager.CONNECTOR_TMLCP; } /*public void setReferenceToSD( TMLSDPanel _panel ) { diff --git a/src/main/java/ui/tmlcp/TMLCPStartState.java b/src/main/java/ui/tmlcp/TMLCPStartState.java index 03816840c1817200800f6c78f911828490f48d92..14b1e024fd2cf21fd9787d56a56f217a22a76668 100755 --- a/src/main/java/ui/tmlcp/TMLCPStartState.java +++ b/src/main/java/ui/tmlcp/TMLCPStartState.java @@ -52,7 +52,7 @@ import ui.ad.TADStartState; * @author Ludovic APVRILLE */ public class TMLCPStartState extends TADStartState /* Issue #69 TGCWithoutInternalComponent*/{ - private int lineLength = 5; + //private int lineLength = 5; public TMLCPStartState(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); diff --git a/src/main/java/ui/tmlcp/TMLCPToolBar.java b/src/main/java/ui/tmlcp/TMLCPToolBar.java index aca7bcf04ae1881d51f92a490421d16d5b9b1a0f..367b7d2eb064354c19979cab08503b724e02e664 100755 --- a/src/main/java/ui/tmlcp/TMLCPToolBar.java +++ b/src/main/java/ui/tmlcp/TMLCPToolBar.java @@ -76,9 +76,13 @@ public class TMLCPToolBar extends TToolBar { mgui.actions[TGUIAction.TMLCP_FOR_LOOP].setEnabled(b); mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.updateZoomInfo(); diff --git a/src/main/java/ui/tmldd/TMLArchiArtifact.java b/src/main/java/ui/tmldd/TMLArchiArtifact.java index f93ad67733f60e3a1100b7a6cb8c63266637787d..4df19c01f486a3b5bafd0de763435de3d32af374 100755 --- a/src/main/java/ui/tmldd/TMLArchiArtifact.java +++ b/src/main/java/ui/tmldd/TMLArchiArtifact.java @@ -58,16 +58,21 @@ import java.awt.*; * @author Ludovic APVRILLE * @version 1.0 02/05/2005 */ -public class TMLArchiArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes, - TMLArchiTaskInterface { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int textY2 = 35; - protected int space = 5; - protected int fileX = 20; - protected int fileY = 25; - protected int cran = 5; +public class TMLArchiArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes, TMLArchiTaskInterface { + + // Issue #31 + private static final int SPACE = 5; + private static final int CRAN = 5; + private static final int FILE_X = 20; + private static final int FILE_Y = 25; +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int textY2 = 35; +// protected int space = 5; +// protected int fileX = 20; +// protected int fileY = 25; +// protected int cran = 5; protected String oldValue = ""; protected String referenceTaskName = "referenceToTask"; @@ -78,16 +83,19 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa private ArchUnitMEC fatherArchUnitMECType = new CpuMEC(); - public String status = ""; - public String lastTransaction = ""; - - public TMLArchiArtifact(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, - TGComponent _father, TDiagramPanel _tdp) { + public String status=""; + public String lastTransaction=""; + + public TMLArchiArtifact(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 100; - height = 40; + // Issue #31 + textX = 5; + textY = 15; +// width = 100; +// height = 40; minWidth = 100; + initScaling( 100, 40 ); nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -96,7 +104,7 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa editable = true; removable = true; userResizable = true; - value = "TMLDesign::task"; + value = "TMLDesign::task "; taskName = "name"; referenceTaskName = "TMLTask"; @@ -105,29 +113,34 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa myImageIcon = IconManager.imgic702; } + @Override public boolean isHidden() { - //TraceManager.addDev("Archi task artifact: Am I hidden?" + getValue()); - boolean ret = false; - if (tdp != null) { - if (tdp instanceof TMLArchiDiagramPanel) { - ret = !(((TMLArchiDiagramPanel) (tdp)).inCurrentView(this)); - - } - } - //TraceManager.addDev("Hidden? -> " + ret); - return ret; + //TraceManager.addDev("Archi task artifact: Am I hidden?" + getValue()); + boolean ret = false; + if (tdp != null) { + if (tdp instanceof TMLArchiDiagramPanel) { + ret = !(((TMLArchiDiagramPanel)(tdp)).inCurrentView(this)); + + } + } + //TraceManager.addDev("Hidden? -> " + ret); + return ret; } public int getPriority() { return priority; } + /*public String getOperation() { + return operation; + }*/ - public void internalDrawing(Graphics g) { - + @Override + protected void internalDrawing(Graphics g) { if (oldValue.compareTo(value) != 0) { setValue(value, g); } + g.drawRect(x, y, width, height); Color c = g.getColor(); @@ -145,23 +158,28 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa g.fillRect(x + 1, y + 1, width - 1, height - 1); g.setColor(c); - //g.drawRoundRect(x, y, width, height, arc, arc); - g.drawLine(x + width - space - fileX, y + space, x + width - space - fileX, y + space + fileY); - g.drawLine(x + width - space - fileX, y + space, x + width - space - cran, y + space); - g.drawLine(x + width - space - cran, y + space, x + width - space, y + space + cran); - g.drawLine(x + width - space, y + space + cran, x + width - space, y + space + fileY); - g.drawLine(x + width - space, y + space + fileY, x + width - space - fileX, y + space + fileY); - g.drawLine(x + width - space - cran, y + space, x + width - space - cran, y + space + cran); - g.drawLine(x + width - space - cran, y + space + cran, x + width - space, y + space + cran); - g.drawString(value, x + textX, y + textY); - //g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); - + // Issue #31 + final int space = scale( SPACE ); + final int marginFileX = scale( SPACE + FILE_X ); + final int marginFileY = scale( SPACE + FILE_Y ); + final int marginCran = scale( SPACE + CRAN ); + + g.drawLine(x+width- marginFileX /*space-fileX*/, y + space, x+width- marginFileX /*space-fileX*/, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width- marginFileX/*space-fileX*/, y + space, x+width-marginCran/*space-cran*/, y+space); + g.drawLine(x+width-marginCran/*space-cran*/, y+space, x+width-space, y+ marginCran/*space + cran*/); + g.drawLine(x+width-space, y+ marginCran/*space + cran*/, x+width-space, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width-space, y+ marginFileY/*space+fileY*/, x+width-marginFileX/*space-fileX*/, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width- marginCran /*space-cran*/, y+space, x+width- marginCran/*space-cran*/, y+ marginCran/*space+cran*/); + g.drawLine(x+width- marginCran/*space-cran*/, y+ marginCran/*space+cran*/, x + width-space, y+marginCran /*space+cran*/); + drawSingleString(g,value, x + textX , y + textY); } public void setValue(String val, Graphics g) { oldValue = value; - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); + int w = g.getFontMetrics().stringWidth(value); + + final int marginFileX = scale( SPACE + FILE_X ); + int w1 = Math.max(minWidth, w + 2 * textX + marginFileX/*fileX + space*/); // if (w1 != width) { @@ -171,6 +189,7 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa // } + @Override public void resizeWithFather() { if ((father != null) && ((father instanceof TMLArchiCPUNode) || (father instanceof TMLArchiHWANode) || (father instanceof TMLArchiFPGANode))) { // @@ -180,7 +199,7 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa } } - + @Override public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; @@ -188,9 +207,9 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa fatherArchUnitMECType = ((TMLArchiNode) father).getMECType(); } JDialogTMLTaskArtifact dialog = new JDialogTMLTaskArtifact(frame, "Setting artifact attributes", this, operationMEC, fatherArchUnitMECType); - // dialog.setSize(400, 350); + // dialog.setSize(400, 350); GraphicLib.centerOnParent(dialog, 400, 350); - dialog.setVisible(true); // blocked until dialog has been closed + dialog.setVisible( true ); // blocked until dialog has been closed operationMEC = dialog.getOperation(); if (!dialog.isRegularClose()) { @@ -228,13 +247,13 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa makeFullValue(); return !error; - } public void makeFullValue() { value = referenceTaskName + "::" + taskName; } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -242,33 +261,35 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa return null; } + @Override public int getType() { return TGComponentManager.TMLARCHI_ARTIFACT; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append("<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\""); - sb.append(referenceTaskName); - sb.append("\" priority=\""); - sb.append(priority); - sb.append("\" operationMEC=\""); - sb.append(operationMEC); - sb.append("\" fatherComponentMECType=\"" + fatherArchUnitMECType.getIndex()); - sb.append("\" />\n"); - sb.append("</extraparam>\n"); + sb.append( "<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\"" ); + sb.append( referenceTaskName ); + sb.append( "\" priority=\"" ); + sb.append( priority ); + sb.append( "\" operationMEC=\"" ); + sb.append( operationMEC ); + sb.append( "\" fatherComponentMECType=\"" + fatherArchUnitMECType.getIndex() ); + sb.append( "\" />\n" ); + sb.append( "</extraparam>\n" ); return new String(sb); } @Override - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ // try { NodeList nli; Node n1, n2; Element elt; - // int t1id; + // int t1id; String svalue = null, sname = null, sreferenceTask = null; String prio; @@ -309,7 +330,7 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa if (svalue != null) { value = svalue; } - if (sname != null) { + if (sname != null){ taskName = sname; } if (sreferenceTask != null) { @@ -321,7 +342,7 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } makeFullValue(); } @@ -338,17 +359,15 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa referenceTaskName = _referenceTaskName; makeFullValue(); } - - public void setFullName(String _taskName, String _referenceTaskName) { - taskName = _taskName; - referenceTaskName = _referenceTaskName; + public void setFullName(String _taskName, String _referenceTaskName){ + taskName= _taskName; + referenceTaskName=_referenceTaskName; makeFullValue(); } - public String getTaskName() { return taskName; } - + public void setTaskName(String s) { taskName = s; } @@ -361,55 +380,52 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa return operationMEC; } - - public int getOperationType() { - - //TraceManager.addDev("GET OP TYPE for" + this.getTaskName()); - - if (fatherArchUnitMECType instanceof FepMEC) { - //TraceManager.addDev("\tFEP" + " opMEC=" + operationMEC); - if (operationMEC.equals("CWM")) { + public int getOperationType() { + if( fatherArchUnitMECType instanceof FepMEC ) { + if( operationMEC.equals( "CWM" ) ) { return FepOperationMEC.CWM_MEC; - } else if (operationMEC.equals("CWL")) { - //TraceManager.addDev( "Operation: " + operationMEC + " returns " + FepOperationMEC.CwlMEC ); + } + else if( operationMEC.equals( "CWL" ) ) { + //TraceManager.addDev( "Operation: " + operation + " returns " + FepOperationMEC.CwlMEC ); return FepOperationMEC.CWL_MEC; - } else if (operationMEC.equals("CWA")) { + } + else if( operationMEC.equals( "CWA" ) ) { //TraceManager.addDev( "Operation: " + operation + " returns " + FepOperationMEC.CwaMEC ); return FepOperationMEC.CWA_MEC; - } else if (operationMEC.equals("CWP")) { + } + else if( operationMEC.equals( "CWP" ) ) { //TraceManager.addDev( "Operation: " + operation + " returns " + FepOperationMEC.CwpMEC ); return FepOperationMEC.CWP_MEC; - } else if (operationMEC.equals("FFT")) { + } + else if( operationMEC.equals( "FFT" ) ) { //TraceManager.addDev( "Operation: " + operation + " returns " + FepOperationMEC.FftMEC ); return FepOperationMEC.FFT_MEC; - } else if (operationMEC.equals("SUM")) { + } + else if( operationMEC.equals( "SUM" ) ) { //TraceManager.addDev( "Operation: " + operation + " returns " + FepOperationMEC.SumMEC ); return FepOperationMEC.SUM_MEC; } - } else if (fatherArchUnitMECType instanceof MapperMEC) { - //TraceManager.addDev("\tMapper"); + } + else if( fatherArchUnitMECType instanceof MapperMEC ) { //TraceManager.addDev( "Operation: " + operation + " returns " + OperationMEC.MappOperationMEC ); return OperationMEC.MAPP_OPERATION_MEC; - } else if (fatherArchUnitMECType instanceof InterleaverMEC) { - //TraceManager.addDev("\tInterleaver"); + } + else if( fatherArchUnitMECType instanceof InterleaverMEC ) { //TraceManager.addDev( "Operation: " + operation + " returns " + OperationMEC.IntlOperationMEC ); return OperationMEC.INTL_OPERATION_MEC; - } else if (fatherArchUnitMECType instanceof AdaifMEC) { - //TraceManager.addDev("\tAdaif"); + } + else if( fatherArchUnitMECType instanceof AdaifMEC ) { //TraceManager.addDev( "Operation: " + operation + " returns " + OperationMEC.AdaifOperationMEC ); return OperationMEC.ADAIF_OPERATION_MEC; - } else if (fatherArchUnitMECType instanceof CpuMEC) { - //TraceManager.addDev("\tCpu MEC"); - ////TraceManager.addDev( "Operation: " + operation + " returns " + OperationMEC.CpuOperationMEC ); + } + else if( fatherArchUnitMECType instanceof CpuMEC ) { + //TraceManager.addDev( "Operation: " + operation + " returns " + OperationMEC.CpuOperationMEC ); return OperationMEC.CPU_OPERATION_MEC; } - //TraceManager.addDev("\tUnknown MEC"); return -1; } public ArchUnitMEC getArchUnitMEC() { return fatherArchUnitMECType; } - - } diff --git a/src/main/java/ui/tmldd/TMLArchiBUSNode.java b/src/main/java/ui/tmldd/TMLArchiBUSNode.java index 63f7fa95863e4be78df2c8be9dbc8ea266c95099..9ffa77554ea2379877659db1e27d8f275b0a1bc2 100755 --- a/src/main/java/ui/tmldd/TMLArchiBUSNode.java +++ b/src/main/java/ui/tmldd/TMLArchiBUSNode.java @@ -36,25 +36,37 @@ * knowledge of the CeCILL license and that you accept its terms. */ +package ui.tmldd; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Polygon; +import java.util.Vector; +import javax.swing.JFrame; +import javax.swing.JOptionPane; -package ui.tmldd; - -import myutil.GraphicLib; -import myutil.TraceManager; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; + +import myutil.GraphicLib; +import myutil.TraceManager; import tmltranslator.HwBus; -import ui.*; +import ui.ColorManager; +import ui.LinkedReference; +import ui.MalformedModelingException; +import ui.SwallowTGComponent; +import ui.TAttribute; +import ui.TDiagramPanel; +import ui.TGComponent; +import ui.TGComponentManager; +import ui.TGConnectingPoint; +import ui.WithAttributes; +import ui.atd.ATDAttack; import ui.util.IconManager; import ui.window.JDialogBUSNode; -import ui.atd.ATDAttack; - -import javax.swing.*; -import java.awt.*; -import java.util.Vector; /** * Class TMLArchiBUSNode @@ -64,11 +76,16 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements SwallowTGComponent, LinkedReference, WithAttributes, TMLArchiElementInterface { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; - private static String stereotype = "Bus"; + + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; + private static final int[] PRIVATE_ICON_OFFSETS_X = new int[]{ 4, 7, 10, 13, 16, 19, 22, 22, 13, 4 }; + private static final int[] PRIVATE_ICON_OFFSETS_Y = new int[]{ 18, 22, 22, 18, 22, 22,18, 35, 43, 35 }; + + private /*static Issue #31 why is this static??*/ String stereotype = "Bus"; private int byteDataSize = HwBus.DEFAULT_BYTE_DATA_SIZE; private int pipelineSize = HwBus.DEFAULT_PIPELINE_SIZE; @@ -81,11 +98,14 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo public TMLArchiBUSNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 50; + // Issue #31 +// width = 250; +// height = 50; + textY = 15; minWidth = 100; minHeight = 50; - + initScaling( 250, 50 ); + nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -122,19 +142,23 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo myImageIcon = IconManager.imgic700; } - public void internalDrawing(Graphics g) { + @Override + protected void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); // 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); + 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); + 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.BUS_BOX); @@ -146,46 +170,54 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY); // Issue #31 g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g,name, x + (width - w)/2, y + 2 * textY ); // Issue #31 // Icon - //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1102.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int imgOffset = scale( 4 ); + g.drawImage( scale( IconManager.imgic1102.getImage() ), x + imgOffset/*4*/, y + imgOffset/*4*/, null); c = g.getColor(); //Draw bus privacy - if (privacy== HwBus.BUS_PUBLIC){ - - } - else { - int[] xps = new int[]{x+4, x+7, x+10, x+13, x+16, x+19, x+22, x+22, x+13, x+4}; - int[] yps = new int[]{y+18, y+22, y+22, y+18, y+22, y+22,y+18, y+35, y+43, y+35}; + if (privacy != HwBus.BUS_PUBLIC){ + final int[] xps = computePoints( x, PRIVATE_ICON_OFFSETS_X );// Issue #31 new int[]{x+4, x+7, x+10, x+13, x+16, x+19, x+22, x+22, x+13, x+4}; + final int[] yps = computePoints( y, PRIVATE_ICON_OFFSETS_Y );// Issue #31 new int[]{y+18, y+22, y+22, y+18, y+22, y+22,y+18, y+35, y+43, y+35}; g.setColor(Color.green); g.fillPolygon(xps, yps,10); - - // g.drawOval(x+6, y+19, 12, 18); - - // g.fillRect(x+4, y+25, 18, 14); g.setColor(c); g.drawPolygon(xps, yps,10); - // g.drawRect(x+4, y+25, 18, 14); } } + + private static int[] computePoints( final int coordinate, + final int[] offsets ) { + final int[] pointsX = new int[ offsets.length ]; + + for ( int index = 0; index < offsets.length; index++ ) { + pointsX[ index ] = coordinate + offsets[ index ]; + } + + return pointsX; + } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); - pol.addPoint(x + derivationx, y - derivationy); - pol.addPoint(x + derivationx + width, y - derivationy); - pol.addPoint(x + derivationx + width, y + height - derivationy); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + pol.addPoint(x + derivationX, y - derivationY); + pol.addPoint(x + derivationX + width, y - derivationY); + pol.addPoint(x + derivationX + width, y + height - derivationY); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { return this; } @@ -206,6 +238,7 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -331,11 +364,12 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_BUSNODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -401,11 +435,10 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } - public int getByteDataSize(){ return byteDataSize; } @@ -425,10 +458,11 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo return privacy; } - public void setPrivacy(int p){ privacy=p; } + + @Override public String getAttributes() { String attr = ""; attr += "Data size (in byte) = " + byteDataSize + "\n"; @@ -443,8 +477,8 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return TRANSFER; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiBridgeNode.java b/src/main/java/ui/tmldd/TMLArchiBridgeNode.java index 3d0a15a4838055c3fec54c5951e56319cada4674..dd89d9d156e9b363d2e549cdd541fc506af73e67 100755 --- a/src/main/java/ui/tmldd/TMLArchiBridgeNode.java +++ b/src/main/java/ui/tmldd/TMLArchiBridgeNode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -61,21 +58,27 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; - private String stereotype = "BRIDGE"; + + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; + + private String stereotype = "BRIDGE"; private int bufferByteDataSize = HwBridge.DEFAULT_BUFFER_BYTE_DATA_SIZE; - public TMLArchiBridgeNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public TMLArchiBridgeNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 100; + // Issue #31 +// width = 250; +// height = 100; + textY = 15; minWidth = 100; minHeight = 35; + initScaling( 250, 100 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -113,20 +116,23 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa myImageIcon = IconManager.imgic700; } - - public void internalDrawing(Graphics g) { - + @Override + protected void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + // 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); + 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); + 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.BRIDGE_BOX); @@ -136,25 +142,30 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa // Strings String ster = "<<" + stereotype + ">>"; int w = g.getFontMetrics().stringWidth(ster); - g.drawString(ster, x + (width - w)/2, y + textY1); + drawSingleString(g,ster, x + (width - w)/2, y + textY ); // Issue #31 w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g,name, x + (width - w)/2, y + 2 * textY ); // Issue #31 // Icon - //g.drawImage(IconManager.imgic1104.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1104.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int iconMargin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1104.getImage() ), x + iconMargin/*4*/, y + iconMargin/*4*/, null); } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); - pol.addPoint(x + derivationx, y - derivationy); - pol.addPoint(x + derivationx + width, y - derivationy); - pol.addPoint(x + derivationx + width, y + height - derivationy); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + pol.addPoint(x + derivationX, y - derivationY); + pol.addPoint(x + derivationX + width, y - derivationY); + pol.addPoint(x + derivationX + width, y + height - derivationY); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { return this; } @@ -164,13 +175,13 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa public String getStereotype() { return stereotype; - } public String getNodeName() { return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -178,7 +189,6 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa String tmpName; JDialogBridgeNode dialog = new JDialogBridgeNode(frame, "Setting bridge attributes", this); - // dialog.setSize(350, 350); GraphicLib.centerOnParent(dialog, 350, 350); dialog.setVisible( true ); // blocked until dialog has been closed @@ -239,11 +249,12 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_BRIDGENODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -299,15 +310,15 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } - public int getBufferByteDataSize(){ return bufferByteDataSize; } + @Override public String getAttributes() { String attr = ""; attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; @@ -315,9 +326,8 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return TRANSFER; } - - } diff --git a/src/main/java/ui/tmldd/TMLArchiCPNode.java b/src/main/java/ui/tmldd/TMLArchiCPNode.java index c6c712522ba9c7cfc417d33132e3715d636732eb..e83a9fb11bed182d693a6bb7892658ae79ffb20a 100755 --- a/src/main/java/ui/tmldd/TMLArchiCPNode.java +++ b/src/main/java/ui/tmldd/TMLArchiCPNode.java @@ -36,10 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - - package ui.tmldd; import myutil.GraphicLib; @@ -55,8 +51,13 @@ import ui.util.IconManager; import ui.window.JDialogCommPatternMapping; import javax.swing.*; -import java.awt.*; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Polygon; import java.util.ArrayList; +import java.util.List; import java.util.ListIterator; import java.util.Vector; @@ -69,10 +70,11 @@ import java.util.Vector; */ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes, TMLArchiCPInterface { // Graphical attributes - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "CP"; private String reference=""; @@ -89,10 +91,13 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow public TMLArchiCPNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 50; + // Issue #31 +// width = 250; +// height = 50; + textY = 15; minWidth = 100; minHeight = 50; + initScaling( 250, 50 ); nbConnectingPoint = 0; connectingPoint = new TGConnectingPoint[0]; @@ -113,19 +118,22 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow } @Override - public void internalDrawing(Graphics g) { + protected void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); // 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); + 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); + 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.BUS_BOX); @@ -137,7 +145,7 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY); // Issue #31 g.setFont(f); // Complete name is derived @@ -146,13 +154,20 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow // String val = name + "::" + reference; // completeName = val; w = g.getFontMetrics().stringWidth(val); - g.drawString(val, x + (width - w)/2, y + textY2); + drawSingleString(g,val, x + (width - w)/2, y + 2 * textY ); // Issue #31 // Icon + + // Issue #31 + final int iconMargin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1102.getImage() ), x + iconMargin/*4*/, y + iconMargin/*4*/, null); + g.drawImage( scale( IconManager.img9 ), x + width - scale( 20 ), y + iconMargin/*4*/, null); + //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1102.getImage(), x + 4, y + 4, null); +// g.drawImage(IconManager.imgic1102.getImage(), x + 4, y + 4, null); //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Link to mapped units if (c == ColorManager.POINTER_ON_ME_0) { TDiagramPanel tdp = getTDiagramPanel(); @@ -188,12 +203,15 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); - pol.addPoint(x + derivationx, y - derivationy); - pol.addPoint(x + derivationx + width, y - derivationy); - pol.addPoint(x + derivationx + width, y + height - derivationy); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + pol.addPoint(x + derivationX, y - derivationY); + pol.addPoint(x + derivationX + width, y - derivationY); + pol.addPoint(x + derivationX + width, y + height - derivationY); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); @@ -421,8 +439,8 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow } } - public java.util.List<TMLArchiPortArtifact> getPortArtifactList() { - java.util.List<TMLArchiPortArtifact> v = new ArrayList<TMLArchiPortArtifact>(); + public List<TMLArchiPortArtifact> getPortArtifactList() { + List<TMLArchiPortArtifact> v = new ArrayList<TMLArchiPortArtifact>(); for( int i = 0; i < nbInternalTGComponent; i++ ) { if( tgcomponent[i] instanceof TMLArchiPortArtifact ) { @@ -487,8 +505,8 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow return vectorToReturn; } - public java.util.List<Integer> getTransferTypes() { - java.util.List<Integer> transferTypes = new ArrayList<Integer>(); + public List<Integer> getTransferTypes() { + List<Integer> transferTypes = new ArrayList<Integer>(); transferTypes.add( transferType1 ); transferTypes.add( transferType2 ); @@ -496,6 +514,7 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow } // Display the mapping of instances onto platform units + @Override public String getAttributes() { String attr = ""; diff --git a/src/main/java/ui/tmldd/TMLArchiCPUNode.java b/src/main/java/ui/tmldd/TMLArchiCPUNode.java index fbe44aac37e306e81fb0e9a7b064ee32b1349e8f..20bc76b997c8b3ad6f4017ab723d8c3887571a4a 100755 --- a/src/main/java/ui/tmldd/TMLArchiCPUNode.java +++ b/src/main/java/ui/tmldd/TMLArchiCPUNode.java @@ -36,12 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ - package ui.tmldd; - import myutil.GraphicLib; -import myutil.TraceManager; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -63,12 +60,13 @@ import java.util.Vector; * @author Ludovic APVRILLE * @version 1.1 21/05/2008 */ -public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, WithAttributes, - TMLArchiElementInterface, TMLArchiElementWithArtifactList { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; +public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { + + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "CPU"; private int nbOfCores = HwCPU.DEFAULT_NB_OF_CORES; @@ -89,10 +87,13 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, public TMLArchiCPUNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 200; + // Issue #31 +// width = 250; +// height = 200; + textY = 15; minWidth = 150; minHeight = 100; + initScaling( 250, 200 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -130,19 +131,23 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, myImageIcon = IconManager.imgic700; } - public void internalDrawing(Graphics g) { + @Override + protected void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); // 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); + 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); + 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.CPU_BOX_1); @@ -154,29 +159,34 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, 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); + drawSingleString(g,ster, x + (width - w) / 2, y + textY);// Issue #31 g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w) / 2, y + textY2); + drawSingleString(g,name, x + (width - w) / 2, y + 2 * textY );// Issue #31 // Icon - g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int imgOffset = scale( 4 ); + g.drawImage( scale( IconManager.imgic1100.getImage() ), x + imgOffset/*4*/, y + imgOffset/*4*/, null); } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); - pol.addPoint(x + derivationx, y - derivationy); - pol.addPoint(x + derivationx + width, y - derivationy); - pol.addPoint(x + derivationx + width, y + height - derivationy); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + pol.addPoint(x + derivationX, y - derivationY); + pol.addPoint(x + derivationX + width, y - derivationY); + pol.addPoint(x + derivationX + width, y + height - derivationY); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); if (pol.contains(x1, y1)) { return this; } - + return null; } @@ -189,6 +199,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -198,18 +209,15 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, JDialogCPUNode dialog = new JDialogCPUNode(getTDiagramPanel().getMainGUI(), frame, "Setting CPU attributes", this, MECType, transactions); dialog.setSize(500, 450); GraphicLib.centerOnParent(dialog, 500, 450); - dialog.setVisible(true); // blocked until dialog has been closed - + // dialog.show(); // blocked until dialog has been closed + dialog.setVisible(true); + MECType = dialog.getMECType(); - //TraceManager.addDev("CPU core 1"); - if (!dialog.isRegularClose()) { return false; } - //TraceManager.addDev("CPU core 2"); - if (dialog.getNodeName().length() != 0) { tmpName = dialog.getNodeName(); tmpName = tmpName.trim(); @@ -220,7 +228,6 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, name = tmpName; } } - // TraceManager.addDev("CPU core 3"); schedulingPolicy = dialog.getSchedulingPolicy(); if (schedulingPolicy == HwCPU.BASIC_ROUND_ROBIN) { @@ -246,13 +253,10 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, } } - //TraceManager.addDev("CPU core 4"); - if (dialog.getNbOfCores().length() != 0) { try { tmp = nbOfCores; nbOfCores = Integer.decode(dialog.getNbOfCores()).intValue(); - //TraceManager.addDev("Nb of cores=" + nbOfCores); if (nbOfCores <= 0) { nbOfCores = tmp; error = true; @@ -427,17 +431,17 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, return true; } - - + @Override public int getType() { return TGComponentManager.TMLARCHI_CPUNODE; } + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof TMLArchiArtifact; - } + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { //Set its coordinates @@ -450,9 +454,9 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, } return false; - } + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } @@ -468,6 +472,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, return v; } + @Override public void hasBeenResized() { for (int i = 0; i < nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLArchiArtifact) { @@ -477,6 +482,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -506,8 +512,6 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, // try { - //TraceManager.addDev("Extra param of CPU node " + this.getValue()); - NodeList nli; Node n1, n2; Element elt; @@ -600,6 +604,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, } } + @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_NODE_TMLARCHI; } @@ -660,7 +665,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, return operation; } - + @Override public String getAttributes() { String attr = ""; attr += "Nb of cores = " + nbOfCores + "\n"; @@ -685,8 +690,8 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, } + @Override public int getComponentType() { return CONTROLLER; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiCommunicationArtifact.java b/src/main/java/ui/tmldd/TMLArchiCommunicationArtifact.java index 6ee5ae33b6d2fb8ea10de09268663dc9a1c98462..df36d41b05ffce93af72456073740e5e1a0cbe85 100755 --- a/src/main/java/ui/tmldd/TMLArchiCommunicationArtifact.java +++ b/src/main/java/ui/tmldd/TMLArchiCommunicationArtifact.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -60,14 +57,20 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes, TMLArchiChannelInterface { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int textY2 = 35; - protected int space = 5; - protected int fileX = 20; - protected int fileY = 25; - protected int cran = 5; + + // Issue #31 + private static final int SPACE = 5; + private static final int CRAN = 5; + private static final int FILE_X = 20; + private static final int FILE_Y = 25; +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int textY2 = 35; +// protected int space = 5; +// protected int fileX = 20; +// protected int fileY = 25; +// protected int cran = 5; protected String oldValue = ""; protected String referenceCommunicationName = "TMLCommunication"; @@ -78,9 +81,13 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i public TMLArchiCommunicationArtifact(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 75; - height = 40; + // Issue #31 +// width = 75; +// height = 40; + textX = 5; + textY = 15; minWidth = 75; + initScaling( 75, 40 ); nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -100,17 +107,18 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i myImageIcon = IconManager.imgic702; } + @Override public boolean isHidden() { - //TraceManager.addDev("Archi task artifact: Am I hidden?" + getValue()); - boolean ret = false; - if (tdp != null) { - if (tdp instanceof TMLArchiDiagramPanel) { - ret = !(((TMLArchiDiagramPanel)(tdp)).inCurrentView(this)); - - } - } - //TraceManager.addDev("Hidden? -> " + ret); - return ret; + //TraceManager.addDev("Archi task artifact: Am I hidden?" + getValue()); + boolean ret = false; + if (tdp != null) { + if (tdp instanceof TMLArchiDiagramPanel) { + ret = !(((TMLArchiDiagramPanel)(tdp)).inCurrentView(this)); + + } + } + //TraceManager.addDev("Hidden? -> " + ret); + return ret; } public int getPriority() { @@ -121,39 +129,49 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i priority = _priority; } - - public void internalDrawing(Graphics g) { - + @Override + protected void internalDrawing(Graphics g) { if (oldValue.compareTo(value) != 0) { setValue(value, g); } g.drawRect(x, y, width, height); - //g.drawRoundRect(x, y, width, height, arc, arc); - g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); - g.drawLine(x+width-space-fileX, y + space, x+width-space-cran, y+space); - g.drawLine(x+width-space-cran, y+space, x+width-space, y+space + cran); - g.drawLine(x+width-space, y+space + cran, x+width-space, y+space+fileY); - g.drawLine(x+width-space, y+space+fileY, x+width-space-fileX, y+space+fileY); - g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); - g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); - + // Issue #31 + final int space = scale( SPACE ); + final int marginFileX = scale( SPACE + FILE_X ); + final int marginFileY = scale( SPACE + FILE_Y ); + final int marginCran = scale( SPACE + CRAN ); + + g.drawLine(x+width-marginFileX/*space-fileX*/, y + space, x+width- marginFileX/*space-fileX*/, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width-marginFileX/*space-fileX*/, y + space, x+width- marginCran/*space-cran*/, y+space); + g.drawLine(x+width- marginCran/*space-cran*/, y+space, x+width-space, y+ marginCran/*space + cran*/); + g.drawLine(x+width-space, y+ marginCran/*space + cran*/, x+width-space, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width-space, y+ marginFileY/*space+fileY*/, x+width- marginFileX/*space-fileX*/, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width- marginCran/*space-cran*/, y+space, x+width- marginCran/*space-cran*/, y+ marginCran/*space+cran*/); + g.drawLine(x+width- marginCran/*space-cran*/, y+ marginCran/*space+cran*/, x + width-space, y+ marginCran/*space+cran*/); + + + g.drawImage( scale( IconManager.img9 ), x+width- scale( SPACE + FILE_X - 3 )/*space-fileX + 3*/, y + scale( SPACE + 7 )/*space + 7*/, null); //g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); + g.drawString(value, x + textX , y + textY); Font f = g.getFont(); g.setFont(f.deriveFont(Font.ITALIC)); - g.drawString(typeName, x + textX , y + textY + 20); + g.drawString(typeName, x + textX , y + textY + scale( 20 ) );// Issue #31 g.setFont(f); - } public void setValue(String val, Graphics g) { oldValue = value; int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); + + // Issue #31 + final int marginFileX = scale( SPACE + FILE_X ); + + int w1 = Math.max(minWidth, w + 2 * textX + marginFileX /*fileX + space*/); // if (w1 != width) { @@ -163,6 +181,7 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i // } + @Override public void resizeWithFather() { if ((father != null) && (father instanceof TMLArchiCommunicationNode)) { // @@ -172,13 +191,12 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i } } - + @Override public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; JDialogCommunicationArtifact dialog = new JDialogCommunicationArtifact(frame, "Setting channel artifact attributes", this); - // dialog.setSize(700, 600); GraphicLib.centerOnParent(dialog, 400, 300); dialog.setVisible( true ); // blocked until dialog has been closed @@ -232,6 +250,7 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i value = referenceCommunicationName + "::" + communicationName; } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -239,10 +258,12 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i return null; } + @Override public int getType() { return TGComponentManager.TMLARCHI_COMMUNICATION_ARTIFACT; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info value=\"" + value + "\" communicationName=\"" + communicationName + "\" referenceCommunicationName=\""); @@ -263,7 +284,6 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i NodeList nli; Node n1, n2; Element elt; - // int t1id; String svalue = null, sname = null, sreferenceCommunication = null, stype = null; String prio = null; @@ -307,8 +327,9 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } + makeFullValue(); } @@ -329,7 +350,6 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i return communicationName; } - public String getFullValue() { String tmp = getValue(); tmp += " (" + getTypeName() + ")"; @@ -340,10 +360,8 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i return typeName; } + @Override public String getAttributes() { return "Priority = " + priority; } - - - } diff --git a/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java b/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java index ac99ba8ee825cf510fba6f9b3f925a3670cbacbd..20114b46648b6b90ffb8561cdc333b21b93b00b1 100755 --- a/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java +++ b/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import ui.SwallowTGComponent; @@ -64,29 +61,30 @@ public abstract class TMLArchiCommunicationNode extends TMLArchiNode implements super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); } - + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return ( (tgc instanceof TMLArchiCommunicationArtifact) || (tgc instanceof TMLArchiEventArtifact) ); } + @Override public boolean addSwallowedTGComponent( TGComponent tgc, int x, int y ) { - if( tgc instanceof TMLArchiCommunicationArtifact ) { // Make it an internal component // It's one of my son //Set its coordinates tgc.setFather(this); tgc.setDrawingZone(true); - tgc.resizeWithFather(); + tgc.resizeWithFather(); //add it addInternalComponent( tgc, 0 ); return true; } else { - TraceManager.addDev("Testing swallow " + tgc); - if( tgc instanceof TMLArchiEventArtifact ) { - TraceManager.addDev("Testing swallow archievent ok " + tgc); + TraceManager.addDev("Testing swallow " + tgc); + + if( tgc instanceof TMLArchiEventArtifact ) { + TraceManager.addDev("Testing swallow archievent ok " + tgc); tgc.setFather( this ); tgc.setDrawingZone( true ); tgc.resizeWithFather(); @@ -97,45 +95,49 @@ public abstract class TMLArchiCommunicationNode extends TMLArchiNode implements } } + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } - public List<TMLArchiCommunicationArtifact> getChannelArtifactList() { - List<TMLArchiCommunicationArtifact> v = new ArrayList<TMLArchiCommunicationArtifact>(); + for( int i = 0; i < nbInternalTGComponent; i++ ) { if( tgcomponent[i] instanceof TMLArchiCommunicationArtifact ) { v.add( (TMLArchiCommunicationArtifact)( tgcomponent[i]) ); } } + return v; } - public ArrayList<TMLArchiKey> getKeyList(){ - ArrayList<TMLArchiKey> v = new ArrayList<TMLArchiKey>(); + public List<TMLArchiKey> getKeyList(){ + List<TMLArchiKey> v = new ArrayList<TMLArchiKey>(); + for( int i = 0; i < nbInternalTGComponent; i++ ) { if( tgcomponent[i] instanceof TMLArchiKey ) { v.add( (TMLArchiKey)( tgcomponent[i]) ); } } + return v; } public List<TMLArchiEventArtifact> getEventArtifactList() { - List<TMLArchiEventArtifact> v = new ArrayList<TMLArchiEventArtifact>(); + for( int i = 0; i < nbInternalTGComponent; i++ ) { if( tgcomponent[i] instanceof TMLArchiEventArtifact ) { v.add( (TMLArchiEventArtifact)(tgcomponent[i]) ); } } + return v; } + @Override public void hasBeenResized() { - for( int i = 0; i < nbInternalTGComponent; i++ ) { if( tgcomponent[i] instanceof TMLArchiCommunicationArtifact ) { tgcomponent[i].resizeWithFather(); @@ -148,11 +150,13 @@ public abstract class TMLArchiCommunicationNode extends TMLArchiNode implements } } + @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_NODE_TMLARCHI; } - public int getComponentType() { + @Override + public int getComponentType() { return OTHER; } } diff --git a/src/main/java/ui/tmldd/TMLArchiConnectingPoint.java b/src/main/java/ui/tmldd/TMLArchiConnectingPoint.java index d7db38ab5140a4dcd5045187700304cb0756173d..996d29edcb3e43cfc74f2ac17a396ea83bafdd6c 100755 --- a/src/main/java/ui/tmldd/TMLArchiConnectingPoint.java +++ b/src/main/java/ui/tmldd/TMLArchiConnectingPoint.java @@ -58,7 +58,7 @@ public class TMLArchiConnectingPoint extends TGConnectingPointWidthHeight{ public TMLArchiConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } - + @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_NODE_TMLARCHI; } diff --git a/src/main/java/ui/tmldd/TMLArchiConnectorNode.java b/src/main/java/ui/tmldd/TMLArchiConnectorNode.java index 681943f6277689ee359aa60365d98d36f036ded4..be27c2340f64b9e9cf0d0bf9f93443065461ec15 100755 --- a/src/main/java/ui/tmldd/TMLArchiConnectorNode.java +++ b/src/main/java/ui/tmldd/TMLArchiConnectorNode.java @@ -78,6 +78,7 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute editable = true; } + @Override public boolean editOndoubleClick(JFrame frame) { JDialogTMLConnectorNode dialog = new JDialogTMLConnectorNode(frame, "Setting connector attributes", this); //dialog.setSize(350, 300); @@ -92,7 +93,7 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute return true; } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ if (hasASpy) { g.drawImage(IconManager.img5200, (x1 + x2)/2, (y1 + y2)/2, null); @@ -106,8 +107,10 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute } public boolean hasASpy() { - return hasASpy; + return hasASpy; } + + @Override public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem generate = null; @@ -122,10 +125,13 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute generate.addActionListener(menuAL); componentMenu.add(generate); } + + @Override public int getType() { return TGComponentManager.CONNECTOR_NODE_TMLARCHI; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info priority=\""); @@ -182,6 +188,7 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute } } + @Override public boolean eventOnPopup(ActionEvent e) { String s = e.getActionCommand(); TraceManager.addDev("action: " + s); @@ -199,6 +206,7 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute return true; } + public TMLArchiCPUNode getOriginNode() { TGComponent tgc = tdp.getComponentToWhichBelongs(getTGConnectingPointP1()); if (tgc instanceof TMLArchiCPUNode) { @@ -220,7 +228,7 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute public int getPriority() { return priority; } - + @Override public String getAttributes() { return "Priority = " + priority; } diff --git a/src/main/java/ui/tmldd/TMLArchiCrossbarNode.java b/src/main/java/ui/tmldd/TMLArchiCrossbarNode.java index 41197522bae849ed7ec4f5eecad216d83e7540d6..6937ebab783b89023cc196844f40241a3089f3de 100755 --- a/src/main/java/ui/tmldd/TMLArchiCrossbarNode.java +++ b/src/main/java/ui/tmldd/TMLArchiCrossbarNode.java @@ -61,10 +61,12 @@ import java.awt.*; * @author Ludovic APVRILLE, adapted for crossbar by Daniela Genius 10/08/2016 */ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; + + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "Crossbar"; private int byteDataSize = HwBus.DEFAULT_BYTE_DATA_SIZE; @@ -75,10 +77,13 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S public TMLArchiCrossbarNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 50; + // Issue #31 +// width = 250; +// height = 50; + textY = 15; minWidth = 100; minHeight = 50; + initScaling( 250, 50 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -116,19 +121,23 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S myImageIcon = IconManager.imgic700; } - public void internalDrawing(Graphics g) { + @Override + protected void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); // 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); + 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); + 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.BUS_BOX); @@ -140,41 +149,28 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY );// Issue #31 g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g,name, x + (width - w)/2, y + 2 * textY );// Issue #31 // Icon - //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1102.getImage(), x + 4, y + 4, null); - g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int iconMargin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1102.getImage() ), x + iconMargin/*4*/, y + iconMargin/*4*/, null); + g.drawImage( scale( IconManager.img9 ), x + width - scale( 20 ), y + iconMargin/*4*/, null); c = g.getColor(); - - //Draw bus privacy - /* if (privacy== HwBus.BUS_PUBLIC){ - - } - else { - int[] xps = new int[]{x+4, x+7, x+10, x+13, x+16, x+19, x+22, x+22, x+13, x+4}; - int[] yps = new int[]{y+18, y+22, y+22, y+18, y+22, y+22,y+18, y+35, y+43, y+35}; - g.setColor(Color.green); - g.fillPolygon(xps, yps,10); - - // g.drawOval(x+6, y+19, 12, 18); - - // g.fillRect(x+4, y+25, 18, 14); - g.setColor(c); - g.drawPolygon(xps, yps,10); - // g.drawRect(x+4, y+25, 18, 14); - }*/ } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); + + // Issue #31 + final int derivationx = scale( DERIVATION_X ); + final int derivationy = scale( DERIVATION_Y ); pol.addPoint(x + derivationx, y - derivationy); pol.addPoint(x + derivationx + width, y - derivationy); pol.addPoint(x + derivationx + width, y + height - derivationy); @@ -196,6 +192,7 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -313,11 +310,12 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_CROSSBARNODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -335,36 +333,36 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ - // - try { - NodeList nli; - Node n1, n2; - Element elt; - // int t1id; - String sstereotype = null, snodeName = null; - 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("info")) { - sstereotype = elt.getAttribute("stereotype"); - snodeName = elt.getAttribute("nodeName"); - } - if (sstereotype != null) { - stereotype = sstereotype; - } - if (snodeName != null){ - name = snodeName; - } - if (elt.getTagName().equals("attributes")) { - byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); - /* arbitrationPolicy =Integer.decode(elt.getAttribute("arbitrationPolicy")).intValue(); pipelineSize = Integer.decode(elt.getAttribute("pipelineSize")).intValue(); + // + try { + NodeList nli; + Node n1, n2; + Element elt; + // int t1id; + String sstereotype = null, snodeName = null; + 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("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + /* arbitrationPolicy =Integer.decode(elt.getAttribute("arbitrationPolicy")).intValue(); pipelineSize = Integer.decode(elt.getAttribute("pipelineSize")).intValue(); if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); } @@ -373,19 +371,17 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S } if ((elt.getAttribute("privacy") != null) && (elt.getAttribute("privacy").length() > 0)){ privacy = Integer.decode(elt.getAttribute("privacy")).intValue();*/ - } - } - } - } - } - } - - catch (Exception e) { - throw new MalformedModelingException(); - } + } + } + } + } + } + } + catch (Exception e) { + throw new MalformedModelingException( e ); + } } - public int getByteDataSize(){ return byteDataSize; } @@ -405,6 +401,7 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S return privacy; }*/ + @Override public String getAttributes() { String attr = ""; attr += "Data size (in byte) = " + byteDataSize + "\n"; @@ -419,8 +416,8 @@ public class TMLArchiCrossbarNode extends TMLArchiCommunicationNode implements S return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return TRANSFER; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiDMANode.java b/src/main/java/ui/tmldd/TMLArchiDMANode.java index 1477f98c645ee0a730112904a89a6606aab6b116..6e023983cb72fcdbd156b7a3b6fe67906d122de3 100755 --- a/src/main/java/ui/tmldd/TMLArchiDMANode.java +++ b/src/main/java/ui/tmldd/TMLArchiDMANode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -61,10 +58,12 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; + + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "DMA"; private int byteDataSize = HwDMA.DEFAULT_BYTE_DATA_SIZE; @@ -73,10 +72,13 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo public TMLArchiDMANode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 200; - height = 200; + // Issue #31 +// width = 200; +// height = 200; + textY = 15; minWidth = 100; minHeight = 50; + initScaling( 200, 200 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -114,18 +116,23 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo myImageIcon = IconManager.imgic1110; } - public void internalDrawing(Graphics g) { + @Override + protected void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + // 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); + 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); + 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.DMA_BOX); @@ -137,21 +144,25 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY ); w = g.getFontMetrics().stringWidth(name); g.setFont(f); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g,name, x + (width - w)/2, y + 2* textY ); // Icon - //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1108.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int iconMargin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1108.getImage() ), x + iconMargin/*4*/, y + iconMargin/*4*/, null); } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); + + // Issue #31 + final int derivationx = scale( DERIVATION_X ); + final int derivationy = scale( DERIVATION_Y ); pol.addPoint(x + derivationx, y - derivationy); pol.addPoint(x + derivationx + width, y - derivationy); pol.addPoint(x + derivationx + width, y + height - derivationy); @@ -173,6 +184,7 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -255,11 +267,12 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_DMANODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -320,7 +333,6 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo } } - public int getByteDataSize(){ return byteDataSize; } @@ -329,6 +341,7 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo return nbOfChannels; } + @Override public String getAttributes() { String attr = ""; attr += "Data size (in byte) = " + byteDataSize + "\n"; @@ -337,8 +350,8 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return TRANSFER; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiDiagramPanel.java b/src/main/java/ui/tmldd/TMLArchiDiagramPanel.java index 2d7dd0f9626a95d0a0442739c83fb8510ae0c5cb..89745e8a62d19553fc65026be8a22251f5b6856d 100755 --- a/src/main/java/ui/tmldd/TMLArchiDiagramPanel.java +++ b/src/main/java/ui/tmldd/TMLArchiDiagramPanel.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.TraceManager; @@ -70,8 +67,6 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib protected int view = 31; - - public TMLArchiDiagramPanel(MainGUI mgui, TToolBar _ttb) { super(mgui, _ttb); /*TDiagramMouseManager tdmm = new TDiagramMouseManager(this); @@ -79,6 +74,7 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib addMouseMotionListener(tdmm);*/ } + @Override public boolean actionOnDoubleClick(TGComponent tgc) { // /*if (tgc instanceof TCDTClass) { @@ -99,6 +95,7 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib return false; } + @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -109,6 +106,7 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib return false; } + @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -119,7 +117,6 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib return false; } - public void replaceArchComponent(TGComponent tgc, TGComponent newtgc){ fatherOfRemoved = tgc.getFather(); @@ -155,10 +152,9 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib actionOnRemove(newtgc); newtgc.actionOnRemove(); return; - - } + @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); @@ -174,26 +170,32 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib masterClockFrequency = _masterClockFrequency; } + @Override public String getXMLHead() { - return "<TMLArchiDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + displayClock() + " >"; + return "<TMLArchiDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + displayClock() + zoomParam() + " >"; // Issue #31 } + @Override public String getXMLTail() { return "</TMLArchiDiagramPanel>"; } + @Override public String getXMLSelectedHead() { return "<TMLArchiDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } + @Override public String getXMLSelectedTail() { return "</TMLArchiDiagramPanelCopy>"; } + @Override public String getXMLCloneHead() { return "<TMLArchiDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } + @Override public String getXMLCloneTail() { return "</TMLArchiDiagramPanelCopy>"; } @@ -279,9 +281,9 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib ll.add( (TMLArchiCommunicationNode) tgc ); } - if (tgc instanceof TGComponentPlugin) { - ll.add(tgc); - } + if (tgc instanceof TGComponentPlugin) { + ll.add(tgc); + } } return ll; diff --git a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java index 536c4f132206ee7970869d718f4fb61b550f5c6e..baeb2e2f67ab49bd5b528e8c1113bfec8015b389 100755 --- a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java +++ b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java @@ -94,7 +94,11 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b); mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID].setEnabled(b); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); diff --git a/src/main/java/ui/tmldd/TMLArchiEventArtifact.java b/src/main/java/ui/tmldd/TMLArchiEventArtifact.java index 03c4e9e9a941cb26351a1973be11e31711c02108..210a750b0afb9a9b248054a8bd9a79af0dcc2af2 100755 --- a/src/main/java/ui/tmldd/TMLArchiEventArtifact.java +++ b/src/main/java/ui/tmldd/TMLArchiEventArtifact.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -61,14 +58,20 @@ import java.awt.*; * @author Andrea ENRICI */ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int textY2 = 35; - protected int space = 5; - protected int fileX = 20; - protected int fileY = 25; - protected int cran = 5; + + // Issue #31 + private static final int SPACE = 5; + private static final int CRAN = 5; + private static final int FILE_X = 20; + private static final int FILE_Y = 25; +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int textY2 = 35; +// protected int space = 5; +// protected int fileX = 20; +// protected int fileY = 25; +// protected int cran = 5; protected String oldValue = ""; protected String referenceEventName = "TMLEvent"; @@ -78,13 +81,16 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement public TMLArchiEventArtifact( int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 75; - height = 40; + // Issue #31 +// width = 75; +// height = 40; + textX = 5; + textY = 15; minWidth = 75; - + initScaling( 75, 40 ); + nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -111,39 +117,45 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement priority = _priority; } - - public void internalDrawing(Graphics g) { - + @Override + protected void internalDrawing(Graphics g) { if (oldValue.compareTo(value) != 0) { setValue(value, g); } g.drawRect(x, y, width, height); - //g.drawRoundRect(x, y, width, height, arc, arc); - g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); - g.drawLine(x+width-space-fileX, y + space, x+width-space-cran, y+space); - g.drawLine(x+width-space-cran, y+space, x+width-space, y+space + cran); - g.drawLine(x+width-space, y+space + cran, x+width-space, y+space+fileY); - g.drawLine(x+width-space, y+space+fileY, x+width-space-fileX, y+space+fileY); - g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); - g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + // Issue #31 + final int space = scale( SPACE ); + final int marginFileX = scale( SPACE + FILE_X ); + final int marginFileY = scale( SPACE + FILE_Y ); + final int marginCran = scale( SPACE + CRAN ); - g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); + g.drawLine(x+width- marginFileX/*space-fileX*/, y + space, x+width - marginFileX/*space-fileX*/, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width- marginFileX/*space-fileX*/, y + space, x+width- marginCran/*space-cran*/, y+space); + g.drawLine(x+width- marginCran/*space-cran*/, y+space, x+width-space, y+ marginCran/*space + cran*/); + g.drawLine(x+ width-space, y+ marginCran/*space + cran*/, x+width-space, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width-space, y+ marginFileY/*space+fileY*/, x+width- marginFileX/*space-fileX*/, y+ marginFileY/*space+fileY*/); + g.drawLine(x+width- marginCran/*space-cran*/, y+space, x+width- marginCran/*space-cran*/, y+ marginCran/*space+cran*/); + g.drawLine(x+width- marginCran/*space-cran*/, y+ marginCran/*space+cran*/, x + width-space, y+ marginCran/*space+cran*/); - g.drawString(value, x + textX , y + textY); + g.drawImage( scale( IconManager.img9 ), x+width- scale( SPACE + FILE_X - 3 )/*space-fileX*/ + 3, y + scale( SPACE + 7 )/*space + 7*/, null);// Issue #31 + + drawSingleString(g,value, x + textX , y + textY); Font f = g.getFont(); g.setFont(f.deriveFont(Font.ITALIC)); - g.drawString(typeName, x + textX , y + textY + 20); + drawSingleString(g,typeName, x + textX , y + textY + scale( 20 ) );// Issue #31 g.setFont(f); - } public void setValue(String val, Graphics g) { oldValue = value; int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); + + // Issue #31 + final int marginFileX = scale( SPACE + FILE_X ); + int w1 = Math.max(minWidth, w + 2 * textX + marginFileX/*fileX + space*/); // if (w1 != width) { @@ -153,6 +165,7 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement // } + @Override public void resizeWithFather() { if ((father != null) && (father instanceof TMLArchiCommunicationNode)) { // @@ -162,9 +175,8 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement } } - + @Override public boolean editOndoubleClick(JFrame frame) { - String tmp; boolean error = false; @@ -214,6 +226,7 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement value = referenceEventName + "::" + eventName; } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -221,12 +234,13 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement return null; } + @Override public int getType() { return TGComponentManager.TMLARCHI_EVENT_ARTIFACT; } + @Override protected String translateExtraParam() { - StringBuffer sb = new StringBuffer( "<extraparam>\n" ); sb.append( "<info value=\"" + value + "\" eventName=\"" + eventName + "\" referenceEventName=\"" ); sb.append( referenceEventName ); @@ -311,7 +325,6 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement return eventName; } - public String getFullValue() { String tmp = getValue(); tmp += " (" + getTypeName() + ")"; @@ -322,8 +335,8 @@ public class TMLArchiEventArtifact extends TGCWithoutInternalComponent implement return typeName; } + @Override public String getAttributes() { return "Priority = " + priority; } - } //End of class diff --git a/src/main/java/ui/tmldd/TMLArchiFPGANode.java b/src/main/java/ui/tmldd/TMLArchiFPGANode.java index fd7a52ed1fd70766bfa2aeb7440d4fe7398b9466..f73e5060b6aef253220be6baea4a9786cfd9a789 100755 --- a/src/main/java/ui/tmldd/TMLArchiFPGANode.java +++ b/src/main/java/ui/tmldd/TMLArchiFPGANode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -62,12 +59,17 @@ import java.util.Vector; * @version 1.1 07/02/2018 * @author Ludovic APVRILLE, Matteo BERTOLINO */ -public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent, WithAttributes, - TMLArchiElementInterface, TMLArchiElementWithArtifactList { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; +public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { + + // Issue #31 + // Issue #31 + private static final int DERIVATION_X = 2; + private static final int DERIVATION_Y = 3; + private static final int MARGIN_Y_2 = 30; +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "FPGA"; private int byteDataSize = HwFPGA.DEFAULT_BYTE_DATA_SIZE; @@ -82,16 +84,15 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent private String operation = ""; private String scheduling = ""; - - public TMLArchiFPGANode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 200; + // Issue #31 +// width = 250; +// height = 200; minWidth = 150; minHeight = 100; - + textY = 15; nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -114,6 +115,9 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent connectingPoint[15] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); addTGConnectingPointsComment(); + + // Issue #31 + initScaling( 250, 200 ); nbInternalTGComponent = 0; @@ -128,19 +132,23 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent myImageIcon = IconManager.imgic1120; } - public void internalDrawing(Graphics g) { + @Override + protected 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); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + 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); + 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.CPU_BOX_1); @@ -152,20 +160,28 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY); // Issue #31 g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + // Issue #31 + final int marginY2 = scale( MARGIN_Y_2 ); + drawSingleString(g,name, x + (width - w)/2, y + marginY2 ); // Icon - g.drawImage(IconManager.imgic1120.getImage(), x + 4, y + 4, null); + // Issue #31 + final int margin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1120.getImage() ), x + margin, y + margin, null); //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); + + // Issue #31 + final int derivationx = scale( DERIVATION_X ); + final int derivationy = scale( DERIVATION_Y ); pol.addPoint(x + derivationx, y - derivationy); pol.addPoint(x + derivationx + width, y - derivationy); pol.addPoint(x + derivationx + width, y + height - derivationy); @@ -178,11 +194,11 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent return null; } - public String getNodeName() { return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -332,7 +348,6 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent } } - if (dialog.getClockRatio().length() != 0) { try { tmp = clockRatio; @@ -363,16 +378,17 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_FPGANODE; } + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof TMLArchiArtifact; - } + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { //Set its coordinates @@ -387,6 +403,7 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent return false; } + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } @@ -402,14 +419,16 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent return v; } - public void hasBeenResized() { - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof TMLArchiArtifact) { - tgcomponent[i].resizeWithFather(); - } - } - } + // Issue #31 +// public void hasBeenResized() { +// for(int i=0; i<nbInternalTGComponent; i++) { +// if (tgcomponent[i] instanceof TMLArchiArtifact) { +// tgcomponent[i].resizeWithFather(); +// } +// } +// } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -439,7 +458,7 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent Element elt; // int t1id; String sstereotype = null, snodeName = null; - String operationTypesTmp; + // String operationTypesTmp; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -513,10 +532,11 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } + @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_NODE_TMLARCHI; } @@ -561,7 +581,7 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent return scheduling; } - + @Override public String getAttributes() { String attr = ""; attr += "Data size (in byte) = " + byteDataSize + "\n"; @@ -573,14 +593,13 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent attr += "EXECI exec. time (in cycle) = " + execiTime + "\n"; attr += "EXECC exec. time (in cycle) = " + execcTime + "\n"; attr += "Operation = " + operation + "\n"; - attr += "Scheduling = " + scheduling + "\n"; attr += "Clock divider = " + clockRatio + "\n"; return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return CONTROLLER; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiFirewallNode.java b/src/main/java/ui/tmldd/TMLArchiFirewallNode.java index 100ddcdd40eaa07d6a8454a08b15948023972432..4479a7736a0a193d40e0cd11763c9d13c2eed8e3 100644 --- a/src/main/java/ui/tmldd/TMLArchiFirewallNode.java +++ b/src/main/java/ui/tmldd/TMLArchiFirewallNode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -50,32 +47,44 @@ import ui.util.IconManager; import ui.window.JDialogFirewallNode; import javax.swing.*; -import java.awt.*; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Polygon; import java.util.ArrayList; +import java.util.List; /** * Class TMLArchiFirewallNode * Node. To be used in TML architecture diagrams. * Creation: 17/10/2016 * @version 1.0 17/10/2016 - * @author Letitia LI + * @author Letitia LI <3 */ public class TMLArchiFirewallNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes, TMLArchiSecurityInterface { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; + + // Issue #31 + private static final int DERIVATION_X = 2; + private static final int DERIVATION_Y = 3; + private static final int MARGIN_Y_2 = 30; +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "FIREWALL"; - private ArrayList<String> rules = new ArrayList<String>(); + private List<String> rules = new ArrayList<String>(); private int latency = 10; public TMLArchiFirewallNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 250; - height = 100; + + // Issue #31 +// width = 250; +// height = 100; minWidth = 100; minHeight = 35; + textY = 15; + initScaling( 250, 100 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -113,11 +122,15 @@ public class TMLArchiFirewallNode extends TMLArchiCommunicationNode implements S myImageIcon = IconManager.imgic700; } - public void internalDrawing(Graphics g) { + @Override + protected void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); // Top lines + // Issue #31 + final int derivationx = scale( DERIVATION_X ); + final int derivationy = scale( DERIVATION_Y ); 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); @@ -134,25 +147,33 @@ public class TMLArchiFirewallNode extends TMLArchiCommunicationNode implements S // Strings String ster = "<<" + stereotype + ">>"; int w = g.getFontMetrics().stringWidth(ster); - g.drawString(ster, x + (width - w)/2, y + textY1); + drawSingleString(g,ster, x + (width - w)/2, y + textY); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + + // Issue #31 + final int marginY2 = scale( MARGIN_Y_2 ); + drawSingleString(g,name, x + (width - w)/2, y + marginY2 ); // Icon - - g.drawImage(IconManager.imgic7001.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int iconMargin = scale( 4 ); + g.drawImage( scale( IconManager.imgic7001.getImage() ), x + iconMargin/*4*/, y + iconMargin/*4*/, null); } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); + + // Issue #31 + final int derivationx = scale( DERIVATION_X ); + final int derivationy = scale( DERIVATION_Y ); pol.addPoint(x + derivationx, y - derivationy); pol.addPoint(x + derivationx + width, y - derivationy); pol.addPoint(x + derivationx + width, y + height - derivationy); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { return this; } @@ -162,13 +183,13 @@ public class TMLArchiFirewallNode extends TMLArchiCommunicationNode implements S public String getStereotype() { return stereotype; - } public String getNodeName() { return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -209,23 +230,24 @@ public class TMLArchiFirewallNode extends TMLArchiCommunicationNode implements S return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_FIREWALL; } + @Override protected String translateExtraParam() { - StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); - sb.append("\" />\n"); - sb.append("<attributes latency=\"" + latency + "\" "); - sb.append("/>\n"); - for (String rule:rules){ - sb.append("<rule value=\"" + rule + "\" "); - sb.append("/>\n"); - } - sb.append("</extraparam>\n"); - return new String(sb); + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes latency=\"" + latency + "\" "); + sb.append("/>\n"); + for (String rule:rules){ + sb.append("<rule value=\"" + rule + "\" "); + sb.append("/>\n"); + } + sb.append("</extraparam>\n"); + return new String(sb); } @Override @@ -275,26 +297,27 @@ public class TMLArchiFirewallNode extends TMLArchiCommunicationNode implements S } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } - - - public int getLatency(){ - return latency; - } - public ArrayList<String> getRules(){ - return rules; - } - public String getAttributes() { - String attr = ""; - attr += "latency = " + latency + "\n"; - return attr; - } - - public int getComponentType() { - return TRANSFER; - } - - + + public int getLatency(){ + return latency; + } + + public List<String> getRules(){ + return rules; + } + + @Override + public String getAttributes() { + String attr = ""; + attr += "latency = " + latency + "\n"; + return attr; + } + + @Override + public int getComponentType() { + return TRANSFER; + } } diff --git a/src/main/java/ui/tmldd/TMLArchiHWANode.java b/src/main/java/ui/tmldd/TMLArchiHWANode.java index 5564e09b9ff94213b29f5879df62c60035a62ff7..e4af4abf9304fe8290624074ecfbe44305ed12f0 100755 --- a/src/main/java/ui/tmldd/TMLArchiHWANode.java +++ b/src/main/java/ui/tmldd/TMLArchiHWANode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -61,12 +58,18 @@ import java.util.Vector; * @version 1.0 23/11/2007 * @author Ludovic APVRILLE */ -public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, WithAttributes, - TMLArchiElementInterface, TMLArchiElementWithArtifactList { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; + +public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { + + // Issue #31 + private static final int DERIVATION_X = 2; + private static final int DERIVATION_Y = 3; + private static final int MARGIN_Y_2 = 30; +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; + private String stereotype = "HWA"; private int byteDataSize = HwCPU.DEFAULT_BYTE_DATA_SIZE; @@ -77,10 +80,12 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, public TMLArchiHWANode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 200; - height = 200; + // Issue #31 +// width = 200; +// height = 200; minWidth = 100; minHeight = 100; + textY = 15; nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -104,6 +109,8 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, connectingPoint[15] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); addTGConnectingPointsComment(); + + initScaling( 200, 200 ); nbInternalTGComponent = 0; @@ -118,19 +125,23 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, myImageIcon = IconManager.imgic700; } - public void internalDrawing(Graphics g) { + @Override + protected 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); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + 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); + 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); @@ -142,20 +153,34 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY ); // Issue #31 g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + + // Issue #31 + final int marginY2 = scale( MARGIN_Y_2 ); + drawSingleString(g,name, x + (width - w)/2, y + marginY2 ); // Icon - g.drawImage(IconManager.imgic1106.getImage(), x + 4, y + 4, null); + + // Issue #31 + final int iconMargin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1106.getImage() ), x + iconMargin /*4*/, y + iconMargin/*4*/, null); + g.drawImage( scale( IconManager.img9 ), x + width - scale( 20 ), y + iconMargin/*4*/, null); + +// g.drawImage(IconManager.imgic1106.getImage(), x + 4, y + 4, null); //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); + + // Issue #31 + final int derivationx = scale( DERIVATION_X ); + final int derivationy = scale( DERIVATION_Y ); pol.addPoint(x + derivationx, y - derivationy); pol.addPoint(x + derivationx + width, y - derivationy); pol.addPoint(x + derivationx + width, y + height - derivationy); @@ -176,6 +201,7 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -261,16 +287,18 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_HWANODE; } + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return (tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0); } + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { if ((tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0)){ tgc.setFather(this); @@ -283,11 +311,11 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, return false; } + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } - public Vector<TMLArchiArtifact> getArtifactList() { Vector<TMLArchiArtifact> v = new Vector<TMLArchiArtifact>(); for(int i=0; i<nbInternalTGComponent; i++) { @@ -299,15 +327,17 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, return v; } - public void hasBeenResized() { - for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof TMLArchiArtifact) { - tgcomponent[i].resizeWithFather(); - } - } - - } + // Issue #31 +// public void hasBeenResized() { +// for(int i=0; i<nbInternalTGComponent; i++) { +// if (tgcomponent[i] instanceof TMLArchiArtifact) { +// tgcomponent[i].resizeWithFather(); +// } +// } +// +// } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -331,7 +361,7 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, Element elt; // int t1id; String sstereotype = null, snodeName = null; - String operationTypesTmp; + // String operationTypesTmp; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -371,10 +401,11 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } + @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_NODE_TMLARCHI; } @@ -391,7 +422,7 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, return operation; } - + @Override public String getAttributes() { String attr = ""; attr += "Data size (in byte) = " + byteDataSize + "\n"; @@ -401,8 +432,8 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, return attr; } + @Override public int getComponentType() { return CONTROLLER; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiKey.java b/src/main/java/ui/tmldd/TMLArchiKey.java index 20d97136408cb1fc084e5d82689845dc0097170e..593ce9d29c4e20dac60ead5dcd4772dc3c4be2e7 100755 --- a/src/main/java/ui/tmldd/TMLArchiKey.java +++ b/src/main/java/ui/tmldd/TMLArchiKey.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -60,16 +57,20 @@ import java.awt.*; * @author Letitia LI, Ludovic APVRILLE */ public class TMLArchiKey extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes, TMLArchiSecurityInterface { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int textY2 = 35; - protected int space = 5; - protected int fileX = 20; - protected int fileY = 25; - protected int cran = 5; - - protected String oldValue = ""; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int textY2 = 35; +// protected int space = 5; +// protected int fileX = 20; +// protected int fileY = 25; +// protected int cran = 5; + private static final int KEY_OFFSET_Y = 5; + private static final int KEY_OFFSET_X = 20; + + //protected String oldValue = ""; protected String referenceKey = "TMLKey"; protected String typeName = "key"; protected int priority = 5; // Between 0 and 10 @@ -77,10 +78,15 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe public TMLArchiKey(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 75; - height = 40; + // Issue #31 +// width = 75; +// height = 40; minWidth = 75; - minHeight = fileY + 5; + minHeight = 30;//fileY + 5; + textX = 5; + textY = 15; + + initScaling( 75, 40 ); nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -100,7 +106,7 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe myImageIcon = IconManager.imgic1118; } - + @Override public boolean isHidden() { //TraceManager.addDev("Archi task artifact: Am I hidden?" + getValue()); boolean ret = false; @@ -113,6 +119,7 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe //TraceManager.addDev("Hidden? -> " + ret); return ret; } + public int getPriority() { return priority; } @@ -121,12 +128,14 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe priority = _priority; } + @Override + protected void internalDrawing(Graphics g) { - public void internalDrawing(Graphics g) { - - if (oldValue.compareTo(value) != 0) { - setValue(value, g); - } + // Issue #31 +// if (oldValue.compareTo(value) != 0) { +// setValue(value, g); +// } + checkWidth( g ); g.drawRect(x, y, width, height); Color c = g.getColor(); @@ -134,10 +143,21 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe g.fillRect(x+1, y+1, width-1, height-1); g.setColor(c); - g.fillOval(x+width-fileX, y+space, height/3, height/3); - g.fillRect(x+width-space-fileX/2,y+space, 3, height*3/4-space); - g.fillRect(x+width-space-fileX/2, y+height*3/4, 8,3); - g.fillRect(x+width-space-fileX/2, y+height*2/3, 8,3); + // Issue #31 + final int keyOffsetX = scale( KEY_OFFSET_X ); + final int keyOffsetY = scale( KEY_OFFSET_Y ); + final int shaftWidth = scale( 3 ); + + // Key head + g.fillOval(x+width-keyOffsetX, y+keyOffsetY, height/3, height/3); + + // Key shaft + g.fillRect(x+width-keyOffsetY-keyOffsetX/2,y+keyOffsetY, shaftWidth/*3*/, height*3/4-keyOffsetY); + + // key teeth + final int teethLength = scale( 8 ); + g.fillRect(x+width-keyOffsetY-keyOffsetX/2, y+height*3/4, teethLength/*8*/, shaftWidth/*3*/); + g.fillRect(x+width-keyOffsetY-keyOffsetX/2, y+height*2/3, teethLength/*8*/, shaftWidth/*3*/); /* //g.drawRoundRect(x, y, width, height, arc, arc); g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); @@ -148,43 +168,43 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); */ - g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); + // Issue #31 + g.drawImage( scale( IconManager.img9 ), x+width-keyOffsetY-keyOffsetX + shaftWidth/*3*/, y + keyOffsetY + scale( 7 ), null ); - g.drawString(value, x + textX , y + textY); + drawSingleString(g,value, x + textX , y + textY); Font f = g.getFont(); g.setFont(f.deriveFont(Font.ITALIC)); - g.drawString(typeName, x + textX , y + textY + 20); + // Issue #31 + drawSingleString(g,typeName, x + textX , y + textY + scale( 20 ) ); g.setFont(f); - } - public void setValue(String val, Graphics g) { - oldValue = value; - int w = fileX + g.getFontMetrics().stringWidth(value) + textX; - int w1 = Math.max(minWidth, w); - - //TraceManager.addDev(" Width=" + width + " w1=" + w1 + " value=" + value); - if (w1 != width) { - width = w1; - resizeWithFather(); - } - //TraceManager.addDev(" Width=" + width + " w1=" + w1 + " value=" + value); - } + // Issue #31 + //private void setValue(String val/*, Graphics g*/) { +// oldValue = value; +// int w = fileX + g.getFontMetrics().stringWidth(value) + textX; +// int w1 = Math.max(minWidth, w); +// +// //TraceManager.addDev(" Width=" + width + " w1=" + w1 + " value=" + value); +// if (w1 != width) { +// width = w1; +// resizeWithFather(); +// } + //TraceManager.addDev(" Width=" + width + " w1=" + w1 + " value=" + value); +// } + @Override public void resizeWithFather() { if ((father != null) && (father instanceof TMLArchiMemoryNode)) { - // setCdRectangle(0, Math.max(0,father.getWidth() - getWidth()), 0, Math.max(father.getHeight() - getHeight(),0)); - //setCd(Math.min(x, father.getWidth() - getWidth()), Math.min(y, father.getHeight() - getHeight())); setMoveCd(x, y); } } - + @Override public boolean editOndoubleClick(JFrame frame) { JDialogArchiKey dialog = new JDialogArchiKey(frame, "Setting channel artifact attributes", this); - // dialog.setSize(700, 600); GraphicLib.centerOnParent(dialog, 700, 600); dialog.setVisible( true ); // blocked until dialog has been closed String tmp; @@ -200,7 +220,6 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe if (dialog.getReferenceCommunicationName().length() != 0) { tmp = dialog.getReferenceCommunicationName(); referenceKey = tmp; - } if (dialog.getCommunicationName().length() != 0) { @@ -217,8 +236,6 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe typeName = dialog.getTypeName(); } - - if (error) { JOptionPane.showMessageDialog(frame, "Name is non-valid", @@ -235,6 +252,7 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe value = referenceKey; } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -242,10 +260,12 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe return null; } + @Override public int getType() { return TGComponentManager.TMLARCHI_KEY; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info value=\"" + value + "\" referenceKeyName=\""); @@ -305,7 +325,7 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } makeFullValue(); } @@ -318,7 +338,6 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe return referenceKey; } - public void setReferenceKey(String s){ referenceKey=s; } @@ -332,8 +351,8 @@ public class TMLArchiKey extends TGCWithoutInternalComponent implements Swallowe return typeName; } + @Override public String getAttributes() { return "Priority = " + priority; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiMemoryNode.java b/src/main/java/ui/tmldd/TMLArchiMemoryNode.java index 767d80a5f129b2e7d5e580cbb8363250175127a3..9b826737032003d718ef16c8d709d5e2552f6776 100755 --- a/src/main/java/ui/tmldd/TMLArchiMemoryNode.java +++ b/src/main/java/ui/tmldd/TMLArchiMemoryNode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -62,10 +59,11 @@ import java.awt.*; */ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "MEMORY"; private int bufferType = 0; @@ -75,10 +73,13 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa public TMLArchiMemoryNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 200; - height = 200; + // Issue #31 +// width = 200; +// height = 200; + textY = 15; minWidth = 100; minHeight = 35; + initScaling( 200, 200 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -116,18 +117,22 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa myImageIcon = IconManager.imgic700; } - public void internalDrawing(Graphics g) { + @Override + protected 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); + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + 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); + 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.MEMORY_BOX); @@ -139,24 +144,28 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY); // Issue #31 w = g.getFontMetrics().stringWidth(name); g.setFont(f); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g,name, x + (width - w)/2, y + 2 * textY/*2*/); // Issue #31 // Icon - //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1108.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int margin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1108.getImage() ), x + margin, y + margin, null); } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); - pol.addPoint(x + derivationx, y - derivationy); - pol.addPoint(x + derivationx + width, y - derivationy); - pol.addPoint(x + derivationx + width, y + height - derivationy); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + pol.addPoint(x + derivationX, y - derivationY); + pol.addPoint(x + derivationX + width, y - derivationY); + pol.addPoint(x + derivationX + width, y + height - derivationY); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); if (pol.contains(x1, y1)) { @@ -166,25 +175,26 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa return null; } - public String getStereotype() { + public String getStereotype() { return stereotype; - } public String getNodeName() { return name; } + @Override public void hasBeenResized() { - super.hasBeenResized(); - for(int i=0; i<nbInternalTGComponent; i++) { + super.hasBeenResized(); + + for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLArchiKey) { tgcomponent[i].resizeWithFather(); } } - } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -268,22 +278,24 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa return true; } - + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { - boolean ret = super.acceptSwallowedTGComponent(tgc); - if (ret == true) { - return true; - } + boolean ret = super.acceptSwallowedTGComponent(tgc); + + if (ret == true) { + return true; + } return (tgc instanceof TMLArchiKey ); } + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - boolean ret = super.addSwallowedTGComponent(tgc, x, y); - - if (ret == true) { - return true; - } + boolean ret = super.addSwallowedTGComponent(tgc, x, y); + + if (ret == true) { + return true; + } //Set its coordinates if (tgc instanceof TMLArchiKey) { @@ -297,11 +309,12 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa return false; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_MEMORYNODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -365,11 +378,10 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } - public int getByteDataSize(){ return byteDataSize; } @@ -378,6 +390,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa return memorySize; } + @Override public String getAttributes() { String attr = ""; attr += "Data size (in byte) = " + byteDataSize + "\n"; @@ -386,12 +399,12 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return STORAGE; } - public int getBufferType() { + public int getBufferType() { return bufferType; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiNode.java b/src/main/java/ui/tmldd/TMLArchiNode.java index 8ef258122f38269bad0971b4dc1f1408d3662776..19c5413314f5231f69742155bbc7f0a990c22f6b 100755 --- a/src/main/java/ui/tmldd/TMLArchiNode.java +++ b/src/main/java/ui/tmldd/TMLArchiNode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import tmltranslator.HwNode; @@ -49,6 +46,7 @@ import ui.TDiagramPanel; import ui.TGCWithInternalComponent; import ui.TGComponent; +import java.util.List; import java.util.ArrayList; /** @@ -59,7 +57,12 @@ import java.util.ArrayList; * @author Ludovic APVRILLE */ public abstract class TMLArchiNode extends TGCWithInternalComponent implements SwallowTGComponent { - protected int clockRatio = HwNode.DEFAULT_CLOCK_RATIO; + + protected int clockRatio = HwNode.DEFAULT_CLOCK_RATIO; + + // Issue #31 + protected static final int DERIVATION_X = 2; + protected static final int DERIVATION_Y = 3; //the return type of method getComponentType public final static int STORAGE = 0; @@ -70,8 +73,12 @@ public abstract class TMLArchiNode extends TGCWithInternalComponent implements S public TMLArchiNode(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); + + // Issue #31 + textY = 15; } + @Override public boolean isHidden() { //TraceManager.addDev("Am I hidden?" + getValue()); if (tdp != null) { @@ -83,8 +90,8 @@ public abstract class TMLArchiNode extends TGCWithInternalComponent implements S return true; } - public ArrayList<TMLArchiArtifact> getAllTMLArchiArtifacts() { - ArrayList<TMLArchiArtifact> artifacts = new ArrayList<TMLArchiArtifact>(); + public List<TMLArchiArtifact> getAllTMLArchiArtifacts() { + List<TMLArchiArtifact> artifacts = new ArrayList<TMLArchiArtifact>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLArchiArtifact) { @@ -104,5 +111,4 @@ public abstract class TMLArchiNode extends TGCWithInternalComponent implements S public ArchUnitMEC getMECType() { return MECType; } - } diff --git a/src/main/java/ui/tmldd/TMLArchiPortArtifact.java b/src/main/java/ui/tmldd/TMLArchiPortArtifact.java index e4fc03a539bf987833f789b5a2c99be50f466aae..2fe16c43df52bb597484c34fe8efeeafed729c24 100644 --- a/src/main/java/ui/tmldd/TMLArchiPortArtifact.java +++ b/src/main/java/ui/tmldd/TMLArchiPortArtifact.java @@ -81,14 +81,20 @@ import ui.window.JDialogPortArtifact; * @author Ludovic APVRILLE */ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes, TMLArchiPortInterface { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int textY2 = 35; - protected int space = 5; - protected int fileX = 20; - protected int fileY = 25; - protected int cran = 5; + + // Issue #31 +// protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int textY2 = 35; +// protected int space = 5; +// protected int fileX = 20; +// protected int fileY = 25; +// protected int cran = 5; + private static final int SPACE = 5; + private static final int CRAN = 5; + private static final int FILE_X = 20; + private static final int FILE_Y = 25; protected String mappedMemory = "VOID"; protected String oldValue = ""; protected String referenceCommunicationName = "TMLCommunication"; @@ -103,9 +109,13 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements public TMLArchiPortArtifact(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 75; - height = 40; + // Issue #31 +// width = 75; +// height = 40; minWidth = 75; + textX = 5; + textY = 15; + initScaling( 75, 40 ); nbConnectingPoint = 0; addTGConnectingPointsComment(); @@ -120,22 +130,20 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements makeFullValue(); - //setPriority(((TMLArchiDiagramPanel)tdp).getPriority(getFullValue(), priority); - myImageIcon = IconManager.imgic702; } + @Override public boolean isHidden() { - //TraceManager.addDev("Archi task artifact: Am I hidden?" + getValue()); - boolean ret = false; - if (tdp != null) { - if (tdp instanceof TMLArchiDiagramPanel) { - ret = !(((TMLArchiDiagramPanel)(tdp)).inCurrentView(this)); - - } - } - //TraceManager.addDev("Hidden? -> " + ret); - return ret; + //TraceManager.addDev("Archi task artifact: Am I hidden?" + getValue()); + boolean ret = false; + if (tdp != null) { + if (tdp instanceof TMLArchiDiagramPanel) { + ret = !(((TMLArchiDiagramPanel)(tdp)).inCurrentView(this)); + } + } + //TraceManager.addDev("Hidden? -> " + ret); + return ret; } public int getPriority() { @@ -146,16 +154,20 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements priority = _priority; } - - public void internalDrawing(Graphics g) { - - if (oldValue.compareTo(value) != 0) { - setValue(value, g); - } + @Override + protected void internalDrawing(Graphics g) { + // Issue #31 +// if (oldValue.compareTo(value) != 0) { +// setValue(value, g); +// } + checkWidth( g ); g.drawRect(x, y, width, height); - //g.drawRoundRect(x, y, width, height, arc, arc); + final int space = scale( SPACE ); + final int fileX = scale( FILE_X ); + final int fileY = scale( FILE_Y ); + final int cran = scale( CRAN ); g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); g.drawLine(x+width-space-fileX, y + space, x+width-space-cran, y+space); g.drawLine(x+width-space-cran, y+space, x+width-space, y+space + cran); @@ -164,13 +176,17 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + + g.drawImage( scale( IconManager.img9 ), x+width - scale( space + fileX - 3 ), y + scale( SPACE + 7 ), null); + //g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); - g.drawString(value, x + textX , y + textY); + + drawSingleString(g,value, x + textX , y + textY); Font f = g.getFont(); g.setFont(f.deriveFont(Font.ITALIC)); - g.drawString(typeName, x + textX , y + textY + 20); + drawSingleString(g,typeName, x + textX , y + textY + 20); g.setFont(f); // Link to selected memory @@ -193,23 +209,22 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements } } } - - - } - - public void setValue(String val, Graphics g) { - oldValue = value; - int w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); - - // - if (w1 != width) { - width = w1; - resizeWithFather(); - } - // } +// +// public void setValue(String val, Graphics g) { +// oldValue = value; +// int w = g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); +// +// // +// if (w1 != width) { +// width = w1; +// resizeWithFather(); +// } +// // +// } + @Override public void resizeWithFather() { if ((father != null) && (father instanceof TMLArchiCommunicationNode)) { // @@ -219,13 +234,13 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements } } - + @Override public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; // Get the list of all other TMLArchiPortArtifact.java and retrieve the mapped ports - Vector<String> portsList = this.getTDiagramPanel().getMGUI().getAllTMLInputPorts(); + Vector<String> portsList = this.getTDiagramPanel().getMGUI().getAllTMLInputPorts(); //TraceManager.addDev( "bufferParameters before opening the window: " + bufferParameters.toString() ); JDialogPortArtifact dialog = new JDialogPortArtifact( frame, "Setting port artifact attributes", this, mappedMemory, portsList, value ); @@ -287,13 +302,13 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements makeFullValue(); return !error; - } private void makeFullValue() { value = referenceCommunicationName + "::" + portName; } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -301,10 +316,12 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements return null; } + @Override public int getType() { return TGComponentManager.TMLARCHI_PORT_ARTIFACT; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info value=\"" + value + "\" portName=\"" + portName + "\" referenceCommunicationName=\""); @@ -342,7 +359,6 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ // try { - NodeList nli; Node n1, n2; Element elt; @@ -424,8 +440,7 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements } } catch (Exception e) { - - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } makeFullValue(); } @@ -447,7 +462,6 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements return portName; } - public String getFullValue() { String tmp = getValue(); tmp += " (" + getTypeName() + ")"; @@ -458,6 +472,7 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements return typeName; } + @Override public String getAttributes() { return "Priority = " + priority; } @@ -466,15 +481,15 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements return mappedMemory; } - public String getEndAddress() { + public String getEndAddress() { return endAddress; } - public String getStartAddress() { + public String getStartAddress() { return startAddress; } - public List<String> getBufferParameters() { + public List<String> getBufferParameters() { return bufferParameters; } } diff --git a/src/main/java/ui/tmldd/TMLArchiRouterNode.java b/src/main/java/ui/tmldd/TMLArchiRouterNode.java index 41b1dc74c6592f60a49853fd2093976faf8e8dab..31c3ca0a50d911e9fcabe4fd4df9e8c29fb575d8 100755 --- a/src/main/java/ui/tmldd/TMLArchiRouterNode.java +++ b/src/main/java/ui/tmldd/TMLArchiRouterNode.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmldd; import myutil.GraphicLib; @@ -46,7 +43,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import tmltranslator.HwBridge; -import tmltranslator.HwExecutionNode; import tmltranslator.HwNoC; import ui.*; import ui.util.IconManager; @@ -64,11 +60,13 @@ import java.util.HashMap; * @author Ludovic APVRILLE */ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; - private String stereotype = "NoC"; + + // Issue #31 +// private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; + private String stereotype = "ROUTER"; private int size = 2; // 2x2 NoC by default private int bufferByteDataSize = HwBridge.DEFAULT_BUFFER_BYTE_DATA_SIZE; @@ -77,10 +75,13 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa public TMLArchiRouterNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 100; + // Issue #31 +// width = 250; +// height = 100; minWidth = 100; minHeight = 35; + textY = 15; + initScaling( 250, 100 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -118,20 +119,24 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa myImageIcon = IconManager.imgic700; } - - public void internalDrawing(Graphics g) { + @Override + protected 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); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + 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); + 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.BRIDGE_BOX); @@ -141,23 +146,27 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa // Strings String ster = "<<" + stereotype + ">>"; int w = g.getFontMetrics().stringWidth(ster); - g.drawString(ster, x + (width - w)/2, y + textY1); + drawSingleString(g,ster, x + (width - w)/2, y + textY ); // Issue #31 w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g,name, x + (width - w)/2, y + 2 * textY ); // Issue #31 // Icon - //g.drawImage(IconManager.imgic1104.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1104.getImage(), x + 4, y + 4, null); - //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + // Issue #31 + final int margin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1104.getImage() ), x + margin, y + margin, null); } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); - pol.addPoint(x + derivationx, y - derivationy); - pol.addPoint(x + derivationx + width, y - derivationy); - pol.addPoint(x + derivationx + width, y + height - derivationy); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + pol.addPoint(x + derivationX, y - derivationY); + pol.addPoint(x + derivationX + width, y - derivationY); + pol.addPoint(x + derivationX + width, y + height - derivationY); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); if (pol.contains(x1, y1)) { @@ -176,15 +185,16 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; int tmp; String tmpName; - JDialogRouterNode dialog = new JDialogRouterNode(frame, "Setting NoC attributes", this); + JDialogRouterNode dialog = new JDialogRouterNode(frame, "Setting router attributes", this); // dialog.setSize(350, 350); - GraphicLib.centerOnParent(dialog, 650, 350); + GraphicLib.centerOnParent(dialog, 350, 350); dialog.setVisible( true ); // blocked until dialog has been closed if (!dialog.isRegularClose()) { @@ -270,11 +280,12 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_ROUTERNODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -292,7 +303,6 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ // try { - NodeList nli; Node n1, n2; Element elt; @@ -339,11 +349,10 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa } } catch (Exception e) { - throw new MalformedModelingException(); + throw new MalformedModelingException(e); } } - public int getBufferByteDataSize(){ return bufferByteDataSize; } @@ -352,6 +361,7 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa return size; } + @Override public String getAttributes() { String attr = ""; attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; @@ -360,13 +370,13 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return TRANSFER; } - + public String getPlacement() { - return placement; + return placement; } - - + } diff --git a/src/main/java/ui/tmldd/TMLArchiVGMNNode.java b/src/main/java/ui/tmldd/TMLArchiVGMNNode.java index da9fdbb81db958d6550bdbc128a2909d97536c87..4f54eb551fac0c3772557151cf44488b36fd70b1 100755 --- a/src/main/java/ui/tmldd/TMLArchiVGMNNode.java +++ b/src/main/java/ui/tmldd/TMLArchiVGMNNode.java @@ -61,10 +61,11 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; + // Issue #31 + // private int textY1 = 15; +// private int textY2 = 30; +// private int derivationx = 2; +// private int derivationy = 3; private String stereotype = "VGMN"; private int byteDataSize = HwBus.DEFAULT_BYTE_DATA_SIZE; @@ -75,10 +76,13 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall public TMLArchiVGMNNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 250; - height = 50; + // Issue #31 +// width = 250; +// height = 50; minWidth = 100; minHeight = 50; + textY = 15; + initScaling( 250, 50 ); nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; @@ -116,19 +120,24 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall myImageIcon = IconManager.imgic700; } - public void internalDrawing(Graphics g) { + @Override + protected 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); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + 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); + 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.BUS_BOX); @@ -140,15 +149,16 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall 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); + drawSingleString(g,ster, x + (width - w)/2, y + textY); // Issue #31 g.setFont(f); w = g.getFontMetrics().stringWidth(name); - g.drawString(name, x + (width - w)/2, y + textY2); + drawSingleString(g,name, x + (width - w)/2, y + 2 * textY); // Issue #31 // Icon //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); - g.drawImage(IconManager.imgic1102.getImage(), x + 4, y + 4, null); - g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + final int imageMargin = scale( 4 ); + g.drawImage( scale( IconManager.imgic1102.getImage() ), x + imageMargin, y + imageMargin, null); + g.drawImage( scale( IconManager.img9 ), x + width - scale( 20 ), y + imageMargin, null); c = g.getColor(); @@ -171,13 +181,17 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall }*/ } + @Override public TGComponent isOnOnlyMe(int x1, int y1) { - Polygon pol = new Polygon(); pol.addPoint(x, y); - pol.addPoint(x + derivationx, y - derivationy); - pol.addPoint(x + derivationx + width, y - derivationy); - pol.addPoint(x + derivationx + width, y + height - derivationy); + + // Issue #31 + final int derivationX = scale( DERIVATION_X ); + final int derivationY = scale( DERIVATION_Y ); + pol.addPoint(x + derivationX, y - derivationY); + pol.addPoint(x + derivationX + width, y - derivationY); + pol.addPoint(x + derivationX + width, y + height - derivationY); pol.addPoint(x + width, y + height); pol.addPoint(x, y + height); if (pol.contains(x1, y1)) { @@ -196,6 +210,7 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall return name; } + @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -311,11 +326,12 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall return true; } - + @Override public int getType() { return TGComponentManager.TMLARCHI_VGMNNODE; } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -333,36 +349,36 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ - // - try { - NodeList nli; - Node n1, n2; - Element elt; - // int t1id; - String sstereotype = null, snodeName = null; - 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("info")) { - sstereotype = elt.getAttribute("stereotype"); - snodeName = elt.getAttribute("nodeName"); - } - if (sstereotype != null) { - stereotype = sstereotype; - } - if (snodeName != null){ - name = snodeName; - } - if (elt.getTagName().equals("attributes")) { - byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); - /* arbitrationPolicy =Integer.decode(elt.getAttribute("arbitrationPolicy")).intValue(); pipelineSize = Integer.decode(elt.getAttribute("pipelineSize")).intValue(); + // + try { + NodeList nli; + Node n1, n2; + Element elt; + // int t1id; + String sstereotype = null, snodeName = null; + 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("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + /* arbitrationPolicy =Integer.decode(elt.getAttribute("arbitrationPolicy")).intValue(); pipelineSize = Integer.decode(elt.getAttribute("pipelineSize")).intValue(); if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); } @@ -372,17 +388,17 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall if ((elt.getAttribute("privacy") != null) && (elt.getAttribute("privacy").length() > 0)){ privacy = Integer.decode(elt.getAttribute("privacy")).intValue(); }*/ - } - }}} - } - } - - catch (Exception e) { - throw new MalformedModelingException(); - } + } + } + } + } + } + } + catch (Exception e) { + throw new MalformedModelingException( e ); + } } - public int getByteDataSize(){ return byteDataSize; } @@ -402,9 +418,10 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall return privacy; }*/ + @Override public String getAttributes() { String attr = ""; - attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Data size (in byte) = " + byteDataSize + "\n"; /*attr += "Pipeline size = " + pipelineSize + "\n"; if (arbitrationPolicy == HwBus.DEFAULT_ARBITRATION) { attr += "Arbitration policy = basic Round Robin\n"; @@ -416,8 +433,8 @@ public class TMLArchiVGMNNode extends TMLArchiCommunicationNode implements Swall return attr; } - public int getComponentType() { + @Override + public int getComponentType() { return TRANSFER; } - } diff --git a/src/main/java/ui/tmlsd/TGConnectingPointTMLSD.java b/src/main/java/ui/tmlsd/TGConnectingPointTMLSD.java index 417421aad7cfab0e7dc9485aad27489e30c7ac0c..2f14729e2ad365ffdb25ad2b38733151e379fb56 100755 --- a/src/main/java/ui/tmlsd/TGConnectingPointTMLSD.java +++ b/src/main/java/ui/tmlsd/TGConnectingPointTMLSD.java @@ -59,7 +59,7 @@ public class TGConnectingPointTMLSD extends TGConnectingPoint{ public TGConnectingPointTMLSD(CDElement _container, int _x, int _y, boolean _in, boolean _out) { super(_container, _x, _y, _in, _out); } - + @Override public boolean isCompatibleWith(int type) { // if ((type == TGComponentManager.CONNECTOR_MESSAGE_ASYNC_TMLSD)) { diff --git a/src/main/java/ui/tmlsd/TGConnectorMessageAsyncTMLSD.java b/src/main/java/ui/tmlsd/TGConnectorMessageAsyncTMLSD.java index 8f15bb0318f5f0cec7d3d946536977307f896805..06cee3dba50d060b8e1ea12bbc6ed45219fa1e35 100755 --- a/src/main/java/ui/tmlsd/TGConnectorMessageAsyncTMLSD.java +++ b/src/main/java/ui/tmlsd/TGConnectorMessageAsyncTMLSD.java @@ -85,7 +85,7 @@ public class TGConnectorMessageAsyncTMLSD extends TGConnectorMessageTMLSD { heightValue = g.getFontMetrics().getHeight(); } - g.drawString(value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); + drawSingleString(g,value, ((p1.getX() + p2.getX()) / 2)-widthValue/2, ((p1.getY() + p2.getY()) / 2) - 5); } public int getType() { diff --git a/src/main/java/ui/tmlsd/TGConnectorMessageTMLSD.java b/src/main/java/ui/tmlsd/TGConnectorMessageTMLSD.java index 4787407b2fdffde9cdc68c93fa3de1a9edef55d1..0d5942402ce3979716249e6f3a26ab134b9a97db 100755 --- a/src/main/java/ui/tmlsd/TGConnectorMessageTMLSD.java +++ b/src/main/java/ui/tmlsd/TGConnectorMessageTMLSD.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlsd; import myutil.GraphicLib; @@ -50,8 +47,10 @@ import ui.util.IconManager; import ui.window.JDialogMultiStringCP; import javax.swing.*; -import java.awt.*; + +import java.awt.Point; import java.util.ArrayList; +import java.util.List; import java.util.Vector; /** @@ -192,9 +191,9 @@ public abstract class TGConnectorMessageTMLSD extends TGConnector { value += ")"; } - public ArrayList<String> getParams() { + public List<String> getParams() { - ArrayList<String> toBeReturned = new ArrayList<String>(); + List<String> toBeReturned = new ArrayList<String>(); for( int i = 0; i < nParam; i++ ) { if( ( params[i] != "" ) && ( params[i] != "null") ) { toBeReturned.add( params[i] ); diff --git a/src/main/java/ui/tmlsd/TMLSDActionState.java b/src/main/java/ui/tmlsd/TMLSDActionState.java index bb0cc83b8b6a154c728fc39ff64ae1195fad0033..5e475ba7ec915a96e19b9b5e09ae6f2f9fb8d18b 100755 --- a/src/main/java/ui/tmlsd/TMLSDActionState.java +++ b/src/main/java/ui/tmlsd/TMLSDActionState.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlsd; import myutil.GraphicLib; @@ -55,18 +52,22 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class TMLSDActionState extends TGCOneLineText implements SwallowedTGComponent { - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; - protected int w; //w1; + + // Issue #31 + // protected int lineLength = 5; +// protected int textX = 5; +// protected int textY = 15; +// protected int arc = 5; + //protected int w; //w1; public TMLSDActionState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 30; - height = 20; - minWidth = 30; + // Issue #31 + initScaling( 30, 20 ); +// width = 30; +// height = 20; + minWidth = scale( 30 ); nbConnectingPoint = 0; addTGConnectingPointsCommentMiddle(); @@ -81,17 +82,21 @@ public class TMLSDActionState extends TGCOneLineText implements SwallowedTGCompo myImageIcon = IconManager.imgic512; } - public void internalDrawing(Graphics g) { - w = g.getFontMetrics().stringWidth(value); - int w1 = Math.max(minWidth, w + 2 * textX); - if ((w1 != width) && (!tdp.isScaled())) { - width = w1; - } + @Override + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int w = checkWidth( g );//g.getFontMetrics().stringWidth(value); +// int w1 = Math.max(minWidth, w + 2 * textX); +// if ((w1 != width) && (!tdp.isScaled())) { +// width = w1; +// } g.drawRoundRect(x - width/2, y, width, height, arc, arc); - g.drawString(value, x - w / 2 , y + textY); + drawSingleString(g,value, x - w / 2 , y + textY); } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x - width/2, y, width, height)) { return this; @@ -99,7 +104,6 @@ public class TMLSDActionState extends TGCOneLineText implements SwallowedTGCompo return null; } - public String getAction() { return value; } @@ -129,8 +133,8 @@ public class TMLSDActionState extends TGCOneLineText implements SwallowedTGCompo return ret; } + @Override public int getType() { return TGComponentManager.TMLSD_ACTION_STATE; } - -} \ No newline at end of file +} diff --git a/src/main/java/ui/tmlsd/TMLSDControllerInstance.java b/src/main/java/ui/tmlsd/TMLSDControllerInstance.java index 3af95fd7db1806a3fda79cdbc03f5019a149cb56..66f6cd9493f985a201fe281c56f0b3a6d5d055a1 100755 --- a/src/main/java/ui/tmlsd/TMLSDControllerInstance.java +++ b/src/main/java/ui/tmlsd/TMLSDControllerInstance.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlsd; import myutil.GraphicLib; @@ -62,17 +59,18 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 10; - height = 500; - //textX = 0; - //textY = 2; - minWidth = 10; - maxWidth = 10; - minHeight = 250; - maxHeight = 1500; + // Issue #31 + initScaling( 10, 500 ); +// width = 10; +// height = 500; + minWidth = scale( 10 ); + maxWidth = scale( 10 ); + minHeight = scale( 250 ); + maxHeight = scale( 1500 ); - makeTGConnectingPoints(); + // Issue #31 Already called in superclass +// makeTGConnectingPoints(); //addTGConnectingPointsComment(); nbInternalTGComponent = 0; @@ -84,7 +82,7 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC value = "Controller instance name"; name = "ControllerInstance"; - isActor = false; + isActor = false; myImageIcon = IconManager.imgic500; } @@ -106,7 +104,6 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC } protected void setJDialogOptions( JDialogTMLCPControllerInstance jda ) { - jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true); @@ -124,7 +121,8 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC //jda.enableTMLKeyword(false); } - @Override public int getType() { + @Override + public int getType() { return TGComponentManager.TMLSD_CONTROLLER_INSTANCE; } diff --git a/src/main/java/ui/tmlsd/TMLSDInstance.java b/src/main/java/ui/tmlsd/TMLSDInstance.java index bdd452406818302e5784ff25351213ea2adf4dc5..abbad573bfd8551b07d606173b2d432066af1864 100755 --- a/src/main/java/ui/tmlsd/TMLSDInstance.java +++ b/src/main/java/ui/tmlsd/TMLSDInstance.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlsd; import myutil.GraphicLib; @@ -50,10 +47,12 @@ import ui.*; import ui.util.IconManager; import javax.swing.*; -import java.awt.*; + +import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedList; +import java.util.List; //Abstract class, getType() and editOndoubleClick( JFrame ) are abstract /** @@ -65,31 +64,43 @@ import java.util.LinkedList; */ public abstract class TMLSDInstance extends TGCWithInternalComponent implements SwallowTGComponent { + // Issue #31 //protected int lineLength = 5; //protected int textX, textY; - protected int spacePt = 10; - protected int wText = 10, hText = 15; - protected int increaseSlice = 250; + private static final int POINT_MARGIN = 10; +// protected int spacePt = 10; +// protected int wText = 10, hText = 15; + private static final int SLICE_INCREMENT = 250; +// protected int increaseSlice = 250; + private static final int ACTOR_HEIGHT = 30; +// protected static int heightActor = 30; + private static final int ACTOR_WIDTH = 16; +// protected static int widthActor = 16; + + private int wText; + private int hText; protected boolean isActor; - protected static int heightActor = 30; - protected static int widthActor = 16; - protected LinkedList<TAttribute> myAttributes; + protected List<TAttribute> myAttributes; protected String mappedUnit = ""; //The arch unit where the instance is mapped to public TMLSDInstance(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 10; - height = 500; - //textX = 0; - //textY = 2; - minWidth = 10; - maxWidth = 10; - minHeight = 250; - maxHeight = 1500; + + initScaling( 10, 500 ); +// width = 10; +// height = 500; + minWidth = scale( 10 ); + maxWidth = scale( 10 ); + minHeight = scale( 250 ); + maxHeight = scale( 1500 ); + wText = 10; + hText = 15; + + // Issue #31 makeTGConnectingPoints(); //addTGConnectingPointsComment(); + nbInternalTGComponent = 0; moveable = true; editable = true; @@ -97,22 +108,39 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements userResizable = true; value = "Instance name"; name = "instance"; - myAttributes = new LinkedList<TAttribute> (); + myAttributes = new LinkedList<TAttribute>(); myImageIcon = IconManager.imgic500; } - public void internalDrawing(Graphics g) { - if (!tdp.isScaled()) { + @Override + protected void internalDrawing(Graphics g) { + + // Issue #31 + final int scaledWText; + final int scaledHText; + + if (!tdp.isScaled()) { wText = g.getFontMetrics().stringWidth(name); - hText = g.getFontMetrics().getHeight(); + scaledWText = wText; + hText = g.getFontMetrics().getHeight(); + scaledHText = hText; } - g.drawString(name, x - (wText / 2) + width/2, y - 3); - g.drawLine(x - (wText / 2) + width/2, y-2, x + (wText / 2) + width/2, y-2); - g.drawLine(x+(width/2), y, x+(width/2), y +height); + else { + scaledWText = scale( wText ); + scaledHText = scale( hText ); + } + drawSingleString(g,name, x - (scaledWText / 2) + width/2, y - 3); // Issue #31 + g.drawLine(x - (scaledWText / 2) + width/2, y-2, x + (scaledWText / 2) + width/2, y-2); // Issue #31 + g.drawLine(x+(width/2), y, x+(width/2), y +height); + if (isActor) { + final int widthActor = scale( ACTOR_WIDTH ); + final int heightActor = scale( ACTOR_HEIGHT ); + int xtmp = x + (width-widthActor) / 2; - int ytmp = y-hText; + int ytmp = y - scaledHText; // Issue #31 + // Head g.drawOval(xtmp+(widthActor/4)-1, ytmp-heightActor, 2+widthActor/2, 2+widthActor/2); //Body @@ -126,103 +154,107 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements } } + @Override public TGComponent isOnOnlyMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; } - if (GraphicLib.isInRectangle(_x, _y, x + (width/2) - (wText/2) , y-hText, wText, hText)) { + final int scaledHText = scale( hText ); + final int scaledWText = scale( wText ); + + if (GraphicLib.isInRectangle(_x, _y, x + (width/2) - (scaledWText/2) , y-scaledHText, scaledWText, scaledHText)) { // Issue #31 return this; } if (isActor) { - if (GraphicLib.isInRectangle(_x, _y, x + (width-widthActor) / 2, y-heightActor-hText, widthActor, heightActor)) { + final int widthActor = scale( ACTOR_WIDTH ); + final int heightActor = scale( ACTOR_HEIGHT ); + + if (GraphicLib.isInRectangle(_x, _y, x + (width-widthActor) / 2, y-heightActor-scaledHText, widthActor, heightActor)) { // Issue #31 return this; } } return null; } + @Override public int getMyCurrentMinX() { - return Math.min(x + (width/2) - (wText/2), x); - + return Math.min(x + (width/2) - ( scale( wText ) / 2 ), x); } + @Override public int getMyCurrentMaxX() { - return Math.max(x + (width/2) + (wText/2), x + width); + return Math.max(x + (width/2) + ( scale( wText ) / 2 ), x + width); } + @Override public int getMyCurrentMinY() { - return Math.min(y-hText-heightActor, y); + return Math.min( y - scale( hText ) - scale( ACTOR_HEIGHT ), y); // Issue #31 } public String getInstanceName() { return getName(); } - public abstract int getType(); +// public abstract int getType(); protected void makeTGConnectingPoints() { - + // Issue #31 + final int spacePt = scale( POINT_MARGIN ); nbConnectingPoint = ( (height - (2 * spacePt) ) / spacePt ) + 1; connectingPoint = new TGConnectingPoint[ nbConnectingPoint ]; int yh = spacePt; for(int i = 0; i < nbConnectingPoint; i++, yh += spacePt ) { - connectingPoint[i] = new TGConnectingPointTMLSD(this, ( width/2), yh, true, true ); + connectingPoint[i] = new TGConnectingPointTMLSD(this, ( width / 2 ), yh, true, true ); } - } - public abstract boolean editOndoubleClick( JFrame frame ); +// public abstract boolean editOndoubleClick( JFrame frame ); + @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return (tgc instanceof TMLSDActionState); } + @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { if (!acceptSwallowedTGComponent(tgc)) { return false; } - - // // Choose its position + final int spacePt = scale( POINT_MARGIN ); int realY = Math.max(y, getY() + spacePt); realY = Math.min(realY, getY() + height + spacePt); int realX = tgc.getX(); - // Make it an internal component // It's one of my son tgc.setFather(this); tgc.setDrawingZone(true); - - if ((tgc instanceof TMLSDActionState)) { realX = getX()+(width/2); //tgc.setCdRectangle((width/2), (width/2), spacePt, height-spacePt-tgc.getHeight()); tgc.setCd(realX, realY); } - setCDRectangleOfSwallowed(tgc); - //add it addInternalComponent(tgc, 0); return true; } + @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } - - // previous in the sense of with y the closer and before public TGComponent getPreviousTGComponent(TGComponent tgcToAnalyse) { int close = Integer.MAX_VALUE; @@ -253,9 +285,9 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements /* now: only message! */ return ((TMLSDPanel)tdp).messageActionCloserTo(tgc, this); - } + @Override public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); @@ -268,15 +300,18 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements componentMenu.add(increase); } + @Override public boolean eventOnPopup(ActionEvent e) { if ((e.getActionCommand().compareTo("Decrease size")) == 0) { decreaseSize(); } else { increaseSize(); } + return true; } + @Override public void updateMinMaxSize() { minHeight = 250; int i; @@ -293,10 +328,13 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements } public boolean canDecreaseSize() { + final int increaseSlice = scale( SLICE_INCREMENT ); // Issue #31 + if (height <= increaseSlice) { return false; } + final int spacePt = scale( POINT_MARGIN ); int newNbConnectingPoint = (((height-increaseSlice) - (2 * spacePt)) / spacePt) + 1; int i; @@ -328,16 +366,17 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements // new nb of connectingPoints // If ok, do the modification - height = height - increaseSlice; + height = height - scale( SLICE_INCREMENT ); // Issue #31 hasBeenResized(); } public void increaseSize() { // - height = height + increaseSlice; + height = height + scale( SLICE_INCREMENT ); // Issue #31 hasBeenResized(); } + @Override public void hasBeenResized(){ int i; @@ -356,15 +395,13 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements } protected void setCDRectangleOfSwallowed(TGComponent tgc) { - - if ((tgc instanceof TMLSDActionState)) { + final int spacePt = scale( POINT_MARGIN ); tgc.setCdRectangle((width/2), (width/2), spacePt, height-spacePt-tgc.getHeight()); } - - } + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer( "<extraparam>\n" ); sb.append( "<Mapping mappedOn=\"" ); @@ -387,6 +424,7 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements sb.append( "\" />\n" ); } sb.append( "</extraparam>\n" ); + return new String(sb); } @@ -449,7 +487,7 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements } } catch ( Exception e ) { - throw new MalformedModelingException(); + throw new MalformedModelingException( e ); } } @@ -469,7 +507,7 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements return connectingPoint; } - public LinkedList<TAttribute> getAttributes() { + public List<TAttribute> getAttributes() { return myAttributes; } } diff --git a/src/main/java/ui/tmlsd/TMLSDPanel.java b/src/main/java/ui/tmlsd/TMLSDPanel.java index 7f6344261a15e6c1d1762e06b97e4253f1d8075c..79fd33f1aa0a709615c9ea5d6da47996c3a9eac3 100755 --- a/src/main/java/ui/tmlsd/TMLSDPanel.java +++ b/src/main/java/ui/tmlsd/TMLSDPanel.java @@ -109,8 +109,8 @@ public class TMLSDPanel extends TDiagramPanel { return false; } - public String getXMLHead() { - return "<TMLSDPanel name=\"" + name + "\"" + sizeParam() + " >"; + public String getXMLHead() { // Issue #31 + return "<TMLSDPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } public String getXMLTail() { diff --git a/src/main/java/ui/tmlsd/TMLSDStorageInstance.java b/src/main/java/ui/tmlsd/TMLSDStorageInstance.java index f639d69cb4be808624839a2bbad279ea0c1eb8f8..f72248a224877d78130bc3bb026f621d4b99cd49 100755 --- a/src/main/java/ui/tmlsd/TMLSDStorageInstance.java +++ b/src/main/java/ui/tmlsd/TMLSDStorageInstance.java @@ -59,19 +59,17 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp TGComponent _father, TDiagramPanel _tdp ) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 10; - height = 500; - //textX = 0; - //textY = 2; - minWidth = 10; - maxWidth = 10; - minHeight = 250; - maxHeight = 1500; - - - makeTGConnectingPoints(); - //addTGConnectingPointsComment(); + initScaling( 10, 500 ); +// width = 10; +// height = 500; + minWidth = scale( 10 ); + maxWidth = scale( 10 ); + minHeight = scale( 250 ); + maxHeight = scale( 1500 ); + // Issue #31 Already called in superclass + // makeTGConnectingPoints(); + nbInternalTGComponent = 0; moveable = true; @@ -103,22 +101,15 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp } protected void setJDialogOptions( JDialogTMLCPStorageInstance 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); jda.addType(TAttribute.getStringType(TAttribute.ADDRESS), true); -/* Vector<String> records = ( (TMLComponentTaskDiagramPanel )(tdp)).getAllRecords(this); - for( String s: records ) { - jda.addType(s, false); - }*/ - jda.enableInitialValue(true); jda.enableRTLOTOSKeyword(true); jda.enableJavaKeyword(false); - //jda.enableTMLKeyword(false); } @Override diff --git a/src/main/java/ui/tmlsd/TMLSDToolBar.java b/src/main/java/ui/tmlsd/TMLSDToolBar.java index 3c24c7f8548b567420e7ef193e0624a08e8c310c..2cc8a1a58a8db46d46f1e4e1dd4f0a48fcde9938 100755 --- a/src/main/java/ui/tmlsd/TMLSDToolBar.java +++ b/src/main/java/ui/tmlsd/TMLSDToolBar.java @@ -37,21 +37,14 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlsd; -import myutil.TraceManager; +import javax.swing.JButton; + import ui.MainGUI; import ui.TGUIAction; import ui.TToolBar; -import javax.swing.*; - -//import java.awt.*; -//import java.awt.event.*; - /** * Class TMLSDToolBar * Implements the toolbar to be used in conjunction with the panel of a TML @@ -67,6 +60,7 @@ public class TMLSDToolBar extends TToolBar { super(_mgui); } + @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.TMLSD_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); @@ -78,12 +72,17 @@ public class TMLSDToolBar extends TToolBar { mgui.actions[TGUIAction.TMLSD_ACTION_STATE].setEnabled(b); mgui.actions[TGUIAction.SD_ALIGN_INSTANCES].setEnabled(b); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); - mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); - mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + // Issue #31 + mgui.actions[ TGUIAction.ACT_ZOOM_MORE ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_ZOOM_LESS ].setEnabled( b ); + mgui.actions[ TGUIAction.ACT_SHOW_ZOOM ].setEnabled( b ); +// mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); +// mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); +// mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); mgui.updateZoomInfo(); } + @Override protected void setButtons() { JButton button; @@ -123,7 +122,5 @@ public class TMLSDToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.SD_ALIGN_INSTANCES]); button.addMouseListener(mgui.mouseHandler); - } - } // Class diff --git a/src/main/java/ui/tmlsd/TMLSDTransferInstance.java b/src/main/java/ui/tmlsd/TMLSDTransferInstance.java index fc475163781e079d7d585e5adbf28cbb38ea845a..2e0ba431d7c479fda704fd57d426b82d9c2a482f 100755 --- a/src/main/java/ui/tmlsd/TMLSDTransferInstance.java +++ b/src/main/java/ui/tmlsd/TMLSDTransferInstance.java @@ -58,20 +58,21 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom public TMLSDTransferInstance( 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); + + // Issue #31 +// width = 10; +// height = 500; + + initScaling( 10, 500 ); + minWidth = scale( 10 ); + maxWidth = scale( 10 ); + minHeight = scale( 250 ); + maxHeight = scale( 1500 ); - width = 10; - height = 500; - //textX = 0; - //textY = 2; - minWidth = 10; - maxWidth = 10; - minHeight = 250; - maxHeight = 1500; - - - makeTGConnectingPoints(); + // Issue #31 Already called in superclass + // makeTGConnectingPoints(); //addTGConnectingPointsComment(); - + nbInternalTGComponent = 0; moveable = true; @@ -103,7 +104,6 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom } protected void setJDialogOptions( JDialogTMLCPTransferInstance jda ) { - jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true); @@ -121,7 +121,8 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom //jda.enableTMLKeyword(false); } - @Override public int getType() { + @Override + public int getType() { return TGComponentManager.TMLSD_TRANSFER_INSTANCE; } diff --git a/src/main/java/ui/ucd/TGConnectingPointActorUCD.java b/src/main/java/ui/ucd/TGConnectingPointActorUCD.java index b703ba97b5237eed215f5c46180d2fac577c90bf..bc99fbebe17bc471a505f2be892468b90dfdd0ce 100755 --- a/src/main/java/ui/ucd/TGConnectingPointActorUCD.java +++ b/src/main/java/ui/ucd/TGConnectingPointActorUCD.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ucd; import ui.CDElement; @@ -53,13 +50,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 18/02/2005 * @author Ludovic APVRILLE */ -public class TGConnectingPointActorUCD extends TGConnectingPointWidthHeight { - - public TGConnectingPointActorUCD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { - super(_container, _x, _y, _in, _out, _w, _h); - } - - public boolean isCompatibleWith(int type) { +public class TGConnectingPointActorUCD extends TGConnectingPointWidthHeight{ + + public TGConnectingPointActorUCD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + super(_container, _x, _y, _in, _out, _w, _h); + } + + @Override + public boolean isCompatibleWith(int type) { return (type == TGComponentManager.CONNECTOR_ACTOR_UCD) || (type == TGComponentManager.CONNECTOR_SPECIA_UCD); } @@ -95,4 +93,4 @@ public class TGConnectingPointActorUCD extends TGConnectingPointWidthHeight { } -} \ No newline at end of file +} diff --git a/src/main/java/ui/ucd/TGConnectingPointUCD.java b/src/main/java/ui/ucd/TGConnectingPointUCD.java index 65fda477621cdd93766048692450413886620057..02c40f34a45f73961a1f8291171ab48f68d166ec 100755 --- a/src/main/java/ui/ucd/TGConnectingPointUCD.java +++ b/src/main/java/ui/ucd/TGConnectingPointUCD.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ucd; @@ -60,11 +57,9 @@ public class TGConnectingPointUCD extends TGConnectingPointWidthHeight{ public TGConnectingPointUCD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } - + + @Override public boolean isCompatibleWith(int type) { - - //TraceManager.addDev("is compatible with"); - // if ((type == TGComponentManager.CONNECTOR_ACTOR_UCD) ||(type == TGComponentManager.CONNECTOR_INCLUDE_UCD) || (type == TGComponentManager.CONNECTOR_SPECIA_UCD) || (type == TGComponentManager.CONNECTOR_EXTEND_UCD)) { // diff --git a/src/main/java/ui/ucd/TGConnectorExtend.java b/src/main/java/ui/ucd/TGConnectorExtend.java index 68656ae8acfabe96ae489440e3eb347c851552db..badb0a78e26465bdeef08e9e039af7b5088765c3 100755 --- a/src/main/java/ui/ucd/TGConnectorExtend.java +++ b/src/main/java/ui/ucd/TGConnectorExtend.java @@ -62,7 +62,7 @@ public class TGConnectorExtend extends TGConnectorUC { myImageIcon = IconManager.imgic608; } - + @Override public int getType() { return TGComponentManager.CONNECTOR_EXTEND_UCD; } diff --git a/src/main/java/ui/ucd/TGConnectorInclude.java b/src/main/java/ui/ucd/TGConnectorInclude.java index 4a5c0704e3e9972144cf6865d2075a0425f8ef91..8db903a5c14193d4bc872a79f1bf314b3567758a 100755 --- a/src/main/java/ui/ucd/TGConnectorInclude.java +++ b/src/main/java/ui/ucd/TGConnectorInclude.java @@ -62,7 +62,8 @@ public class TGConnectorInclude extends TGConnectorUC { myImageIcon = IconManager.imgic606; } - + + @Override public int getType() { return TGComponentManager.CONNECTOR_INCLUDE_UCD; } diff --git a/src/main/java/ui/ucd/TGConnectorSpecialization.java b/src/main/java/ui/ucd/TGConnectorSpecialization.java index 8b50a11bb3b62a597c9f64e5062172f60bee2cca..0963dc1a1c43f33331d4ed4b9e9aaee4b59feb63 100755 --- a/src/main/java/ui/ucd/TGConnectorSpecialization.java +++ b/src/main/java/ui/ucd/TGConnectorSpecialization.java @@ -62,14 +62,15 @@ public class TGConnectorSpecialization extends TGConnector { myImageIcon = IconManager.imgic610; } - - + + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); GraphicLib.arrowWithLine(g, 1, 0, 0, x1, y1, x2, y2, false); } - public int getType() { + @Override + public int getType() { return TGComponentManager.CONNECTOR_SPECIA_UCD; } diff --git a/src/main/java/ui/ucd/TGConnectorUC.java b/src/main/java/ui/ucd/TGConnectorUC.java index af3a58f670e3f3df5f68ec0577f5bd563da3cfac..9b100d0c63b61fcb1ce3d9b738ae850d56152b7f 100755 --- a/src/main/java/ui/ucd/TGConnectorUC.java +++ b/src/main/java/ui/ucd/TGConnectorUC.java @@ -65,7 +65,7 @@ public abstract class TGConnectorUC extends TGConnector { value = _value; } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); @@ -73,13 +73,15 @@ public abstract class TGConnectorUC extends TGConnector { // Indicate semantics w = g.getFontMetrics().stringWidth(value); h = g.getFontMetrics().getHeight(); - g.drawString(value, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2); + drawSingleString(g, value, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2); } + @Override protected void drawMiddleSegment(Graphics g, int x1, int y1, int x2, int y2) { GraphicLib.dashedLine(g, x1, y1, x2, y2); } + @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { return this; diff --git a/src/main/java/ui/ucd/TGConnectorUseCase.java b/src/main/java/ui/ucd/TGConnectorUseCase.java index f90a5afad61ad7f07faa3078871a06558f6c86e6..31118d9451bac945d736c865339664805e94b10b 100755 --- a/src/main/java/ui/ucd/TGConnectorUseCase.java +++ b/src/main/java/ui/ucd/TGConnectorUseCase.java @@ -62,13 +62,13 @@ public class TGConnectorUseCase extends TGConnector { myImageIcon = IconManager.imgic604; } - + @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ g.drawLine(x1, y1, x2, y2); } + - - + @Override public int getType() { return TGComponentManager.CONNECTOR_ACTOR_UCD; } diff --git a/src/main/java/ui/ucd/UCDActor.java b/src/main/java/ui/ucd/UCDActor.java index 5023cc8a00e810962908138fc4ff22d775f76a3f..a4c705c4ced10404d4e6843818231d44e3cba604 100755 --- a/src/main/java/ui/ucd/UCDActor.java +++ b/src/main/java/ui/ucd/UCDActor.java @@ -37,6 +37,8 @@ */ + + package ui.ucd; import myutil.GraphicLib; @@ -64,54 +66,54 @@ public class UCDActor extends TGCScalableWithoutInternalComponentOneLineText { private int maxFontSize = 12; private int minFontSize = 4; private int currentFontSize = -1;*/ - - public UCDActor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + + public UCDActor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = (int) (30 * tdp.getZoom()); - height = (int) (70 * tdp.getZoom()); + + width = (int)(30 * tdp.getZoom()); + height = (int)(70 * tdp.getZoom()); oldScaleFactor = tdp.getZoom(); //minWidth = 30; - + nbConnectingPoint = 24; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; int i; - for (int j = 0; j < 24; j = j + 12) { - for (i = 0; i < 5; i++) { - connectingPoint[i + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.0, ((double) (i)) / 4); + for(int j=0; j<24; j = j + 12) { + for(i=0; i<5; i++) { + connectingPoint[i + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.0, ((double)(i))/4); } - connectingPoint[5 + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 0.0); - connectingPoint[6 + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 1.0); - for (i = 0; i < 5; i++) { - connectingPoint[i + 7 + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 1.0, ((double) i) / 4); + connectingPoint[5+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 0.0); + connectingPoint[6+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 1.0); + for(i=0; i<5; i++) { + connectingPoint[i+7+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 1.0, ((double)i)/4); } } addTGConnectingPointsComment(); - + moveable = true; editable = true; removable = true; super.oldScaleFactor = tdp.getZoom(); //currentFontSize = (int) (maxFontSize*oldScaleFactor); - + value = "Actor"; name = "actor"; - + myImageIcon = IconManager.imgic600; } @Override - public void internalDrawing(Graphics graph) { - Font font = graph.getFont(); - this.internalDrawingAux(graph); - graph.setFont(font); + public void internalDrawing (Graphics graph) { + Font font = graph.getFont (); + this.internalDrawingAux (graph); + graph.setFont (font); } - + public void internalDrawingAux(Graphics graph) { - //Font font = graph.getFont (); - // String ster; - + //Font font = graph.getFont (); + // String ster; + /*if (this.rescaled && !this.tdp.isScaled ()) { this.rescaled = false; // Must set the font size... @@ -139,49 +141,53 @@ public class UCDActor extends TGCScalableWithoutInternalComponentOneLineText { } }*/ - - w = graph.getFontMetrics().stringWidth(value); + + w = graph.getFontMetrics().stringWidth(value); h = graph.getFontMetrics().getHeight(); height = height - h; //g.drawRoundRect(x - width/2, y, width, height, arc, arc); - graph.drawOval(x + width / 4, y, width / 2, width / 2); + graph.drawOval(x + width/4, y, width/2, width/2); //Body - graph.drawLine(x + width / 2, y + width / 2, x + width / 2, y + height - width / 2); + graph.drawLine(x+width/2, y+width/2, x+width/2, y+height-width/2); //Arms - graph.drawLine(x, y + width / 2 + 8, x + width, y + width / 2 + 8); + graph.drawLine(x, y+width/2 + 8, x+width, y+width/2 + 8); //Left leg - graph.drawLine(x + width / 2, y + height - width / 2, x, y + height); + graph.drawLine(x+width/2, y+height-width/2, x, y+height); //right leg - graph.drawLine(x + width / 2, y + height - width / 2, x + width, y + height); + graph.drawLine(x+width/2, y+height-width/2, x+width, y+height); //name of actor - graph.drawString(value, x + width / 2 - w / 2, y + height + h); + drawSingleString(graph, value, x + width / 2 - w / 2 , y + height + h); height = height + h; } - + + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; } - if (GraphicLib.isInRectangle(_x, _y, x + width / 2 - w / 2, y + height - h, w, h)) { + if (GraphicLib.isInRectangle(_x, _y, x + width / 2 - w / 2, y +height - h, w, h)) { return this; } return null; } - + + @Override public int getMyCurrentMinX() { return Math.min(x + width / 2 - w / 2, x); } - + + @Override public int getMyCurrentMaxX() { return Math.max(x + width / 2 + w / 2, x + width); } - + public String getActorName() { return value; } - - + + + @Override public int getType() { return TGComponentManager.UCD_ACTOR; } diff --git a/src/main/java/ui/ucd/UCDActorBox.java b/src/main/java/ui/ucd/UCDActorBox.java index 72317ef0c30d37851a3218eafb9d7e9825e37f22..0a5706d053b437c0ec3e59fdea406a6c838e3a41 100755 --- a/src/main/java/ui/ucd/UCDActorBox.java +++ b/src/main/java/ui/ucd/UCDActorBox.java @@ -37,6 +37,8 @@ */ + + package ui.ucd; import myutil.GraphicLib; @@ -46,12 +48,11 @@ import ui.util.IconManager; import java.awt.*; /** - * Class UCDActorBox - * Actor in a box - * Creation: 04/01/2011 - * - * @author Ludovic APVRILLE - * @version 1.0 04/01/2011 + * Class UCDActorBox + * Actor in a box + * Creation: 04/01/2011 + * @version 1.0 04/01/2011 + * @author Ludovic APVRILLE */ public class UCDActorBox extends TGCScalableWithoutInternalComponentOneLineText { /*protected int lineLength = 5; @@ -62,7 +63,7 @@ public class UCDActorBox extends TGCScalableWithoutInternalComponentOneLineText protected final static String STEREOTYPE = "<<Actor>>"; protected int space = 4; - public UCDActorBox(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public UCDActorBox(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); width = (int) (40 * tdp.getZoom()); @@ -73,14 +74,14 @@ public class UCDActorBox extends TGCScalableWithoutInternalComponentOneLineText nbConnectingPoint = 24; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; int i; - for (int j = 0; j < 24; j = j + 12) { - for (i = 0; i < 5; i++) { - connectingPoint[i + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.0, ((double) (i)) / 4); + for(int j=0; j<24; j = j + 12) { + for(i=0; i<5; i++) { + connectingPoint[i + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.0, ((double)(i))/4); } - connectingPoint[5 + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 0.0); - connectingPoint[6 + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 1.0); - for (i = 0; i < 5; i++) { - connectingPoint[i + 7 + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 1.0, ((double) i) / 4); + connectingPoint[5+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 0.0); + connectingPoint[6+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 1.0); + for(i=0; i<5; i++) { + connectingPoint[i+7+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 1.0, ((double)i)/4); } } addTGConnectingPointsComment(); @@ -96,19 +97,21 @@ public class UCDActorBox extends TGCScalableWithoutInternalComponentOneLineText myImageIcon = IconManager.imgic600; } - + + @Override public void internalDrawing(Graphics g) { - w = g.getFontMetrics().stringWidth(value); - int w1 = g.getFontMetrics().stringWidth(STEREOTYPE); + w = g.getFontMetrics().stringWidth(value); + int w1 = g.getFontMetrics().stringWidth(STEREOTYPE); if (!tdp.isScaled()) { width = Math.max(Math.max(w, w1) + space, minWidth); } h = g.getFontMetrics().getHeight(); - g.drawString(STEREOTYPE, x + ((width - w1) / 2), y + h + space / 2); - g.drawString(value, x + ((width - w) / 2), y + height - h); + drawSingleString(g, STEREOTYPE, x + ((width - w1) / 2), y + h + space/2); + drawSingleString(g, value, x + ((width - w) / 2) , y + height - h); g.drawRect(x, y, width, height); } - + + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -118,12 +121,14 @@ public class UCDActorBox extends TGCScalableWithoutInternalComponentOneLineText }*/ return null; } - + + @Override public int getMyCurrentMinX() { return Math.min(x + width / 2 - w / 2, x); } - + + @Override public int getMyCurrentMaxX() { return Math.max(x + width / 2 + w / 2, x + width); } @@ -132,7 +137,8 @@ public class UCDActorBox extends TGCScalableWithoutInternalComponentOneLineText return value; } - + + @Override public int getType() { return TGComponentManager.UCD_ACTORBOX; } diff --git a/src/main/java/ui/ucd/UCDBorder.java b/src/main/java/ui/ucd/UCDBorder.java index 5a6941d5c9e4fa1959a4869260ba0ea5c5f36ee1..c5252de9911883422ca81c11d278f43bb69bdc98 100755 --- a/src/main/java/ui/ucd/UCDBorder.java +++ b/src/main/java/ui/ucd/UCDBorder.java @@ -87,14 +87,16 @@ public class UCDBorder extends TGCScalableWithoutInternalComponentOneLineText { myImageIcon = IconManager.imgic612; } + @Override public void internalDrawing(Graphics g) { w = g.getFontMetrics().stringWidth(value); h = g.getFontMetrics().getHeight(); g.drawRect(x, y, width, height); - g.drawString(value, x + width - w - textSpace, y + h); + drawSingleString(g, value, x + width - w - textSpace, y + h); } + @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -107,6 +109,7 @@ public class UCDBorder extends TGCScalableWithoutInternalComponentOneLineText { } + @Override public int getType() { return TGComponentManager.UCD_BORDER; } diff --git a/src/main/java/ui/ucd/UCDUseCase.java b/src/main/java/ui/ucd/UCDUseCase.java index cec990392ea7a70bc4a756afbe3a189f12745378..a0eca17301452c0aea0f9f0091d0509698f2e20a 100755 --- a/src/main/java/ui/ucd/UCDUseCase.java +++ b/src/main/java/ui/ucd/UCDUseCase.java @@ -61,8 +61,8 @@ import java.awt.*; */ public class UCDUseCase extends TGCScalableWithoutInternalComponent { protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; +// protected int textX = 5; +// protected int textY = 15; protected int arc = 5; protected int w, h, w1, w2; //w1; @@ -71,9 +71,12 @@ public class UCDUseCase extends TGCScalableWithoutInternalComponent { public UCDUseCase(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = (int)(50 * tdp.getZoom()); + width = (int)(50 * tdp.getZoom()); height = (int)(40 * tdp.getZoom()); //minWidth = 30; + textY = 15; + textX = 5; + nbConnectingPoint = 16; int index = 0; @@ -114,6 +117,7 @@ public class UCDUseCase extends TGCScalableWithoutInternalComponent { myImageIcon = IconManager.imgic602; } + @Override public void internalDrawing(Graphics g) { if (extension.length() > 0) { w1 = g.getFontMetrics().stringWidth(value); @@ -136,11 +140,11 @@ public class UCDUseCase extends TGCScalableWithoutInternalComponent { //name of use case if (extension.length() > 0) { - g.drawString(value, x + width / 2 - w1 / 2 , y + height/2 + h / 2 - 8); + drawSingleString(g, value, x + width / 2 - w1 / 2 , y + height/2 + h / 2 - 8); g.drawLine(x + width / 2 - w / 2, y + height/2 + h / 2 -6, x + width / 2 + w / 2, y + height/2 + h / 2 - 6); - g.drawString(extension, x + width / 2 - w2 / 2 , y + height/2 + h / 2 + 5); + drawSingleString(g, extension, x + width / 2 - w2 / 2 , y + height/2 + h / 2 + 5); } else { - g.drawString(value, x + width / 2 - w / 2 , y + height/2 + h / 2 - 3); + drawSingleString(g, value, x + width / 2 - w / 2 , y + height/2 + h / 2 - 3); } } @@ -160,11 +164,13 @@ public class UCDUseCase extends TGCScalableWithoutInternalComponent { return extension; } - + + @Override public int getType() { return TGComponentManager.UCD_USECASE; } + @Override public boolean editOndoubleClick(JFrame frame) { // boolean error = false; // String errors = ""; @@ -190,7 +196,8 @@ public class UCDUseCase extends TGCScalableWithoutInternalComponent { return true; } - + + @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info extension=\"" + extension + "\" "); diff --git a/src/main/java/ui/ucd/UseCaseDiagramToolBar.java b/src/main/java/ui/ucd/UseCaseDiagramToolBar.java index b5c0a5a355bd3a8f5258a79de6ecefca6b926453..8daec1fd10bf83311febf2852bab7aaa558b44bb 100755 --- a/src/main/java/ui/ucd/UseCaseDiagramToolBar.java +++ b/src/main/java/ui/ucd/UseCaseDiagramToolBar.java @@ -36,9 +36,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.ucd; import myutil.TraceManager; @@ -60,12 +57,11 @@ public class UseCaseDiagramToolBar extends TToolBar { public UseCaseDiagramToolBar(MainGUI _mgui) { super(_mgui); - } protected void setActive(boolean b) { - TraceManager.addDev("Setting to " + b + " Zoom"); - mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); + TraceManager.addDev("Setting to " + b + " Zoom"); + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b); diff --git a/src/main/java/ui/util/IconManager.java b/src/main/java/ui/util/IconManager.java index ab646504fa9388dc88b4ab84a91913d11ee7a7e0..71c183f98656a1263359a8d99d34360411d385e5 100755 --- a/src/main/java/ui/util/IconManager.java +++ b/src/main/java/ui/util/IconManager.java @@ -745,7 +745,10 @@ public class IconManager { if (imgic8 != null) { img8 = imgic8.getImage(); } - if (img9 != null) { + + // Issue #31: Need to check imgic9 not img9! + if ( imgic9 == null) { +// if (img9 != null) { img9 = imgic9.getImage(); } diff --git a/src/main/java/ui/window/JDialogCryptographicConfiguration.java b/src/main/java/ui/window/JDialogCryptographicConfiguration.java index 018b8787587362a34f78f2b9dc0c38d9e942d65f..46293afd204ec072dac422e7f78b7269e30688bc 100644 --- a/src/main/java/ui/window/JDialogCryptographicConfiguration.java +++ b/src/main/java/ui/window/JDialogCryptographicConfiguration.java @@ -36,23 +36,30 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.window; -import ui.util.IconManager; -import myutil.TraceManager; - -import javax.swing.*; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.HashMap; -import java.util.Vector; import java.util.List; -import java.util.ArrayList; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import myutil.TraceManager; /** * Class JDialogCryptographicConfiguration @@ -71,7 +78,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac private JPanel panel1; - private List<securityAlgorithm> secAlgs; + private List<SecurityAlgorithm> secAlgs; private Vector<String> algNames; // Panel1 private JTextField [] texts; @@ -96,16 +103,15 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac nonces=_nonces; keys=_keys; texts = new JTextField[nbString]; - secAlgs= new ArrayList<securityAlgorithm>(); + secAlgs= new ArrayList<SecurityAlgorithm>(); algNames=new Vector<String>(); initComponents(); - myInitComponents(); + //myInitComponents(); pack(); } - - private void myInitComponents() { - } +// private void myInitComponents() { +// } private void initComponents() { //These values are normalized to AES 128 bit as 100 @@ -114,28 +120,25 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac //http://www.cs.wustl.edu/~jain/cse567-06/ftp/encryption_perf/index.html //https://automationrhapsody.com/md5-sha-1-sha-256-sha-512-speed-performance/ //Add list of sample security algorithms - secAlgs.add(new securityAlgorithm("AES", "0","100","100","128","Symmetric Encryption")); - secAlgs.add(new securityAlgorithm("Triple-DES", "0","200","200","128","Symmetric Encryption")); + secAlgs.add(new SecurityAlgorithm("AES", "0","100","100","128","Symmetric Encryption")); + secAlgs.add(new SecurityAlgorithm("Triple-DES", "0","200","200","128","Symmetric Encryption")); - secAlgs.add(new securityAlgorithm("RSA", "0","250","150","128","Asymmetric Encryption")); - secAlgs.add(new securityAlgorithm("ECC", "0","315","310","128","Asymmetric Encryption")); + secAlgs.add(new SecurityAlgorithm("RSA", "0","250","150","128","Asymmetric Encryption")); + secAlgs.add(new SecurityAlgorithm("ECC", "0","315","310","128","Asymmetric Encryption")); - secAlgs.add(new securityAlgorithm("SHA-256", "0","370","370","128","Hash")); - secAlgs.add(new securityAlgorithm("Whirlpool", "0","550","550","128","Hash")); + secAlgs.add(new SecurityAlgorithm("SHA-256", "0","370","370","128","Hash")); + secAlgs.add(new SecurityAlgorithm("Whirlpool", "0","550","550","128","Hash")); - secAlgs.add(new securityAlgorithm("Poly-1305", "0","400","400","128","MAC")); - secAlgs.add(new securityAlgorithm("HMAC", "0","800","800","128","MAC")); + secAlgs.add(new SecurityAlgorithm("Poly-1305", "0","400","400","128","MAC")); + secAlgs.add(new SecurityAlgorithm("HMAC", "0","800","800","128","MAC")); - for (securityAlgorithm secAlg: secAlgs){ + for (SecurityAlgorithm secAlg: secAlgs){ algNames.add(secAlg.name); } inserts = new JButton[nbString]; helps = new HashMap<>(); c = getContentPane(); - //GridBagLayout gridbag0 = new GridBagLayout(); - - setFont(new Font("Helvetica", Font.PLAIN, 14)); c.setLayout(new BorderLayout()); @@ -146,7 +149,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac panel1= new EncryptPanel(this); } else { - panel1=new funcPanel(this); + panel1=new FuncPanel(this); } /*c0.gridwidth = 1; c0.gridheight = 10; @@ -167,8 +170,9 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac c.add(panelButton, BorderLayout.SOUTH); } + @Override public void actionPerformed(ActionEvent evt) { - String command = evt.getActionCommand(); + //String command = evt.getActionCommand(); // Compare the action command to the known actions. if (evt.getSource() == closeButton) { @@ -181,7 +185,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac if (evt.getSource() == inserts[0]) { texts[1].setText(helps.get(1).getSelectedItem().toString()); boolean repanel = false; - if (helps.get(1).getSelectedIndex()==5 && !(panel1 instanceof advPanel)){ + if (helps.get(1).getSelectedIndex()==5 && !(panel1 instanceof AdvPanel)){ values[1]=helps.get(1).getSelectedItem().toString(); values[0]=texts[0].getText(); values[3]=texts[3].getText(); @@ -191,9 +195,9 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac values[9]=texts[9].getText(); repanel=true; c.removeAll(); - panel1= new advPanel(this); + panel1= new AdvPanel(this); } - else if ((helps.get(1).getSelectedIndex() >2) && !(panel1 instanceof funcPanel)){ + else if ((helps.get(1).getSelectedIndex() >2) && !(panel1 instanceof FuncPanel)){ values[1]=helps.get(1).getSelectedItem().toString(); values[0]=texts[0].getText(); values[3]=texts[3].getText(); @@ -203,7 +207,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac values[9]=texts[9].getText(); repanel=true; c.removeAll(); - panel1= new funcPanel(this); + panel1= new FuncPanel(this); } else if ((helps.get(1).getSelectedIndex() <3) && !(panel1 instanceof EncryptPanel)){ values[1]=helps.get(1).getSelectedItem().toString(); @@ -261,7 +265,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac if (evt.getSource() == inserts[9]) { if (helps.get(9).getSelectedItem()!=null){ texts[9].setText(helps.get(9).getSelectedItem().toString()); - for (securityAlgorithm secAlg: secAlgs){ + for (SecurityAlgorithm secAlg: secAlgs){ if (secAlg.name.equals(texts[9].getText())){ //Set algorithm times + overhead texts[1].setText(secAlg.type); @@ -397,14 +401,10 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac texts[9]=new JTextField(values[9],15); c1.gridwidth = GridBagConstraints.REMAINDER; //end row add(texts[9],c1); - } - - - } - public class funcPanel extends JPanel { + public class FuncPanel extends JPanel { private void addEmptyLine(GridBagConstraints gc) { gc.weighty = 1.0; gc.weightx = 1.0; @@ -414,7 +414,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac add(new JLabel(" "), gc); } - funcPanel(JDialogCryptographicConfiguration j){ + FuncPanel(JDialogCryptographicConfiguration j){ GridBagConstraints c1 = new GridBagConstraints(); GridBagLayout gridbag1 = new GridBagLayout(); @@ -494,8 +494,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac } } - - public class advPanel extends JPanel { + public class AdvPanel extends JPanel { private void addEmptyLine(GridBagConstraints gc) { gc.weighty = 1.0; gc.weightx = 1.0; @@ -505,7 +504,7 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac add(new JLabel(" "), gc); } - advPanel(JDialogCryptographicConfiguration j){ + AdvPanel(JDialogCryptographicConfiguration j){ GridBagConstraints c1 = new GridBagConstraints(); GridBagLayout gridbag1 = new GridBagLayout(); @@ -604,14 +603,14 @@ public class JDialogCryptographicConfiguration extends JDialogBase implements Ac dispose(); } - public class securityAlgorithm { + public class SecurityAlgorithm { String name; String overhead; String encryptCC; String decryptCC; String keysize; String type; - public securityAlgorithm(String name, String overhead, String encryptCC, String decryptCC, String keysize, String type){ + public SecurityAlgorithm(String name, String overhead, String encryptCC, String decryptCC, String keysize, String type){ this.name=name; this.overhead=overhead; this.encryptCC = encryptCC; diff --git a/test.txt b/test.txt deleted file mode 100644 index d6417118431a3e084ed83cd81f49dd4e97e77ef2..0000000000000000000000000000000000000000 --- a/test.txt +++ /dev/null @@ -1,2 +0,0 @@ -THIS IS A TEST FILE TO SYNC GITHUB REPOSITORIES -test diff --git a/ttool-cli/.classpath b/ttool-cli/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..2dbe4b3ccb4a0c70bee8e8b3018e238fcb574831 --- /dev/null +++ b/ttool-cli/.classpath @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> + <attributes> + <attribute name="module" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="src/main/java"/> + <classpathentry combineaccessrules="false" kind="src" path="/src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/ttool-cli/.gitignore b/ttool-cli/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..564a2861a7342279f860cfd3a61b229ce9964f9f --- /dev/null +++ b/ttool-cli/.gitignore @@ -0,0 +1,5 @@ +/bin/ +/*.class +*.class +*.gif +ttool-cli/build/resources/ \ No newline at end of file diff --git a/ttool-cli/.project b/ttool-cli/.project new file mode 100644 index 0000000000000000000000000000000000000000..336c5c01d7d23c3c74e7954be9bf8d202753b39f --- /dev/null +++ b/ttool-cli/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ttool-cli</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/ttool/launch_configurations/test/UIBotTests.launch b/ttool/launch_configurations/test/UIBotTests.launch deleted file mode 100644 index 7400079479c89840c5154f0b7bcac58a28405770..0000000000000000000000000000000000000000 --- a/ttool/launch_configurations/test/UIBotTests.launch +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.junit.launchconfig"> - <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> - <listEntry value="/ttool/src/test/java/ui/bot/MainFrameBasicTests.java"/> - </listAttribute> - <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> - <listEntry value="1"/> - </listAttribute> - <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> - <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> - <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value="openModel"/> - <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> - <listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="5" projectName="ttool" type="1"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="5" projectName="src" type="1"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/junit-4.12.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/ttool/src/test/libs/fr.tpt.mem4csd.utils.compare_1.0.0.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/assertj/assertj-core/3.11.1/assertj-core-3.11.1.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/assertj/assertj-swing/3.8.0/assertj-swing-3.8.0.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/assertj/assertj-swing-junit/3.8.0/assertj-swing-junit-3.8.0-sources.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/assertj/assertj-swing-junit/3.8.0/assertj-swing-junit-3.8.0.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/assertj/assertj-swing/3.8.0/assertj-swing-3.8.0-sources.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/hamcrest-core-1.3.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libs/commons-io-2.5.jar" path="5" type="2"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" path="5" type="4"/> "/> - <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/src/main/resources" path="5" type="2"/> "/> - </listAttribute> - <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> - <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ui.bot.MainFrameBasicTests"/> - <listAttribute key="org.eclipse.jdt.launching.MODULEPATH"/> - <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="ttool"/> - <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/> -</launchConfiguration>