From 1c0ea804de35b45d3200469bc4220bb367d32406 Mon Sep 17 00:00:00 2001 From: jerray <jawher.jerray@eurecom.fr> Date: Tue, 6 Jun 2023 16:02:27 +0200 Subject: [PATCH] update drawAuth functions + format code --- .../AvatarAttributeState.java | 9 +- src/main/java/tmltranslator/TMLModeling.java | 116 ++++++++++++++---- .../tmltranslator/toavatarsec/TML2Avatar.java | 35 +++--- src/main/java/ui/GTURTLEModeling.java | 9 +- src/main/java/ui/MainGUI.java | 2 +- src/main/java/ui/tmlad/TMLADDecrypt.java | 54 +++++--- src/main/java/ui/tmlad/TMLADReadChannel.java | 53 +++++--- .../java/ui/tmlcompd/TMLCPrimitivePort.java | 99 ++++++++++----- 8 files changed, 261 insertions(+), 116 deletions(-) diff --git a/src/main/java/avatartranslator/AvatarAttributeState.java b/src/main/java/avatartranslator/AvatarAttributeState.java index f8fc7aa0dd..96772e80df 100644 --- a/src/main/java/avatartranslator/AvatarAttributeState.java +++ b/src/main/java/avatartranslator/AvatarAttributeState.java @@ -47,9 +47,9 @@ package avatartranslator; public class AvatarAttributeState extends AvatarElement { private AvatarAttribute attribute; private AvatarState state; + public AvatarAttributeState(String _name, Object _referenceObject, AvatarAttribute attr, AvatarState st) { - //super(_name, _referenceObject); - super(attr.getBlock().getName() + "." + st.getName() + "." + attr.getName(), _referenceObject); + super(_name, _referenceObject); attribute = attr; state = st; } @@ -76,4 +76,9 @@ public class AvatarAttributeState extends AvatarElement { public String toString() { return this.attribute.getBlock().getName().replaceAll("__", ".") + "." + this.state.getName() + "." + this.attribute.getName(); } + + @Override + public String getName() { + return getAttribute().getBlock().getName() + "." + getState().getName() + "." + getAttribute().getName(); + } } diff --git a/src/main/java/tmltranslator/TMLModeling.java b/src/main/java/tmltranslator/TMLModeling.java index c5cb618594..cc3f89ee98 100755 --- a/src/main/java/tmltranslator/TMLModeling.java +++ b/src/main/java/tmltranslator/TMLModeling.java @@ -915,8 +915,12 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : channel.ports) { if (port.getCheckAuth()) { //port.setStrongAuthStatus(2); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setMappingName(mappingName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -937,8 +941,12 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : req.ports) { if (port.getCheckAuth()) { //port.setStrongAuthStatus(2); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setMappingName(mappingName); } } @@ -980,8 +988,13 @@ public class TMLModeling<E> { // TraceManager.addDev("adding to port " + channelName); if (port.getCheckAuth()) { //port.setStrongAuthStatus(2); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setSecName(signalName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -1013,8 +1026,14 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : channel.ports) { if (port.getCheckAuth()) { //port.setStrongAuthStatus(2); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); port.setSecName(signalName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -1038,8 +1057,12 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : channel.ports) { if (port.getCheckAuth()) { //port.setWeakAuthStatus(2); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setMappingName(mappingName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -1063,8 +1086,12 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : req.ports) { if (port.getCheckAuth()) { //port.setWeakAuthStatus(2); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setMappingName(mappingName); } } @@ -1106,9 +1133,14 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : channel.ports) { if (port.getCheckAuth()) { //port.setStrongAuthStatus(3); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); //port.setWeakAuthStatus(2); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setSecName(signalName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -1142,8 +1174,14 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : channel.ports) { if (port.getCheckAuth()) { //port.setWeakAuthStatus(2); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); port.setSecName(signalName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -1171,8 +1209,12 @@ public class TMLModeling<E> { if (port.getCheckAuth()) { TraceManager.addDev("Backtracing Authenticity proved but not satisfied / Found port with checkAuth"); //port.setStrongAuthStatus(3); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setMappingName(mappingName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -1195,8 +1237,12 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : req.ports) { if (port.getCheckAuth()) { //port.setStrongAuthStatus(3); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); port.setMappingName(mappingName); } } @@ -1233,8 +1279,13 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : channel.ports) { if (port.getCheckAuth()) { //port.setStrongAuthStatus(3); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), + port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), + result.isWeakProved(), result.isWeakSatisfied())); TraceManager.addDev("Backtracing Authenticity not verified " + signalName); port.setSecName(signalName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); @@ -1267,8 +1318,14 @@ public class TMLModeling<E> { for (TMLPortWithSecurityInformation port : channel.ports) { if (port.getCheckAuth()) { //port.setWeakAuthStatus(3); - port.setStrongAuthStatus(updateStrongAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); - port.setWeakAuthStatus(updateWeakAuthenticityStatus(port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), result.isProved(), result.isSatisfied(), result.isWeakProved(), result.isWeakSatisfied())); + port.setStrongAuthStatus(updateStrongAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); + port.setWeakAuthStatus(updateWeakAuthenticityStatus( + port.getCheckStrongAuthStatus(), port.getCheckWeakAuthStatus(), + result.isProved(), result.isSatisfied(), result.isWeakProved(), + result.isWeakSatisfied())); port.setSecName(signalName); ProVerifResultTrace trace = pvoa.getResults().get(pragma).getTrace(); if (trace != null && !port.isOrigin()) { @@ -3099,8 +3156,11 @@ public class TMLModeling<E> { return true; } - public int updateStrongAuthenticityStatus(int _lastStrongAuthStatus, int _lastWeakAuthStatus, Boolean _isStrongAuthProved, Boolean _isStrongAuthSatisfied, Boolean _isWeakAuthProved, Boolean _isWeakAuthSatisfied) { - if (_isStrongAuthProved && _isStrongAuthSatisfied && _isWeakAuthProved && _isWeakAuthSatisfied && _lastStrongAuthStatus != 3 && _lastWeakAuthStatus != 3) { + public int updateStrongAuthenticityStatus(int _lastStrongAuthStatus, int _lastWeakAuthStatus, + boolean _isStrongAuthProved, boolean _isStrongAuthSatisfied, boolean _isWeakAuthProved, + boolean _isWeakAuthSatisfied) { + if (_isStrongAuthProved && _isStrongAuthSatisfied && _isWeakAuthProved && _isWeakAuthSatisfied + && _lastStrongAuthStatus != 3 && _lastWeakAuthStatus != 3) { return 2; } else if (!_isStrongAuthProved && !(_isWeakAuthProved && !_isWeakAuthSatisfied) && _lastStrongAuthStatus < 3 && _lastWeakAuthStatus < 3) { return 1; @@ -3110,7 +3170,9 @@ public class TMLModeling<E> { } } - public int updateWeakAuthenticityStatus(int _lastStrongAuthStatus, int _lastWeakAuthStatus, Boolean _isStrongAuthProved, Boolean _isStrongAuthSatisfied, Boolean _isWeakAuthProved, Boolean _isWeakAuthSatisfied) { + public int updateWeakAuthenticityStatus(int _lastStrongAuthStatus, int _lastWeakAuthStatus, + boolean _isStrongAuthProved, boolean _isStrongAuthSatisfied, boolean _isWeakAuthProved, + boolean _isWeakAuthSatisfied) { if (_isWeakAuthProved && _isWeakAuthSatisfied && _lastWeakAuthStatus != 3) { return 2; } else if (!_isWeakAuthProved && _lastWeakAuthStatus < 3) { diff --git a/src/main/java/tmltranslator/toavatarsec/TML2Avatar.java b/src/main/java/tmltranslator/toavatarsec/TML2Avatar.java index 283b803aac..cfcc6adde7 100644 --- a/src/main/java/tmltranslator/toavatarsec/TML2Avatar.java +++ b/src/main/java/tmltranslator/toavatarsec/TML2Avatar.java @@ -316,7 +316,7 @@ public class TML2Avatar { TraceManager.addDev(channelMap); }*/ - public List<AvatarStateMachineElement> translateState(TMLActivityElement ae, AvatarBlock block, Boolean autoAuthChans) { + public List<AvatarStateMachineElement> translateState(TMLActivityElement ae, AvatarBlock block, boolean autoAuthChans) { // TMLActionState tmlaction; // TMLChoice tmlchoice; @@ -1555,7 +1555,7 @@ public class TML2Avatar { } } - public AvatarSpecification generateAvatarSpec(String _loopLimit, Boolean autoAuthChans) { + public AvatarSpecification generateAvatarSpec(String _loopLimit, boolean autoAuthChans) { TraceManager.addDev("security patterns " + tmlmodel.secPatterns); TraceManager.addDev("keys " + tmlmap.mappedSecurity); @@ -1884,7 +1884,8 @@ public class TML2Avatar { for (TMLActivityElement actElem : task.getActivityDiagram().getElements()) { if (actElem instanceof TMLWriteChannel) { TMLWriteChannel wc = (TMLWriteChannel) actElem; - if (wc != null && wc.hasChannel(ch) && actElem.securityPattern != null && actElem.securityPattern.getName().equals(secPattern.getName())) { + if (wc != null && wc.hasChannel(ch) && actElem.securityPattern != null + && actElem.securityPattern.getName().equals(secPattern.getName())) { checkAuthSecPattern = true; break; } @@ -1911,8 +1912,9 @@ public class TML2Avatar { for (AvatarAttributeState attributeStateOrigin : signalAuthOriginMap.get(s)) { if (signalAuthDestMap.containsKey(s)) { for (AvatarAttributeState attributeStateDest : signalAuthDestMap.get(s)) { - AvatarPragmaAuthenticity pragma = new AvatarPragmaAuthenticity("#Authenticity " + attributeStateOrigin.getName() + " " - + attributeStateDest.getName(), attributeStateOrigin.getReferenceObject(), attributeStateOrigin, attributeStateDest); + AvatarPragmaAuthenticity pragma = new AvatarPragmaAuthenticity( + "#Authenticity " + attributeStateOrigin.getName() + " " + attributeStateDest.getName(), + attributeStateOrigin.getReferenceObject(), attributeStateOrigin, attributeStateDest); if (secChannelMap.containsKey(s)) { for (String channel : secChannelMap.get(s)) { TMLChannel ch = tmlmodel.getChannelByShortName(channel); @@ -2374,14 +2376,14 @@ public class TML2Avatar { ProVerifQueryAuthResult result = authenticityResults.get(pragma); if (!result.isProved() || !result.isWeakProved()) continue; - int r_weakAuthStatus = 1; - int r_strongAuthStatus = 1; + int resWeakAuthStatus = 1; + int resStrongAuthStatus = 1; if (result.isWeakProved()) { - r_weakAuthStatus = result.isWeakSatisfied() ? 2 : 3; + resWeakAuthStatus = result.isWeakSatisfied() ? 2 : 3; } if (result.isProved()) { - r_strongAuthStatus = result.isSatisfied() ? 2 : 3; + resStrongAuthStatus = result.isSatisfied() ? 2 : 3; } if (pragma.getAttrB().getReferenceObject()!= null && pragma.getAttrB().getReferenceObject() instanceof TMLADReadChannel) { @@ -2391,9 +2393,9 @@ public class TML2Avatar { rc.setAuthCheck(channel.checkAuth); } if (rc.getWeakAuthStatus() < 3) { - rc.setWeakAuthStatus(r_weakAuthStatus); + rc.setWeakAuthStatus(resWeakAuthStatus); if (rc.getStrongAuthStatus() < 3) { - rc.setStrongAuthStatus(r_strongAuthStatus); + rc.setStrongAuthStatus(resStrongAuthStatus); } } } @@ -2402,15 +2404,16 @@ public class TML2Avatar { TMLADDecrypt dec = (TMLADDecrypt) pragma.getAttrB().getReferenceObject(); for (TMLTask t : taskBlockMap.keySet()) { if (taskBlockMap.get(t).equals(pragma.getAttrB().getAttribute().getBlock())) { - ch_des_task: + chDestinationTask: for (TMLChannel ch : tmlmodel.getChannels(t)) { if (ch.hasDestinationTask(t)) { for (TMLActivityElement actElem : t.getActivityDiagram().getElements()) { if (actElem instanceof TMLReadChannel) { TMLReadChannel rc = (TMLReadChannel) actElem; - if (rc.hasChannel(ch) && actElem.securityPattern != null && actElem.securityPattern.getName().equals(dec.securityContext)) { + if (rc.hasChannel(ch) && actElem.securityPattern != null + && actElem.securityPattern.getName().equals(dec.securityContext)) { dec.setAuthCheck(ch.checkAuth); - break ch_des_task; + break chDestinationTask; } } } @@ -2419,9 +2422,9 @@ public class TML2Avatar { } } if (dec.getWeakAuthStatus() < 3) { - dec.setWeakAuthStatus(r_weakAuthStatus); + dec.setWeakAuthStatus(resWeakAuthStatus); if (dec.getStrongAuthStatus() < 3) { - dec.setStrongAuthStatus(r_strongAuthStatus); + dec.setStrongAuthStatus(resStrongAuthStatus); } } } diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index f2d72059d2..1f56db39aa 100644 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -1655,7 +1655,7 @@ public class GTURTLEModeling { } TURTLEPanel tmlap = tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel().tp; int arch = gui.tabs.indexOf(tmlap); - DateFormat dateFormat = new SimpleDateFormat("ddMMyy_HHmmss"); + DateFormat dateFormat = new SimpleDateFormat("HHmmss"); Date date = new Date(); String dateAndTime = dateFormat.format(date); String newTabSuffix = "enc_" + dateAndTime; @@ -1679,13 +1679,14 @@ public class GTURTLEModeling { } TURTLEPanel tmlap = tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel().tp; int arch = gui.tabs.indexOf(tmlap); - DateFormat dateFormat = new SimpleDateFormat("ddMMyy_HHmmss"); + DateFormat dateFormat = new SimpleDateFormat("HHmmss"); Date date = new Date(); String dateAndTime = dateFormat.format(date); String newTabSuffix = "enc_" + dateAndTime; gui.cloneRenameTab(arch, newTabSuffix); TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size() - 1); - return autoSecure(gui, newTabSuffix, tmap, newarch, encComp, overhead, decComp, true, false, false, new HashMap<String, java.util.List<String>>()); + return autoSecure(gui, newTabSuffix, tmap, newarch, encComp, overhead, decComp, true, false, false, + new HashMap<String, java.util.List<String>>()); } public TMLMapping<TGComponent> autoSecure(MainGUI gui, String encComp, String overhead, String decComp, boolean autoConf, boolean autoWeakAuth, @@ -1695,7 +1696,7 @@ public class GTURTLEModeling { } TURTLEPanel tmlap = tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel().tp; int arch = gui.tabs.indexOf(tmlap); - DateFormat dateFormat = new SimpleDateFormat("ddMMyy_HHmmss"); + DateFormat dateFormat = new SimpleDateFormat("HHmmss"); Date date = new Date(); String dateAndTime = dateFormat.format(date); String newTabSuffix = "enc_" + dateAndTime; diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 8a02671fb7..bebaf52c27 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -4734,7 +4734,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per tp = tabs.elementAt(i); if (tp instanceof TMLComponentDesignPanel) { for (String s : ((TMLComponentDesignPanel) tp).getAllKeys()) { - list.add(tp.getNameOfTab()+"::"+s); + list.add(tp.getNameOfTab() + "::" + s); } } } diff --git a/src/main/java/ui/tmlad/TMLADDecrypt.java b/src/main/java/ui/tmlad/TMLADDecrypt.java index 9940b9a53b..aa45c3024b 100755 --- a/src/main/java/ui/tmlad/TMLADDecrypt.java +++ b/src/main/java/ui/tmlad/TMLADDecrypt.java @@ -259,6 +259,24 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } public void drawAuthenticityInformation(Graphics g) { + final double coeffSpacePortAuthLock = 0.1; + final double coeffAuthOval = 0.55; + final double coeffAuthLock = 0.65; + final double coeffXCoordinateOffsetDrawAuth = 1.5; + final double coeffYCoordinateOffsetDrawAuth = 0.95; + double spacePortAuthLock = width * coeffSpacePortAuthLock; + double authOvalWidth = height * coeffAuthOval; + double authOvalHeight = height * coeffAuthOval; + double authLockWidth = height * coeffAuthLock; + double authLockHeight = height * coeffAuthLock; + double xCoordinateAuthLockLeft = securityMaxX + spacePortAuthLock; + double xCoordinateAuthLockRight = securityMaxX + authLockWidth + spacePortAuthLock; + double yCoordinateAuthLockTop = y + height - authLockHeight; + double yCoordinateAuthLockBottom = y + height; + double xCoordinateAuthLockCenter = xCoordinateAuthLockLeft + authLockWidth/2; + double yCoordinateAuthLockCenter = yCoordinateAuthLockBottom - authLockHeight/2; + double xCoordinateAuthOvalLeft = xCoordinateAuthLockLeft + (authLockWidth - authOvalWidth)/2; + double yCoordinateAuthOvalTop = yCoordinateAuthLockTop - authOvalHeight/2; Color c = g.getColor(); Color c1; Color c2; @@ -282,18 +300,14 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T default: c2 = c1; } - double space_port_authlock = height * 0.1; - double authovalwidth = height * 0.55; - double authovalheight = height * 0.55; - double authlockwidth = height * 0.65; - double authlockheight = height * 0.65; - g.drawOval((int)(securityMaxX + (authlockwidth-authovalwidth)/2 + space_port_authlock), (int)(y + height - authlockheight - authovalheight/2), (int)authovalwidth, (int)authovalheight); + + g.drawOval((int) (xCoordinateAuthOvalLeft), (int) (yCoordinateAuthOvalTop), (int) (authOvalWidth), (int) (authOvalHeight)); g.setColor(c1); - int[] xps = new int[]{(int)(securityMaxX + space_port_authlock), (int)(securityMaxX + space_port_authlock), (int)(securityMaxX + authlockwidth + space_port_authlock)}; - int[] yps = new int[]{(int)(y + height - authlockheight), y + height, y + height}; - int[] xpw = new int[]{(int)(securityMaxX + authlockwidth + space_port_authlock), (int)(securityMaxX + authlockwidth + space_port_authlock), (int)(securityMaxX + space_port_authlock)}; - int[] ypw = new int[]{y + height, (int)(y + height - authlockheight), (int)(y + height - authlockheight)}; + int[] xps = new int[]{(int) (xCoordinateAuthLockLeft), (int) (xCoordinateAuthLockLeft), (int) (xCoordinateAuthLockRight)}; + int[] yps = new int[]{(int) (yCoordinateAuthLockTop), (int) (yCoordinateAuthLockBottom), (int) (yCoordinateAuthLockBottom)}; + int[] xpw = new int[]{(int) (xCoordinateAuthLockRight), (int) (xCoordinateAuthLockRight), (int) (xCoordinateAuthLockLeft)}; + int[] ypw = new int[]{(int) (yCoordinateAuthLockBottom), (int) (yCoordinateAuthLockTop), (int) (yCoordinateAuthLockTop)}; g.fillPolygon(xps, yps, 3); g.setColor(c2); @@ -301,15 +315,21 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T g.setColor(c); g.drawPolygon(xps, yps, 3); g.drawPolygon(xpw, ypw, 3); - drawSingleString(g, "S", (int)(securityMaxX + 1.5*space_port_authlock), (int) (y + 0.95*height)); - drawSingleString(g, "W", (int)(securityMaxX + 0.95*authlockwidth/2 + space_port_authlock), (int)(y + height - 0.95*authlockheight/2)); + drawSingleString(g, "S", (int) (securityMaxX + coeffXCoordinateOffsetDrawAuth * spacePortAuthLock), + (int) (y + coeffYCoordinateOffsetDrawAuth * height)); + drawSingleString(g, "W", (int) (xCoordinateAuthLockLeft + coeffYCoordinateOffsetDrawAuth * authLockWidth / 2), + (int) (yCoordinateAuthLockBottom - coeffYCoordinateOffsetDrawAuth * authLockHeight / 2)); if (strongAuthStatus == 3) { - g.drawLine((int)(securityMaxX + space_port_authlock), y + height, (int)(securityMaxX + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight/2)); - g.drawLine((int)(securityMaxX + space_port_authlock), (int)(y + height - authlockheight/2), (int)(securityMaxX + authlockwidth/2 + space_port_authlock), y + height); + g.drawLine((int) (xCoordinateAuthLockLeft), (int) (yCoordinateAuthLockBottom), + (int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockCenter)); + g.drawLine((int) (xCoordinateAuthLockLeft), (int) (yCoordinateAuthLockCenter), + (int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockBottom)); } if (weakAuthStatus == 3 || strongAuthStatus == 3 && weakAuthStatus < 2) { - g.drawLine((int)(securityMaxX + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight/2), (int)(securityMaxX + authlockwidth + space_port_authlock), (int)(y + height - authlockheight)); - g.drawLine((int)(securityMaxX + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight), (int)(securityMaxX + authlockwidth + space_port_authlock), (int)(y + height - authlockheight/2)); + g.drawLine((int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockCenter), + (int) (xCoordinateAuthLockRight), (int) (yCoordinateAuthLockTop)); + g.drawLine((int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockTop), + (int) (xCoordinateAuthLockRight), (int) (yCoordinateAuthLockCenter)); } } @@ -332,7 +352,7 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T return authCheck; } - public void setAuthCheck(Boolean _authCheck) { + public void setAuthCheck(boolean _authCheck) { authCheck = _authCheck; } diff --git a/src/main/java/ui/tmlad/TMLADReadChannel.java b/src/main/java/ui/tmlad/TMLADReadChannel.java index 2febf83867..7c9e208a1a 100755 --- a/src/main/java/ui/tmlad/TMLADReadChannel.java +++ b/src/main/java/ui/tmlad/TMLADReadChannel.java @@ -296,6 +296,25 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # } public void drawAuthenticityInformation(Graphics g) { + final double coeffSpacePortAuthLock = 0.1; + final double coeffAuthOval = 1; + final double coeffAuthLock = 1.1; + final double coeffXCoordinateOffsetDrawAuth = 0.85; + final double coeffYCoordinateOffsetDrawAuth = 0.95; + double spacePortAuthLock = width * coeffSpacePortAuthLock; + double authOvalWidth = height * coeffAuthOval; + double authOvalHeight = height * coeffAuthOval; + double authLockWidth = height * coeffAuthLock; + double authLockHeight = height * coeffAuthLock; + double xCoordinateAuthLockLeft = x + width + spacePortAuthLock; + double xCoordinateAuthLockRight = x + width + authLockWidth + spacePortAuthLock; + double yCoordinateAuthLockTop = y + height - authLockHeight; + double yCoordinateAuthLockBottom = y + height; + double xCoordinateAuthLockCenter = xCoordinateAuthLockLeft + authLockWidth/2; + double yCoordinateAuthLockCenter = yCoordinateAuthLockBottom - authLockHeight/2; + double xCoordinateAuthOvalLeft = xCoordinateAuthLockLeft + (authLockWidth - authOvalWidth)/2; + double yCoordinateAuthOvalTop = yCoordinateAuthLockTop - authOvalHeight/2; + Color c = g.getColor(); Color c1; Color c2; @@ -319,18 +338,13 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # default: c2 = c1; } - double space_port_authlock = width * 0.1; - double authovalwidth = height * 1; - double authovalheight = height * 1; - double authlockwidth = height * 1.1; - double authlockheight = height * 1.1; - g.drawOval((int)(x + width + (authlockwidth-authovalwidth)/2 + space_port_authlock), (int)(y + height - authlockheight - authovalheight/2), (int)authovalwidth, (int)authovalheight); + g.drawOval((int) (xCoordinateAuthOvalLeft), (int) (yCoordinateAuthOvalTop), (int) (authOvalWidth), (int) (authOvalHeight)); g.setColor(c1); - int[] xps = new int[]{(int)(x + width + space_port_authlock), (int)(x + width + space_port_authlock), (int)(x + width + authlockwidth + space_port_authlock)}; - int[] yps = new int[]{(int)(y + height - authlockheight), y + height, y + height}; - int[] xpw = new int[]{(int)(x + width + authlockwidth + space_port_authlock), (int)(x + width + authlockwidth + space_port_authlock), (int)(x + width + space_port_authlock)}; - int[] ypw = new int[]{y + height, (int)(y + height - authlockheight), (int)(y + height - authlockheight)}; + int[] xps = new int[]{(int) (xCoordinateAuthLockLeft), (int) (xCoordinateAuthLockLeft), (int) (xCoordinateAuthLockRight)}; + int[] yps = new int[]{(int) (yCoordinateAuthLockTop), (int) (yCoordinateAuthLockBottom), (int) (yCoordinateAuthLockBottom)}; + int[] xpw = new int[]{(int) (xCoordinateAuthLockRight), (int) (xCoordinateAuthLockRight), (int) (xCoordinateAuthLockLeft)}; + int[] ypw = new int[]{(int) (yCoordinateAuthLockBottom), (int) (yCoordinateAuthLockTop), (int) (yCoordinateAuthLockTop)}; g.fillPolygon(xps, yps, 3); g.setColor(c2); @@ -338,15 +352,20 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # g.setColor(c); g.drawPolygon(xps, yps, 3); g.drawPolygon(xpw, ypw, 3); - drawSingleString(g, "S", (int)(x + width + space_port_authlock), (int) (y + 0.95*height)); - drawSingleString(g, "W", (int)(x + 0.85*authlockwidth/2 + width + space_port_authlock), (int)(y + height - 0.95*authlockheight/2)); + drawSingleString(g, "S", (int) (xCoordinateAuthLockLeft), (int) (y + coeffYCoordinateOffsetDrawAuth*height)); + drawSingleString(g, "W", (int) (xCoordinateAuthLockLeft + coeffXCoordinateOffsetDrawAuth * authLockWidth / 2), + (int) (yCoordinateAuthLockBottom - coeffYCoordinateOffsetDrawAuth * authLockHeight / 2)); if (strongAuthStatus == 3) { - g.drawLine((int)(x + width + space_port_authlock), y + height, (int)(x + width + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight/2)); - g.drawLine((int)(x + width + space_port_authlock), (int)(y + height - authlockheight/2), (int)(x + width + authlockwidth/2 + space_port_authlock), y + height); + g.drawLine((int) (xCoordinateAuthLockLeft), (int) (yCoordinateAuthLockBottom), + (int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockCenter)); + g.drawLine((int) (xCoordinateAuthLockLeft), (int) (yCoordinateAuthLockCenter), + (int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockBottom)); } if (weakAuthStatus == 3 || strongAuthStatus == 3 && weakAuthStatus < 2) { - g.drawLine((int)(x + width + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight/2), (int)(x + width + authlockwidth + space_port_authlock), (int)(y + height - authlockheight)); - g.drawLine((int)(x + width + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight), (int)(x + width + authlockwidth + space_port_authlock), (int)(y + height - authlockheight/2)); + g.drawLine((int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockCenter), + (int) (xCoordinateAuthLockRight), (int) (yCoordinateAuthLockTop)); + g.drawLine((int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockTop), + (int) (xCoordinateAuthLockRight), (int) (yCoordinateAuthLockCenter)); } } @@ -548,7 +567,7 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # return authCheck; } - public void setAuthCheck(Boolean _authCheck) { + public void setAuthCheck(boolean _authCheck) { authCheck = _authCheck; makeValue(); } diff --git a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java index dc004e100e..2daa623388 100755 --- a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java +++ b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java @@ -370,6 +370,25 @@ public void drawAuthVerification(Graphics g) { + final double coeffSpacePortAuthLock = 0.1; + final double coeffAuthOval = 0.6; + final double coeffAuthLock = 0.7; + final double coeffOffsetSecName = 0.7; + final double coeffXCoordinateOffsetDrawAuth = 0.8; + final double coeffYCoordinateOffsetDrawAuth = 0.95; + double spacePortAuthLock = width * coeffSpacePortAuthLock; + double authOvalWidth = width * coeffAuthOval; + double authOvalHeight = height * coeffAuthOval; + double authLockWidth = width * coeffAuthLock; + double authLockHeight = height * coeffAuthLock; + double xCoordinateAuthLockLeft = x + width + spacePortAuthLock; + double xCoordinateAuthLockRight = x + width + authLockWidth + spacePortAuthLock; + double yCoordinateAuthLockTop = y + height - authLockHeight; + double yCoordinateAuthLockBottom = y + height; + double xCoordinateAuthLockCenter = xCoordinateAuthLockLeft + authLockWidth/2; + double yCoordinateAuthLockCenter = yCoordinateAuthLockBottom - authLockHeight/2; + double xCoordinateAuthOvalLeft = xCoordinateAuthLockLeft + (authLockWidth - authOvalWidth)/2; + double yCoordinateAuthOvalTop = yCoordinateAuthLockTop - authOvalHeight/2; Color c = g.getColor(); Color c1; Color c2; @@ -393,19 +412,14 @@ default: c2 = c1; } - double space_port_authlock = width * 0.1; - double authovalwidth = width * 0.6; - double authovalheight = height * 0.6; - double authlockwidth = width * 0.7; - double authlockheight = height * 0.7; - drawSingleString(g, secName, (int)(x + width + space_port_authlock), (int)(y + height + 0.7*authlockheight)); - g.drawOval((int)(x + width + (authlockwidth-authovalwidth)/2 + space_port_authlock), (int)(y + height - authlockheight - authovalheight/2), (int)authovalwidth, (int)authovalheight); + drawSingleString(g, secName, (int) (xCoordinateAuthLockLeft), (int) (yCoordinateAuthLockBottom + coeffOffsetSecName*authLockHeight)); + g.drawOval((int) (xCoordinateAuthOvalLeft), (int) (yCoordinateAuthOvalTop), (int) (authOvalWidth), (int) (authOvalHeight)); g.setColor(c1); - int[] xps = new int[]{(int)(x + width + space_port_authlock), (int)(x + width + space_port_authlock), (int)(x + width + authlockwidth + space_port_authlock)}; - int[] yps = new int[]{(int)(y + height - authlockheight), y + height, y + height}; - int[] xpw = new int[]{(int)(x + width + authlockwidth + space_port_authlock), (int)(x + width + authlockwidth + space_port_authlock), (int)(x + width + space_port_authlock)}; - int[] ypw = new int[]{y + height, (int)(y + height - authlockheight), (int)(y + height - authlockheight)}; + int[] xps = new int[]{(int) (xCoordinateAuthLockLeft), (int) (xCoordinateAuthLockLeft), (int) (xCoordinateAuthLockRight)}; + int[] yps = new int[]{(int) (yCoordinateAuthLockTop), (int) (yCoordinateAuthLockBottom), (int) (yCoordinateAuthLockBottom)}; + int[] xpw = new int[]{(int) (xCoordinateAuthLockRight), (int) (xCoordinateAuthLockRight), (int) (xCoordinateAuthLockLeft)}; + int[] ypw = new int[]{(int) (yCoordinateAuthLockBottom), (int) (yCoordinateAuthLockTop), (int) (yCoordinateAuthLockTop)}; g.fillPolygon(xps, yps, 3); g.setColor(c2); @@ -413,20 +427,41 @@ g.setColor(c); g.drawPolygon(xps, yps, 3); g.drawPolygon(xpw, ypw, 3); - drawSingleString(g, "S", (int)(x + width + space_port_authlock), (int) (y + 0.95*height)); - drawSingleString(g, "W", (int)(x + 0.85*authlockwidth/2 + width + space_port_authlock), (int)(y + height - 0.95*authlockheight/2)); + drawSingleString(g, "S", (int) (xCoordinateAuthLockLeft), (int) (y + coeffYCoordinateOffsetDrawAuth * height)); + drawSingleString(g, "W", (int) (xCoordinateAuthLockLeft + coeffXCoordinateOffsetDrawAuth * authLockWidth / 2), + (int) (yCoordinateAuthLockBottom - coeffYCoordinateOffsetDrawAuth * authLockHeight / 2)); if (checkStrongAuthStatus == 3) { - g.drawLine((int)(x + width + space_port_authlock), y + height, (int)(x + width + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight/2)); - g.drawLine((int)(x + width + space_port_authlock), (int)(y + height - authlockheight/2), (int)(x + width + authlockwidth/2 + space_port_authlock), y + height); + g.drawLine((int) (xCoordinateAuthLockLeft), (int) (yCoordinateAuthLockBottom), + (int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockCenter)); + g.drawLine((int) (xCoordinateAuthLockLeft), (int) (yCoordinateAuthLockCenter), + (int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockBottom)); } if (checkWeakAuthStatus == 3 || checkStrongAuthStatus == 3 && checkWeakAuthStatus < 2) { - g.drawLine((int)(x + width + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight/2), (int)(x + width + authlockwidth + space_port_authlock), (int)(y + height - authlockheight)); - g.drawLine((int)(x + width + authlockwidth/2 + space_port_authlock), (int)(y + height - authlockheight), (int)(x + width + authlockwidth + space_port_authlock), (int)(y + height - authlockheight/2)); + g.drawLine((int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockCenter), + (int) (xCoordinateAuthLockRight), (int) (yCoordinateAuthLockTop)); + g.drawLine((int) (xCoordinateAuthLockCenter), (int) (yCoordinateAuthLockTop), + (int) (xCoordinateAuthLockRight), (int) (yCoordinateAuthLockCenter)); } } public void drawConfVerification(Graphics g) { + final double coeffSpacePortConfLock = 0.1; + final double coeffConfLock = 0.5; + final double coeffConfOval = 0.4; + final double coeffYCoordinateOffsetDrawConf = 1.01; + double spacePortConfLock = width * coeffSpacePortConfLock; + double confLockWidth = width * coeffConfLock; + double confLockHeight = height * coeffConfLock; + double confOvalWidth = width * coeffConfOval; + double confOvalHeight = height * coeffConfOval; + double xCoordinateConfLockLeft = x - confLockWidth - spacePortConfLock; + double xCoordinateConfLockRight = x - spacePortConfLock; + double yCoordinateConfLockTop = y + height - confLockHeight; + double yCoordinateConfLockBottom = y + height; + double xCoordinateConfOvalLeft = xCoordinateConfLockRight - (confOvalWidth/2) - (confLockWidth/2); + double yCoordinateConfOvalTop = yCoordinateConfLockTop - confOvalHeight/2; + Color c = g.getColor(); Color c1; switch (checkConfStatus) { @@ -442,20 +477,19 @@ default: return; } - double space_port_conflock = width * 0.1; - double conflockwidth = width * 0.5; - double conflockheight = height * 0.5; - double confovalwidth = width * 0.4; - double confovalheight = height * 0.4; - drawSingleString(g, mappingName, (int)(x - conflockwidth - space_port_conflock), (int)(y + height + 1.01*conflockheight)); - g.drawOval((int)(x - (confovalwidth/2) - (conflockwidth/2) - space_port_conflock), (int)(y + conflockheight - confovalheight/2), (int)confovalwidth, (int)confovalheight); + + drawSingleString(g, mappingName, (int) (xCoordinateConfLockLeft), + (int) (yCoordinateConfLockBottom + coeffYCoordinateOffsetDrawConf * confLockHeight)); + g.drawOval((int) (xCoordinateConfOvalLeft), (int) (yCoordinateConfOvalTop), (int)confOvalWidth, (int)confOvalHeight); g.setColor(c1); - g.fillRect((int)(x - conflockwidth - space_port_conflock), (int)(y + conflockheight), (int)conflockwidth, (int)conflockheight); + g.fillRect((int) (xCoordinateConfLockLeft), (int) (yCoordinateConfLockTop), (int)confLockWidth, (int)confLockHeight); g.setColor(c); - g.drawRect((int)(x - conflockwidth - space_port_conflock), (int)(y + conflockheight), (int)conflockwidth, (int)conflockheight); + g.drawRect((int) (xCoordinateConfLockLeft), (int) (yCoordinateConfLockTop), (int)confLockWidth, (int)confLockHeight); if (checkConfStatus == 3) { - g.drawLine((int)(x - conflockwidth - space_port_conflock), (int)(y + conflockheight), (int)(x - space_port_conflock), y + height); - g.drawLine((int)(x - space_port_conflock), (int)(y + conflockheight), (int)(x - conflockwidth - space_port_conflock), y + height); + g.drawLine((int) (xCoordinateConfLockLeft), (int) (yCoordinateConfLockTop), + (int) (xCoordinateConfLockRight), (int) (yCoordinateConfLockBottom)); + g.drawLine((int) (xCoordinateConfLockRight), (int) (yCoordinateConfLockTop), + (int) (xCoordinateConfLockLeft), (int) (yCoordinateConfLockBottom)); } if (!secName.equals("")) { @@ -472,12 +506,13 @@ default: return; } - drawSingleString(g, mappingName, (int)(x - conflockwidth - space_port_conflock), (int)(y + height + 1.01*conflockheight)); - g.drawOval((int)(x - (confovalwidth/2) - (conflockwidth/2) - space_port_conflock), (int)(y + conflockheight - confovalheight/2), (int)confovalwidth, (int)confovalheight); + drawSingleString(g, mappingName, (int) (xCoordinateConfLockLeft), + (int) (yCoordinateConfLockBottom + coeffYCoordinateOffsetDrawConf * confLockHeight)); + g.drawOval((int) (xCoordinateConfOvalLeft), (int) (yCoordinateConfOvalTop), (int)confOvalWidth, (int)confOvalHeight); g.setColor(c1); - g.fillRect((int)(x - conflockwidth - space_port_conflock), (int)(y + conflockheight), (int)conflockwidth, (int)conflockheight); + g.fillRect((int) (xCoordinateConfLockLeft), (int) (yCoordinateConfLockTop), (int)confLockWidth, (int)confLockHeight); g.setColor(c); - g.drawRect((int)(x - conflockwidth - space_port_conflock), (int)(y + conflockheight), (int)conflockwidth, (int)conflockheight); + g.drawRect((int) (xCoordinateConfLockLeft), (int) (yCoordinateConfLockTop), (int)confLockWidth, (int)confLockHeight); } } -- GitLab