diff --git a/src/main/java/ui/TGCOneLineText.java b/src/main/java/ui/TGCOneLineText.java index deccf35e869e419652348fab0fa3b2fc0218cb31..139455f925449af994e918509b1e55da92373db5 100644 --- a/src/main/java/ui/TGCOneLineText.java +++ b/src/main/java/ui/TGCOneLineText.java @@ -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/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/TGComponent.java b/src/main/java/ui/TGComponent.java index bbb7b5cc97c34fb64723c4a9212ecead693762eb..ed1477d146b3a5323f87b73a316bc79d48f66985 100644 --- a/src/main/java/ui/TGComponent.java +++ b/src/main/java/ui/TGComponent.java @@ -241,7 +241,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); @@ -1038,6 +1038,14 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem return 10; } + /** + * Issue #31 + * @return + */ + protected int getUnknownMargin() { + return 2; + } + /** * Issue #31 * @return @@ -1076,7 +1084,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem 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 .. @@ -2343,6 +2351,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/TGConnectingPoint.java b/src/main/java/ui/TGConnectingPoint.java index 1ac1d98c38896be8c6410853863030f12c7cd896..96631aa785ce095b9c5a79527600f141130f1b68 100644 --- a/src/main/java/ui/TGConnectingPoint.java +++ b/src/main/java/ui/TGConnectingPoint.java @@ -116,6 +116,22 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* 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(); @@ -183,16 +199,16 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* public int getX() { if (container != null) { - return x + container.getX(); + return scaledX() + container.getX(); } - return x; + return scaledX(); } public int getY() { if (container != null) { - return y + container.getY(); + return scaledY() + container.getY(); } - return y; + return scaledY(); } public int getId() { 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..aadf74709f52a8aa7bcaaed80aa651bba488219d 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; @@ -59,12 +59,12 @@ public class TGConnectingPointWidthHeight extends TGConnectingPoint{ @Override public int getX() { - return x + container.getX() + (int)(container.getWidth() * w); + return scaledX() + container.getX() + (int)(container.getWidth() * w ); } @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 index c16d6028ed1094257d32bdb84f0340db22d30e99..1866c66e2ec2ffe4cc358edd986f6a8a99f3c65c 100644 --- a/src/main/java/ui/TGConnector.java +++ b/src/main/java/ui/TGConnector.java @@ -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/TGScalableComponent.java b/src/main/java/ui/TGScalableComponent.java index f3ac3cee6b5b21fce5af8df30fef8be4e2ce35ff..b5c7a0bc43599af120d5518a2d477e7cf883440a 100644 --- a/src/main/java/ui/TGScalableComponent.java +++ b/src/main/java/ui/TGScalableComponent.java @@ -1,5 +1,10 @@ package ui; +import java.awt.Graphics; +import java.awt.Image; + +import javax.swing.ImageIcon; + /** * Issue #31 * @author dblouin @@ -21,7 +26,9 @@ public abstract class TGScalableComponent extends TGComponent implements Scalabl protected double darc; protected int lineLength; + protected double dLineLength; protected int linebreak; + protected double dLinebreak; public TGScalableComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { @@ -90,8 +97,13 @@ public abstract class TGScalableComponent extends TGComponent implements Scalabl arc = (int)(darc); darc = darc - arc; - lineLength = scale( lineLength ); - linebreak = scale( linebreak ); + dLineLength = lineLength * oldScaleFactor; + lineLength = (int) dLineLength; + dLineLength = dLineLength - lineLength; + + dLinebreak = linebreak * oldScaleFactor; + linebreak = (int) dLinebreak; + dLinebreak = dLinebreak - linebreak; dMaxWidth = defMaxWidth * oldScaleFactor; dMaxHeight = defMaxHeight * oldScaleFactor; @@ -157,8 +169,13 @@ public abstract class TGScalableComponent extends TGComponent implements Scalabl arc = (int) (darc); darc = darc - arc; - lineLength = scale( lineLength, factor ); - linebreak = scale( linebreak, factor ); + 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; @@ -215,4 +232,39 @@ public abstract class TGScalableComponent extends TGComponent implements Scalabl 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 ); + } + + protected int checkWidth( final Graphics graphics, + final String text ) { + // Issue #31: This is just to increase the width in case the actual width is not enough to display the text. + // It is typically used when a component is created + 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; + } + + protected Image scale( final Image image ) { + return new ImageIcon( image.getScaledInstance( width, - 1, Image.SCALE_SMOOTH ) ).getImage(); + } } diff --git a/src/main/java/ui/ad/TADActionState.java b/src/main/java/ui/ad/TADActionState.java index 5a70a7780f8b00784ceb0141a56c1dae1cb1c2b6..3b9d2c9f715c07f0e8228a47690ebe828d1d7dc4 100755 --- a/src/main/java/ui/ad/TADActionState.java +++ b/src/main/java/ui/ad/TADActionState.java @@ -53,7 +53,7 @@ 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 lineLength = 5; // Issue #31 // protected int textX = 5; @@ -66,16 +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); + // Issue #31 + // Must be created before the dimensions are scaled for zoom + createConnectingPoints(); // width = 30; // height = 20; - minWidth = 30; - - // Issue #31 - textX = 5; initSize( 30, 20 ); - createConnectingPoints(); + 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); @@ -102,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 c8510cfb26d5ec66fd90d3dbbd72af712eede360..810a5650a6d1d86d7982651e365aec959ae7fe5d 100755 --- a/src/main/java/ui/ad/TADChoice.java +++ b/src/main/java/ui/ad/TADChoice.java @@ -64,10 +64,11 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit //protected int lineLength = 10; - protected int lineOutLength = 25; + protected static final int OUT_LINE_LENGTH = 25; + protected static final int MARGIN = 5; // Issue # 31 private int textX1, textY1, textX2, textY2, textX3, textY3; - private double dtextX1, dtextY1, dtextX2, dtextY2, dtextX3, dtextY3; + //private double dtextX1, dtextY1, dtextX2, dtextY2, dtextX3, dtextY3; protected int stateOfError = 0; @@ -75,32 +76,24 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // Issue #31 + createConnectingPoints(); + // width = 30; // height = 30; initSize( 30, 30 ); - 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 ); - - 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(); - 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"); @@ -125,56 +118,46 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit myImageIcon = IconManager.imgic208; } - // Issue #31 - @Override - public void rescale( final double scaleFactor ) { - super.rescale( scaleFactor ); - - final double factor = scaleFactor / oldScaleFactor; - - lineOutLength = (int) (lineOutLength * factor); - - dtextX1 = dtextX1 * factor; - dtextY1 = dtextY1 * factor; - dtextX2 = dtextX2 * factor; - dtextY2 = dtextY2 * factor; - dtextX3 = dtextX3 * factor; - dtextY3 = dtextY3 * factor; - } - protected void 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); + 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() { // Issue #31 - TGCOneLineText tgc = new TGCOneLineText((int)(x+dtextX1), (int)(y+dtextY1), (int)(dtextX1-50), (int)(dtextX1+5), (int)dtextY1, (int)(dtextY1 + 25), true, this, tdp); + 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; // Issue #31 - tgc = new TGCOneLineText((int)(x+dtextX2), (int)(y+dtextY2), (int)dtextX2, (int)(dtextX2+20), (int)dtextY2, (int)(dtextY2+25), true, this, tdp); + 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; // Issue #31 - tgc = new TGCOneLineText((int)(x+dtextX3), (int)(y+dtextY3), (int)dtextX3, (int)(dtextX3+20), (int)dtextY3, (int)(dtextY3+25), true, this, tdp); + 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) { @@ -196,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); @@ -208,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/TADExec.java b/src/main/java/ui/ad/TADExec.java new file mode 100755 index 0000000000000000000000000000000000000000..f32da418259a3e3fda2e74d4cd8d0845b165f4b3 --- /dev/null +++ b/src/main/java/ui/ad/TADExec.java @@ -0,0 +1,176 @@ +/* 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; + +/** + * Class TMLADExecC + * Fixed custom duration operator. To be used in TML activity diagrams + * Creation: 21/05/2008 + * @version 1.0 21/05/2008 + * @author Ludovic APVRILLE + */ +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); + + initSize( 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 5aa82583e08865634736c38df7398c210275b03a..2cae989cda78f777adef4a85ca9aa52b62f01195 100644 --- a/src/main/java/ui/ad/TADForLoop.java +++ b/src/main/java/ui/ad/TADForLoop.java @@ -46,6 +46,7 @@ public abstract class TADForLoop extends TADComponentWithoutSubcomponents implem super( _x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp ); // Issue #31 + createConnectingPoints(); // width = 30; // height = 20; initSize( 30, 20 ); @@ -59,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/TADSequence.java b/src/main/java/ui/ad/TADSequence.java index ffc07b425e5c9d41fc4adcaf62b41399b014fbd6..5984f6cbbfd0c9c0bd355150cf48fee2be1973ee 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; + initSize( 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 34bd24858e2474245ed3a8d987fd840046d9a4de..bc395cf45e927682592e3c6c7a220daf5dc15af0 100755 --- a/src/main/java/ui/ad/TADStartState.java +++ b/src/main/java/ui/ad/TADStartState.java @@ -54,21 +54,17 @@ 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); + // Issue #3& + createConnectingPoints(); // width = 15; // height = 15; - initSize( 15, 15 ); - createConnectingPoints(); -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); - nbInternalTGComponent = 0; moveable = true; @@ -87,11 +83,11 @@ public class TADStartState extends TADComponentWithoutSubcomponents/* Issue #69 } @Override - public void internalDrawing(Graphics g) { + 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)); + 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..d65bb70999ddaa4872f1e4f58eaae49cce1a28a8 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; + initSize( 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/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/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 ee16cbd88d9ed986eadb8672f9344a69d9c50e12..596730f17b17d7bd5460d91b2a318144ecd7d52d 100755 --- a/src/main/java/ui/tmlad/TMLADActionState.java +++ b/src/main/java/ui/tmlad/TMLADActionState.java @@ -104,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); diff --git a/src/main/java/ui/tmlad/TMLADChoice.java b/src/main/java/ui/tmlad/TMLADChoice.java index 0c4ae73f4dccdd0067486a504d0234d879722577..24e43bad657e45a43223d216a27b8a73c8e986eb 100755 --- a/src/main/java/ui/tmlad/TMLADChoice.java +++ b/src/main/java/ui/tmlad/TMLADChoice.java @@ -119,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 164c453224253a34281fa49fc359bb8ddc3014a8..98823bd797c94b6b0db54c5b2307525a53dc3488 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 @@ -66,9 +78,12 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T // 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 @@ -76,18 +91,15 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // 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 + MARGIN, false, true, 0.5, 1.0); // width = 15; // height = 35; // textX = width + 5; // textY = height/2 + 5; initSize( 15, 35 ); - lineLength1 = scale( 2 ); - - 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); - moveable = true; editable = true; @@ -99,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) { @@ -111,30 +125,26 @@ 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) - scale( lineLength1 ), y + (height - ilength) / 2, x + (width / 2) - scale( 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.drawImage( scale( IconManager.imgic7000.getImage() ), x - scale( 22 ), y + height / 2, null ); + g.drawString("sec:" + securityContext, x + 3 * width / 2, y + height / 2); } @@ -145,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); @@ -190,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 ac53aafa69671e3bbc3e014eb111026c08f8583b..81792152eea62371e8ff56360a673c938033499b 100755 --- a/src/main/java/ui/tmlad/TMLADDelay.java +++ b/src/main/java/ui/tmlad/TMLADDelay.java @@ -67,6 +67,10 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // 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; initSize( 10, 30 ); @@ -74,11 +78,6 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi 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]; @@ -101,7 +100,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 eb32d497d3fca53fa57b834ff8cf661e01728790..10093a223040cd243d7c3b50780a38f53c59b15f 100755 --- a/src/main/java/ui/tmlad/TMLADDelayInterval.java +++ b/src/main/java/ui/tmlad/TMLADDelayInterval.java @@ -60,8 +60,10 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # //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 @@ -69,6 +71,10 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // 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; initSize( 10, 30 ); @@ -76,11 +82,6 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # 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]; @@ -103,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) { @@ -121,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 e13e2f52fe2f7bc209ed28fd2b1c66b9fb722ab2..116d64be4046bae1a9c7def1d2dc3c03eb8c63d4 100755 --- a/src/main/java/ui/tmlad/TMLADEncrypt.java +++ b/src/main/java/ui/tmlad/TMLADEncrypt.java @@ -65,12 +65,16 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T // Issue #31 // private int lineLength = 5; // private int textX, textY; - private int ex = 5; - private int textHeight = 8; - - // Issue #31 - private double dlength = 12; - private double dlineLength1 = 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 = ""; @@ -88,18 +92,16 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // 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 + MARGIN, false, true, 0.5, 1.0); // width = 15; // height = 35; // textX = width + 5; // textY = height/2 + 5; initSize( 15, 35 ); - 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); - - moveable = true; editable = true; removable = true; @@ -110,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) { @@ -122,82 +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 ilength = (int) dlength; - final int lineLength1 = (int) dlineLength1; + 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")) { //H - 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); + 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); + + 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); + g.drawString("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); + g.drawString("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]); @@ -321,15 +332,4 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T public void setStateAction(int _stateAction) { stateOfError = _stateAction; } - - // Issue #31 - @Override - public void rescale( final double scaleFactor ) { - super.rescale(scaleFactor); - - final double factor = scaleFactor / oldScaleFactor; - - dlength = dlength * factor; - dlineLength1 = dlineLength1 * factor; - } } diff --git a/src/main/java/ui/tmlad/TMLADForEverLoop.java b/src/main/java/ui/tmlad/TMLADForEverLoop.java index 50face4fe2978140c595d929d28d098ce96608b8..feaf4dfaf1410b209d558add85898ed8c61b8082 100755 --- a/src/main/java/ui/tmlad/TMLADForEverLoop.java +++ b/src/main/java/ui/tmlad/TMLADForEverLoop.java @@ -76,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; @@ -93,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(); @@ -118,7 +128,7 @@ 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); } diff --git a/src/main/java/ui/tmlad/TMLADForLoop.java b/src/main/java/ui/tmlad/TMLADForLoop.java index d7fbb038fbe406f6da365dd278bed74e774d2058..f203e4ac6c7deda78cb640aeb7c04608afbf4a35 100755 --- a/src/main/java/ui/tmlad/TMLADForLoop.java +++ b/src/main/java/ui/tmlad/TMLADForLoop.java @@ -95,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; @@ -113,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(); diff --git a/src/main/java/ui/tmlad/TMLADForStaticLoop.java b/src/main/java/ui/tmlad/TMLADForStaticLoop.java index 64fa69a662799871205d01e40321581a7f857a25..049a75720b892adddfcc3c18ae62a9c22cb62b93 100755 --- a/src/main/java/ui/tmlad/TMLADForStaticLoop.java +++ b/src/main/java/ui/tmlad/TMLADForStaticLoop.java @@ -74,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; @@ -91,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(); diff --git a/src/main/java/ui/tmlad/TMLADNotifiedEvent.java b/src/main/java/ui/tmlad/TMLADNotifiedEvent.java index 8f47eb9bcbed2aa703b7919427541c5aa81fbeed..1cf6bab6c98855d24c503da5545254802298e581 100755 --- a/src/main/java/ui/tmlad/TMLADNotifiedEvent.java +++ b/src/main/java/ui/tmlad/TMLADNotifiedEvent.java @@ -65,8 +65,8 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue // protected int textX = 5; // protected int textY = 15; //protected int linebreak = 10; - private int textX1; - private double dtextX1; +// private int textX1; +// private double dtextX1; protected String eventName = "evt"; @@ -78,17 +78,14 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // Issue #31 -// width = 30; -// height = 20; - initSize( 30, 20 ); - minWidth = 30; - textX1 = scale( 2 ); - dtextX1 = textX1 * oldScaleFactor; - 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; + initSize( 30, 20 ); + minWidth = 30; moveable = true; editable = true; @@ -101,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(); @@ -151,7 +149,7 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue 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); + g.drawString(value, x + linebreak + scale( 2 ), y + textY); } @Override @@ -271,22 +269,8 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue return TGComponentManager.CONNECTOR_TMLAD; } + @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } - - /* Issue #31 - * (non-Javadoc) - * @see ui.TGScalableComponent#rescale(double) - */ - @Override - public void rescale( final double scaleFactor ) { - super.rescale(scaleFactor); - - final double factor = scaleFactor / oldScaleFactor; - - dtextX1 = (textX1 + dtextX1) * factor; - textX1 = (int) (dtextX1); - dtextX1 = dtextX1 - textX1; - } } diff --git a/src/main/java/ui/tmlad/TMLADRandom.java b/src/main/java/ui/tmlad/TMLADRandom.java index 9570c9fc4e7d1bc35d57100ff1a70f322b816cfc..a8bf86a50c5ebd2a3352f70d526c9516bc3e3379 100755 --- a/src/main/java/ui/tmlad/TMLADRandom.java +++ b/src/main/java/ui/tmlad/TMLADRandom.java @@ -77,15 +77,14 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // Issue #31 -// width = 30; -// height = 20; - initSize( 30, 20 ); - minWidth = scale( 30 ); - 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; + initSize( 30, 20 ); + minWidth = scale( 30 ); moveable = true; editable = true; @@ -104,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(); diff --git a/src/main/java/ui/tmlad/TMLADReadChannel.java b/src/main/java/ui/tmlad/TMLADReadChannel.java index 31daa378cf8d63c3efec13f82c920c88e0803c8c..834794115d08a5853917ff0afbfd437255ef4550 100755 --- a/src/main/java/ui/tmlad/TMLADReadChannel.java +++ b/src/main/java/ui/tmlad/TMLADReadChannel.java @@ -88,7 +88,7 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # protected int textX0 = 2; //protected int textY0 = 0; protected int textY1 = 15; - protected int linebreak = 10; + // protected int linebreak = 10; protected int decSec = 4; @@ -116,17 +116,16 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // 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; initSize( 30, 20 ); minWidth = scale( 30 ); textY = 0; - 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); - moveable = true; editable = true; removable = true; @@ -148,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(); diff --git a/src/main/java/ui/tmlad/TMLADReadRequestArg.java b/src/main/java/ui/tmlad/TMLADReadRequestArg.java index ff1dcc8af2d6d9adb1d5d0a5d59ecfeeff3e4927..6cd3ec97e891daa4eb621c9f21cf7ad5ea599c63 100755 --- a/src/main/java/ui/tmlad/TMLADReadRequestArg.java +++ b/src/main/java/ui/tmlad/TMLADReadRequestArg.java @@ -72,19 +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); - // 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 initSize( 30, 20 ); - 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 for(int i=0; i<nParam; i++) { params[i] = ""; @@ -102,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) { @@ -157,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) { diff --git a/src/main/java/ui/tmlad/TMLADSelectEvt.java b/src/main/java/ui/tmlad/TMLADSelectEvt.java index ad68fa193dbed9c2ad7275ebedd6f6cb4d75ee1a..6fb4423a22a010bf6adb3a91ce889d3e0ba8c575 100755 --- a/src/main/java/ui/tmlad/TMLADSelectEvt.java +++ b/src/main/java/ui/tmlad/TMLADSelectEvt.java @@ -58,8 +58,9 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 // Issue #31 // private int lineLength = 10; //private int textX1, textY1, textX2, textY2, textX3, textY3; +// private int lineOutLength;// = 25; - private int lineOutLength;// = 25; + protected static final int OUT_LINE_LENGTH = 25; protected int stateOfError = 0; // Not yet checked @@ -67,29 +68,27 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); // 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; initSize( 30, 30 ); - lineOutLength = scale( 25 ); /*textX1 = -lineOutLength; textY1 = height/2 - 5; textX2 = width + 5; textY2 = height/2 - 5; 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; @@ -101,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) { @@ -124,15 +123,14 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 g.drawLine(x + width, y + height/2, x + width/2, y + height); // Issue #31 - final int scaledLineOutLength = scale( lineOutLength ); + 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-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+ scale( 7 ), y + height/2 + scale( 3 ) ); // Issue #31 + g.drawString("evt", x + scale( 5 ), y + height/2 + scale( 3 ) ); // Issue #31 } @Override @@ -142,7 +140,7 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 } // Issue #31 - final int scaledLineOutLength = scale( lineOutLength ); + 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; diff --git a/src/main/java/ui/tmlad/TMLADSendEvent.java b/src/main/java/ui/tmlad/TMLADSendEvent.java index a3189d2d00d1f1a5bf3012ff0b050b502984aca4..bc2eea46787613e447614ebbd8b7fd293f3e17c0 100755 --- a/src/main/java/ui/tmlad/TMLADSendEvent.java +++ b/src/main/java/ui/tmlad/TMLADSendEvent.java @@ -99,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; + initSize( 30, 20 ); + minWidth = scale( 30 ); for (int i = 0; i < nParam; i++) { params[i] = ""; @@ -119,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) { @@ -242,8 +244,8 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements } } - value += ")"; + value += ")"; } public String getEventName() { @@ -255,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 3cfd8099190cb7381b14426446c83d58e9b0a0e5..6d6a7ce147545afd51ade9728313a9d80e6377eb 100755 --- a/src/main/java/ui/tmlad/TMLADSendRequest.java +++ b/src/main/java/ui/tmlad/TMLADSendRequest.java @@ -68,8 +68,8 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # // protected int lineLength = 5; // protected int textX = 5; // protected int textY = 15; - protected int arc = 5; - protected int linebreak = 10; +// protected int arc = 5; +// protected int linebreak = 10; protected String requestName = "req"; int nParam = 5; @@ -86,17 +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 - textX = 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 = 30; +// height = 20; + initSize( 30, 20 ); + minWidth = scale( 30 ); + + // Issue #31 + //textX = 5; for(int i=0; i<nParam; i++) { params[i] = ""; @@ -114,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: @@ -145,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); @@ -218,8 +227,8 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # } } - value += ")"; + value += ")"; } public String getRequestName() { diff --git a/src/main/java/ui/tmlad/TMLADWaitEvent.java b/src/main/java/ui/tmlad/TMLADWaitEvent.java index 217c619fb9421a297daee43a05f68f8327a083e8..6903cb719f7463c1c240f2f4f824d3508d19cfd7 100755 --- a/src/main/java/ui/tmlad/TMLADWaitEvent.java +++ b/src/main/java/ui/tmlad/TMLADWaitEvent.java @@ -68,8 +68,8 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 // protected int lineLength = 5; // protected int textX = 5; // protected int textY = 15; - protected int linebreak = 10; - protected int textX1 = 2; + // protected int linebreak = 10; + //protected int textX1 = 2; protected String eventName = "evt"; int nParam = 5; @@ -86,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; + initSize( 30, 20 ); + minWidth = scale( 30 ); for(int i=0; i<nParam; i++) { params[i] = ""; @@ -111,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) { @@ -166,7 +169,7 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 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); + g.drawString(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 86231f8e4af87c1cee8cc95a885d9778af3ef280..968b39aa95fb6977b5272596f7b61acd7db04608 100755 --- a/src/main/java/ui/tmlad/TMLADWriteChannel.java +++ b/src/main/java/ui/tmlad/TMLADWriteChannel.java @@ -87,8 +87,8 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue // protected int textX = 5; // protected int textY = 15; // protected int arc = 5; - protected int linebreak = 10; - protected int decSec = 4; +// protected int linebreak = 10; + //protected int decSec = 4; private Map<String, String> latencyVals; @@ -115,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; + initSize( 30, 20 ); + minWidth = scale( 30 ); moveable = true; editable = true; @@ -141,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) { @@ -199,7 +201,7 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue if (!isEncForm){ g.setColor(Color.RED); } - g.drawString("sec:" + securityContext, x + 3 * width / 4, y + height + textY - decSec); + g.drawString("sec:" + securityContext, x + 3 * width / 4, y + height + textY - scale( 4 ) ); g.setColor(c); } @@ -211,6 +213,7 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue drawLatencyInformation(g); } } + drawReachabilityInformation(g); } @@ -226,13 +229,12 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue } } - 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/tmlcd/TMLOperationBox.java b/src/main/java/ui/tmlcd/TMLOperationBox.java index 8f157b7dcefee9a4d549e220ca0751e94ed08f0c..130e870804f697400dea7a3c8d49457a090607a5 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,7 +83,8 @@ 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); @@ -96,6 +94,7 @@ public class TMLOperationBox extends TGCWithoutInternalComponent { } } + @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/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..53a89272c23af136071da91a9810fa84734b8626 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,7 +106,16 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp } @Override - public void internalDrawing(Graphics g) { + 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) { final int textWidth = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, textWidth + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) {