diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java index 6c9b90c2de90b789c22a24ff17a4e177cd5ed011..6fe3ec9b74ad63bfe2e80aa486cddfd99cac2d93 100644 --- a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java @@ -53,14 +53,16 @@ import java.awt.event.ActionListener; import java.awt.geom.RoundRectangle2D; /** - * Class ELNComponentCurrentSourceTDF - * Current source driven by a TDF input signal signal to be used in ELN diagrams - * Creation: 19/07/2018 + * Class ELNComponentCurrentSourceTDF Current source driven by a TDF input + * signal signal to be used in ELN diagrams Creation: 19/07/2018 + * * @version 1.0 19/07/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { +public class ELNComponentCurrentSourceTDF extends + TGCScalableWithInternalComponent implements ActionListener, + SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -74,11 +76,14 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone private double scale; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, + fh_1_3 = false; private int old; private boolean first; - public ELNComponentCurrentSourceTDF(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentCurrentSourceTDF(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); initScaling(100, 100); @@ -110,9 +115,12 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); - connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "inp"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "n"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "inp"); } public Color getMyColor() { @@ -126,7 +134,10 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max( + 0, + Math.min(this.height, + (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -162,7 +173,7 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); - int sw2 = g.getFontMetrics().stringWidth("outp"); + int sw2 = g.getFontMetrics().stringWidth("inp"); int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); @@ -178,18 +189,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { rotateTop(g); - ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, - y + height + height / 20 + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -197,18 +212,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true) || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true)) { rotateBottomFlip(g); - ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, - y + height + height / 20 + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -216,18 +235,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true) || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false)) { rotateTopFlip(g); - ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, - y + height + height / 20 + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -235,18 +258,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true)) { rotateBottom(g); - ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, - y + height + height / 20 + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); } } } else if (position == 1) { @@ -278,16 +305,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { rotateRight(g); ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, - y + height + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 16 - sw1, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 16, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -296,17 +328,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true)) { rotateRightFlip(g); ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, - y + height + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, - y + height + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 20 - sw1, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -315,16 +351,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false)) { rotateLeftFlip(g); ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, - y + height + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -333,17 +374,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true)) { rotateLeft(g); ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, - y + height + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, - y + height + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); } } } else if (position == 2) { @@ -359,7 +404,7 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); - int sw2 = g.getFontMetrics().stringWidth("outp"); + int sw2 = g.getFontMetrics().stringWidth("inp"); int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); @@ -375,18 +420,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { rotateBottom(g); - ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, - y + height + height / 20 + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -394,18 +443,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true) || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true)) { rotateTopFlip(g); - ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, - y + height + height / 20 + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -413,18 +466,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true) || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false)) { rotateBottomFlip(g); - ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, - y + height + height / 20 + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -432,18 +489,22 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true)) { rotateTop(g); - ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); ((ELNPortTerminal) connectingPoint[2]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, - y + height + height / 20 + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, - y + height / 2 + height / 5 + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); } } } else if (position == 3) { @@ -475,17 +536,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { rotateLeft(g); ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, - y + height + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, - y + height + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -494,16 +559,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true)) { rotateLeftFlip(g); ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, - y + height + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -512,17 +582,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false)) { rotateRightFlip(g); ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, - y + height + sh1); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, - y + height + sh0); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 20 - sw1, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -531,16 +605,21 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true)) { rotateRight(g); ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); - ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); - ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); ((ELNPortTerminal) connectingPoint[2]).setW(0.5); - ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); - g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); - g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, - y + height + sh2); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 16 - sw1, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 16, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); } } } @@ -550,237 +629,345 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone private void rotateTop(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x, x + 2 * width / 5, x + 2 * width / 5 }; - int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, - y + height - height / 20, y + height / 20 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + 2 * width / 5 - width / 20, x + 2 * width / 5, x + 2 * width / 5 + width / 20 }; - int[] pty1 = { y + height / 2, y + height / 2 + height / 20, y + height / 2 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, + y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width, x + 3 * width / 5, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, + y + 4 * height / 5 - height / 10, y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + 2 * width / 5, y + height / 2 - height / 5, width / 5 + + width / 5, height / 5 + height / 5); + g.drawLine(x + 2 * width / 5, y + height / 2, x + 4 * width / 5, y + + height / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 + width / 10, y + + height / 5 + height / 10, x + 4 * width / 5 + width / 10, y + + 4 * height / 5 - height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5, y + height / 2, x + + 2 * width / 5, y + height / 2, true); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 * width / 5 + width / 10 - width / 20, - height + height / 10, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); g2d.dispose(); - g.drawOval(x, y, width / 10, height / 10); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y, width / 10, height / 10); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(c); - g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(c); } private void rotateTopFlip(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x, x + 2 * width / 5, x + 2 * width / 5 }; - int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, - y + height - height / 20, y + height / 20 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + 2 * width / 5 - width / 20, x + 2 * width / 5, x + 2 * width / 5 + width / 20 }; - int[] pty1 = { y + height / 2, y + height / 2 - height / 20, y + height / 2 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, + y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width, x + 3 * width / 5, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, + y + 4 * height / 5 - height / 10, y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + 2 * width / 5, y + height / 2 - height / 5, width / 5 + + width / 5, height / 5 + height / 5); + g.drawLine(x + 2 * width / 5, y + height / 2, x + 4 * width / 5, y + + height / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 + width / 10, y + + 4 * height / 5 - height / 10, x + 4 * width / 5 + width / 10, + y + height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5, y + height / 2, x + + 2 * width / 5, y + height / 2, true); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 * width / 5 + width / 10 - width / 20, - height + height / 10, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); g2d.dispose(); - g.drawOval(x, y, width / 10, height / 10); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y, width / 10, height / 10); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(c); - g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(c); } private void rotateBottom(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + width, x + 3 * width / 5, - x + 3 * width / 5 }; - int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, - y + height - height / 20, y + height / 20 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + 3 * width / 5 - width / 20, x + 3 * width / 5, x + 3 * width / 5 + width / 20 }; - int[] pty1 = { y + height / 2, y + height / 2 - height / 20, y + height / 2 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, + x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, + y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x, x + 2 * width / 5, x + 2 * width / 5, + x + 2 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, + y + 4 * height / 5 - height / 10, y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 5, y + height / 2 - height / 5, width / 5 + + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 5, y + height / 2, x + 3 * width / 5, y + height + / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 10, y + 4 * height + / 5 - height / 10, x + width / 10, + y + height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5, + y + height / 2, x + 3 * width / 5, y + height / 2, true); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 * width / 5 + width / 10 - width / 20, - height + height / 10, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); g2d.dispose(); - g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.fillOval(x, y, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); } private void rotateBottomFlip(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + width, x + 3 * width / 5, - x + 3 * width / 5 }; - int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, - y + height - height / 20, y + height / 20 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + 3 * width / 5 - width / 20, x + 3 * width / 5, x + 3 * width / 5 + width / 20 }; - int[] pty1 = { y + height / 2, y + height / 2 + height / 20, y + height / 2 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, + x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, + y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x, x + 2 * width / 5, x + 2 * width / 5, + x + 2 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, + y + 4 * height / 5 - height / 10, y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 5, y + height / 2 - height / 5, width / 5 + + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 5, y + height / 2, x + 3 * width / 5, y + height + / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 10, y + height / 5 + + height / 10, x + width / 10, + y + 4 * height / 5 - height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5, + y + height / 2, x + 3 * width / 5, y + height / 2, true); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 * width / 5 + width / 10 - width / 20, - height + height / 10, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); g2d.dispose(); - g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.fillOval(x, y, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); } private void rotateRight(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, - x + width - width / 20, x + width / 20 }; - int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y, y + 2 * height / 5, y + 2 * height / 5 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + width / 2, x + width / 2 - width / 20, x + width / 2 }; - int[] pty1 = { y + 2 * height / 5 - height / 20, y + 2 * height / 5, y + 2 * height / 5 + height / 20 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + int[] ptx0 = { x + width / 20, x + width / 20, + x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, + x + 4 * width / 5 - width / 10, x + width - width / 20 }; + int[] pty1 = { y + height, y + 3 * height / 5, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + 2 * height / 5, width / 5 + + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + 2 * height / 5, x + width / 2, y + 4 + * height / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 - width / 10, y + + 4 * height / 5 + height / 10, x + width / 5 + width / 10, y + + 4 * height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + height / 5, x + + width / 2, y + 2 * height / 5, true); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, - 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); g2d.dispose(); - g.drawOval(x, y, width / 10, height / 10); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y, width / 10, height / 10); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(c); } private void rotateRightFlip(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, - x + width - width / 20, x + width / 20 }; - int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + height, y + 3 * height / 5, - y + 3 * height / 5 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + width / 2, x + width / 2 - width / 20, x + width / 2 }; - int[] pty1 = { y + 3 * height / 5 - height / 20, y + 3 * height / 5, y + 3 * height / 5 + height / 20 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + int[] ptx0 = { x + width / 20, x + width / 20, + x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, + y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, + x + 4 * width / 5 - width / 10, x + width - width / 20 }; + int[] pty1 = { y, y + 2 * height / 5, y + 2 * height / 5, + y + 2 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + height / 5, width / 5 + width + / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + height / 5, x + width / 2, y + 3 * height + / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 - width / 10, y + + height / 10, x + width / 5 + width / 10, y + height / 10, + true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, + y + 4 * height / 5, x + width / 2, y + 3 * height / 5, true); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, width + width / 10, - 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); g2d.dispose(); - g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.fillOval(x, y, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(c); } private void rotateLeft(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, - x + width - width / 20, x + width / 20 }; - int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + height, y + 3 * height / 5, - y + 3 * height / 5 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + width / 2, x + width / 2 + width / 20, x + width / 2 }; - int[] pty1 = { y + 3 * height / 5 - height / 20, y + 3 * height / 5, y + 3 * height / 5 + height / 20 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + int[] ptx0 = { x + width / 20, x + width / 20, + x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, + y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, + x + 4 * width / 5 - width / 10, x + width - width / 20 }; + int[] pty1 = { y, y + 2 * height / 5, y + 2 * height / 5, + y + 2 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + height / 5, width / 5 + width + / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + height / 5, x + width / 2, y + 3 * height + / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5 + width / 10, y + + height / 10, x + 4 * width / 5 - width / 10, y + height / 10, + true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, + y + 4 * height / 5, x + width / 2, y + 3 * height / 5, true); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, width + width / 10, - 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); g2d.dispose(); - g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.fillOval(x, y, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); g.setColor(c); } private void rotateLeftFlip(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, - x + width - width / 20, x + width / 20 }; - int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y, y + 2 * height / 5, y + 2 * height / 5 }; - g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + width / 2, x + width / 2 + width / 20, x + width / 2 }; - int[] pty1 = { y + 2 * height / 5 - height / 20, y + 2 * height / 5, y + 2 * height / 5 + height / 20 }; - g.drawPolygon(ptx1, pty1, 3); - g.fillPolygon(ptx1, pty1, 3); - g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + int[] ptx0 = { x + width / 20, x + width / 20, + x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, + x + 4 * width / 5 - width / 10, x + width - width / 20 }; + int[] pty1 = { y + height, y + 3 * height / 5, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + 2 * height / 5, width / 5 + + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + 2 * height / 5, x + width / 2, y + 4 + * height / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5 + width / 10, y + 4 + * height / 5 + height / 10, x + 4 * width / 5 - width / 10, y + + 4 * height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + height / 5, x + + width / 2, y + 2 * height / 5, true); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); Graphics2D g2d = (Graphics2D) g.create(); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g2d.setStroke(dashed); - g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, - 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); g2d.dispose(); - g.drawOval(x, y, width / 10, height / 10); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x, y, width / 10, height / 10); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); g.setColor(c); } @@ -796,7 +983,8 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone } public boolean editOndoubleClick(JFrame frame) { - JDialogELNComponentCurrentSourceTDF jde = new JDialogELNComponentCurrentSourceTDF(this); + JDialogELNComponentCurrentSourceTDF jde = new JDialogELNComponentCurrentSourceTDF( + this); jde.setVisible(true); return true; } @@ -815,7 +1003,8 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) + throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -834,13 +1023,20 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - scale = Double.parseDouble(elt.getAttribute("scale")); - position = Integer.parseInt(elt.getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt.getAttribute("first")); + scale = Double.parseDouble(elt + .getAttribute("scale")); + position = Integer.parseInt(elt + .getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt + .getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt + .getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt + .getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt + .getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt + .getAttribute("first")); setScale(scale); setPosition(position); setFv_0_2(fv_0_2); @@ -858,7 +1054,8 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone } } - public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, + ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -989,7 +1186,8 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, + father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -1002,6 +1200,7 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), + tdp.getMaxY()); } } \ No newline at end of file