Skip to content
Snippets Groups Projects
Commit 0725100a authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Adding icons in the FT diagram

parent de11c9fc
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@
<property name="caretWidth" class="java.lang.Integer" />
</properties>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
/* 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,14 +31,12 @@
* 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.ftd;
import myutil.GraphicLib;
......@@ -51,19 +49,25 @@ import ui.window.JDialogConstraintText;
import javax.swing.*;
import java.awt.*;
import myutil.*;;
/**
* Class FTDConstraint
* Constraint of SysML Parametric diagrams, adapted to fault trees
* Creation: 14/12/2017
* @version 1.0 14/12/2017
* @author Ludovic APVRILLE
* Class FTDConstraint
* Constraint of SysML Parametric diagrams, adapted to fault trees
* Creation: 14/12/2017
*
* @author Ludovic APVRILLE
* @version 1.0 14/12/2017
*/
public class FTDConstraint extends TGCScalableWithInternalComponent implements SwallowedTGComponent, ConstraintListInterface {
public class FTDConstraint extends TGCScalableWithInternalComponent implements SwallowedTGComponent, ConstraintListInterface {
private int textY1 = 5;
//private int textY2 = 30;
public static final String[] STEREOTYPES = {"<<OR>>", "<<XOR>>", "<<AND>>", "<<NOT>>", "<<SEQUENCE>>", "<<AFTER>>", "<<BEFORE>>", "<<VOTE>>"};
public static final String[] STEREOTYPES = {"<<OR>>", "<<XOR>>", "<<AND>>", "<<NOT>>", "<<SEQUENCE>>", "<<AFTER>>",
"<<BEFORE>>", "<<VOTE>>"};
public static final Image[] ICONS = {IconManager.img1400, IconManager.img1400, IconManager.img1400,
IconManager.img1408, IconManager.img1402, IconManager.img1404
, IconManager.img1406, IconManager.img1400};
protected String oldValue = "";
......@@ -71,17 +75,19 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
private static int minFontSize = 4;
private int currentFontSize = -1;
private boolean displayText = true;
// private int textX = 1;
// private int textX = 1;
private static int arc = 7;
private int index;
private String equation;
public FTDConstraint(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
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 = (int) (150 * tdp.getZoom());
height = (int) (50 * tdp.getZoom());
minWidth = 100;
nbConnectingPoint = 12;
......@@ -106,6 +112,7 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
removable = true;
value = "<<OR>>";
index = 0;
equation = "";
currentFontSize = -1;
......@@ -117,7 +124,7 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
public void internalDrawing(Graphics g) {
Font f = g.getFont();
// Font fold = f;
// Font fold = f;
if (currentFontSize == -1) {
currentFontSize = f.getSize();
......@@ -127,9 +134,9 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
rescaled = false;
float scale = (float)(f.getSize()*tdp.getZoom());
float scale = (float) (f.getSize() * tdp.getZoom());
scale = Math.min(maxFontSize, scale);
currentFontSize = (int)scale;
currentFontSize = (int) scale;
displayText = !(scale < minFontSize);
}
......@@ -145,25 +152,33 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
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);
}
Font f0 = g.getFont();
if (displayText) {
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()));
g.setFont(f0.deriveFont(f0.getSize()-2).deriveFont(Font.ITALIC));
w = g.getFontMetrics().stringWidth(equation);
int w = g.getFontMetrics().stringWidth(value);
g.drawString(value, x + (width - w) / 2, y + currentFontSize + (int) (textY1 * tdp.getZoom()));
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()));
w = g.getFontMetrics().stringWidth("...");
g.drawString("...", x + (width - w) / 2, y + (2 * currentFontSize) + (int) (textY1 * tdp.getZoom()));
} else {
g.drawString(equation, x + (width - w)/2, y + (2*currentFontSize) + (int)(textY1*tdp.getZoom()));
g.drawString(equation, x + (width - w) / 2, y + (2 * currentFontSize) + (int) (textY1 * tdp.getZoom()));
}
g.setFont(f0);
}
}
/* public void setValue(String val, Graphics g) {
oldValue = value;
int w = g.getFontMetrics().stringWidth(value);
......@@ -178,16 +193,14 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
}*/
public boolean editOndoubleClick(JFrame frame) {
// String tmp;
// boolean error = false;
JDialogConstraintText dialog = new JDialogConstraintText(frame, "Setting constraint attributes", this, equation, "Equation");
// dialog.setSize(450, 350);
// dialog.setSize(450, 350);
GraphicLib.centerOnParent(dialog, 450, 350);
dialog.setVisible( true ); // blocked until dialog has been closed
dialog.setVisible(true); // blocked until dialog has been closed
if (!dialog.isRegularClose()) {
return false;
......@@ -199,6 +212,7 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
if (dialog.getStereotype().length() > 0) {
value = dialog.getStereotype();
index = dialog.getSelectedIndex();
}
equation = dialog.getText();
......@@ -233,62 +247,67 @@ public class FTDConstraint extends TGCScalableWithInternalComponent implements
}
public boolean isOR() {
return (value.compareTo(STEREOTYPES[0]) == 0);
return (value.compareTo(STEREOTYPES[0]) == 0);
}
public boolean isXOR() {
return (value.compareTo(STEREOTYPES[1]) == 0);
return (value.compareTo(STEREOTYPES[1]) == 0);
}
public boolean isAND() {
return (value.compareTo(STEREOTYPES[2]) == 0);
return (value.compareTo(STEREOTYPES[2]) == 0);
}
public boolean isSequence() {
return (value.compareTo(STEREOTYPES[3]) == 0);
return (value.compareTo(STEREOTYPES[3]) == 0);
}
public boolean isBefore() {
return (value.compareTo(STEREOTYPES[4]) == 0);
return (value.compareTo(STEREOTYPES[4]) == 0);
}
public boolean isAfter() {
return (value.compareTo(STEREOTYPES[5]) == 0);
return (value.compareTo(STEREOTYPES[5]) == 0);
}
protected String translateExtraParam() {
StringBuffer sb = new StringBuffer("<extraparam>\n");
sb.append("<info equation=\"" + GTURTLEModeling.transformString(getEquation()));
sb.append("\" index=\"" + GTURTLEModeling.transformString("" + index));
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 {
//System.out.println("*** load extra synchro ***");
try {
NodeList nli;
Node n1, n2;
Element elt;
String tmp;
// int t1id;
// String sdescription = null;
// String prio;
// String isRoot = null;
for(int i=0; i<nl.getLength(); i++) {
for (int i = 0; i < nl.getLength(); i++) {
n1 = nl.item(i);
//System.out.println(n1);
if (n1.getNodeType() == Node.ELEMENT_NODE) {
nli = n1.getChildNodes();
for(int j=0; j<nli.getLength(); j++) {
for (int j = 0; j < nli.getLength(); j++) {
n2 = nli.item(j);
//System.out.println(n2);
if (n2.getNodeType() == Node.ELEMENT_NODE) {
elt = (Element) n2;
if (elt.getTagName().equals("info")) {
equation = elt.getAttribute("equation");
tmp = elt.getAttribute("index");
//TraceManager.addDev("index=" + tmp);
index = Integer.decode(tmp).intValue();
}
}
}
......
......@@ -119,6 +119,10 @@ public class IconManager {
public static ImageIcon imgic1070, imgic1072, imgic1074, imgic1076, imgic1078;
public static ImageIcon imgic1080, imgic1082, imgic1084;
// Fault Tree Diagrams
public static ImageIcon imgic1400, imgic1402, imgic1404, imgic1406, imgic1408;
public static Image img1400, img1402, img1404, img1406, img1408;
// TMLDD
public static ImageIcon imgic1100, imgic1102, imgic1104, imgic1106, imgic1108;
public static ImageIcon imgic1110, imgic1112, imgic1114, imgic1116, imgic1118;
......@@ -487,6 +491,13 @@ public class IconManager {
private static String icon1082 = "atdcountermeasure.gif";
private static String icon1084 = "atdcountermeasureconnector.gif";
// Fault trees
private static String icon1400 = "AndFT.png";
private static String icon1402 = "SequenceFT.png";
private static String icon1404 = "AfterFT.png";
private static String icon1406 = "BeforeFT.png";
private static String icon1408 = "NotFT.png";
// DIPLODOCUS architecture
private static String icon1100 = "tmlcpunode.gif";
private static String icon1102 = "tmlbusnode.gif";
......@@ -624,9 +635,12 @@ public class IconManager {
//Attacker Scenarios
private static String icon7008 = "attacker.gif";
private static String icon7009 = "uppaal.gif";
//
public IconManager() {
......@@ -921,6 +935,26 @@ public class IconManager {
imgic1082 = getIcon(icon1082);
imgic1084 = getIcon(icon1084);
imgic1400 = getIcon(icon1400);
if (imgic1400 != null) {
img1400 = imgic1400.getImage();
}
imgic1402 = getIcon(icon1402);
if (imgic1402 != null) {
img1402 = imgic1402.getImage();
}
imgic1404 = getIcon(icon1404);
if (imgic1404 != null) {
img1404 = imgic1404.getImage();
}
imgic1408 = getIcon(icon1408);
if (imgic1408 != null) {
img1408 = imgic1408.getImage();
}
imgic1406 = getIcon(icon1406);
if (imgic1406 != null) {
img1406 = imgic1406.getImage();
}
imgic1100 = getIcon(icon1100);
imgic1102 = getIcon(icon1102);
imgic1104 = getIcon(icon1104);
......
......@@ -171,6 +171,10 @@ public class JDialogConstraintText extends JDialogBase implements ActionListener
return (String)(stereotype.getSelectedItem());
}
public int getSelectedIndex() {
return stereotype.getSelectedIndex();
}
public String getText() {
return textEdition.getText();
......
src/main/resources/ui/util/AfterFT.png

4.17 KiB

src/main/resources/ui/util/AndFT.png

3.77 KiB

src/main/resources/ui/util/BeforeFT.png

4.2 KiB

src/main/resources/ui/util/NotFT.png

4.14 KiB

src/main/resources/ui/util/SequenceFT.png

4.03 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment