From 4ad0480d4eb08e26e97f0e14dde4791167172d3d Mon Sep 17 00:00:00 2001 From: Lee <irina.lee@etu.upmc.fr> Date: Sun, 8 Jul 2018 23:12:46 +0200 Subject: [PATCH] added port terminal (eln) --- src/main/java/ui/TDiagramPanel.java | 8 + src/main/java/ui/eln/ELNComponent.java | 5 + src/main/java/ui/eln/ELNConnectingPoint.java | 14 +- src/main/java/ui/eln/ELNPortTerminal.java | 35 +- .../ui/eln/sca_eln/ELNComponentCapacitor.java | 449 +++++++++++++----- .../ELNComponentIndependentCurrentSource.java | 351 ++++++++------ .../ELNComponentIndependentVoltageSource.java | 360 ++++++++------ .../ui/eln/sca_eln/ELNComponentInductor.java | 346 ++++++++------ .../ui/eln/sca_eln/ELNComponentNodeRef.java | 239 +++++++--- .../ui/eln/sca_eln/ELNComponentResistor.java | 426 ++++++++++++----- .../ui/syscams/SysCAMSCompositeComponent.java | 22 +- ...minal.java => JDialogELNPortTerminal.java} | 6 +- 12 files changed, 1439 insertions(+), 822 deletions(-) create mode 100644 src/main/java/ui/eln/ELNComponent.java rename src/main/java/ui/window/{JDialogELNTerminal.java => JDialogELNPortTerminal.java} (96%) diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index 1dfb0fe420..ae7d358285 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -2602,6 +2602,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { || (o instanceof SysCAMSBlockTDF && this.checkSysCAMSBlockTDFComponent((SysCAMSBlockTDF) o, name)) || (o instanceof SysCAMSBlockDE && this.checkSysCAMSBlockDEComponent((SysCAMSBlockDE) o, name)) || (o instanceof SysCAMSCompositeComponent && this.checkSysCAMSCompositeComponent((SysCAMSCompositeComponent) o, name)) + || (o instanceof ELNComponentNodeRef && this.checkELNComponentNodeRef((ELNComponentNodeRef) o, name)) || (o instanceof ELNComponentResistor && this.checkELNComponentResistor((ELNComponentResistor) o, name)) || (o instanceof ELNComponentCapacitor && this.checkELNComponentCapacitor((ELNComponentCapacitor) o, name)) || (o instanceof ELNComponentInductor && this.checkELNComponentInductor((ELNComponentInductor) o, name)) @@ -2674,6 +2675,10 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return false; } + public boolean checkELNComponentNodeRef(ELNComponentNodeRef o, String name) { + return false; + } + public boolean checkELNComponentResistor(ELNComponentResistor o, String name) { return false; } @@ -2861,6 +2866,9 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { public String findELNComponentName(String name) { return this.findGoodName(name, new NameChecker() { + public boolean checkELNComponentNodeRef(ELNComponentNodeRef o, String name) { + return o.getValue().equals(name); + } public boolean checkELNComponentResistor(ELNComponentResistor o, String name) { return o.getValue().equals(name); } diff --git a/src/main/java/ui/eln/ELNComponent.java b/src/main/java/ui/eln/ELNComponent.java new file mode 100644 index 0000000000..5c3b72da30 --- /dev/null +++ b/src/main/java/ui/eln/ELNComponent.java @@ -0,0 +1,5 @@ +package ui.eln; + +public interface ELNComponent { + +} diff --git a/src/main/java/ui/eln/ELNConnectingPoint.java b/src/main/java/ui/eln/ELNConnectingPoint.java index b58a5aa1f4..25c6551b90 100644 --- a/src/main/java/ui/eln/ELNConnectingPoint.java +++ b/src/main/java/ui/eln/ELNConnectingPoint.java @@ -52,22 +52,12 @@ import ui.TGConnectingPointWidthHeight; public class ELNConnectingPoint extends TGConnectingPointWidthHeight { public boolean positionned; - private String name; - public ELNConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h, String _name) { + public ELNConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); - name = _name; } public boolean isCompatibleWith(int type) { return type == TGComponentManager.ELN_CONNECTOR; } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} +} \ No newline at end of file diff --git a/src/main/java/ui/eln/ELNPortTerminal.java b/src/main/java/ui/eln/ELNPortTerminal.java index 94d385a842..5618d9ef8d 100644 --- a/src/main/java/ui/eln/ELNPortTerminal.java +++ b/src/main/java/ui/eln/ELNPortTerminal.java @@ -39,18 +39,14 @@ package ui.eln; import myutil.GraphicLib; - import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; import ui.eln.ELNConnectingPoint; -import ui.window.JDialogELNTerminal; - +import ui.window.JDialogELNPortTerminal; import javax.swing.*; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * Class ELNPortTerminal @@ -60,20 +56,19 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNPortTerminal extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent { +public class ELNPortTerminal extends TGCScalableWithInternalComponent implements SwallowedTGComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; private int minFontSize = 4; private int currentFontSize = -1; - protected int oldx, oldy; + protected int oldx, oldy; private int textX = 15; private double dtextX = 0.0; protected int decPoint = 3; - public ELNPortTerminal(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, - TGComponent _father, TDiagramPanel _tdp) { + public ELNPortTerminal(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(10, 10); @@ -100,7 +95,7 @@ public class ELNPortTerminal extends TGCScalableWithInternalComponent implements public void initConnectingPoint(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.5, ""); + connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.5, 0.5); } public Color getMyColor() { @@ -135,6 +130,7 @@ public class ELNPortTerminal extends TGCScalableWithInternalComponent implements } Color c = g.getColor(); + g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); g.setColor(c); g.setFont(fold); @@ -152,7 +148,7 @@ public class ELNPortTerminal extends TGCScalableWithInternalComponent implements } public boolean editOndoubleClick(JFrame frame) { - JDialogELNTerminal jde = new JDialogELNTerminal(this); + JDialogELNPortTerminal jde = new JDialogELNPortTerminal(this); jde.setVisible(true); return true; } @@ -194,10 +190,6 @@ public class ELNPortTerminal extends TGCScalableWithInternalComponent implements } } - public void actionPerformed(ActionEvent arg0) { - return; - } - public int getDefaultConnector() { return TGComponentManager.ELN_CONNECTOR; } @@ -214,16 +206,9 @@ public class ELNPortTerminal extends TGCScalableWithInternalComponent implements } public void resizeWithFather() { - if ((father != null) && (father instanceof SysCAMSBlockTDF)) { - // Too large to fit in the father? -> resize it! - setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2)); - setMoveCd(x, y); - oldx = -1; - oldy = -1; - } - if ((father != null) && (father instanceof SysCAMSBlockDE)) { - // Too large to fit in the father? -> resize it! - setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2)); + if ((father != null) && (father instanceof ELNComponent)) { + setCdRectangle(0 - getWidth() / 2, father.getWidth() - (getWidth() / 2), 0 - getHeight() / 2, + father.getHeight() - (getHeight() / 2)); setMoveCd(x, y); oldx = -1; oldy = -1; diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java index dbd7f6888e..3af0c836d3 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java @@ -39,14 +39,12 @@ package ui.eln.sca_eln; import myutil.GraphicLib; - import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.eln.ELNConnectingPoint; +import ui.eln.*; import ui.window.JDialogELNComponentCapacitor; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -60,7 +58,7 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentCapacitor extends TGCScalableWithInternalComponent implements ActionListener { +public class ELNComponentCapacitor extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -75,12 +73,14 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl private String unit0, unit1; private int position = 0; - private boolean fv = false, fh = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; - private boolean first; + private boolean first, f = true; + + 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,8 +92,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl minWidth = 1; minHeight = 1; - initConnectingPoint(2); - addTGConnectingPointsComment(); moveable = true; @@ -106,17 +104,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl setQ0(0.0); setUnit0("F"); setUnit1("C"); - - old = width; - width = height; - height = old; - } - - public void initConnectingPoint(int nb) { - nbConnectingPoint = nb; - connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.5, "p"); - connectingPoint[1] = new ELNConnectingPoint(this, 0, 0, true, true, 1.0, 0.5, "n"); } public Color getMyColor() { @@ -124,6 +111,24 @@ 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; @@ -174,24 +179,57 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl g.drawString(value, x + (width - w) / 2, y - height / 2); g.setFont(f.deriveFont(Font.PLAIN)); - if (fh == true) { - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh0); - } else { - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); + } + 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); + } + 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); } } else if (position == 1) { if (first == false) { @@ -213,22 +251,57 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl g.drawString(value, x + (width - w) / 2, y - height / 5); g.setFont(f.deriveFont(Font.PLAIN)); - if (fv == true) { - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 4, - y + height + sh0); - } else { - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 4, - y + height + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); + } + 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); + } + 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); } } else if (position == 2) { if (first == false) { @@ -252,24 +325,57 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl g.drawString(value, x + (width - w) / 2, y - height / 2); g.setFont(f.deriveFont(Font.PLAIN)); - if (fh == true) { - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 4 + sh0); - } else { - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); + } + 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); + } + 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); } } else if (position == 3) { if (first == false) { @@ -291,22 +397,57 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl g.drawString(value, x + (width - w) / 2, y - height / 5); g.setFont(f.deriveFont(Font.PLAIN)); - if (fv == true) { - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 4, - y + height + sh0); - } else { - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 4, - y + height + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); + } + 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); + } + 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); } } g.setColor(c); @@ -376,8 +517,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl sb.append("\" position=\"" + position); sb.append("\" width=\"" + width); sb.append("\" height=\"" + height); - sb.append("\" fv=\"" + fv); - sb.append("\" fh=\"" + fh); + sb.append("\" fv_0_2=\"" + fv_0_2); + sb.append("\" fv_1_3=\"" + fv_1_3); + sb.append("\" fh_0_2=\"" + fh_0_2); + sb.append("\" fh_1_3=\"" + fh_1_3); sb.append("\" first=\"" + first + "\""); sb.append("/>\n"); sb.append("</extraparam>\n"); @@ -393,7 +536,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl double value, q0; String unit0, unit1; int position, width, height; - boolean fv, fh, first; + boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); @@ -411,8 +554,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl position = Integer.parseInt(elt.getAttribute("position")); width = Integer.parseInt(elt.getAttribute("width")); height = Integer.parseInt(elt.getAttribute("height")); - fv = Boolean.parseBoolean(elt.getAttribute("fv")); - fh = Boolean.parseBoolean(elt.getAttribute("fh")); + 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")); setVal(value); setQ0(q0); @@ -421,8 +566,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl setPosition(position); this.width = width; this.height = height; - setFv(fv); - setFh(fh); + setFv_0_2(fv_0_2); + setFv_1_3(fv_1_3); + setFh_0_2(fh_0_2); + setFh_1_3(fh_1_3); setFirst(first); } } @@ -457,8 +604,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl } public void actionPerformed(ActionEvent e) { - fv = false; - fh = false; if (e.getActionCommand().equals("Rotate right 90\u00b0")) { position++; position %= 4; @@ -470,17 +615,35 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl first = false; } if (e.getActionCommand().equals("Flip vertically")) { - if (fv == false) { - fv = true; - } else { - fv = false; + if (position == 0 || position == 2) { + if (fv_0_2 == false) { + fv_0_2 = true; + } else { + fv_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fv_1_3 == false) { + fv_1_3 = true; + } else { + fv_1_3 = false; + } } } if (e.getActionCommand().equals("Flip horizontally")) { - if (fh == false) { - fh = true; - } else { - fh = false; + if (position == 0 || position == 2) { + if (fh_0_2 == false) { + fh_0_2 = true; + } else { + fh_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fh_1_3 == false) { + fh_1_3 = true; + } else { + fh_1_3 = false; + } } } } @@ -525,31 +688,79 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl return position; } - public void setPosition(int position) { - this.position = position; + public void setPosition(int _position) { + position = _position; + } + + public boolean isFv_0_2() { + return fv_0_2; + } + + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; + } + + public boolean isFv_1_3() { + return fv_1_3; } - public boolean isFv() { - return fv; + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; } - public void setFv(boolean fv) { - this.fv = fv; + public boolean isFh_0_2() { + return fh_0_2; } - public boolean isFh() { - return fh; + public void setFh_0_2(boolean _fh_0_2) { + fh_0_2 = _fh_0_2; } - public void setFh(boolean fh) { - this.fh = fh; + public boolean isFh_1_3() { + return fh_1_3; + } + + public void setFh_1_3(boolean _fh_1_3) { + fh_1_3 = _fh_1_3; } public boolean isFirst() { return first; } - public void setFirst(boolean first) { - this.first = first; + public void setFirst(boolean _first) { + first = _first; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof ELNPortTerminal) { + return tgc instanceof ELNPortTerminal; + } else { + return true; + } + } + + 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(); + } + } } -} +} \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java index e16121ffa9..d0b808c68b 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java @@ -39,14 +39,12 @@ package ui.eln.sca_eln; import myutil.GraphicLib; - import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.eln.ELNConnectingPoint; +import ui.eln.*; import ui.window.JDialogELNComponentIndependentCurrentSource; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -60,7 +58,7 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentIndependentCurrentSource extends TGCScalableWithInternalComponent implements ActionListener { +public class ELNComponentIndependentCurrentSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -78,10 +76,12 @@ 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; + private boolean first, f = true; + + 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,8 +93,6 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna minWidth = 1; minHeight = 1; - initConnectingPoint(2); - addTGConnectingPointsComment(); moveable = true; @@ -113,17 +111,6 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna setAcAmplitude(0.0); setAcPhase(0.0); setAcNoiseAmplitude(0.0); - - old = width; - width = height; - height = old; - } - - public void initConnectingPoint(int nb) { - nbConnectingPoint = nb; - connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 1.0 / 3.0, 0.0, "p"); - connectingPoint[1] = new ELNConnectingPoint(this, 0, 0, true, true, 1.0 / 3.0, 1.0, "n"); } public Color getMyColor() { @@ -131,6 +118,24 @@ 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; @@ -182,52 +187,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)) { rotateTop(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 3 + width / 6, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 3 + width / 6, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, - y + height + sh0); + 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); } } else if (position == 1) { if (first == false) { @@ -254,56 +263,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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 3 + height / 6 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 3 + height / 6 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + 2 * height / 3 + height / 6 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + 2 * height / 3 + height / 6 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(2.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 3 + height / 6 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 3 + height / 6 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(2.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + 2 * height / 3 + height / 6 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + 2 * height / 3 + height / 6 + sh1); + 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); } } else if (position == 2) { if (first == false) { @@ -328,52 +337,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)) { rotateBottom(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 3 + width / 6, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 3 + width / 6, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 3 + width / 6, - y + height + sh1); + 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); } } else if (position == 3) { if (first == false) { @@ -400,56 +413,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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(2.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + 2 * height / 3 + height / 6 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + 2 * height / 3 + height / 6 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(2.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(2.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 3 + height / 6 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 3 + height / 6 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + 2 * height / 3 + height / 6 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + 2 * height / 3 + height / 6 + sh0); + 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); } 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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 3.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 3.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 3 + height / 6 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 3 + height / 6 + sh0); + 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); } } g.setColor(c); @@ -895,47 +908,79 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna return position; } - public void setPosition(int position) { - this.position = position; + public void setPosition(int _position) { + position = _position; } public boolean isFv_0_2() { return fv_0_2; } - public void setFv_0_2(boolean fv_0_2) { - this.fv_0_2 = fv_0_2; + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; } public boolean isFv_1_3() { return fv_1_3; } - public void setFv_1_3(boolean fv_1_3) { - this.fv_1_3 = fv_1_3; + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; } public boolean isFh_0_2() { return fh_0_2; } - public void setFh_0_2(boolean fh_0_2) { - this.fh_0_2 = fh_0_2; + public void setFh_0_2(boolean _fh_0_2) { + fh_0_2 = _fh_0_2; } public boolean isFh_1_3() { return fh_1_3; } - public void setFh_1_3(boolean fh_1_3) { - this.fh_1_3 = fh_1_3; + public void setFh_1_3(boolean _fh_1_3) { + fh_1_3 = _fh_1_3; } public boolean isFirst() { return first; } - public void setFirst(boolean first) { - this.first = first; + public void setFirst(boolean _first) { + first = _first; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof ELNPortTerminal) { + return tgc instanceof ELNPortTerminal; + } else { + return true; + } + } + + 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(); + } + } } -} +} \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java index 2a5864b9f6..85a4cf6ed5 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java @@ -44,23 +44,23 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.eln.ELNConnectingPoint; +import ui.eln.*; import ui.window.JDialogELNComponentIndependentVoltageSource; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** - * Class ELNComponentIndependentVoltageSource - * Independent voltage source to be used in ELN diagrams - * Creation: 15/06/2018 + * Class ELNComponentIndependentVoltageSource Independent voltage source to be + * used in ELN diagrams Creation: 15/06/2018 + * * @version 1.0 15/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentIndependentVoltageSource extends TGCScalableWithInternalComponent implements ActionListener { +public class ELNComponentIndependentVoltageSource extends TGCScalableWithInternalComponent + implements ActionListener, SwallowTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -78,7 +78,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; + private boolean first, f = true; + + 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) { @@ -93,8 +96,6 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna minWidth = 1; minHeight = 1; - initConnectingPoint(2); - addTGConnectingPointsComment(); moveable = true; @@ -113,17 +114,6 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna setAcAmplitude(0.0); setAcPhase(0.0); setAcNoiseAmplitude(0.0); - - old = width; - width = height; - height = old; - } - - public void initConnectingPoint(int nb) { - nbConnectingPoint = nb; - connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.5, 0.0, "p"); - connectingPoint[1] = new ELNConnectingPoint(this, 0, 0, true, true, 0.5, 1.0, "n"); } public Color getMyColor() { @@ -131,6 +121,24 @@ 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; @@ -182,52 +190,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)) { rotateTop(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } } else if (position == 1) { if (first == false) { @@ -254,56 +266,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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh0); + 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); } } else if (position == 2) { if (first == false) { @@ -328,52 +340,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)) { rotateBottom(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } } else if (position == 3) { if (first == false) { @@ -400,56 +416,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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + 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); } 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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + 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); } } g.setColor(c); @@ -481,7 +497,7 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna x + width / 2 + width / 4 + width / 8, x + width / 2 + width / 4 + width / 8, x + width / 2 + width / 4 + width / 8, x + width }; int[] pty1 = { y + 3 * height / 4 + height / 8, y + 3 * height / 4 + height / 8, - y + 3 * height / 4 + height / 8 + width / 8, y + 3 * height / 4 + height / 8 + width / 8, + y + 3 * height / 4 + height / 8 + width / 8, y + 3 * height / 4 + height / 8 - width / 8, y + 3 * height / 4 + height / 8, y + 3 * height / 4 + height / 8 }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 2 + width / 4, x + width }; @@ -545,8 +561,8 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna g.drawPolygon(ptx0, pty0, 2); int[] ptx1 = { x + width - width / 8, x + width - width / 8, x + width - width / 8 - height / 8, x + width - width / 8 + height / 8, x + width - width / 8, x + width - width / 8 }; - int[] pty1 = { y + height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, - y + height / 4 + height / 8, y + height / 4 + height / 8, y }; + int[] pty1 = { y + height / 4, y + height / 4 - height / 8, y + height / 4 - height / 8, + y + height / 4 - height / 8, y + height / 4 - height / 8, y }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 8, x + width / 8 }; int[] pty2 = { y + height / 4, y }; @@ -867,47 +883,79 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna return position; } - public void setPosition(int position) { - this.position = position; + public void setPosition(int _position) { + position = _position; } public boolean isFv_0_2() { return fv_0_2; } - public void setFv_0_2(boolean fv_0_2) { - this.fv_0_2 = fv_0_2; + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; } public boolean isFv_1_3() { return fv_1_3; } - public void setFv_1_3(boolean fv_1_3) { - this.fv_1_3 = fv_1_3; + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; } public boolean isFh_0_2() { return fh_0_2; } - public void setFh_0_2(boolean fh_0_2) { - this.fh_0_2 = fh_0_2; + public void setFh_0_2(boolean _fh_0_2) { + fh_0_2 = _fh_0_2; } public boolean isFh_1_3() { return fh_1_3; } - public void setFh_1_3(boolean fh_1_3) { - this.fh_1_3 = fh_1_3; + public void setFh_1_3(boolean _fh_1_3) { + fh_1_3 = _fh_1_3; } public boolean isFirst() { return first; } - public void setFirst(boolean first) { - this.first = first; + public void setFirst(boolean _first) { + first = _first; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof ELNPortTerminal) { + return tgc instanceof ELNPortTerminal; + } else { + return true; + } + } + + 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(); + } + } } -} +} \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java index 7fcd19a977..c2d20528bf 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java @@ -44,9 +44,8 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.eln.ELNConnectingPoint; +import ui.eln.*; import ui.window.JDialogELNComponentInductor; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -60,7 +59,7 @@ import java.awt.event.ActionListener; * @author Irina Kit Yan LEE */ -public class ELNComponentInductor extends TGCScalableWithInternalComponent implements ActionListener { +public class ELNComponentInductor extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -77,8 +76,11 @@ 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; + private boolean first, f = true; + 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) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -92,8 +94,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple minWidth = 1; minHeight = 1; - initConnectingPoint(2); - addTGConnectingPointsComment(); moveable = true; @@ -106,17 +106,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple setPhi0(0.0); setUnit0("H"); setUnit1("Wb"); - - old = width; - width = height; - height = old; - } - - public void initConnectingPoint(int nb) { - nbConnectingPoint = nb; - connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.5, "p"); - connectingPoint[1] = new ELNConnectingPoint(this, 0, 0, true, true, 1.0, 0.5, "n"); } public Color getMyColor() { @@ -124,6 +113,24 @@ 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; @@ -177,56 +184,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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 4 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 4 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 4 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 4 + sh0); + 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); } } else if (position == 1) { if (first == false) { @@ -251,52 +258,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)) { rotateRight(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } } else if (position == 2) { if (first == false) { @@ -323,56 +334,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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 2 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 2 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 2 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 2 + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, - y + height / 2 + height / 2 + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, - y + height / 2 + height / 2 + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, - y + height / 2 + height / 2 + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, - y + height / 2 + height / 2 + sh1); + 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); } } else if (position == 3) { if (first == false) { @@ -397,39 +408,42 @@ 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } 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); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, - y + height + sh0); + 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); } 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) @@ -437,12 +451,14 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple || (fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true)) { rotateRight(g); ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, - y + height + sh1); + 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); } } g.setColor(c); @@ -697,47 +713,79 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple return position; } - public void setPosition(int position) { - this.position = position; + public void setPosition(int _position) { + position = _position; } public boolean isFv_0_2() { return fv_0_2; } - public void setFv_0_2(boolean fv_0_2) { - this.fv_0_2 = fv_0_2; + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; } public boolean isFv_1_3() { return fv_1_3; } - public void setFv_1_3(boolean fv_1_3) { - this.fv_1_3 = fv_1_3; + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; } public boolean isFh_0_2() { return fh_0_2; } - public void setFh_0_2(boolean fh_0_2) { - this.fh_0_2 = fh_0_2; + public void setFh_0_2(boolean _fh_0_2) { + fh_0_2 = _fh_0_2; } public boolean isFh_1_3() { return fh_1_3; } - public void setFh_1_3(boolean fh_1_3) { - this.fh_1_3 = fh_1_3; + public void setFh_1_3(boolean _fh_1_3) { + fh_1_3 = _fh_1_3; } public boolean isFirst() { return first; } - public void setFirst(boolean first) { - this.first = first; + public void setFirst(boolean _first) { + first = _first; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof ELNPortTerminal) { + return tgc instanceof ELNPortTerminal; + } else { + return true; + } + } + + 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(); + } + } } -} +} \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java index d52798c413..dcc644de94 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java @@ -46,17 +46,15 @@ import org.w3c.dom.NodeList; import ui.*; import ui.eln.ELNConnectingPoint; import ui.window.JDialogELNComponentNodeRef; -import ui.window.JDialogELNComponentResistor; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** - * Class ELNComponentNodeRef Reference node to be used in ELN diagrams Creation: - * 27/06/2018 - * + * Class ELNComponentNodeRef + * Reference node to be used in ELN diagrams + * Creation: 27/06/2018 * @version 1.0 27/06/2018 * @author Irina Kit Yan LEE */ @@ -73,12 +71,11 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem protected int decPoint = 3; private int position = 0; - private boolean fv = false, fh = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public 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); @@ -108,7 +105,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.5, 0.0); } public Color getMyColor() { @@ -160,15 +157,38 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem g.drawString(value, x + (width - w) / 2, y - height / 2); g.setFont(f.deriveFont(Font.PLAIN)); - if (fv == true) { - rotateBottom(g); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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)) { + rotateTop(g); ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - } else { + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + } + 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); ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); } + 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); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + } + 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); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + } } else if (position == 1) { if (first == false) { first = true; @@ -185,15 +205,39 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem g.drawString(value, x + (width - w) / 2, y - height / 2); g.setFont(f.deriveFont(Font.PLAIN)); - if (fh == true) { - rotateLeft(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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)) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - } else { + } + 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); ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); } + 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); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + } + 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); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + ; + } } else if (position == 2) { if (first == false) { first = true; @@ -210,15 +254,38 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem g.drawString(value, x + (width - w) / 2, y - height / 2); g.setFont(f.deriveFont(Font.PLAIN)); - if (fv == true) { - rotateTop(g); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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)) { + rotateBottom(g); ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - } else { + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + } + 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); ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); } + 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); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + } + 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); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + } } else if (position == 3) { if (first == false) { first = true; @@ -235,15 +302,39 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem g.drawString(value, x + (width - w) / 2, y - height / 2); g.setFont(f.deriveFont(Font.PLAIN)); - if (fh == true) { - rotateRight(g); - ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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)) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); - } else { + } + 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); ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); } + 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); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + } + 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(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); + ; + } } g.setColor(c); g.setFont(fold); @@ -299,8 +390,10 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem sb.append("<attributes position=\"" + position); sb.append("\" width=\"" + width); sb.append("\" height=\"" + height); - sb.append("\" fv=\"" + fv); - sb.append("\" fh=\"" + fh); + sb.append("\" fv_0_2=\"" + fv_0_2); + sb.append("\" fv_1_3=\"" + fv_1_3); + sb.append("\" fh_0_2=\"" + fh_0_2); + sb.append("\" fh_1_3=\"" + fh_1_3); sb.append("\" first=\"" + first + "\""); sb.append("/>\n"); sb.append("</extraparam>\n"); @@ -314,7 +407,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem Element elt; int position, width, height; - boolean fv, fh, first; + boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); @@ -328,14 +421,18 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem position = Integer.parseInt(elt.getAttribute("position")); width = Integer.parseInt(elt.getAttribute("width")); height = Integer.parseInt(elt.getAttribute("height")); - fv = Boolean.parseBoolean(elt.getAttribute("fv")); - fh = Boolean.parseBoolean(elt.getAttribute("fh")); + 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(fv); - setFh(fh); + setFv_0_2(fv_0_2); + setFv_1_3(fv_1_3); + setFh_0_2(fh_0_2); + setFh_1_3(fh_1_3); setFirst(first); } } @@ -370,8 +467,6 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem } public void actionPerformed(ActionEvent e) { - fv = false; - fh = false; if (e.getActionCommand().equals("Rotate right 90\u00b0")) { position++; position %= 4; @@ -383,17 +478,35 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem first = false; } if (e.getActionCommand().equals("Flip vertically")) { - if (fv == false) { - fv = true; - } else { - fv = false; + if (position == 0 || position == 2) { + if (fv_0_2 == false) { + fv_0_2 = true; + } else { + fv_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fv_1_3 == false) { + fv_1_3 = true; + } else { + fv_1_3 = false; + } } } if (e.getActionCommand().equals("Flip horizontally")) { - if (fh == false) { - fh = true; - } else { - fh = false; + if (position == 0 || position == 2) { + if (fh_0_2 == false) { + fh_0_2 = true; + } else { + fh_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fh_1_3 == false) { + fh_1_3 = true; + } else { + fh_1_3 = false; + } } } } @@ -406,31 +519,47 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem return position; } - public void setPosition(int position) { - this.position = position; + public void setPosition(int _position) { + position = _position; + } + + public boolean isFv_0_2() { + return fv_0_2; + } + + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; + } + + public boolean isFv_1_3() { + return fv_1_3; + } + + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; } - public boolean isFv() { - return fv; + public boolean isFh_0_2() { + return fh_0_2; } - public void setFv(boolean fv) { - this.fv = fv; + public void setFh_0_2(boolean _fh_0_2) { + fh_0_2 = _fh_0_2; } - public boolean isFh() { - return fh; + public boolean isFh_1_3() { + return fh_1_3; } - public void setFh(boolean fh) { - this.fh = fh; + public void setFh_1_3(boolean _fh_1_3) { + fh_1_3 = _fh_1_3; } public boolean isFirst() { return first; } - public void setFirst(boolean first) { - this.first = first; + public void setFirst(boolean _first) { + first = _first; } -} +} \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java index 3abfe88704..3f29e61e61 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java @@ -39,20 +39,16 @@ package ui.eln.sca_eln; import myutil.GraphicLib; - import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.eln.ELNConnectingPoint; -import ui.eln.ELNPortTerminal; +import ui.eln.*; import ui.window.JDialogELNComponentResistor; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.ComponentListener; /** * Class ELNComponentResistor @@ -62,7 +58,7 @@ import java.awt.event.ComponentListener; * @author Irina Kit Yan LEE */ -public class ELNComponentResistor extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent { +public class ELNComponentResistor extends TGCScalableWithInternalComponent implements ActionListener, SwallowTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -77,12 +73,14 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple private String unit; private int position = 0; - private boolean fv = false, fh = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first, f = true; - public ELNComponentResistor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, - TGComponent _father, TDiagramPanel _tdp) { + 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) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(100, 20); @@ -94,7 +92,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple minWidth = 1; minHeight = 1; -// initConnectingPoint(2); addTGConnectingPointsComment(); moveable = true; @@ -105,32 +102,31 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple setVal(1.0); setUnit("\u03A9"); - - old = width; - width = height; - height = old; } -// public void initConnectingPoint(int nb) { -// nbConnectingPoint = nb; -// connectingPoint = new TGConnectingPoint[nb]; -// connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.5, "p"); -// connectingPoint[1] = new ELNConnectingPoint(this, 0, 0, true, true, 1.0, 0.5, "n"); -// } - public Color getMyColor() { return myColor; } public void internalDrawing(Graphics g) { if (f == true) { - ELNPortTerminal term0 = new ELNPortTerminal(x, y+width/2-width/4, this.minX, this.maxX, this.minY, this.maxY, false, this.father, this.tdp); + 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+width/2-width/4, true, false); + 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; @@ -181,24 +177,57 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple g.drawString(value, x + (width - w) / 2, y - height); g.setFont(f.deriveFont(Font.PLAIN)); - if (fh == true) { -// ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); -// ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); -// ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, -// y + height / 2 + height / 2 + sh1); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, -// y + height / 2 + height / 2 + sh0); - } else { -// ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); -// ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); -// ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, -// y + height / 2 + height / 2 + sh0); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, -// y + height / 2 + height / 2 + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); + } + 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); + } + 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); } } else if (position == 1) { if (first == false) { @@ -220,23 +249,59 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple g.drawString(value, x + (width - w) / 2, y - height / 5); g.setFont(f.deriveFont(Font.PLAIN)); - if (fv == true) { -// ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); -// ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, -// y + height + sh0); - } else { -// ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); -// ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, -// y + height + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); } + 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); + } + 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); + } + } else if (position == 2) { if (first == false) { first = true; @@ -259,24 +324,57 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple g.drawString(value, x + (width - w) / 2, y - height); g.setFont(f.deriveFont(Font.PLAIN)); - if (fh == true) { -// ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); -// ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); -// ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw1, -// y + height / 2 + height / 2 + sh1); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, -// y + height / 2 + height / 2 + sh0); - } else { -// ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); -// ((ELNConnectingPoint) connectingPoint[0]).setH(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); -// ((ELNConnectingPoint) connectingPoint[1]).setH(0.5); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw0, -// y + height / 2 + height / 2 + sh0); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, -// y + height / 2 + height / 2 + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); + } + 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); + } + 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); } } else if (position == 3) { if (first == false) { @@ -298,22 +396,57 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple g.drawString(value, x + (width - w) / 2, y - height / 5); g.setFont(f.deriveFont(Font.PLAIN)); - if (fv == true) { -// ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); -// ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, -// y + height + sh0); - } else { -// ((ELNConnectingPoint) connectingPoint[0]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); -// ((ELNConnectingPoint) connectingPoint[1]).setW(0.5); -// ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); -// g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); -// g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width / 2 + width / 2, -// y + height + sh1); + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + } + 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); + } + 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); + } + 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); } } g.setColor(c); @@ -381,14 +514,16 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple sb.append("\" position=\"" + position); sb.append("\" width=\"" + width); sb.append("\" height=\"" + height); - sb.append("\" fv=\"" + fv); - sb.append("\" fh=\"" + fh); + sb.append("\" fv_0_2=\"" + fv_0_2); + sb.append("\" fv_1_3=\"" + fv_1_3); + sb.append("\" fh_0_2=\"" + fh_0_2); + sb.append("\" fh_1_3=\"" + fh_1_3); sb.append("\" first=\"" + first + "\""); sb.append("/>\n"); sb.append("</extraparam>\n"); return new String(sb); } - + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; @@ -398,8 +533,8 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple double value; String unit; int position, width, height; - boolean fv, fh, first; - + boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; + for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); if (n1.getNodeType() == Node.ELEMENT_NODE) { @@ -414,16 +549,20 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple position = Integer.parseInt(elt.getAttribute("position")); width = Integer.parseInt(elt.getAttribute("width")); height = Integer.parseInt(elt.getAttribute("height")); - fv = Boolean.parseBoolean(elt.getAttribute("fv")); - fh = Boolean.parseBoolean(elt.getAttribute("fh")); + 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")); setVal(value); setUnit(unit); setPosition(position); this.width = width; this.height = height; - setFv(fv); - setFh(fh); + setFv_0_2(fv_0_2); + setFv_1_3(fv_1_3); + setFh_0_2(fh_0_2); + setFh_1_3(fh_1_3); setFirst(first); } } @@ -458,8 +597,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple } public void actionPerformed(ActionEvent e) { - fv = false; - fh = false; if (e.getActionCommand().equals("Rotate right 90\u00b0")) { position++; position %= 4; @@ -471,17 +608,35 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple first = false; } if (e.getActionCommand().equals("Flip vertically")) { - if (fv == false) { - fv = true; - } else { - fv = false; + if (position == 0 || position == 2) { + if (fv_0_2 == false) { + fv_0_2 = true; + } else { + fv_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fv_1_3 == false) { + fv_1_3 = true; + } else { + fv_1_3 = false; + } } } if (e.getActionCommand().equals("Flip horizontally")) { - if (fh == false) { - fh = true; - } else { - fh = false; + if (position == 0 || position == 2) { + if (fh_0_2 == false) { + fh_0_2 = true; + } else { + fh_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fh_1_3 == false) { + fh_1_3 = true; + } else { + fh_1_3 = false; + } } } } @@ -510,32 +665,48 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple return position; } - public void setPosition(int position) { - this.position = position; + public void setPosition(int _position) { + position = _position; + } + + public boolean isFv_0_2() { + return fv_0_2; + } + + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; + } + + public boolean isFv_1_3() { + return fv_1_3; } - public boolean isFv() { - return fv; + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; } - public void setFv(boolean fv) { - this.fv = fv; + public boolean isFh_0_2() { + return fh_0_2; } - public boolean isFh() { - return fh; + public void setFh_0_2(boolean _fh_0_2) { + fh_0_2 = _fh_0_2; } - public void setFh(boolean fh) { - this.fh = fh; + public boolean isFh_1_3() { + return fh_1_3; + } + + public void setFh_1_3(boolean _fh_1_3) { + fh_1_3 = _fh_1_3; } public boolean isFirst() { return first; } - public void setFirst(boolean first) { - this.first = first; + public void setFirst(boolean _first) { + first = _first; } public boolean acceptSwallowedTGComponent(TGComponent tgc) { @@ -560,16 +731,13 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } - + public void hasBeenResized() { rescaled = true; - for(int i=0; i<nbInternalTGComponent; i++) { + for (int i = 0; i < nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof ELNPortTerminal) { tgcomponent[i].resizeWithFather(); } } - if (getFather() != null) { - resizeWithFather(); - } } -} +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java index ed78d9a142..2713598512 100644 --- a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java +++ b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java @@ -246,9 +246,6 @@ public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent tgc.setDrawingZone(true); //Set its coordinates - if (tgc instanceof SysCAMSCompositeComponent) { - tgc.resizeWithFather(); - } if (tgc instanceof SysCAMSBlockTDF) { tgc.resizeWithFather(); } @@ -286,28 +283,12 @@ public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent public void hasBeenResized() { rescaled = true; for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { - tgcomponent[i].resizeWithFather(); - } if (tgcomponent[i] instanceof SysCAMSBlockTDF) { tgcomponent[i].resizeWithFather(); } if (tgcomponent[i] instanceof SysCAMSBlockDE) { tgcomponent[i].resizeWithFather(); } - } - if (getFather() != null) { - resizeWithFather(); - } - } - - public void resizeWithFather() { - if ((father != null) && ((father instanceof SysCAMSCompositeComponent) || (father instanceof SysCAMSBlockTDF) || (father instanceof SysCAMSBlockDE))) { - // Too large to fit in the father? -> resize it! - resizeToFatherSize(); - - setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); - setMoveCd(x, y); } } @@ -507,5 +488,4 @@ public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent return true; } } -} - +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogELNTerminal.java b/src/main/java/ui/window/JDialogELNPortTerminal.java similarity index 96% rename from src/main/java/ui/window/JDialogELNTerminal.java rename to src/main/java/ui/window/JDialogELNPortTerminal.java index 24ade84f5c..6f686dfb4c 100644 --- a/src/main/java/ui/window/JDialogELNTerminal.java +++ b/src/main/java/ui/window/JDialogELNPortTerminal.java @@ -45,7 +45,7 @@ import java.awt.event.*; import javax.swing.*; /** - * Class JDialogELNTerminal + * Class JDialogELNPortTerminal * Dialog for managing of ELN port terminal * Creation: 06/07/2018 * @version 1.0 06/07/2018 @@ -54,13 +54,13 @@ import javax.swing.*; @SuppressWarnings("serial") -public class JDialogELNTerminal extends JDialog implements ActionListener { +public class JDialogELNPortTerminal extends JDialog implements ActionListener { private JTextField nameTextField; private ELNPortTerminal term; - public JDialogELNTerminal(ELNPortTerminal term) { + public JDialogELNPortTerminal(ELNPortTerminal term) { this.setTitle("Setting Port Terminal Attributes"); this.setLocationRelativeTo(null); this.setVisible(true); -- GitLab