diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 8f4181f9eed1993a428411c8d25c53c3e313b542..1a2e69cff236c785c2270d8805fd883221b50638 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -3553,6 +3553,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per JFrameBasicText fbt = new JFrameBasicText("SysML V2 - " + getCurrentTDiagramPanel().getName(), data); fbt.setSize(800, 800); fbt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + GraphicLib.centerFrame(fbt, frame); fbt.setVisible(true); TraceManager.addDev("Frame shown"); } @@ -3588,7 +3589,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per JFrameBasicText fbt = new JFrameBasicText("Textual format - " + getCurrentTDiagramPanel().getName(), data); fbt.setSize(800, 800); fbt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - + GraphicLib.centerFrame(fbt, frame); fbt.setVisible(true); TraceManager.addDev("Frame shown"); } diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index 831dd8a59a44c805fa4d4130c0252af56e413af4..6f405c98785259ce96fbebac984ba92ce654d656 100644 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -108,6 +108,7 @@ import java.util.*; public abstract class TDiagramPanel extends JPanel implements GenericTree { protected final static String CR = "\n"; + protected final static String CSV_SEP = ","; protected TDiagramMouseManager tdmm; protected PanelKeyListener pkl; diff --git a/src/main/java/ui/atd/AttackTreeDiagramPanel.java b/src/main/java/ui/atd/AttackTreeDiagramPanel.java index 8e94a378231d5a2102d285afe66b7c84d97426c1..323bf128b2c166a645279e09f069570a159db38f 100644 --- a/src/main/java/ui/atd/AttackTreeDiagramPanel.java +++ b/src/main/java/ui/atd/AttackTreeDiagramPanel.java @@ -618,6 +618,8 @@ public class AttackTreeDiagramPanel extends TDiagramPanel implements TDPWithAttr public String getStats() { + double synCorrect = 0.0; + StringBuffer sb = new StringBuffer(); sb.append(CR + "# General stats" + CR); @@ -634,15 +636,18 @@ public class AttackTreeDiagramPanel extends TDiagramPanel implements TDPWithAttr sb.append("- Tree has " + getNbOfRootAttacks() + " root attacks -> ERROR " + CR + CR); } + double tva = 0.0; HashMap<ATDAttack, ArrayList<Boolean>> mapOfSyntaxForAttacks = computeSyntaxRulesForAttacks(); for(ATDAttack attack: mapOfSyntaxForAttacks.keySet()) { sb.append("- Attack " + attack.getAttackName()); int nbOfTrue = 0; ArrayList<Boolean> list = mapOfSyntaxForAttacks.get(attack); String notRespected = ""; + double not = list.size(); for(int i=0; i<list.size(); i++) { if (list.get(i)) { nbOfTrue++; } else { notRespected += " " + (i+1); + not --; } } if (nbOfTrue == syntaxRulesOfAttacks.length) { @@ -650,9 +655,11 @@ public class AttackTreeDiagramPanel extends TDiagramPanel implements TDPWithAttr } else { sb.append(" does NOT respect rules: " + notRespected.trim() + ". ERROR" + CR); } + tva += not / list.size(); } sb.append(CR); + double tvo = 0.0; HashMap<ATDConstraint, ArrayList<Boolean>> mapOfSyntaxForConstraints = computeSyntaxRulesForOperators(); for(ATDConstraint constraint: mapOfSyntaxForConstraints.keySet()) { String name = constraint.getValue(); @@ -664,9 +671,11 @@ public class AttackTreeDiagramPanel extends TDiagramPanel implements TDPWithAttr int nbOfTrue = 0; ArrayList<Boolean> list = mapOfSyntaxForConstraints.get(constraint); String notRespected = ""; + double not = list.size(); for(int i=0; i<list.size(); i++) { if (list.get(i)) { nbOfTrue++; } else { notRespected += " " + (i+1); + not --; } } if (nbOfTrue == syntaxRulesOfOperators.length) { @@ -674,8 +683,21 @@ public class AttackTreeDiagramPanel extends TDiagramPanel implements TDPWithAttr } else { sb.append(" does NOT respect rules: " + notRespected.trim() + ". ERROR" + CR); } + tvo += not / list.size(); + } + sb.append(CR + "# Summary of syntaxic correctness: " + CR); + sb.append("- tva = " + tva + CR); + sb.append("- tvo = " + tvo + CR); + synCorrect = ((tva + tvo)/getComplexity()); + sb.append("- syntaxic correctness = " + synCorrect + CR); + + + sb.append(CR + "# CSV line" + CR + getName() + CSV_SEP + getComplexity() + CSV_SEP + "?" + CSV_SEP + "?" + CSV_SEP + + + "?" + CSV_SEP + "?" + CSV_SEP + "?" + CSV_SEP + "?" + CSV_SEP + synCorrect + CR); + sb.append(CR + CR + CR + "# Definition of Metrics" + CR + CR); sb.append(CR + "## Semantic correctness: (ra + ro) / complexity" + CR); @@ -686,9 +708,11 @@ public class AttackTreeDiagramPanel extends TDiagramPanel implements TDPWithAttr sb.append("- ma: number of attack nodes that should have been in the attack tree but were absent" + CR); sb.append("- mo: number of operator nodes that should have been in the attack tree but were absent" + CR); - sb.append(CR + "## Syntaxic correctness = (Tva + Tvo) / complexity " + CR); - sb.append("- Tva: the sum of for each attack node, the number of respected syntax rules divided by the total number of attack node syntax rules" + CR); - sb.append("- Tvo: the sum of for each operator node, the number of respected syntax rules divided by the total number of operator node syntax rules" + CR); + sb.append(CR + "## Syntaxic correctness = (tva + tvo) / complexity " + CR); + sb.append("- tva: the sum of for each attack node, the number of respected syntax rules divided by the total number of attack node syntax " + + "rules" + CR); + sb.append("- tvo: the sum of for each operator node, the number of respected syntax rules divided by the total number of operator node " + + "syntax rules" + CR); sb.append(CR + "## Syntax rules of attack trees" + CR); for(int i=0; i<syntaxRulesOfAttackTree.length; i++) {