diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 0027a10eaa90158db5014162f321743f203e5458..58e6f162155dbc79ee6578aebea267585e2281db 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -5170,6 +5170,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } + // TMLCP public boolean createTMLCPSequenceDiagram(int index, String s) { @@ -6630,6 +6631,20 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } } + public boolean selectMainTab(String id) { + TURTLEPanel tp; + + for(int i=0; i<tabs.size(); i++) { + tp = (TURTLEPanel)(tabs.elementAt(i)); + if (getTabName(tp).compareTo(id) == 0) { + selectTab(tp); + return true; + } + } + + return false; + } + public void selectTab(TURTLEPanel tp) { int index1 = tabs.indexOf(tp); mainTabbedPane.setSelectedIndex(index1); diff --git a/src/ui/TGCScalableWithoutInternalComponent.java b/src/ui/TGCScalableWithoutInternalComponent.java new file mode 100755 index 0000000000000000000000000000000000000000..8178d2b5172f522b401264c7394b024433b3a086 --- /dev/null +++ b/src/ui/TGCScalableWithoutInternalComponent.java @@ -0,0 +1,125 @@ +/**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. + +/** + * Class TGCScalableWithoutInternalComponent + * Graphical component that contains no internal components, and which is scalable + * Creation: 14/04/2014 + * @version 1.0 14/04/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui; + +//import java.awt.*; + +public abstract class TGCScalableWithoutInternalComponent extends TGCWithoutInternalComponent implements ScalableTGComponent { + 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); + } + + public void rescale(double scaleFactor){ + rescaled = true; + + dwidth = (width + dwidth) / oldScaleFactor * scaleFactor; + dheight = (height + dheight) / oldScaleFactor * scaleFactor; + dx = (dx + x) / oldScaleFactor * scaleFactor; + dy = (dy + y) / oldScaleFactor * scaleFactor; + dMaxWidth = (maxWidth + dMaxWidth) / oldScaleFactor * scaleFactor; + dMaxHeight = (maxWidth + dMaxWidth) / oldScaleFactor * scaleFactor; + + width = (int)(dwidth); + dwidth = dwidth - width; + height = (int)(dheight); + dheight = dheight - height; + maxWidth = (int)(dMaxWidth); + maxHeight = (int)(dMaxHeight); + dMaxWidth = dMaxWidth - maxWidth; + dMaxHeight = dMaxHeight - maxHeight; + x = (int)(dx); + dx = dx - x; + y = (int)(dy); + dy = dy - y; + + oldScaleFactor = scaleFactor; + + if (father != null) { + // Must rescale my zone... + resizeWithFather(); + + } + + } + + public 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 = (int)defMaxWidth; + maxHeight = (int)defMaxHeight; + + dMaxWidth = dMaxWidth - maxWidth; + dMaxHeight = dMaxHeight - maxHeight; + + rescaled = true; + } + +} + + + + + + + diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java index 1e8bc4c1db82638bf7680e205e6bce05ce1af4a0..65a5faafe7339ccb651a80a63800dd27a94d79e1 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java @@ -54,24 +54,26 @@ import javax.swing.*; import ui.*; import myutil.*; -public class DiplodocusMethodologyDiagramName extends TGCWithoutInternalComponent implements SwallowedTGComponent { +public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternalComponent implements SwallowedTGComponent { //protected boolean emptyText; - protected int minSim = -1; - protected int maxSim = -1; - protected final static String Sim = "sim"; + public final static int X_MARGIN = 5; + public final static int Y_MARGIN = 3; - protected int minUpp = -1; - protected int maxUpp = -1; - protected final static String Upp = "ipp"; - protected int minLot = -1; - protected int maxLot = -1; - protected final static String Lot = "lot"; - - protected int minTml = -1; - protected int maxTml = -1; - protected final static String Tml = "tml"; + protected final static String SIM = "sim"; + protected final static String UPP = "ipp"; + protected final static String LOT = "lot"; + protected final static String TML = "tml"; + + protected String[] validations; + protected int[] valMinX; + protected int[] valMaxX; + + protected int indexOnMe; // -1 -> on main element. -2: on not precise element; Other: on a validations item. + + private int myWidth, myHeight, widthAppli; + 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); @@ -86,32 +88,163 @@ public class DiplodocusMethodologyDiagramName extends TGCWithoutInternalComponen name = "value "; + + + initScaling(10, 10); + + myImageIcon = IconManager.imgic302; } public void internalDrawing(Graphics g) { - if (!tdp.isScaled()) { - width = g.getFontMetrics().stringWidth(value); - height = g.getFontMetrics().getHeight(); + boolean onMe = false; + + if (tdp.componentPointed() == this) { + onMe = true; + } + + if ((y+Y_MARGIN) > (getFather().getY()+getFather().getHeight())) { + return; + } + + //TraceManager.addDev("Internal drawing ..."); + int currentMaxX; + 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)) { + val = "."; } + widthAppli = g.getFontMetrics().stringWidth(val); + + Font f = g.getFont(); + + if (onMe && indexOnMe == -1) { + g.setFont(f.deriveFont(Font.BOLD)); + } + g.drawString(val, x, y); + g.setFont(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]; + } + + /*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); + return; + } + //TraceManager.addDev("Tracing validation Validation size=" + validations.length); + oneWritten = false; - g.drawString(value, x, y); - if (value.equals("")) { - g.drawString("value?", x, y); + 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]); + w1 = g.getFontMetrics().stringWidth(validations[i]); + + if ((currentMaxX - w1) > (x + w)) { + if ((onMe && indexOnMe == i)) { + g.setFont(f.deriveFont(Font.BOLD)); + } + g.drawString(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 { + break; + } + + } + } + + + + g.setFont(f); + + if (oneWritten) { + makeScale(g, saveCurrentMaxX - x); + } else { + makeScale(g, w); + } + + if (onMe) + g.drawRect(x-2, y-12, myWidth+4, 15); + + return; + + + } + + private void makeScale(Graphics g, int _size) { + if (!tdp.isScaled()) { + myWidth = _size; + myHeight = g.getFontMetrics().getHeight(); } } + public TGComponent isOnMe(int _x, int _y) { - if (GraphicLib.isInRectangle(_x, _y, x, y - height, Math.max(width, minWidth), height)) { + int oldIndex = indexOnMe; + if (GraphicLib.isInRectangle(_x, _y, x, y - height, Math.max(myWidth, minWidth), myHeight)) { + indexOnMe = -2; + + if (_x <= (x+widthAppli)) { + indexOnMe = -1; + } + if ((validations != null) && (validations.length > 0)) { + for(int i=0; i<validations.length; i++) { + if ((_x >= valMinX[i]) && (_x <= valMaxX[i])) { + indexOnMe = i; + //TraceManager.addDev("Index on " + indexOnMe); + break; + } + } + } + + if (oldIndex != indexOnMe) { + tdp.repaint(); + } + + return this; } return null; } public boolean editOndoubleClick(JFrame frame) { - + DiplodocusMethodologyDiagramReference ref = ((DiplodocusMethodologyDiagramReference)(getFather())); + + if (indexOnMe == -1) { + // Opening the diagram + if (!tdp.getMGUI().selectMainTab(value)) { + TraceManager.addDev("Diagram removed?"); + } + + } return false; } @@ -124,4 +257,24 @@ public class DiplodocusMethodologyDiagramName extends TGCWithoutInternalComponen public int getDefaultConnector() { return TGComponentManager.DIPLODOCUSMETHODOLOGY_CONNECTOR; } + + public void setValidationsNumber(int size) { + validations = new String[size]; + } + + public void setValidationsInfo(int index, String s) { + validations[index] = s; + } + + 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/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java index 56dae45005252459de6d8c6648c4327dc06ac27c..f5244cdfa6d33514e534a9cfd3041622672866b0 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReference.java @@ -421,11 +421,13 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW // We then add the ones that are newly selected int index; index = 0; - int tmpy; + int tmpx, tmpy; for(String s: selected) { if (!hasDiplodocusMethodologyDiagramName(s)) { - tmpy = y + 40 + (index * 15); - dn = new DiplodocusMethodologyDiagramName(x + 10, tmpy, x + 10, x+10, tmpy, tmpy, true, this, getTDiagramPanel()); + tmpy = (int)(y + (40*tdp.getZoom()) + (index * 15 *tdp.getZoom())); + tmpx = (int)(DiplodocusMethodologyDiagramName.X_MARGIN*tdp.getZoom()); + dn = new DiplodocusMethodologyDiagramName(x+tmpx, tmpy, x+tmpx, x+tmpx, tmpy, tmpy, true, this, getTDiagramPanel()); + //makeValidationInfos(dn); dn.setValue(s); addInternalComponent(dn, index); @@ -434,6 +436,8 @@ public abstract class DiplodocusMethodologyDiagramReference extends TGCScalableW } } + public abstract void makeValidationInfos(DiplodocusMethodologyDiagramName dn); + public boolean hasDiplodocusMethodologyDiagramName(String s) { for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i].getValue().compareTo(s) == 0) { diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java index 3ba92bc8e511653b0adb6540dc06743d958d3cb6..da306bf79a023db3bece34a4841fd5496f8372cf 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java @@ -89,6 +89,16 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc return false; } + public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { + dn.setValidationsNumber(4); + dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM); + dn.setValidationsInfo(1, DiplodocusMethodologyDiagramName.LOT); + dn.setValidationsInfo(2, DiplodocusMethodologyDiagramName.UPP); + dn.setValidationsInfo(3, DiplodocusMethodologyDiagramName.TML); + } + + + } diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java index e65a110bfc0a21199d8af26adc104778bca846f2..14157f54312f355885128b589fe6adbaecac9abf 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToArchitecture.java @@ -90,6 +90,10 @@ public class DiplodocusMethodologyDiagramReferenceToArchitecture extends Diplodo return false; } + public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { + dn.setValidationsNumber(0); + } + } diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java index 858c50f9f5881b8ef484592829836e6be0990641..ac1147648a67f685e07d2bd0d00fe63e8b49ce09 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java @@ -90,6 +90,12 @@ public class DiplodocusMethodologyDiagramReferenceToMapping extends DiplodocusMe return false; } + public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { + dn.setValidationsNumber(3); + dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM); + dn.setValidationsInfo(1, DiplodocusMethodologyDiagramName.LOT); + dn.setValidationsInfo(2, DiplodocusMethodologyDiagramName.TML); + } } diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java index 737e7752aa63537826b6b9bdb7232f5a9cf421f9..c443ced64b13e9929c2f96f28e41f4c8207c9519 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToRequirement.java @@ -80,13 +80,16 @@ public class DiplodocusMethodologyDiagramReferenceToRequirement extends Diplodoc return TGComponentManager.DIPLODODUSMETHODOLOGY_REF_REQUIREMENT; } - public - boolean isAValidPanelType(TURTLEPanel panel) { + public boolean isAValidPanelType(TURTLEPanel panel) { if (panel instanceof AvatarRequirementPanel) { return true; } return false; } + + public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { + dn.setValidationsNumber(0); + } }