From 4194c966eaf6fb57cfe2d9ff450e17ec73308358 Mon Sep 17 00:00:00 2001 From: Lee <irina.lee@etu.upmc.fr> Date: Mon, 16 Jul 2018 10:29:43 +0200 Subject: [PATCH] added port terminal as connecting point in component (eln) --- .../ui/eln/sca_eln/ELNComponentCapacitor.java | 347 ++++----- .../sca_eln/ELNComponentIdealTransformer.java | 624 ++++++++-------- .../ELNComponentIndependentCurrentSource.java | 401 +++++----- .../ELNComponentIndependentVoltageSource.java | 393 +++++----- .../ui/eln/sca_eln/ELNComponentInductor.java | 367 +++++----- .../ui/eln/sca_eln/ELNComponentNodeRef.java | 20 +- .../ui/eln/sca_eln/ELNComponentResistor.java | 352 ++++----- .../sca_eln/ELNComponentTransmissionLine.java | 614 +++++++--------- ...mponentVoltageControlledCurrentSource.java | 688 ++++++++--------- ...mponentVoltageControlledVoltageSource.java | 689 +++++++++--------- 10 files changed, 2203 insertions(+), 2292 deletions(-) diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java index 53ca177560..a0739e3b9a 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentCapacitor extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentCapacitor extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -75,12 +76,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - - public ELNComponentCapacitor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentCapacitor(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, 40); @@ -92,6 +91,8 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl minWidth = 1; minHeight = 1; + initPortTerminal(2); + addTGConnectingPointsComment(); moveable = true; @@ -104,6 +105,17 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl setQ0(0.0); setUnit0("F"); setUnit1("C"); + + old = width; + width = height; + height = old; + } + + 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"); } public Color getMyColor() { @@ -111,21 +123,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y + height / 2 - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("p"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y + height / 2 - height / 8, true, false); - term1 = new ELNPortTerminal(x + width - height / 4, y + height / 2 - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("n"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - height / 4, y + height / 2 - height / 8, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -180,53 +177,53 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 8, true); - term1.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 8, true); - term0.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 8, true); - term1.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 8, true); - term0.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } else if (position == 1) { if (first == false) { @@ -252,53 +249,49 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x + width / 2 - width / 8, y, true); - term1.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term1.setMoveCd(x + width / 2 - width / 8, y, true); - term0.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x + width / 2 - width / 8, y, true); - term1.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x + width / 2 - width / 8, y, true); - term0.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } else if (position == 2) { if (first == false) { @@ -326,53 +319,53 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 8, true); - term0.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 8, true); - term1.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 8, true); - term0.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 8, true); - term1.setMoveCd(x + width - height / 4, y + height / 2 - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } else if (position == 3) { if (first == false) { @@ -398,53 +391,49 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x + width / 2 - width / 8, y, true); - term0.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term0.setMoveCd(x + width / 2 - width / 8, y, true); - term1.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x + width / 2 - width / 8, y, true); - term0.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x + width / 2 - width / 8, y, true); - term1.setMoveCd(x + width / 2 - width / 8, y + height - width / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } g.setColor(c); @@ -452,21 +441,39 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl } private void rotateTopBottom(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 }; int[] pty0 = { y + height / 2, y + height / 2, y, y + height, y + height / 2 }; g.drawPolygon(ptx0, pty0, 5); int[] ptx1 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 }; int[] pty1 = { y + height / 2, y + height / 2, y, y + height, y + height / 2 }; g.drawPolygon(ptx1, pty1, 5); + g.drawOval(x, y + height / 2 - height / 8, width / 10, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 8, width / 10, height / 4); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height / 2 - height / 8, width / 10, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height / 2 - height / 8, width / 10, height / 4); + g.setColor(c); } private void rotateRightLeft(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 2, x + width / 2, x, x + width, x + width / 2 }; int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 }; g.drawPolygon(ptx0, pty0, 5); int[] ptx1 = { x + width / 2, x + width / 2, x, x + width, x + width / 2 }; int[] pty1 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 }; g.drawPolygon(ptx1, pty1, 5); + g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 10); + g.setColor(c); + g.drawOval(x + width / 2 - width / 8, y + height - height / 10, width / 4, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y + height - height / 10, width / 4, height / 10); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -512,8 +519,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl sb.append("\" unit1=\""); sb.append(encode(unit1)); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -532,7 +537,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl double value, q0; String unit0, unit1; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -549,8 +554,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl unit0 = elt.getAttribute("unit0"); unit1 = elt.getAttribute("unit1"); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -561,8 +564,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl setUnit0(unit0); setUnit1(unit1); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -729,38 +730,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -769,7 +738,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java b/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java index 90e765b3cf..0c7f689551 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentIdealTransformer extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentIdealTransformer extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -74,14 +75,10 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - private ELNPortTerminal term2; - private ELNPortTerminal term3; - - public ELNComponentIdealTransformer(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentIdealTransformer(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); @@ -93,6 +90,8 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone minWidth = 1; minHeight = 1; + initPortTerminal(4); + addTGConnectingPointsComment(); moveable = true; @@ -102,6 +101,19 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone value = tdp.findELNComponentName("IdealTransformer"); setRatio(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p1"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p2"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n1"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n2"); } public Color getMyColor() { @@ -109,32 +121,6 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("p1"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y, true, false); - - term1 = new ELNPortTerminal(x + width - width / 10, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("p2"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - width / 10, y, true, false); - - term2 = new ELNPortTerminal(x, y + height - height / 10, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term2.setValue("n1"); - getTDiagramPanel().getComponentList().add(term2); - term2.getTDiagramPanel().addComponent(term2, x, y + height - height / 10, true, false); - - term3 = new ELNPortTerminal(x + width - width / 10, y + height - height / 10, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term3.setValue("n2"); - getTDiagramPanel().getComponentList().add(term3); - term3.getTDiagramPanel().addComponent(term3, x + width - width / 10, y + height - height / 10, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -192,88 +178,76 @@ public class ELNComponentIdealTransformer 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); - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 10, y, true); - term2.setMoveCd(x, y + height - height / 10, true); - term3.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateTop(g); - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 10, y, true); - term3.setMoveCd(x, y + height - height / 10, true); - term2.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateBottom(g); - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 10, y, true); - term0.setMoveCd(x, y + height - height / 10, true); - term1.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 10, y, true); - term1.setMoveCd(x, y + height - height / 10, true); - term0.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } } else if (position == 1) { if (first == false) { @@ -304,88 +278,72 @@ public class ELNComponentIdealTransformer 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)) { rotateRight(g); - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 10, y, true); - term3.setMoveCd(x, y + height - height / 10, true); - term1.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateRight(g); - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 10, y, true); - term2.setMoveCd(x, y + height - height / 10, true); - term0.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 10, y, true); - term1.setMoveCd(x, y + height - height / 10, true); - term3.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 10, y, true); - term0.setMoveCd(x, y + height - height / 10, true); - term2.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } } else if (position == 2) { if (first == false) { @@ -416,88 +374,76 @@ public class ELNComponentIdealTransformer 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); - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 10, y, true); - term1.setMoveCd(x, y + height - height / 10, true); - term0.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateBottom(g); - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 10, y, true); - term0.setMoveCd(x, y + height - height / 10, true); - term1.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateTop(g); - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 10, y, true); - term3.setMoveCd(x, y + height - height / 10, true); - term2.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 10, y, true); - term2.setMoveCd(x, y + height - height / 10, true); - term3.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(19.0 / 20.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } } else if (position == 3) { if (first == false) { @@ -528,88 +474,72 @@ public class ELNComponentIdealTransformer 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)) { rotateLeft(g); - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 10, y, true); - term0.setMoveCd(x, y + height - height / 10, true); - term2.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateLeft(g); - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 10, y, true); - term1.setMoveCd(x, y + height - height / 10, true); - term3.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 10, y, true); - term2.setMoveCd(x, y + height - height / 10, true); - term0.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 10, y, true); - term3.setMoveCd(x, y + height - height / 10, true); - term1.setMoveCd(x + width - width / 10, y + height - height / 10, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } } g.setColor(c); @@ -617,6 +547,7 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone } private void rotateTop(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width / 5, x + width / 5, x + width / 5 }; int[] pty0 = { y + height / 20, y + height / 20, y + height / 5, y + height / 20 }; g.drawPolygon(ptx0, pty0, 4); @@ -654,13 +585,29 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone y + 4 * height / 5 + height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); - int w = g.getFontMetrics().stringWidth(Double.toString(ratio)); int h = g.getFontMetrics().getAscent(); g.drawString(Double.toString(ratio), x + (width - w) / 2, y + height + height / 10 + h); + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + 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.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + 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 + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateBottom(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width / 5, x + width / 5, x + width / 5 }; int[] pty0 = { y + height / 20, y + height / 20, y + height / 5, y + height / 20 }; g.drawPolygon(ptx0, pty0, 4); @@ -698,12 +645,28 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone y + height / 5 - height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); - int w = g.getFontMetrics().stringWidth(Double.toString(ratio)); g.drawString(Double.toString(ratio), x + (width - w) / 2, y - height / 20); + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + 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.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + 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 + 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 / 5, x + width / 20 }; int[] pty0 = { y, y + height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx0, pty0, 4); @@ -739,13 +702,29 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone y + height / 5 + height / 10 + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); - int w = g.getFontMetrics().stringWidth(Double.toString(ratio)); int h = g.getFontMetrics().getAscent(); g.drawString(Double.toString(ratio), x - width / 10 - w, y + height / 2 + h / 2); + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + 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.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + 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 + height - height / 10, 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 / 5, x + width / 20 }; int[] pty0 = { y, y + height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx0, pty0, 4); @@ -781,9 +760,24 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone y + height / 5 + height / 10 + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); - int h = g.getFontMetrics().getAscent(); g.drawString(Double.toString(ratio), x + width + width / 10, y + height / 2 + h / 2); + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + 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.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + 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 + height - height / 10, width / 10, height / 10); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -807,8 +801,6 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<attributes ratio=\"" + ratio); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -826,7 +818,7 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone Element elt; double ratio; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -840,8 +832,6 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone if (elt.getTagName().equals("attributes")) { ratio = Double.parseDouble(elt.getAttribute("ratio")); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -849,8 +839,6 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone first = Boolean.parseBoolean(elt.getAttribute("first")); setRatio(ratio); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -993,38 +981,6 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -1033,7 +989,7 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java index 76aaf26191..36d9357436 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentIndependentCurrentSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentIndependentCurrentSource extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -76,12 +77,10 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - - public ELNComponentIndependentCurrentSource(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentIndependentCurrentSource(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(60, 80); @@ -93,6 +92,8 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna minWidth = 1; minHeight = 1; + initPortTerminal(2); + addTGConnectingPointsComment(); moveable = true; @@ -111,6 +112,17 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna setAcAmplitude(0.0); setAcPhase(0.0); setAcNoiseAmplitude(0.0); + + old = width; + width = height; + height = old; + } + + 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"); } public Color getMyColor() { @@ -118,21 +130,6 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("p"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y + height / 2 - height / 4, true, false); - term1 = new ELNPortTerminal(x + width - height / 2, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("n"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - height / 2, y + height / 2 - height / 4, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -184,56 +181,52 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna || (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); - term0.setMoveCd(x + width / 3 - width / 12, y, true); - term1.setMoveCd(x + width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 3 + width / 6, y); - g.drawString(term1.getValue(), x + width / 3 + width / 6, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, + y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term0.setMoveCd(x + 2 * width / 3 - width / 12, y, true); - term1.setMoveCd(x + 2 * width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + 2 * width / 3 + width / 6, y); - g.drawString(term1.getValue(), x + 2 * width / 3 + width / 6, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term1.setMoveCd(x + width / 3 - width / 12, y, true); - term0.setMoveCd(x + width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 3 + width / 6, y); - g.drawString(term0.getValue(), x + width / 3 + width / 6, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term1.setMoveCd(x + 2 * width / 3 - width / 12, y, true); - term0.setMoveCd(x + 2 * width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + 2 * width / 3 + width / 6, y); - g.drawString(term0.getValue(), x + 2 * width / 3 + width / 6, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh0); } } else if (position == 1) { if (first == false) { @@ -260,56 +253,56 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna || (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)) { rotateRight(g); - term1.setMoveCd(x, y + height / 3 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 3 + height / 6 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 3 + height / 6 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 3 + height / 6 + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateRightFlip(g); - term1.setMoveCd(x, y + 2 * height / 3 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + 2 * height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + 2 * height / 3 + height / 6 + sh1); - g.drawString(term0.getValue(), x + width, y + 2 * height / 3 + height / 6 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + 2 * height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y + height / 3 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 3 + height / 6 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 3 + height / 6 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 3 + height / 6 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term0.setMoveCd(x, y + 2 * height / 3 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + 2 * height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + 2 * height / 3 + height / 6 + sh0); - g.drawString(term1.getValue(), x + width, y + 2 * height / 3 + height / 6 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + 2 * height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh1); } } else if (position == 2) { if (first == false) { @@ -334,56 +327,52 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna || (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); - term1.setMoveCd(x + 2 * width / 3 - width / 12, y, true); - term0.setMoveCd(x + 2 * width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + 2 * width / 3 + width / 6, y); - g.drawString(term0.getValue(), x + 2 * width / 3 + width / 6, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term1.setMoveCd(x + width / 3 - width / 12, y, true); - term0.setMoveCd(x + width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 3 + width / 6, y); - g.drawString(term0.getValue(), x + width / 3 + width / 6, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x + 2 * width / 3 - width / 12, y, true); - term1.setMoveCd(x + 2 * width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + 2 * width / 3 + width / 6, y); - g.drawString(term1.getValue(), x + 2 * width / 3 + width / 6, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x + width / 3 - width / 12, y, true); - term1.setMoveCd(x + width / 3 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 3 + width / 6, y); - g.drawString(term1.getValue(), x + width / 3 + width / 6, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, + y + height + sh1); } } else if (position == 3) { if (first == false) { @@ -410,56 +399,56 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna || (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)) { rotateLeft(g); - term0.setMoveCd(x, y + 2 * height / 3 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + 2 * height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + 2 * height / 3 + height / 6 + sh0); - g.drawString(term1.getValue(), x + width, y + 2 * height / 3 + height / 6 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + 2 * height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y + height / 3 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 3 + height / 6 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 3 + height / 6 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 3 + height / 6 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRightFlip(g); - term1.setMoveCd(x, y + 2 * height / 3 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + 2 * height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + 2 * height / 3 + height / 6 + sh1); - g.drawString(term0.getValue(), x + width, y + 2 * height / 3 + height / 6 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(2.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + 2 * height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - term1.setMoveCd(x, y + height / 3 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height / 3 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 3 + height / 6 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 3 + height / 6 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 3.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 3 + height / 6 + sh0); } } g.setColor(c); @@ -467,6 +456,7 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna } private void rotateTop(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 3, x + width / 3 }; int[] pty0 = { y, y + height / 4 }; g.drawPolygon(ptx0, pty0, 2); @@ -484,9 +474,18 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x + width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(c); + g.drawOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(c); } private void rotateTopFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 3, x + width / 3 }; int[] pty0 = { y, y + height / 4 }; g.drawPolygon(ptx0, pty0, 2); @@ -504,9 +503,18 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x + width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(c); + g.drawOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(c); } private void rotateBottom(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + 2 * width / 3, x + 2 * width / 3 }; int[] pty0 = { y, y + height / 4 }; g.drawPolygon(ptx0, pty0, 2); @@ -523,9 +531,18 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x + 2 * width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + 2 * width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(c); + g.drawOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(c); } private void rotateBottomFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + 2 * width / 3, x + 2 * width / 3 }; int[] pty0 = { y, y + height / 4 }; g.drawPolygon(ptx0, pty0, 2); @@ -542,9 +559,18 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x + 2 * width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + 2 * width / 3 - width / 12, y, width / 6, height / 8); + g.setColor(c); + g.drawOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); + g.setColor(c); } private void rotateRight(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width / 4 }; int[] pty0 = { y + height / 3, y + height / 3 }; g.drawPolygon(ptx0, pty0, 2); @@ -562,9 +588,18 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + 2 * height / 3 + height / 6 + height / 12, y + 2 * height / 3 + height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); } private void rotateRightFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width / 4 }; int[] pty0 = { y + 2 * height / 3, y + 2 * height / 3 }; g.drawPolygon(ptx0, pty0, 2); @@ -582,9 +617,18 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + height / 3 - height / 6 + height / 12, y + height / 3 - height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); + g.drawOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); } private void rotateLeft(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width / 4 }; int[] pty0 = { y + 2 * height / 3, y + 2 * height / 3 }; g.drawPolygon(ptx0, pty0, 2); @@ -602,9 +646,18 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + height / 3 - height / 6 + height / 12, y + height / 3 - height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); + g.drawOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); } private void rotateLeftFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width / 4 }; int[] pty0 = { y + height / 3, y + height / 3 }; g.drawPolygon(ptx0, pty0, 2); @@ -622,6 +675,14 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna y + 2 * height / 3 + height / 6 + height / 12, y + 2 * height / 3 + height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); + g.drawOval(x, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -671,8 +732,6 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna sb.append("\" ac_phase=\"" + acPhase); sb.append("\" ac_noise_amplitude=\"" + acNoiseAmplitude); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -692,7 +751,7 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna double initValue, offset, amplitude, frequency, phase, acAmplitude, acPhase, acNoiseAmplitude; String delay; String unit0; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -715,8 +774,6 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna acPhase = Double.parseDouble(elt.getAttribute("ac_phase")); acNoiseAmplitude = Double.parseDouble(elt.getAttribute("ac_noise_amplitude")); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -733,8 +790,6 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna setAcPhase(acPhase); setAcNoiseAmplitude(acNoiseAmplitude); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -949,38 +1004,6 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -989,7 +1012,7 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java index 07c764496d..73a0a72100 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentIndependentVoltageSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentIndependentVoltageSource extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -76,12 +77,10 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - - public ELNComponentIndependentVoltageSource(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentIndependentVoltageSource(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(40, 80); @@ -93,6 +92,8 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna minWidth = 1; minHeight = 1; + initPortTerminal(2); + addTGConnectingPointsComment(); moveable = true; @@ -111,6 +112,17 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna setAcAmplitude(0.0); setAcPhase(0.0); setAcNoiseAmplitude(0.0); + + old = width; + width = height; + height = old; + } + + 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"); } public Color getMyColor() { @@ -118,21 +130,6 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("p"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y + height / 2 - height / 4, true, false); - term1 = new ELNPortTerminal(x + width - height / 2, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("n"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - height / 2, y + height / 2 - height / 4, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -184,56 +181,52 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna || (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); - term0.setMoveCd(x + width / 2 - width / 12, y, true); - term1.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term0.setMoveCd(x + width / 2 - width / 12, y, true); - term1.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term1.setMoveCd(x + width / 2 - width / 12, y, true); - term0.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term1.setMoveCd(x + width / 2 - width / 12, y, true); - term0.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } else if (position == 1) { if (first == false) { @@ -260,56 +253,56 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna || (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)) { rotateRight(g); - term1.setMoveCd(x, y + height / 2 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 4 + sh0); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 4 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateRightFlip(g); - term1.setMoveCd(x, y + height / 2 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 4 + sh0); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 4 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y + height / 2 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw1, y + height / 2 + height / 4 + sh1); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 4 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term0.setMoveCd(x, y + height / 2 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw1, y + height / 2 + height / 4 + sh1); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 4 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } else if (position == 2) { if (first == false) { @@ -334,56 +327,52 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna || (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); - term1.setMoveCd(x + width / 2 - width / 12, y, true); - term0.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term1.setMoveCd(x + width / 2 - width / 12, y, true); - term0.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x + width / 2 - width / 12, y, true); - term1.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x + width / 2 - width / 12, y, true); - term1.setMoveCd(x + width / 2 - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } else if (position == 3) { if (first == false) { @@ -410,56 +399,56 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna || (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)) { rotateLeft(g); - term0.setMoveCd(x, y + height / 2 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw1, y + height / 2 + height / 4 + sh1); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 4 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y + height / 2 - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw1, y + height / 2 + height / 4 + sh1); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 4 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRightFlip(g); - term1.setMoveCd(x, y + height / 2 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 4 + sh0); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 4 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - term1.setMoveCd(x, y + height / 2 - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height / 2 - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw0, y + height / 2 + height / 4 + sh0); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 4 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } g.setColor(c); @@ -467,6 +456,7 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna } private void rotateTop(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -481,9 +471,18 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + 3 * height / 4 + height / 8, y + 3 * height / 4 + height / 8 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, width, height / 2); + g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(c); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(c); } private void rotateTopFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -498,9 +497,18 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + height / 8, y + height / 8 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, width, height / 2); + g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(c); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(c); } private void rotateBottom(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -515,9 +523,18 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + height / 4 - height / 8, y + height / 4 - height / 8 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, width, height / 2); + g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(c); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(c); } private void rotateBottomFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -531,9 +548,18 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + 3 * height / 4 + height / 8, y + 3 * height / 4 + height / 8 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, width, height / 2); + g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); + g.setColor(c); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); + g.setColor(c); } private void rotateRight(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx0, pty0, 2); @@ -547,9 +573,18 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + height / 2 + height / 4, y + height }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, height); + g.drawOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); } private void rotateRightFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx0, pty0, 2); @@ -562,9 +597,18 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + height / 4, y }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, height); + g.drawOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); } private void rotateLeft(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx0, pty0, 2); @@ -578,9 +622,18 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + height / 2 - height / 4, y }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, height); + g.drawOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); } private void rotateLeftFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx0, pty0, 2); @@ -594,6 +647,14 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna int[] pty2 = { y + height / 2 + height / 4, y + height }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, height); + g.drawOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -921,38 +982,6 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -961,7 +990,7 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java index f7358f3cb8..877374bcfe 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java @@ -59,7 +59,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentInductor extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentInductor extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -76,12 +77,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - - public ELNComponentInductor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentInductor(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, 20); @@ -93,6 +92,8 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple minWidth = 1; minHeight = 1; + initPortTerminal(2); + addTGConnectingPointsComment(); moveable = true; @@ -105,6 +106,17 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple setPhi0(0.0); setUnit0("H"); setUnit1("Wb"); + + old = width; + width = height; + height = old; + } + + 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"); } public Color getMyColor() { @@ -112,21 +124,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("p"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y + height / 2 - height / 4, true, false); - term1 = new ELNPortTerminal(x + width - height / 2, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("n"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - height / 2, y + height / 2 - height / 4, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -180,56 +177,56 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple || (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); - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateTop(g); - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateBottom(g); - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } else if (position == 1) { if (first == false) { @@ -254,56 +251,52 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple || (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)) { rotateRight(g); - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateRight(g); - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } else if (position == 2) { if (first == false) { @@ -330,56 +323,56 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple || (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); - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateBottom(g); - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateTop(g); - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } else if (position == 3) { if (first == false) { @@ -404,57 +397,53 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple || (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)) { rotateLeft(g); - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateLeft(g); - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } g.setColor(c); @@ -462,35 +451,71 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple } private void rotateTop(Graphics g) { + Color c = g.getColor(); g.drawLine(x, y + height / 2, x + width / 5, y + height / 2); g.drawLine(x + 4 * width / 5, y + height / 2, x + width, y + height / 2); g.drawArc(x + width / 5, y, width / 5, height, 0, 180); g.drawArc(x + 2 * width / 5, y, width / 5, height, 0, 180); g.drawArc(x + 3 * width / 5, y, width / 5, height, 0, 180); + g.drawOval(x, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(c); } private void rotateBottom(Graphics g) { + Color c = g.getColor(); g.drawLine(x, y + height / 2, x + width / 5, y + height / 2); g.drawLine(x + 4 * width / 5, y + height / 2, x + width, y + height / 2); g.drawArc(x + width / 5, y, width / 5, height, 180, 180); g.drawArc(x + 2 * width / 5, y, width / 5, height, 180, 180); g.drawArc(x + 3 * width / 5, y, width / 5, height, 180, 180); + g.drawOval(x, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(c); } private void rotateRight(Graphics g) { + Color c = g.getColor(); g.drawLine(x + width / 2, y, x + width / 2, y + height / 5); g.drawLine(x + width / 2, y + 4 * height / 5, x + width / 2, y + height); g.drawArc(x, y + height / 5, width, height / 5, 270, 180); g.drawArc(x, y + 2 * height / 5, width, height / 5, 270, 180); g.drawArc(x, y + 3 * height / 5, width, height / 5, 270, 180); + g.drawOval(x + width / 2 - width / 4, y, width / 2, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 4, y, width / 2, height / 10); + g.setColor(c); + g.drawOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); + g.setColor(c); } private void rotateLeft(Graphics g) { + Color c = g.getColor(); g.drawLine(x + width / 2, y, x + width / 2, y + height / 5); g.drawLine(x + width / 2, y + 4 * height / 5, x + width / 2, y + height); g.drawArc(x, y + height / 5, width, height / 5, 90, 180); g.drawArc(x, y + 2 * height / 5, width, height / 5, 90, 180); g.drawArc(x, y + 3 * height / 5, width, height / 5, 90, 180); + g.drawOval(x + width / 2 - width / 4, y, width / 2, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 4, y, width / 2, height / 10); + g.setColor(c); + g.drawOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -536,8 +561,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple sb.append("\" unit1=\""); sb.append(encode(unit1)); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -556,7 +579,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple double value, phi0; String unit0, unit1; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -573,8 +596,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple unit0 = elt.getAttribute("unit0"); unit1 = elt.getAttribute("unit1"); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -585,8 +606,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple setUnit0(unit0); setUnit1(unit1); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -753,38 +772,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -793,7 +780,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java index fb868d0ba4..28a52e8104 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java @@ -60,7 +60,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implements SwallowedTGComponent, ActionListener { +public class ELNComponentNodeRef extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -76,7 +77,8 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem private int old; private boolean first; - public ELNComponentNodeRef(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentNodeRef(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(40, 40); @@ -106,7 +108,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem public void initConnectingPoint(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); + connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.0); } public Color getMyColor() { @@ -389,8 +391,6 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<attributes position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -407,7 +407,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem Node n1, n2; Element elt; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -420,16 +420,12 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem elt = (Element) n2; if (elt.getTagName().equals("attributes")) { position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -563,7 +559,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem public void setFirst(boolean _first) { first = _first; } - + public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -572,7 +568,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java index 757867f637..80ba758d1d 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentResistor extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentResistor extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -75,12 +76,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - - public ELNComponentResistor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentResistor(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, 20); @@ -92,6 +91,8 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple minWidth = 1; minHeight = 1; + initPortTerminal(2); + addTGConnectingPointsComment(); moveable = true; @@ -102,6 +103,17 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple setVal(1.0); setUnit("\u03A9"); + + old = width; + width = height; + height = old; + } + + 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"); } public Color getMyColor() { @@ -109,21 +121,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("p"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y + height / 2 - height / 4, true, false); - term1 = new ELNPortTerminal(x + width - height / 2, y + height / 2 - height / 4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("n"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - height / 2, y + height / 2 - height / 4, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -178,53 +175,53 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } else if (position == 1) { if (first == false) { @@ -250,53 +247,49 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } else if (position == 2) { @@ -325,53 +318,53 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y + height / 2 - height / 4, true); - term0.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - sw1, y + height / 2 + height / 2 + sh1); - g.drawString(term0.getValue(), x + width, y + height / 2 + height / 2 + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y + height / 2 - height / 4, true); - term1.setMoveCd(x + width - height / 2, y + height / 2 - height / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - sw0, y + height / 2 + height / 2 + sh0); - g.drawString(term1.getValue(), x + width, y + height / 2 + height / 2 + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.5); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.5); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } else if (position == 3) { if (first == false) { @@ -397,53 +390,49 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x + width / 2 - width / 4, y, true); - term0.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.0); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y + height + sh0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x + width / 2 - width / 4, y, true); - term1.setMoveCd(x + width / 2 - width / 4, y + height - width / 4, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(1.0); - g.drawString(term0.getValue(), x + width / 2 + width / 2, y); - g.drawString(term1.getValue(), x + width / 2 + width / 2, y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.5); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.5); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } g.setColor(c); @@ -451,19 +440,37 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple } private void rotateTopBottom(Graphics g) { + Color c = g.getColor(); int[] ptx = { x, x + width / 5, x + width / 5, x + 4 * width / 5, x + 4 * width / 5, x + width, x + 4 * width / 5, x + 4 * width / 5, x + width / 5, x + width / 5 }; int[] pty = { y + height / 2, y + height / 2, y, y, y + height / 2, y + height / 2, y + height / 2, y + height, y + height, y + height / 2 }; g.drawPolygon(ptx, pty, 10); + g.drawOval(x, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(Color.WHITE); + g.fillOval(x, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); + g.setColor(c); } private void rotateRightLeft(Graphics g) { + Color c = g.getColor(); int[] ptx = { x + width / 2, x + width / 2, x, x, x + width / 2, x + width / 2, x + width / 2, x + width, x + width, x + width / 2 }; int[] pty = { y, y + height / 5, y + height / 5, y + 4 * height / 5, y + 4 * height / 5, y + height, y + 4 * height / 5, y + 4 * height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx, pty, 10); + g.drawOval(x + width / 2 - width / 4, y, width / 2, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 4, y, width / 2, height / 10); + g.setColor(c); + g.drawOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -509,8 +516,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple sb.append("\" unit=\""); sb.append(encode(unit)); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + Math.max(width, height)); - sb.append("\" height=\"" + Math.min(width, height)); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -529,7 +534,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple double value; String unit; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -544,8 +549,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple value = Double.parseDouble(elt.getAttribute("value")); unit = elt.getAttribute("unit"); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -554,13 +557,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple setVal(value); setUnit(unit); setPosition(position); - if (position == 0 || position == 2) { - this.height = width; - this.width = height; - } else if (position == 1 || position == 3) { - this.width = width; - this.height = height; - } setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -711,38 +707,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -751,7 +715,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java b/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java index 3b3551de6d..96a35beeb4 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentTransmissionLine extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentTransmissionLine extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -76,14 +77,10 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - private ELNPortTerminal term2; - private ELNPortTerminal term3; - - public ELNComponentTransmissionLine(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentTransmissionLine(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(120, 80); @@ -95,6 +92,8 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone minWidth = 1; minHeight = 1; + initPortTerminal(4); + addTGConnectingPointsComment(); moveable = true; @@ -108,6 +107,19 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone setDelay("sc_core::SC_ZERO_TIME"); setDelta0(0.0); setUnit2("Hz"); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "a1"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "a2"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "b1"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "b2"); } public Color getMyColor() { @@ -115,32 +127,6 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("a1"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y, true, false); - - term1 = new ELNPortTerminal(x + width - width / 12, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("a2"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - width / 12, y, true, false); - - term2 = new ELNPortTerminal(x, y + height - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term2.setValue("b1"); - getTDiagramPanel().getComponentList().add(term2); - term2.getTDiagramPanel().addComponent(term2, x, y + height - height / 8, true, false); - - term3 = new ELNPortTerminal(x + width - width / 12, y + height - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term3.setValue("b2"); - getTDiagramPanel().getComponentList().add(term3); - term3.getTDiagramPanel().addComponent(term3, x + width - width / 12, y + height - height / 8, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -199,85 +185,73 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 12, y, true); - term2.setMoveCd(x, y + height - height / 8, true); - term3.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 12, y, true); - term3.setMoveCd(x, y + height - height / 8, true); - term2.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 12, y, true); - term0.setMoveCd(x, y + height - height / 8, true); - term1.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 12, y, true); - term1.setMoveCd(x, y + height - height / 8, true); - term0.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } } else if (position == 1) { if (first == false) { @@ -309,85 +283,69 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 8, y, true); - term3.setMoveCd(x, y + height - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 8, y, true); - term2.setMoveCd(x, y + height - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 8, y, true); - term1.setMoveCd(x, y + height - height / 12, true); - term3.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 8, y, true); - term0.setMoveCd(x, y + height - height / 12, true); - term2.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } } else if (position == 2) { if (first == false) { @@ -419,85 +377,73 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 12, y, true); - term1.setMoveCd(x, y + height - height / 8, true); - term0.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 12, y, true); - term0.setMoveCd(x, y + height - height / 8, true); - term1.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 12, y, true); - term3.setMoveCd(x, y + height - height / 8, true); - term2.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 12, y, true); - term2.setMoveCd(x, y + height - height / 8, true); - term3.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } } else if (position == 3) { if (first == false) { @@ -529,85 +475,69 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 8, y, true); - term0.setMoveCd(x, y + height - height / 12, true); - term2.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 8, y, true); - term1.setMoveCd(x, y + height - height / 12, true); - term3.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 8, y, true); - term2.setMoveCd(x, y + height - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 8, y, true); - term3.setMoveCd(x, y + height - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } } g.setColor(c); @@ -615,25 +545,63 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone } private void rotateTopBottom(Graphics g) { - int[] ptx0 = { x, x + width / 6, x + 5 * width / 6, x + width, x + 5 * width / 6, x + width / 6 }; - int[] pty0 = { y, y + height / 2 - height / 8, y + height / 2 - height / 8, y, y + height / 2 - height / 8, - y + height / 2 - height / 8 }; + Color c = g.getColor(); + int[] ptx0 = { x + width / 24, x + width / 6, x + 5 * width / 6, x + width - width / 24, x + 5 * width / 6, + x + width / 6 }; + int[] pty0 = { y + height / 16, y + height / 2 - height / 8, y + height / 2 - height / 8, y + height / 16, + y + height / 2 - height / 8, y + height / 2 - height / 8 }; g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x, x + width / 6, x + 5 * width / 6, x + width, x + 5 * width / 6, x + width / 6 }; - int[] pty1 = { y + height, y + height / 2 + height / 8, y + height / 2 + height / 8, y + height, - y + height / 2 + height / 8, y + height / 2 + height / 8 }; + int[] ptx1 = { x + width / 24, x + width / 6, x + 5 * width / 6, x + width - width / 24, x + 5 * width / 6, + x + width / 6 }; + int[] pty1 = { y + height - height / 16, y + height / 2 + height / 8, y + height / 2 + height / 8, + y + height - height / 16, y + height / 2 + height / 8, y + height / 2 + height / 8 }; g.drawPolygon(ptx1, pty1, 6); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateRightLeft(Graphics g) { - int[] ptx0 = { x, x + width / 2 - width / 8, x + width / 2 - width / 8, x, x + width / 2 - width / 8, - x + width / 2 - width / 8 }; - int[] pty0 = { y, y + height / 6, y + 5 * height / 6, y + height, y + 5 * height / 6, y + height / 6 }; + Color c = g.getColor(); + int[] ptx0 = { x + width / 16, x + width / 2 - width / 8, x + width / 2 - width / 8, x + width / 16, + x + width / 2 - width / 8, x + width / 2 - width / 8 }; + int[] pty0 = { y + height / 24, y + height / 6, y + 5 * height / 6, y + height - height / 24, + y + 5 * height / 6, y + height / 6 }; g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + width, x + width / 2 + width / 8, x + width / 2 + width / 8, x + width, - x + width / 2 + width / 8, x + width / 2 + width / 8 }; - int[] pty1 = { y, y + height / 6, y + 5 * height / 6, y + height, y + 5 * height / 6, y + height / 6 }; + int[] ptx1 = { x + width - width / 16, x + width / 2 + width / 8, x + width / 2 + width / 8, + x + width - width / 16, x + width / 2 + width / 8, x + width / 2 + width / 8 }; + int[] pty1 = { y + height / 24, y + height / 6, y + 5 * height / 6, y + height - height / 24, + y + 5 * height / 6, y + height / 6 }; g.drawPolygon(ptx1, pty1, 6); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -681,8 +649,6 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone sb.append("\" delta0=\"" + delta0); sb.append("\" unit2=\"" + encode(unit2)); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -702,7 +668,7 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone double z0, delta0; String delay; String unit0, unit2; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -720,8 +686,6 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone delta0 = Double.parseDouble(elt.getAttribute("delta0")); unit2 = elt.getAttribute("unit2"); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -733,8 +697,6 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone setDelta0(delta0); setUnit2(unit2); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -909,38 +871,6 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -949,7 +879,7 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java index da6a457557..2799cfb682 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -75,14 +76,10 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - private ELNPortTerminal term2; - private ELNPortTerminal term3; - - public ELNComponentVoltageControlledCurrentSource(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentVoltageControlledCurrentSource(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(120, 80); @@ -94,6 +91,8 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI minWidth = 1; minHeight = 1; + initPortTerminal(4); + addTGConnectingPointsComment(); moveable = true; @@ -104,6 +103,19 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI setVal(1.0); setUnit("S"); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncp"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "np"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncn"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "nn"); } public Color getMyColor() { @@ -111,32 +123,6 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("ncp"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y, true, false); - - term1 = new ELNPortTerminal(x + width - width / 12, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("np"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - width / 12, y, true, false); - - term2 = new ELNPortTerminal(x, y + height - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term2.setValue("ncn"); - getTDiagramPanel().getComponentList().add(term2); - term2.getTDiagramPanel().addComponent(term2, x, y + height - height / 8, true, false); - - term3 = new ELNPortTerminal(x + width - width / 12, y + height - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term3.setValue("nn"); - getTDiagramPanel().getComponentList().add(term3); - term3.getTDiagramPanel().addComponent(term3, x + width - width / 12, y + height - height / 8, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -194,88 +180,76 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI || (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); - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 12, y, true); - term2.setMoveCd(x, y + height - height / 8, true); - term3.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 12, y, true); - term3.setMoveCd(x, y + height - height / 8, true); - term2.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 12, y, true); - term0.setMoveCd(x, y + height - height / 8, true); - term1.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 12, y, true); - term1.setMoveCd(x, y + height - height / 8, true); - term0.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } } else if (position == 1) { if (first == false) { @@ -306,88 +280,72 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI || (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)) { rotateRight(g); - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 8, y, true); - term3.setMoveCd(x, y + height - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateRightFlip(g); - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 8, y, true); - term2.setMoveCd(x, y + height - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 8, y, true); - term1.setMoveCd(x, y + height - height / 12, true); - term3.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 8, y, true); - term0.setMoveCd(x, y + height - height / 12, true); - term2.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } } else if (position == 2) { if (first == false) { @@ -418,88 +376,76 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI || (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); - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 12, y, true); - term1.setMoveCd(x, y + height - height / 8, true); - term0.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 12, y, true); - term0.setMoveCd(x, y + height - height / 8, true); - term1.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 12, y, true); - term3.setMoveCd(x, y + height - height / 8, true); - term2.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 12, y, true); - term2.setMoveCd(x, y + height - height / 8, true); - term3.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } } else if (position == 3) { if (first == false) { @@ -530,88 +476,72 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI || (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)) { rotateLeft(g); - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 8, y, true); - term0.setMoveCd(x, y + height - height / 12, true); - term2.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 8, y, true); - term1.setMoveCd(x, y + height - height / 12, true); - term3.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRightFlip(g); - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 8, y, true); - term2.setMoveCd(x, y + height - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 8, y, true); - term3.setMoveCd(x, y + height - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } } g.setColor(c); @@ -619,6 +549,7 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI } private void rotateTop(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + 2 * width / 6 }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -648,9 +579,26 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateTopFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + 2 * width / 6 }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -680,9 +628,26 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateBottom(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + 4 * width / 6, x + width }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -712,9 +677,26 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateBottomFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + 4 * width / 6, x + width }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -744,9 +726,26 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateRight(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx0, pty0, 2); @@ -776,9 +775,26 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } private void rotateRightFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -808,9 +824,26 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + height / 6 - height / 12 - height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } private void rotateLeft(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -840,9 +873,26 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + height / 6 - height / 12 - height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } private void rotateLeftFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx0, pty0, 2); @@ -872,6 +922,22 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -914,8 +980,6 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI sb.append("<attributes value=\"" + val); sb.append("\" unit=\"" + encode(unit)); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -934,7 +998,7 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI double value; String unit; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -949,8 +1013,6 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI value = Double.parseDouble(elt.getAttribute("value")); unit = elt.getAttribute("unit"); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -959,8 +1021,6 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI setVal(value); setUnit(unit); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -1111,38 +1171,6 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -1151,7 +1179,7 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java index 4d3793de72..31870bce62 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java @@ -58,7 +58,8 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, SwallowedTGComponent, ELNComponent { +public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithInternalComponent + implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -74,14 +75,10 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI private int position = 0; private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first, f = true; + private boolean first; - private ELNPortTerminal term0; - private ELNPortTerminal term1; - private ELNPortTerminal term2; - private ELNPortTerminal term3; - - public ELNComponentVoltageControlledVoltageSource(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentVoltageControlledVoltageSource(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(120, 80); @@ -93,6 +90,8 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI minWidth = 1; minHeight = 1; + initPortTerminal(4); + addTGConnectingPointsComment(); moveable = true; @@ -102,6 +101,19 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI value = tdp.findELNComponentName("VCVS"); setVal(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncp"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "np"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncn"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "nn"); } public Color getMyColor() { @@ -109,32 +121,6 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI } public void internalDrawing(Graphics g) { - if (f == true) { - term0 = new ELNPortTerminal(x, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term0.setValue("ncp"); - getTDiagramPanel().getComponentList().add(term0); - term0.getTDiagramPanel().addComponent(term0, x, y, true, false); - - term1 = new ELNPortTerminal(x + width - width / 12, y, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term1.setValue("np"); - getTDiagramPanel().getComponentList().add(term1); - term1.getTDiagramPanel().addComponent(term1, x + width - width / 12, y, true, false); - - term2 = new ELNPortTerminal(x, y + height - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term2.setValue("ncn"); - getTDiagramPanel().getComponentList().add(term2); - term2.getTDiagramPanel().addComponent(term2, x, y + height - height / 8, true, false); - - term3 = new ELNPortTerminal(x + width - width / 12, y + height - height / 8, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); - term3.setValue("nn"); - getTDiagramPanel().getComponentList().add(term3); - term3.getTDiagramPanel().addComponent(term3, x + width - width / 12, y + height - height / 8, true, false); - old = width; - width = height; - height = old; - f = false; - } - Font f = g.getFont(); Font fold = f; @@ -192,88 +178,76 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI || (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); - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 12, y, true); - term2.setMoveCd(x, y + height - height / 8, true); - term3.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 12, y, true); - term3.setMoveCd(x, y + height - height / 8, true); - term2.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 12, y, true); - term0.setMoveCd(x, y + height - height / 8, true); - term1.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 12, y, true); - term1.setMoveCd(x, y + height - height / 8, true); - term0.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } } else if (position == 1) { if (first == false) { @@ -304,88 +278,72 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI || (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)) { rotateRight(g); - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 8, y, true); - term3.setMoveCd(x, y + height - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateRightFlip(g); - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 8, y, true); - term2.setMoveCd(x, y + height - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 8, y, true); - term1.setMoveCd(x, y + height - height / 12, true); - term3.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateLeft(g); - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 8, y, true); - term0.setMoveCd(x, y + height - height / 12, true); - term2.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } } else if (position == 2) { if (first == false) { @@ -416,88 +374,77 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI || (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); - term3.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 12, y, true); - term1.setMoveCd(x, y + height - height / 8, true); - term0.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - height / 8 - sw3, y); - g.drawString(term2.getValue(), x + width + height / 8, y); - g.drawString(term1.getValue(), x - height / 8 - sw1, y + height + sh1); - g.drawString(term0.getValue(), x + width + height / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, + y + height + sh0); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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); - term2.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 12, y, true); - term0.setMoveCd(x, y + height - height / 8, true); - term1.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - height / 8 - sw2, y); - g.drawString(term3.getValue(), x + width + height / 8, y); - g.drawString(term0.getValue(), x - height / 8 - sw0, y + height + sh0); - g.drawString(term1.getValue(), x + width + height / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, + y + height + sh1); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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); - term1.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 12, y, true); - term3.setMoveCd(x, y + height - height / 8, true); - term2.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - height / 8 - sw1, y); - g.drawString(term0.getValue(), x + width + height / 8, y); - g.drawString(term3.getValue(), x - height / 8 - sw3, y + height + sh3); - g.drawString(term2.getValue(), x + width + height / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(0.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + ; + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - height / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - height / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + height / 8, + y + height + sh2); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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); - term0.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 12, y, true); - term2.setMoveCd(x, y + height - height / 8, true); - term3.setMoveCd(x + width - width / 12, y + height - height / 8, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - height / 8 - sw0, y); - g.drawString(term1.getValue(), x + width + height / 8, y); - g.drawString(term2.getValue(), x - height / 8 - sw2, y + height + sh2); - g.drawString(term3.getValue(), x + width + height / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0); + ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - height / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + height / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - height / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + height / 8, + y + height + sh3); } } else if (position == 3) { if (first == false) { @@ -528,88 +475,72 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI || (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)) { rotateLeft(g); - term1.setMoveCd(x, y, true); - term3.setMoveCd(x + width - width / 8, y, true); - term0.setMoveCd(x, y + height - height / 12, true); - term2.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term1.getValue(), x - width / 8 - sw1, y); - g.drawString(term3.getValue(), x + width + width / 8, y); - g.drawString(term0.getValue(), x - width / 8 - sw0, y + height + sh0); - g.drawString(term2.getValue(), x + width + width / 8, y + height + sh2); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y + height + sh2); } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) || (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)) { rotateLeftFlip(g); - term0.setMoveCd(x, y, true); - term2.setMoveCd(x + width - width / 8, y, true); - term1.setMoveCd(x, y + height - height / 12, true); - term3.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term0.getValue(), x - width / 8 - sw0, y); - g.drawString(term2.getValue(), x + width + width / 8, y); - g.drawString(term1.getValue(), x - width / 8 - sw1, y + height + sh1); - g.drawString(term3.getValue(), x + width + width / 8, y + height + sh3); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 8 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 8 - sw1, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 8, y + height + sh3); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRightFlip(g); - term3.setMoveCd(x, y, true); - term1.setMoveCd(x + width - width / 8, y, true); - term2.setMoveCd(x, y + height - height / 12, true); - term0.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term3.getValue(), x - width / 8 - sw3, y); - g.drawString(term1.getValue(), x + width + width / 8, y); - g.drawString(term2.getValue(), x - width / 8 - sw2, y + height + sh2); - g.drawString(term0.getValue(), x + width + width / 8, y + height + sh0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y + height + sh0); } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true) || (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)) { rotateRight(g); - term2.setMoveCd(x, y, true); - term0.setMoveCd(x + width - width / 8, y, true); - term3.setMoveCd(x, y + height - height / 12, true); - term1.setMoveCd(x + width - width / 8, y + height - height / 12, true); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term2.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term0.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setW(0.0); - ((ELNConnectingPoint) (term3.getTGConnectingPointAtIndex(0))).setH(0.5); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setW(1.0); - ((ELNConnectingPoint) (term1.getTGConnectingPointAtIndex(0))).setH(0.5); - g.drawString(term2.getValue(), x - width / 8 - sw2, y); - g.drawString(term0.getValue(), x + width + width / 8, y); - g.drawString(term3.getValue(), x - width / 8 - sw3, y + height + sh3); - g.drawString(term1.getValue(), x + width + width / 8, y + height + sh1); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[3]).setW(1.0 / 16.0); + ((ELNPortTerminal) connectingPoint[3]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 8 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 8, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 8 - sw3, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 8, y + height + sh1); } } g.setColor(c); @@ -617,6 +548,7 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI } private void rotateTop(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + 2 * width / 6 }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -648,9 +580,26 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateTopFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x, x + 2 * width / 6 }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -682,9 +631,26 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateBottom(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + 4 * width / 6, x + width }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -715,9 +681,26 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateBottomFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + 4 * width / 6, x + width }; int[] pty0 = { y + height / 16, y + height / 16 }; g.drawPolygon(ptx0, pty0, 2); @@ -748,9 +731,26 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y, width / 12, height / 8); + g.setColor(c); + g.drawOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 8, width / 12, height / 8); + g.setColor(c); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); + g.setColor(c); } private void rotateRight(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx0, pty0, 2); @@ -782,9 +782,26 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + width / 4, x + width / 4 }; int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } private void rotateRightFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -816,9 +833,26 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + width / 4, x + width / 4 }; int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } private void rotateLeft(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx0, pty0, 2); @@ -850,9 +884,26 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + width - width / 4, x + width - width / 4 }; int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } private void rotateLeftFlip(Graphics g) { + Color c = g.getColor(); int[] ptx0 = { x + width / 16, x + width / 16 }; int[] pty0 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx0, pty0, 2); @@ -884,6 +935,22 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI int[] ptx6 = { x + width - width / 4, x + width - width / 4 }; int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); + g.drawOval(x, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y, width / 8, height / 12); + g.setColor(c); + g.drawOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 12, width / 8, height / 12); + g.setColor(c); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -908,8 +975,6 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<attributes value=\"" + val); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -927,7 +992,7 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI Element elt; double value; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -941,8 +1006,6 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI if (elt.getTagName().equals("attributes")) { value = Double.parseDouble(elt.getAttribute("value")); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); 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")); @@ -950,8 +1013,6 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI first = Boolean.parseBoolean(elt.getAttribute("first")); setVal(value); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -1094,38 +1155,6 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI first = _first; } - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - return tgc instanceof ELNPortTerminal; - } - - public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNPortTerminal) { - tgc.setFather(this); - tgc.setDrawingZone(true); - tgc.resizeWithFather(); - addInternalComponent(tgc, 0); - return true; - } - return false; - } - - public void removeSwallowedTGComponent(TGComponent tgc) { - removeInternalComponent(tgc); - } - - public void hasBeenResized() { - rescaled = true; - for (int i = 0; i < nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNPortTerminal) { - tgcomponent[i].resizeWithFather(); - } - } - - if (getFather() != null) { - resizeWithFather(); - } - } - public void resizeWithFather() { if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); @@ -1134,7 +1163,7 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI setMoveCd(x, y); } } - + public void wasSwallowed() { myColor = null; } -- GitLab