diff --git a/build.txt b/build.txt index 3fefd94c0455d8d4b3aa8b3259ea328a0d34eb92..aca79dfb56238442153fe00dc35fb7a6061fb442 100644 --- a/build.txt +++ b/build.txt @@ -1 +1 @@ -12698 \ No newline at end of file +12700 \ No newline at end of file diff --git a/src/main/java/tmltranslator/toavatar/TML2Avatar.java b/src/main/java/tmltranslator/toavatar/TML2Avatar.java index f32e1404f4aee4910b653fba19620e7bcfa57580..cac9761a2308ad90b69ee9b3e26dbca7ed6c6143 100644 --- a/src/main/java/tmltranslator/toavatar/TML2Avatar.java +++ b/src/main/java/tmltranslator/toavatar/TML2Avatar.java @@ -94,7 +94,7 @@ public class TML2Avatar { this.tmlmap = tmlmap; this.tmlmodel = tmlmap.getTMLModeling(); - + allStates = new ArrayList<String>(); attrsToCheck = new ArrayList<String>(); @@ -1482,6 +1482,30 @@ public class TML2Avatar { } attrsToCheck.clear(); tmlmodel.removeForksAndJoins(); + + System.out.println("MODIFIED model " + tmlmodel); + + for (TMLChannel chan: tmlmodel.getChannels()){ + System.out.println("chan " + chan); + TMLTask task = chan.getOriginTask(); + + TMLTask task2 = chan.getDestinationTask(); + HwExecutionNode node = (HwExecutionNode) tmlmap.getHwNodeOf(task); + HwExecutionNode node2 = (HwExecutionNode) tmlmap.getHwNodeOf(task2); + if (node==null){ + tmlmap.addTaskToHwExecutionNode(task, node2); + } + + if (node2==null){ + tmlmap.addTaskToHwExecutionNode(task2, node); + } + + if (chan.getName().contains("fork__") || chan.getName().contains("FORKCHANNEL")){ + chan.setName(chan.getName().replaceAll("__","")); + } + + } + //Only set the loop limit if it's a number String pattern = "^[0-9]{1,2}$"; Pattern r = Pattern.compile(pattern); diff --git a/src/main/java/ui/AvatarDesignPanel.java b/src/main/java/ui/AvatarDesignPanel.java index 5e590ebbe4eb2545c68f9ba77a42fdb5adb72072..0b3194ef27d7efe7c20a4d37d372227b87a2b6b8 100644 --- a/src/main/java/ui/AvatarDesignPanel.java +++ b/src/main/java/ui/AvatarDesignPanel.java @@ -45,11 +45,14 @@ import avatartranslator.AvatarAttribute; import avatartranslator.AvatarPragmaAuthenticity; import avatartranslator.AvatarPragmaReachability; import avatartranslator.AvatarPragmaSecret; +import avatartranslator.AvatarPragma; import avatartranslator.AvatarPragmaLatency; import myutil.GraphicLib; import proverifspec.ProVerifOutputAnalyzer; import proverifspec.ProVerifQueryAuthResult; import proverifspec.ProVerifQueryResult; +import proverifspec.ProVerifResultTrace; + import ui.avatarbd.*; import ui.avatardd.ADDDiagramPanel; import ui.avatarsmd.AvatarSMDPanel; @@ -453,17 +456,17 @@ public class AvatarDesignPanel extends TURTLEPanel { // Confidential attributes Map<AvatarPragmaSecret, ProVerifQueryResult> confResults = pvoa.getConfidentialityResults(); - List<AvatarAttribute> secretAttributes = new LinkedList<AvatarAttribute> (); - List<AvatarAttribute> nonSecretAttributes = new LinkedList<AvatarAttribute> (); + HashMap<AvatarAttribute, AvatarPragma> secretAttributes = new HashMap<AvatarAttribute, AvatarPragma> (); + HashMap<AvatarAttribute, AvatarPragma> nonSecretAttributes = new HashMap<AvatarAttribute, AvatarPragma> (); for (AvatarPragmaSecret pragma: confResults.keySet()) { ProVerifQueryResult result = confResults.get(pragma); if (result.isProved()) { if (result.isSatisfied()) - secretAttributes.add(pragma.getArg()); + secretAttributes.put(pragma.getArg(), pragma); else - nonSecretAttributes.add(pragma.getArg()); + nonSecretAttributes.put(pragma.getArg(),pragma); } } @@ -474,15 +477,23 @@ public class AvatarDesignPanel extends TURTLEPanel { int toBeFound = types.size (); boolean ko = false; for (TAttribute type: types) { - for(AvatarAttribute attribute: secretAttributes) + for(AvatarAttribute attribute: secretAttributes.keySet()) if (attribute.getBlock ().getName ().equals (bdBlock.getBlockName ()) && attribute.getName ().equals (tattr.getId () + "__" + type.getId ())) { toBeFound --; + ProVerifResultTrace trace = confResults.get(secretAttributes.get(attribute)).getTrace(); + if (trace!=null){ + bdBlock.addProVerifTrace(tattr, trace); + } break; } - for(AvatarAttribute attribute: nonSecretAttributes) + for(AvatarAttribute attribute: nonSecretAttributes.keySet()) if (attribute.getBlock ().getName ().equals (bdBlock.getBlockName ()) && attribute.getName ().equals (tattr.getId () + "__" + type.getId ())) { ko = true; + ProVerifResultTrace trace = confResults.get(nonSecretAttributes.get(attribute)).getTrace(); + if (trace!=null){ + bdBlock.addProVerifTrace(tattr, trace); + } break; } @@ -490,17 +501,31 @@ public class AvatarDesignPanel extends TURTLEPanel { break; } - if (ko) + if (ko){ tattr.setConfidentialityVerification(TAttribute.CONFIDENTIALITY_KO); - else if (toBeFound == 0) + + } + else if (toBeFound == 0) { tattr.setConfidentialityVerification(TAttribute.CONFIDENTIALITY_OK); + + } } else { - for(AvatarAttribute attribute: secretAttributes) - if (attribute.getBlock ().getName ().equals (bdBlock.getBlockName ()) && attribute.getName ().equals (tattr.getId ())) + for(AvatarAttribute attribute: secretAttributes.keySet()) + if (attribute.getBlock ().getName ().equals (bdBlock.getBlockName ()) && attribute.getName ().equals (tattr.getId ())){ tattr.setConfidentialityVerification(TAttribute.CONFIDENTIALITY_OK); - for(AvatarAttribute attribute: nonSecretAttributes) - if (attribute.getBlock ().getName ().equals (bdBlock.getBlockName ()) && attribute.getName ().equals (tattr.getId ())) + ProVerifResultTrace trace = confResults.get(secretAttributes.get(attribute)).getTrace(); + if (trace!=null){ + bdBlock.addProVerifTrace(tattr, trace); + } + } + for(AvatarAttribute attribute: nonSecretAttributes.keySet()) + if (attribute.getBlock ().getName ().equals (bdBlock.getBlockName ()) && attribute.getName ().equals (tattr.getId ())){ tattr.setConfidentialityVerification(TAttribute.CONFIDENTIALITY_KO); + ProVerifResultTrace trace = confResults.get(nonSecretAttributes.get(attribute)).getTrace(); + if (trace!=null){ + bdBlock.addProVerifTrace(tattr, trace); + } + } } } @@ -565,7 +590,7 @@ public class AvatarDesignPanel extends TURTLEPanel { boolean weakKo = false; boolean isNotProved = false; boolean weakIsNotProved = false; - + ProVerifQueryAuthResult result= new ProVerifQueryAuthResult(false, false); for (TAttribute type: types) { for (AvatarPragmaAuthenticity pragmaAuth: authResults.keySet()) { @@ -577,7 +602,7 @@ public class AvatarDesignPanel extends TURTLEPanel { || !pragmaAuth.getAttrB().getState().getName().equals(argB[1].replaceAll("\\.", "__"))) continue; - ProVerifQueryAuthResult result = authResults.get(pragmaAuth); + result = authResults.get(pragmaAuth); toBeFound --; if (result.isProved()) @@ -625,7 +650,10 @@ public class AvatarDesignPanel extends TURTLEPanel { else pragma.authWeakMap.put(prop, 1); } - + ProVerifResultTrace trace = result.getTrace(); + if (trace!=null){ + pragma.pragmaTraceMap.put(prop, trace); + } } else { for (AvatarPragmaAuthenticity pragmaAuth: authResults.keySet()) { @@ -670,7 +698,11 @@ public class AvatarDesignPanel extends TURTLEPanel { { pragma.authWeakMap.put(prop, 3); } - + //Add ProVerif Result Trace to pragma + ProVerifResultTrace trace = pvoa.getResults().get(pragmaAuth).getTrace(); + if (trace!=null){ + pragma.pragmaTraceMap.put(prop, trace); + } break; } } diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index 75ca70e77ca707bae107f511667aadd284fd89aa..58ebcefc3e8e66ab9faa452fd55bf35b5fd3e7ae 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -44,6 +44,7 @@ import ui.atd.ATDAttack; import ui.atd.ATDBlock; import ui.avatarad.AvatarADActivity; import ui.avatarbd.AvatarBDBlock; +import ui.avatarbd.AvatarBDPragma; import ui.avatarbd.AvatarBDDataType; import ui.avatarbd.AvatarBDLibraryFunction; import ui.avatarcd.AvatarCDBlock; @@ -1858,6 +1859,12 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { if (componentPopup instanceof TMLCPrimitivePort){ ((TMLCPrimitivePort) componentPopup).showTrace(); } + else if (componentPopup instanceof AvatarBDBlock){ + ((AvatarBDBlock) componentPopup).showTrace(currentY); + } + else if (componentPopup instanceof AvatarBDPragma){ + ((AvatarBDPragma) componentPopup).showTrace(currentY); + } } if (e.getSource() == checkMasterMutex) { @@ -2113,11 +2120,12 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } - if (componentPointed instanceof TMLCPrimitivePort){ + if (componentPointed instanceof TMLCPrimitivePort || componentPointed instanceof AvatarBDBlock || componentPointed instanceof AvatarBDPragma){ showProVerifTrace.setEnabled(true); } else { showProVerifTrace.setEnabled(false); } + if (componentPointed instanceof CheckableInvariant) { diff --git a/src/main/java/ui/TGConnector.java b/src/main/java/ui/TGConnector.java index cf9c8d6902ae407d3a136f2a8b1e179b59774490..6231c5aff8bb2e9561181abbf0bd6946035d73b5 100755 --- a/src/main/java/ui/TGConnector.java +++ b/src/main/java/ui/TGConnector.java @@ -43,6 +43,7 @@ package ui; import myutil.*; +import ui.eln.ELNMidPortTerminal; import javax.swing.*; import java.awt.*; @@ -632,6 +633,30 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent return; } + private boolean addELNMidPortTerminal(int x, int y) { + CDElement [] pt = getPointedSegment(x, y); + if (pt != null) { + Point p = new Point((pt[0].getX() + pt[1].getX()) / 2, (pt[0].getY() + pt[1].getY()) / 2); + int distance1 = (int)(new Point(x, y).distance(pt[0].getX(), pt[0].getY())); + int distance2 = (int)(new Point(x, y).distance(pt[1].getX(), pt[1].getY())); + int index = indexPointedSegment(x, y); + int indexCon; + + if (distance1 < distance2) { + indexCon = 0; + } else { + indexCon = 1; + } + + ELNMidPortTerminal t = new ELNMidPortTerminal(p.x, p.y, minX, maxX, minY, maxY, false, this, tdp); + if (addInternalComponent(t, index) ) { + pointHasBeenAdded(t, index, indexCon); + return true; + } + } + return false; + } + private boolean addTGCPointOfConnector(int x, int y) { //TraceManager.addDev("Adding point of connector at "+ x + "," + y); CDElement [] pt = getPointedSegment(x, y); @@ -759,6 +784,9 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent JMenuItem addPoint = new JMenuItem("Add Point"); addPoint.addActionListener(menuAL); componentMenu.add(addPoint); + JMenuItem CPPoint = new JMenuItem("Add Connecting Point"); + CPPoint.addActionListener(menuAL); + componentMenu.add(CPPoint); JMenuItem align = new JMenuItem("Align"); align.addActionListener(menuAL); componentMenu.add(align); @@ -787,7 +815,9 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent public boolean eventOnPopup(ActionEvent e) { if (e.getActionCommand().equals("Add Point")) { return addTGCPointOfConnector(popupx, popupy); - } else if (e.getActionCommand().equals("Add Point")){ + } else if (e.getActionCommand().equals("Add Connecting Point")) { + return addELNMidPortTerminal(popupx, popupy); + } else if (e.getActionCommand().equals("Align")){ return alignTGComponents(); } else if (e.getActionCommand().equals("NO automatic drawing")){ automaticDrawing = false; diff --git a/src/main/java/ui/avatarbd/AvatarBDBlock.java b/src/main/java/ui/avatarbd/AvatarBDBlock.java index 3f1efd9f50ea92f279719242c8ac2bea3db72730..e5e329766904ad9895140bb6227f5caf972fb344 100644 --- a/src/main/java/ui/avatarbd/AvatarBDBlock.java +++ b/src/main/java/ui/avatarbd/AvatarBDBlock.java @@ -52,13 +52,25 @@ import ui.util.IconManager; import ui.window.JDialogAvatarBlock; import ui.window.JDialogIDAndStereotype; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; + + import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; - +import java.util.HashMap; +import proverifspec.ProVerifResultTrace; +import proverifspec.ProVerifResultTraceStep; +import ui.interactivesimulation.JFrameSimulationSDPanel; /** * Class AvatarBDBlock @@ -104,7 +116,9 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S protected LinkedList<AvatarSignal> mySignals; protected String[] globalCode; - + protected HashMap<TAttribute, ProVerifResultTrace> attrTraceMap = new HashMap<TAttribute, ProVerifResultTrace>(); + protected HashMap<TAttribute, Integer> attrLocMap = new HashMap<TAttribute, Integer>(); + public String oldValue; public AvatarBDBlock(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { @@ -168,6 +182,10 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S this.internalDrawingAux(graph); graph.setFont(font); } + + public void addProVerifTrace(TAttribute attr, ProVerifResultTrace trace){ + attrTraceMap.put(attr,trace); + } public void setSignalsAsNonAttached() { for (AvatarSignal mySig : mySignals) mySig.attachedToARelation = false; @@ -338,6 +356,8 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S // Try to draw it w = graph.getFontMetrics().stringWidth(attrString); + + attrLocMap.put(attr,this.y+h); if (w + 2 * textX < this.width) { graph.drawString(attrString, this.x + textX, this.y + h); this.drawConfidentialityVerification(attr.getConfidentialityVerification(), graph, this.x, this.y + h); @@ -504,6 +524,45 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S g.setColor(c); } + public void showTrace(int y){ + + if (y< limitAttr){ + for (TAttribute attr: attrLocMap.keySet()){ + if (attrLocMap.get(attr) < y && y < attrLocMap.get(attr) +currentFontSize && attrTraceMap.get(attr)!=null){ + PipedOutputStream pos = new PipedOutputStream(); + try { + PipedInputStream pis = new PipedInputStream(pos, 4096); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(pos)); + + JFrameSimulationSDPanel jfssdp = new JFrameSimulationSDPanel(null, tdp.getMGUI(), "Confidentiality " + attr.toString()); + jfssdp.setIconImage(IconManager.img8); + GraphicLib.centerOnParent(jfssdp, 600, 600); + jfssdp.setFileReference(new BufferedReader(new InputStreamReader(pis))); + jfssdp.setVisible(true); + //jfssdp.setModalExclusionType(ModalExclusionType + // .APPLICATION_EXCLUDE); + jfssdp.toFront(); + + // TraceManager.addDev("\n--- Trace ---"); + int i = 0; + for (ProVerifResultTraceStep step : attrTraceMap.get(attr).getTrace()) { + step.describeAsTMLSDTransaction(bw, i); + i++; + } + bw.close(); + } catch (IOException e) { + TraceManager.addDev("Error when writing trace step SD transaction"); + } finally { + try { + pos.close(); + } catch (IOException ignored) { + } + } + + } + } + } + } private void drawConfidentialityVerification(int confidentialityVerification, Graphics g, int _x, int _y) { Color c = g.getColor(); diff --git a/src/main/java/ui/avatarbd/AvatarBDPragma.java b/src/main/java/ui/avatarbd/AvatarBDPragma.java index 65fe6e83b48bf43107216edef2bf8ab8001f77da..7dd4d58ffcd5f8878fcc683c6cc9c7b1d1a121a1 100755 --- a/src/main/java/ui/avatarbd/AvatarBDPragma.java +++ b/src/main/java/ui/avatarbd/AvatarBDPragma.java @@ -41,13 +41,31 @@ package ui.avatarbd; import myutil.Conversion; import myutil.GraphicLib; +import myutil.TraceManager; + import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; + + import ui.*; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; + import ui.util.IconManager; import ui.window.JDialogPragma; +import proverifspec.ProVerifResultTrace; +import proverifspec.ProVerifResultTraceStep; + +import ui.interactivesimulation.JFrameSimulationSDPanel; + import javax.swing.*; import java.awt.*; import java.util.ArrayList; @@ -93,6 +111,10 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { public final static int NOT_PROVED = 3; public HashMap<String, Integer> authStrongMap = new HashMap<String, Integer>(); public HashMap<String, Integer> authWeakMap = new HashMap<String, Integer>(); + + protected HashMap<String, Integer> pragmaLocMap = new HashMap<String, Integer>(); + + public HashMap<String, ProVerifResultTrace> pragmaTraceMap = new HashMap<String, ProVerifResultTrace>(); public AvatarBDPragma(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); @@ -232,6 +254,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { g.drawString("Security features", x + textX, y + textY + currentFontSize); g.setFont(fold); for (String s : models) { + pragmaLocMap.put(s,y + textY + (i + 1) * currentFontSize); g.drawString(s, x + textX, y + textY + (i + 1) * currentFontSize); if (syntaxErrors.contains(s)) { Color ctmp = g.getColor(); @@ -259,7 +282,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { g.setFont(fold); } g.drawString(s, x + textX, y + textY + (i + 1) * currentFontSize); - + pragmaLocMap.put(s,y + textY + i * currentFontSize); if (syntaxErrors.contains(s)) { Color ctmp = g.getColor(); g.setColor(Color.red); @@ -481,4 +504,46 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { throw new MalformedModelingException(); } } + + public void showTrace(int y){ + + //TraceManager.addDev(pragmaTraceMap + " " + pragmaLocMap + " " + y); + //On right click, display verification trace + for (String pragma: pragmaLocMap.keySet()){ + if (pragmaLocMap.get(pragma) < y && y <pragmaLocMap.get(pragma) +currentFontSize && pragmaTraceMap.get(pragma)!=null){ + PipedOutputStream pos = new PipedOutputStream(); + try { + PipedInputStream pis = new PipedInputStream(pos, 4096); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(pos)); + + JFrameSimulationSDPanel jfssdp = new JFrameSimulationSDPanel(null, tdp.getMGUI(), pragma); + jfssdp.setIconImage(IconManager.img8); + GraphicLib.centerOnParent(jfssdp, 600, 600); + jfssdp.setFileReference(new BufferedReader(new InputStreamReader(pis))); + jfssdp.setVisible(true); + //jfssdp.setModalExclusionType(ModalExclusionType + // .APPLICATION_EXCLUDE); + jfssdp.toFront(); + + // TraceManager.addDev("\n--- Trace ---"); + int i = 0; + for (ProVerifResultTraceStep step : pragmaTraceMap.get(pragma).getTrace()) { + step.describeAsTMLSDTransaction(bw, i); + i++; + } + bw.close(); + } catch (IOException e) { + TraceManager.addDev("Error when writing trace step SD transaction"); + } finally { + try { + pos.close(); + } catch (IOException ignored) { + } + } + break; + + } + } + // + } } diff --git a/src/main/java/ui/eln/ELNDiagramToolBar.java b/src/main/java/ui/eln/ELNDiagramToolBar.java index b5086acedea943e855f7989e7d6847264e460201..d7ddfe3b6df88bc733a988c6aee8c6b979b4167f 100644 --- a/src/main/java/ui/eln/ELNDiagramToolBar.java +++ b/src/main/java/ui/eln/ELNDiagramToolBar.java @@ -67,7 +67,6 @@ public class ELNDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ELN_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); - mgui.actions[TGUIAction.ELN_CONNECTOR].setEnabled(b); mgui.actions[TGUIAction.ELN_RESISTOR].setEnabled(b); mgui.actions[TGUIAction.ELN_CAPACITOR].setEnabled(b); mgui.actions[TGUIAction.ELN_INDUCTOR].setEnabled(b); @@ -151,11 +150,6 @@ public class ELNDiagramToolBar extends TToolBar { this.addSeparator(); - button = this.add(mgui.actions[TGUIAction.ELN_CONNECTOR]); - button.addMouseListener(mgui.mouseHandler); - - this.addSeparator(); - button = this.add(mgui.actions[TGUIAction.ELN_TOGGLE_ATTR]); button.addMouseListener(mgui.mouseHandler); } diff --git a/src/main/java/ui/eln/ELNMidPortTerminal.java b/src/main/java/ui/eln/ELNMidPortTerminal.java new file mode 100644 index 0000000000000000000000000000000000000000..a2dfcb99c2cb3611ba87caa8f6ce7f56e093734d --- /dev/null +++ b/src/main/java/ui/eln/ELNMidPortTerminal.java @@ -0,0 +1,116 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package ui.eln; + +import myutil.GraphicLib; +import ui.*; +import ui.window.JDialogELNMidPortTerminal; +import java.awt.*; +import javax.swing.JFrame; + +/** + * Class ELNMidPortTerminal + * Implements the intermediate points of connectors, when the connector is made of several lines. + * Creation: 18/07/2018 + * @version 1.0 18/07/2003 + * @author Irina Kit Yan LEE + */ + +public class ELNMidPortTerminal extends TGCPointOfConnector { + private int width = 10; + private int height = 10; + + public ELNMidPortTerminal(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(width, height); + + initConnectingPoint(1); + + nbInternalTGComponent = 0; + + moveable = true; + editable = false; + removable = true; + canBeCloned = false; + + value = ""; + } + + public void initConnectingPoint(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, -width/2, -height/2, true, true, 0.5, 0.5, ""); + } + + public void internalDrawing(Graphics g) { + g.drawOval(x - width/2, y - height /2, width, height); + g.fillOval(x - width/2, y - height /2, width, height); + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x - width/2, y - height/2, width, height)) { + return this; + } + return null; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNMidPortTerminal jde = new JDialogELNMidPortTerminal(this); + jde.setVisible(true); + return true; + } + + public void myActionWhenRemoved() { + if (father != null) { + if (father instanceof TGConnector) { + TGConnector tg = (TGConnector)father; + tg.pointHasBeenRemoved(this); + } + } + } + + public int getCurrentMaxX() { + return getX() + getWidth(); + } + + public int getCurrentMaxY() { + return getY() + getHeight(); + } +} \ No newline at end of file diff --git a/src/main/java/ui/eln/ELNModuleTerminal.java b/src/main/java/ui/eln/ELNModuleTerminal.java index 2618f1a158a1d916f542ea1ea5eadc3eef59395a..a3b98595d0a75e2f43cf23d9ab7f3b1a49396e44 100644 --- a/src/main/java/ui/eln/ELNModuleTerminal.java +++ b/src/main/java/ui/eln/ELNModuleTerminal.java @@ -48,188 +48,254 @@ import javax.swing.*; import java.awt.*; /** - * Class ELNModuleTerminal - * Primitive port. To be used in ELN diagrams + * Class ELNModuleTerminal + * Primitive port. To be used in ELN diagrams * Creation: 13/07/2018 * @version 1.0 13/07/2018 * @author Irina Kit Yan LEE */ public class ELNModuleTerminal extends TGCScalableWithInternalComponent implements SwallowedTGComponent, LinkedReference { - protected Color myColor; - protected int orientation; + protected Color myColor; + protected int orientation; private int maxFontSize = 14; - private int minFontSize = 4; - private int currentFontSize = -1; - protected int oldx, oldy; - protected int currentOrientation = GraphicLib.NORTH; - - private int isOrigin = -1; - - private int textX = 15; - private double dtextX = 0.0; - protected int decPoint = 3; - - public ELNModuleTerminal(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); - - dtextX = textX * oldScaleFactor; - textX = (int)dtextX; - dtextX = dtextX - textX; - - minWidth = 1; - minHeight = 1; - - initConnectingPoint(1); - - addTGConnectingPointsComment(); - - nbInternalTGComponent = 0; - - moveable = true; - editable = true; - removable = true; - userResizable = false; - - value = ""; - } - - public void initConnectingPoint(int nb) { - nbConnectingPoint = nb; - connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); - } - - public Color getMyColor() { - return myColor; - } - - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - - if ((x != oldx) | (oldy != y)) { - manageMove(); - oldx = x; - oldy = y; - } - - if (this.rescaled && !this.tdp.isScaled()) { - this.rescaled = false; - int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); - f = f.deriveFont((float) maxCurrentFontSize); - - while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { - if (g.getFontMetrics().stringWidth(value) < (width - (2 * textX))) { - break; - } - maxCurrentFontSize--; - f = f.deriveFont((float) maxCurrentFontSize); - } - - if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { - maxCurrentFontSize++; - f = f.deriveFont((float) maxCurrentFontSize); - } - g.setFont(f); - this.currentFontSize = maxCurrentFontSize; - } else { - f = f.deriveFont(this.currentFontSize); - } - - Color c = g.getColor(); - g.drawOval(x, y, width, height); - g.setColor(Color.WHITE); - g.fillOval(x, y, width, height); - g.setColor(c); - g.setFont(fold); - } - - public void manageMove() { - if (father != null) { - Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); - - x = p.x - width/2; - y = p.y - height/2; - - setMoveCd(x, y); - - int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); - if (orientation != currentOrientation) { - setOrientation(orientation); - } - } - } - - public void setOrientation(int orientation) { - currentOrientation = orientation; - double w0, h0; - - switch(orientation) { - case GraphicLib.NORTH: - w0 = 0.5; - h0 = 1.0; - break; - case GraphicLib.WEST: - w0 = 1.0; - h0 = 0.5; - break; - case GraphicLib.SOUTH: - w0 = 0.5; - h0 = 0.0; - break; - case GraphicLib.EAST: - default: - w0 = 0.0; - h0 = 0.5; - } - - for (int i=0; i<1; i++) { - ((ELNConnectingPoint) connectingPoint[i]).setW(w0); - ((ELNConnectingPoint) connectingPoint[i]).setH(h0); - } - } - - public TGComponent isOnOnlyMe(int _x, int _y) { - if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { - return this; - } - return null; - } - + private int minFontSize = 4; + private int currentFontSize = -1; + protected int oldx, oldy; + protected int currentOrientation = GraphicLib.NORTH; + + private int isOrigin = -1; + + private int textX = 15; + private double dtextX = 0.0; + protected int decPoint = 3; + + public ELNModuleTerminal(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); + + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + initConnectingPoint(1); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = false; + + value = ""; + } + + public void initConnectingPoint(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); + } + + public Color getMyColor() { + return myColor; + } + + public void internalDrawing(Graphics g) { + Font f = g.getFont(); + Font fold = f; + + if ((x != oldx) | (oldy != y)) { + manageMove(g, f); + oldx = x; + oldy = y; + } else { + MainGUI mgui = getTDiagramPanel().getMainGUI(); + int attributeFontSize = this.currentFontSize * 5 / 6; + int w = g.getFontMetrics().stringWidth(value); + int h = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.PLAIN)); + switch (currentOrientation) { + case GraphicLib.NORTH: + if (mgui.getHidden() == false) { + g.drawString(value, x + 2 * width, y - height / 2); + } + break; + case GraphicLib.WEST: + if (mgui.getHidden() == false) { + g.drawString(value, x - width / 2 - w, y + 2 * height + h); + } + break; + case GraphicLib.SOUTH: + if (mgui.getHidden() == false) { + g.drawString(value, x + 2 * width, y + height + height / 2 + h); + } + break; + case GraphicLib.EAST: + default: + if (mgui.getHidden() == false) { + g.drawString(value, x + width + width / 2, y + 2 * height + h); + } + } + } + + if (this.rescaled && !this.tdp.isScaled()) { + this.rescaled = false; + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); + f = f.deriveFont((float) maxCurrentFontSize); + + while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { + if (g.getFontMetrics().stringWidth(value) < (width - (2 * textX))) { + break; + } + maxCurrentFontSize--; + f = f.deriveFont((float) maxCurrentFontSize); + } + + if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { + maxCurrentFontSize++; + f = f.deriveFont((float) maxCurrentFontSize); + } + g.setFont(f); + this.currentFontSize = maxCurrentFontSize; + } else { + f = f.deriveFont(this.currentFontSize); + } + + Color c = g.getColor(); + g.drawOval(x, y, width, height); + g.setColor(Color.WHITE); + g.fillOval(x, y, width, height); + g.setColor(c); + g.setFont(fold); + } + + public void manageMove(Graphics g, Font f) { + MainGUI mgui = getTDiagramPanel().getMainGUI(); + + if (father != null) { + Point p = GraphicLib.putPointOnRectangle(x + (width / 2), y + (height / 2), father.getX(), father.getY(), + father.getWidth(), father.getHeight()); + + x = p.x - width / 2; + y = p.y - height / 2; + + setMoveCd(x, y); + + int orientation = GraphicLib.getCloserOrientation(x + (width / 2), y + (height / 2), father.getX(), + father.getY(), father.getWidth(), father.getHeight()); + + int attributeFontSize = this.currentFontSize * 5 / 6; + int w = g.getFontMetrics().stringWidth(value); + int h = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.PLAIN)); + + switch (orientation) { + case GraphicLib.NORTH: + if (mgui.getHidden() == false) { + g.drawString(value, x + 2 * width, y - height / 2); + } + break; + case GraphicLib.WEST: + if (mgui.getHidden() == false) { + g.drawString(value, x - width / 2 - w, y + 2 * height + h); + } + break; + case GraphicLib.SOUTH: + if (mgui.getHidden() == false) { + g.drawString(value, x + 2 * width, y + height + height / 2 + h); + } + break; + case GraphicLib.EAST: + default: + if (mgui.getHidden() == false) { + g.drawString(value, x + width + width / 2, y + 2 * height + h); + } + } + + if (orientation != currentOrientation) { + setOrientation(orientation); + } + } + } + + public void setOrientation(int orientation) { + currentOrientation = orientation; + double w0, h0; + + switch (orientation) { + case GraphicLib.NORTH: + w0 = 0.5; + h0 = 1.0; + break; + case GraphicLib.WEST: + w0 = 1.0; + h0 = 0.5; + break; + case GraphicLib.SOUTH: + w0 = 0.5; + h0 = 0.0; + break; + case GraphicLib.EAST: + default: + w0 = 0.0; + h0 = 0.5; + } + + for (int i = 0; i < 1; i++) { + ((ELNConnectingPoint) connectingPoint[i]).setW(w0); + ((ELNConnectingPoint) connectingPoint[i]).setH(h0); + } + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + public int getType() { return TGComponentManager.ELN_MODULE_TERMINAL; } - public void wasSwallowed() { - myColor = null; - } - - public void wasUnswallowed() { - myColor = null; - setFather(null); - TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); - } - - public void resizeWithFather() { - if ((father != null) && (father instanceof ELNModule)) { - setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2)); - setMoveCd(x, y); - oldx = -1; - oldy = -1; - } - } - - public boolean editOndoubleClick(JFrame frame) { + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof ELNModule)) { + setCdRectangle(0 - getWidth() / 2, father.getWidth() - (getWidth() / 2), 0 - getHeight() / 2, + father.getHeight() - (getHeight() / 2)); + setMoveCd(x, y); + oldx = -1; + oldy = -1; + } + } + + public boolean editOndoubleClick(JFrame frame) { JDialogELNModuleTerminal jde = new JDialogELNModuleTerminal(this); jde.setVisible(true); return true; } - protected String translateExtraParam() { + protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<attributes name=\"" + getValue() + "\""); sb.append("/>\n"); @@ -266,15 +332,15 @@ public class ELNModuleTerminal extends TGCScalableWithInternalComponent implemen } } - public int getOrigin() { - return isOrigin; - } - - public void setOrigin(int orig) { - isOrigin = orig; - } - - public int getDefaultConnector() { - return TGComponentManager.ELN_CONNECTOR; - } + public int getOrigin() { + return isOrigin; + } + + public void setOrigin(int orig) { + isOrigin = orig; + } + + public int getDefaultConnector() { + return TGComponentManager.ELN_CONNECTOR; + } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java index b88e8d0682ae4a990a35d3dd6e2371848f4ac35a..4c85129e249ecfcfeea007a541519100804bb9d7 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java @@ -51,15 +51,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** - * Class ELNComponentCapacitor Capacitor to be used in ELN diagrams Creation: - * 12/06/2018 - * + * Class ELNComponentCapacitor + * Capacitor to be used in ELN diagrams + * Creation: 12/06/2018 * @version 1.0 12/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentCapacitor extends TGCScalableWithInternalComponent - implements ActionListener, SwallowedTGComponent, ELNComponent { +public class ELNComponentCapacitor extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -74,14 +73,11 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent private String unit0, unit1; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public 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); @@ -116,10 +112,8 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "p"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "n"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); } public Color getMyColor() { @@ -133,10 +127,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -192,12 +183,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -209,12 +198,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -226,12 +213,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -243,12 +228,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } } else if (position == 1) { @@ -282,12 +265,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -299,12 +279,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -316,12 +293,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -333,12 +307,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } } else if (position == 2) { @@ -374,12 +345,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -391,12 +360,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -408,12 +375,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -425,12 +390,10 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } } else if (position == 3) { @@ -464,12 +427,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -481,12 +441,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -498,12 +455,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -515,12 +469,9 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } } @@ -530,49 +481,37 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent private void rotateTopBottom(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, - x + 2 * width / 5, x + 2 * width / 5 }; - int[] pty0 = { y + height / 2, y + height / 2, y, y + height, - y + height / 2 }; + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 2, y + height / 2, y, y + height, y + height / 2 }; g.drawPolygon(ptx0, pty0, 5); - int[] ptx1 = { x + width, x + 3 * width / 5, x + 3 * width / 5, - x + 3 * width / 5, x + 3 * width / 5 }; - int[] pty1 = { y + height / 2, y + height / 2, y, y + height, - y + height / 2 }; + int[] ptx1 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 }; + int[] pty1 = { y + height / 2, y + height / 2, y, y + height, y + height / 2 }; g.drawPolygon(ptx1, pty1, 5); g.drawOval(x, y + height / 2 - height / 8, width / 10, height / 4); g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 8, width / 10, height / 4); g.setColor(c); - g.drawOval(x + width - width / 10, y + height / 2 - height / 8, - width / 10, height / 4); + g.drawOval(x + width - width / 10, y + height / 2 - height / 8, width / 10, height / 4); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height / 2 - height / 8, - width / 10, height / 4); + g.fillOval(x + width - width / 10, y + height / 2 - height / 8, width / 10, height / 4); g.setColor(c); } private void rotateRightLeft(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 2, x + width / 2, x, x + width, - x + width / 2 }; - int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, - y + 2 * height / 5, y + 2 * height / 5 }; + int[] ptx0 = { x + width / 2, x + width / 2, x, x + width, x + width / 2 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 }; g.drawPolygon(ptx0, pty0, 5); - int[] ptx1 = { x + width / 2, x + width / 2, x, x + width, - x + width / 2 }; - int[] pty1 = { y + height, y + 3 * height / 5, y + 3 * height / 5, - y + 3 * height / 5, y + 3 * height / 5 }; + int[] ptx1 = { x + width / 2, x + width / 2, x, x + width, x + width / 2 }; + int[] pty1 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 }; g.drawPolygon(ptx1, pty1, 5); g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 10); g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 10); g.setColor(c); - g.drawOval(x + width / 2 - width / 8, y + height - height / 10, - width / 4, height / 10); + g.drawOval(x + width / 2 - width / 8, y + height - height / 10, width / 4, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 8, y + height - height / 10, - width / 4, height / 10); + g.fillOval(x + width / 2 - width / 8, y + height - height / 10, width / 4, height / 10); g.setColor(c); } @@ -588,8 +527,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent } public boolean editOndoubleClick(JFrame frame) { - JDialogELNComponentCapacitor jde = new JDialogELNComponentCapacitor( - this); + JDialogELNComponentCapacitor jde = new JDialogELNComponentCapacitor(this); jde.setVisible(true); return true; } @@ -630,8 +568,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -651,23 +588,16 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - value = Double.parseDouble(elt - .getAttribute("value")); + value = Double.parseDouble(elt.getAttribute("value")); q0 = Double.parseDouble(elt.getAttribute("q0")); unit0 = elt.getAttribute("unit0"); unit1 = elt.getAttribute("unit1"); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setVal(value); setQ0(q0); setUnit0(unit0); @@ -688,8 +618,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -844,8 +773,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -858,7 +786,6 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java b/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java index 7a613f6be3a27d6d8a17d5ec7494997566d2ccc8..993b933ac0c6d706e6fd73690e864fffc2d9fad9 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java @@ -49,18 +49,17 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; /** - * Class ELNComponentIdealTransformer Ideal transformer to be used in ELN - * diagrams Creation: 13/06/2018 - * + * Class ELNComponentIdealTransformer + * Ideal transformer to be used in ELN diagrams + * Creation: 13/06/2018 * @version 1.0 13/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentIdealTransformer extends - TGCScalableWithInternalComponent implements ActionListener, - SwallowedTGComponent, ELNComponent { +public class ELNComponentIdealTransformer extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -74,14 +73,11 @@ public class ELNComponentIdealTransformer extends private double ratio; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public ELNComponentIdealTransformer(int _x, int _y, int _minX, int _maxX, - int _minY, int _maxY, boolean _pos, TGComponent _father, - TDiagramPanel _tdp) { + public ELNComponentIdealTransformer(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(100, 100); @@ -113,14 +109,10 @@ public class ELNComponentIdealTransformer extends public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "p1"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "p2"); - connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "n1"); - connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "n2"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p1"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p2"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n1"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n2"); } public Color getMyColor() { @@ -134,10 +126,7 @@ public class ELNComponentIdealTransformer extends if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -200,18 +189,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 20 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 20 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 20 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 20 + sh3); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -228,18 +211,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 20 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 20 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 20 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 20 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -256,18 +233,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 20 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -284,18 +255,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 20 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); } } } else if (position == 1) { @@ -338,18 +303,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 20 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 20 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 20, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 20 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 20 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -366,18 +325,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 20 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 20 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 20, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 20 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 20 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -394,18 +347,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[3]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 20 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 20 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 20, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 20, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -422,18 +369,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[2]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 20 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 20 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 20, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 20, + y + height + sh2); } } } else if (position == 2) { @@ -476,18 +417,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 20 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -504,18 +439,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 20 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -532,18 +461,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 20 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 20 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 20 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 20 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -560,18 +483,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(19.0 / 20.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 20); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 20 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 20 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 20 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 20 + sh3); } } } else if (position == 3) { @@ -614,18 +531,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[2]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 20 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 20 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 20, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 20, + y + height + sh2); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -642,18 +553,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[3]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 20 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 20 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 20, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 20, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -670,18 +575,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 20 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 20 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 20, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 20 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 20 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -698,18 +597,12 @@ public class ELNComponentIdealTransformer extends ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 20 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 20, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 20 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 20, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 20 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 20 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); } } } @@ -720,61 +613,54 @@ public class ELNComponentIdealTransformer extends private void rotateTop(Graphics g) { Color c = g.getColor(); int[] ptx0 = { x, x + width / 5, x + width / 5, x + width / 5 }; - int[] pty0 = { y + height / 20, y + height / 20, y + height / 5, - y + height / 20 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height / 5, y + height / 20 }; g.drawPolygon(ptx0, pty0, 4); int[] ptx1 = { x, x + width / 5, x + width / 5, x + width / 5 }; - int[] pty1 = { y + height - height / 20, y + height - height / 20, - y + 4 * height / 5, y + height - height / 20 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5, + y + height - height / 20 }; g.drawPolygon(ptx1, pty1, 4); - int[] ptx2 = { x + width, x + 4 * width / 5, x + 4 * width / 5, - x + 4 * width / 5 }; - int[] pty2 = { y + height / 20, y + height / 20, y + height / 5, - y + height / 20 }; + int[] ptx2 = { x + width, x + 4 * width / 5, x + 4 * width / 5, x + 4 * width / 5 }; + int[] pty2 = { y + height / 20, y + height / 20, y + height / 5, y + height / 20 }; g.drawPolygon(ptx2, pty2, 4); - int[] ptx3 = { x + width, x + 4 * width / 5, x + 4 * width / 5, - x + 4 * width / 5 }; - int[] pty3 = { y + height - height / 20, y + height - height / 20, - y + 4 * height / 5, y + height - height / 20 }; + int[] ptx3 = { x + width, x + 4 * width / 5, x + 4 * width / 5, x + 4 * width / 5 }; + int[] pty3 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5, + y + height - height / 20 }; g.drawPolygon(ptx3, pty3, 4); g.drawArc(x, y + height / 5, 2 * width / 5, height / 5, 270, 180); g.drawArc(x, y + 2 * height / 5, 2 * width / 5, height / 5, 270, 180); g.drawArc(x, y + 3 * height / 5, 2 * width / 5, height / 5, 270, 180); - g.drawArc(x + 3 * width / 5, y + height / 5, 2 * width / 5, height / 5, - 90, 180); - g.drawArc(x + 3 * width / 5, y + 2 * height / 5, 2 * width / 5, - height / 5, 90, 180); - g.drawArc(x + 3 * width / 5, y + 3 * height / 5, 2 * width / 5, - height / 5, 90, 180); - g.drawOval(x + 2 * width / 5 - width / 20, y + width / 20, width / 10, - width / 10); - g.fillOval(x + 2 * width / 5 - width / 20, y + width / 20, width / 10, - width / 10); - g.drawOval(x + 3 * width / 5 - width / 20, y + width / 20, width / 10, - width / 10); - g.fillOval(x + 3 * width / 5 - width / 20, y + width / 20, width / 10, - width / 10); - g.drawArc(x + width / 5 + width / 10, y + 4 * height / 5, - 2 * width / 5, height / 5, 180, 180); + g.drawArc(x + 3 * width / 5, y + height / 5, 2 * width / 5, height / 5, 90, 180); + g.drawArc(x + 3 * width / 5, y + 2 * height / 5, 2 * width / 5, height / 5, 90, 180); + g.drawArc(x + 3 * width / 5, y + 3 * height / 5, 2 * width / 5, height / 5, 90, 180); + g.drawOval(x + 2 * width / 5 - width / 20, y + width / 20, width / 10, width / 10); + g.fillOval(x + 2 * width / 5 - width / 20, y + width / 20, width / 10, width / 10); + g.drawOval(x + 3 * width / 5 - width / 20, y + width / 20, width / 10, width / 10); + g.fillOval(x + 3 * width / 5 - width / 20, y + width / 20, width / 10, width / 10); + g.drawArc(x + width / 5 + width / 10, y + 4 * height / 5, 2 * width / 5, height / 5, 180, 180); int[] ptx4 = { x + width / 5 + width / 10, x + width / 5 + width / 10, x + width / 5 + width / 10 + width / 10 }; - int[] pty4 = { y + 4 * height / 5 + height / 10 + height / 10, - y + 4 * height / 5 + height / 10, + int[] pty4 = { y + 4 * height / 5 + height / 10 + height / 10, y + 4 * height / 5 + height / 10, y + 4 * height / 5 + height / 10 }; g.drawPolygon(ptx4, pty4, 3); g.fillPolygon(ptx4, pty4, 3); - int[] ptx5 = { x + width / 5 + width / 10 + 2 * width / 5, - x + width / 5 + width / 10 + 2 * width / 5, + int[] ptx5 = { x + width / 5 + width / 10 + 2 * width / 5, x + width / 5 + width / 10 + 2 * width / 5, x + width / 5 + width / 10 + 2 * width / 5 - width / 10 }; - int[] pty5 = { y + 4 * height / 5 + height / 10 + height / 10, - y + 4 * height / 5 + height / 10, + int[] pty5 = { y + 4 * height / 5 + height / 10 + height / 10, y + 4 * height / 5 + height / 10, y + 4 * height / 5 + height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); + int w = g.getFontMetrics().stringWidth(Double.toString(ratio)); int h = g.getFontMetrics().getAscent(); - g.drawString(Double.toString(ratio), x + (width - w) / 2, y + height - + height / 10 + h); + g.drawString(Double.toString(ratio), x + (width - w) / 2, y + height + height / 10 + h); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, width - width / 10, height + height / 10, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); g.fillOval(x, y, width / 10, height / 10); @@ -787,69 +673,62 @@ public class ELNComponentIdealTransformer extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(c); } private void rotateBottom(Graphics g) { Color c = g.getColor(); int[] ptx0 = { x, x + width / 5, x + width / 5, x + width / 5 }; - int[] pty0 = { y + height / 20, y + height / 20, y + height / 5, - y + height / 20 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height / 5, y + height / 20 }; g.drawPolygon(ptx0, pty0, 4); int[] ptx1 = { x, x + width / 5, x + width / 5, x + width / 5 }; - int[] pty1 = { y + height - height / 20, y + height - height / 20, - y + 4 * height / 5, y + height - height / 20 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5, + y + height - height / 20 }; g.drawPolygon(ptx1, pty1, 4); - int[] ptx2 = { x + width, x + 4 * width / 5, x + 4 * width / 5, - x + 4 * width / 5 }; - int[] pty2 = { y + height / 20, y + height / 20, y + height / 5, - y + height / 20 }; + int[] ptx2 = { x + width, x + 4 * width / 5, x + 4 * width / 5, x + 4 * width / 5 }; + int[] pty2 = { y + height / 20, y + height / 20, y + height / 5, y + height / 20 }; g.drawPolygon(ptx2, pty2, 4); - int[] ptx3 = { x + width, x + 4 * width / 5, x + 4 * width / 5, - x + 4 * width / 5 }; - int[] pty3 = { y + height - height / 20, y + height - height / 20, - y + 4 * height / 5, y + height - height / 20 }; + int[] ptx3 = { x + width, x + 4 * width / 5, x + 4 * width / 5, x + 4 * width / 5 }; + int[] pty3 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5, + y + height - height / 20 }; g.drawPolygon(ptx3, pty3, 4); g.drawArc(x, y + height / 5, 2 * width / 5, height / 5, 270, 180); g.drawArc(x, y + 2 * height / 5, 2 * width / 5, height / 5, 270, 180); g.drawArc(x, y + 3 * height / 5, 2 * width / 5, height / 5, 270, 180); - g.drawArc(x + 3 * width / 5, y + height / 5, 2 * width / 5, height / 5, - 90, 180); - g.drawArc(x + 3 * width / 5, y + 2 * height / 5, 2 * width / 5, - height / 5, 90, 180); - g.drawArc(x + 3 * width / 5, y + 3 * height / 5, 2 * width / 5, - height / 5, 90, 180); - g.drawOval(x + 2 * width / 5 - width / 20, y + width - width / 20 - - width / 10, width / 10, width / 10); - g.fillOval(x + 2 * width / 5 - width / 20, y + width - width / 20 - - width / 10, width / 10, width / 10); - g.drawOval(x + 3 * width / 5 - width / 20, y + width - width / 20 - - width / 10, width / 10, width / 10); - g.fillOval(x + 3 * width / 5 - width / 20, y + width - width / 20 - - width / 10, width / 10, width / 10); - g.drawArc(x + width / 5 + width / 10, y, 2 * width / 5, height / 5, 0, - 180); + g.drawArc(x + 3 * width / 5, y + height / 5, 2 * width / 5, height / 5, 90, 180); + g.drawArc(x + 3 * width / 5, y + 2 * height / 5, 2 * width / 5, height / 5, 90, 180); + g.drawArc(x + 3 * width / 5, y + 3 * height / 5, 2 * width / 5, height / 5, 90, 180); + g.drawOval(x + 2 * width / 5 - width / 20, y + width - width / 20 - width / 10, width / 10, width / 10); + g.fillOval(x + 2 * width / 5 - width / 20, y + width - width / 20 - width / 10, width / 10, width / 10); + g.drawOval(x + 3 * width / 5 - width / 20, y + width - width / 20 - width / 10, width / 10, width / 10); + g.fillOval(x + 3 * width / 5 - width / 20, y + width - width / 20 - width / 10, width / 10, width / 10); + g.drawArc(x + width / 5 + width / 10, y, 2 * width / 5, height / 5, 0, 180); int[] ptx4 = { x + width / 5 + width / 10, x + width / 5 + width / 10, x + width / 5 + width / 10 + width / 10 }; - int[] pty4 = { y + height / 5 - height / 10 - height / 10, - y + height / 5 - height / 10, y + height / 5 - height / 10 }; + int[] pty4 = { y + height / 5 - height / 10 - height / 10, y + height / 5 - height / 10, + y + height / 5 - height / 10 }; g.drawPolygon(ptx4, pty4, 3); g.fillPolygon(ptx4, pty4, 3); - int[] ptx5 = { x + width / 5 + width / 10 + 2 * width / 5, - x + width / 5 + width / 10 + 2 * width / 5, + int[] ptx5 = { x + width / 5 + width / 10 + 2 * width / 5, x + width / 5 + width / 10 + 2 * width / 5, x + width / 5 + width / 10 + 2 * width / 5 - width / 10 }; - int[] pty5 = { y + height / 5 - height / 10 - height / 10, - y + height / 5 - height / 10, y + height / 5 - height / 10 }; + int[] pty5 = { y + height / 5 - height / 10 - height / 10, y + height / 5 - height / 10, + y + height / 5 - height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); + int w = g.getFontMetrics().stringWidth(Double.toString(ratio)); - g.drawString(Double.toString(ratio), x + (width - w) / 2, y - height - / 20); + g.drawString(Double.toString(ratio), x + (width - w) / 2, y - height / 10); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, width - width / 10, height + height / 10, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); g.fillOval(x, y, width / 10, height / 10); @@ -862,71 +741,61 @@ public class ELNComponentIdealTransformer extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(c); } private void rotateRight(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 20, x + width / 20, x + width / 5, - x + width / 20 }; + int[] ptx0 = { x + width / 20, x + width / 20, x + width / 5, x + width / 20 }; int[] pty0 = { y, y + height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx0, pty0, 4); - int[] ptx1 = { x + width - width / 20, x + width - width / 20, - x + 4 * width / 5, x + width - width / 20 }; + int[] ptx1 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5, x + width - width / 20 }; int[] pty1 = { y, y + height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx1, pty1, 4); - int[] ptx2 = { x + width / 20, x + width / 20, x + width / 5, - x + width / 20 }; - int[] pty2 = { y + height, y + 4 * height / 5, y + 4 * height / 5, - y + 4 * height / 5 }; + int[] ptx2 = { x + width / 20, x + width / 20, x + width / 5, x + width / 20 }; + int[] pty2 = { y + height, y + 4 * height / 5, y + 4 * height / 5, y + 4 * height / 5 }; g.drawPolygon(ptx2, pty2, 4); - int[] ptx3 = { x + width - width / 20, x + width - width / 20, - x + 4 * width / 5, x + width - width / 20 }; - int[] pty3 = { y + height, y + 4 * height / 5, y + 4 * height / 5, - y + 4 * height / 5 }; + int[] ptx3 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5, x + width - width / 20 }; + int[] pty3 = { y + height, y + 4 * height / 5, y + 4 * height / 5, y + 4 * height / 5 }; g.drawPolygon(ptx3, pty3, 4); g.drawArc(x + width / 5, y, width / 5, 2 * height / 5, 180, 180); g.drawArc(x + 2 * width / 5, y, width / 5, 2 * height / 5, 180, 180); g.drawArc(x + 3 * width / 5, y, width / 5, 2 * height / 5, 180, 180); - g.drawArc(x + width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, - 0, 180); - g.drawArc(x + 2 * width / 5, y + 3 * height / 5, width / 5, - 2 * height / 5, 0, 180); - g.drawArc(x + 3 * width / 5, y + 3 * height / 5, width / 5, - 2 * height / 5, 0, 180); - g.drawOval(x + width - width / 10 - width / 20, y + 2 * height / 5 - - height / 20, width / 10, height / 10); - g.fillOval(x + width - width / 10 - width / 20, y + 2 * height / 5 - - height / 20, width / 10, height / 10); - g.drawOval(x + width - width / 10 - width / 20, y + 3 * height / 5 - - height / 20, width / 10, height / 10); - g.fillOval(x + width - width / 10 - width / 20, y + 3 * height / 5 - - height / 20, width / 10, height / 10); - g.drawArc(x, y + height / 5 + height / 10, width / 5, 2 * height / 5, - 90, 180); - int[] ptx4 = { x + width / 5 - width / 10 - width / 10, - x + width / 5 - width / 10, x + width / 5 - width / 10 }; - int[] pty4 = { y + height / 5 + height / 10, - y + height / 5 + height / 10, + g.drawArc(x + width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, 0, 180); + g.drawArc(x + 2 * width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, 0, 180); + g.drawArc(x + 3 * width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, 0, 180); + g.drawOval(x + width - width / 10 - width / 20, y + 2 * height / 5 - height / 20, width / 10, height / 10); + g.fillOval(x + width - width / 10 - width / 20, y + 2 * height / 5 - height / 20, width / 10, height / 10); + g.drawOval(x + width - width / 10 - width / 20, y + 3 * height / 5 - height / 20, width / 10, height / 10); + g.fillOval(x + width - width / 10 - width / 20, y + 3 * height / 5 - height / 20, width / 10, height / 10); + g.drawArc(x, y + height / 5 + height / 10, width / 5, 2 * height / 5, 90, 180); + int[] ptx4 = { x + width / 5 - width / 10 - width / 10, x + width / 5 - width / 10, + x + width / 5 - width / 10 }; + int[] pty4 = { y + height / 5 + height / 10, y + height / 5 + height / 10, y + height / 5 + height / 10 + height / 10 }; g.drawPolygon(ptx4, pty4, 3); g.fillPolygon(ptx4, pty4, 3); - int[] ptx5 = { x + width / 5 - width / 10 - width / 10, - x + width / 5 - width / 10, x + width / 5 - width / 10 }; - int[] pty5 = { y + height / 5 + height / 10 + 2 * height / 5, - y + height / 5 + height / 10 + 2 * height / 5, + int[] ptx5 = { x + width / 5 - width / 10 - width / 10, x + width / 5 - width / 10, + x + width / 5 - width / 10 }; + int[] pty5 = { y + height / 5 + height / 10 + 2 * height / 5, y + height / 5 + height / 10 + 2 * height / 5, y + height / 5 + height / 10 + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); + int w = g.getFontMetrics().stringWidth(Double.toString(ratio)); int h = g.getFontMetrics().getAscent(); - g.drawString(Double.toString(ratio), x - width / 10 - w, y + height / 2 - + h / 2); + g.drawString(Double.toString(ratio), x - width / 10 - w, y + height / 2 + h / 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, height - height / 10, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); g.fillOval(x, y, width / 10, height / 10); @@ -939,70 +808,60 @@ public class ELNComponentIdealTransformer extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(c); } private void rotateLeft(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 20, x + width / 20, x + width / 5, - x + width / 20 }; + int[] ptx0 = { x + width / 20, x + width / 20, x + width / 5, x + width / 20 }; int[] pty0 = { y, y + height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx0, pty0, 4); - int[] ptx1 = { x + width - width / 20, x + width - width / 20, - x + 4 * width / 5, x + width - width / 20 }; + int[] ptx1 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5, x + width - width / 20 }; int[] pty1 = { y, y + height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx1, pty1, 4); - int[] ptx2 = { x + width / 20, x + width / 20, x + width / 5, - x + width / 20 }; - int[] pty2 = { y + height, y + 4 * height / 5, y + 4 * height / 5, - y + 4 * height / 5 }; + int[] ptx2 = { x + width / 20, x + width / 20, x + width / 5, x + width / 20 }; + int[] pty2 = { y + height, y + 4 * height / 5, y + 4 * height / 5, y + 4 * height / 5 }; g.drawPolygon(ptx2, pty2, 4); - int[] ptx3 = { x + width - width / 20, x + width - width / 20, - x + 4 * width / 5, x + width - width / 20 }; - int[] pty3 = { y + height, y + 4 * height / 5, y + 4 * height / 5, - y + 4 * height / 5 }; + int[] ptx3 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5, x + width - width / 20 }; + int[] pty3 = { y + height, y + 4 * height / 5, y + 4 * height / 5, y + 4 * height / 5 }; g.drawPolygon(ptx3, pty3, 4); g.drawArc(x + width / 5, y, width / 5, 2 * height / 5, 180, 180); g.drawArc(x + 2 * width / 5, y, width / 5, 2 * height / 5, 180, 180); g.drawArc(x + 3 * width / 5, y, width / 5, 2 * height / 5, 180, 180); - g.drawArc(x + width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, - 0, 180); - g.drawArc(x + 2 * width / 5, y + 3 * height / 5, width / 5, - 2 * height / 5, 0, 180); - g.drawArc(x + 3 * width / 5, y + 3 * height / 5, width / 5, - 2 * height / 5, 0, 180); - g.drawOval(x + width / 20, y + 2 * height / 5 - height / 20, - width / 10, height / 10); - g.fillOval(x + width / 20, y + 2 * height / 5 - height / 20, - width / 10, height / 10); - g.drawOval(x + width / 20, y + 3 * height / 5 - height / 20, - width / 10, height / 10); - g.fillOval(x + width / 20, y + 3 * height / 5 - height / 20, - width / 10, height / 10); - g.drawArc(x + 4 * width / 5, y + height / 5 + height / 10, width / 5, - 2 * height / 5, 270, 180); - int[] ptx4 = { x + 4 * width / 5 + width / 10 + width / 10, - x + 4 * width / 5 + width / 10, x + 4 * width / 5 + width / 10 }; - int[] pty4 = { y + height / 5 + height / 10, - y + height / 5 + height / 10, + g.drawArc(x + width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, 0, 180); + g.drawArc(x + 2 * width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, 0, 180); + g.drawArc(x + 3 * width / 5, y + 3 * height / 5, width / 5, 2 * height / 5, 0, 180); + g.drawOval(x + width / 20, y + 2 * height / 5 - height / 20, width / 10, height / 10); + g.fillOval(x + width / 20, y + 2 * height / 5 - height / 20, width / 10, height / 10); + g.drawOval(x + width / 20, y + 3 * height / 5 - height / 20, width / 10, height / 10); + g.fillOval(x + width / 20, y + 3 * height / 5 - height / 20, width / 10, height / 10); + g.drawArc(x + 4 * width / 5, y + height / 5 + height / 10, width / 5, 2 * height / 5, 270, 180); + int[] ptx4 = { x + 4 * width / 5 + width / 10 + width / 10, x + 4 * width / 5 + width / 10, + x + 4 * width / 5 + width / 10 }; + int[] pty4 = { y + height / 5 + height / 10, y + height / 5 + height / 10, y + height / 5 + height / 10 + height / 10 }; g.drawPolygon(ptx4, pty4, 3); g.fillPolygon(ptx4, pty4, 3); - int[] ptx5 = { x + 4 * width / 5 + width / 10 + width / 10, - x + 4 * width / 5 + width / 10, x + 4 * width / 5 + width / 10 }; - int[] pty5 = { y + height / 5 + height / 10 + 2 * height / 5, - y + height / 5 + height / 10 + 2 * height / 5, + int[] ptx5 = { x + 4 * width / 5 + width / 10 + width / 10, x + 4 * width / 5 + width / 10, + x + 4 * width / 5 + width / 10 }; + int[] pty5 = { y + height / 5 + height / 10 + 2 * height / 5, y + height / 5 + height / 10 + 2 * height / 5, y + height / 5 + height / 10 + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx5, pty5, 3); g.fillPolygon(ptx5, pty5, 3); + int h = g.getFontMetrics().getAscent(); - g.drawString(Double.toString(ratio), x + width + width / 10, y + height - / 2 + h / 2); + g.drawString(Double.toString(ratio), x + width + width / 10, y + height / 2 + h / 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, height - height / 10, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 10, height / 10); g.setColor(Color.WHITE); g.fillOval(x, y, width / 10, height / 10); @@ -1015,11 +874,9 @@ public class ELNComponentIdealTransformer extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 10, width / 10, height / 10); g.setColor(c); - g.drawOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height - height / 10, - width / 10, height / 10); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); g.setColor(c); } @@ -1035,8 +892,7 @@ public class ELNComponentIdealTransformer extends } public boolean editOndoubleClick(JFrame frame) { - JDialogELNComponentIdealTransformer jde = new JDialogELNComponentIdealTransformer( - this); + JDialogELNComponentIdealTransformer jde = new JDialogELNComponentIdealTransformer(this); jde.setVisible(true); return true; } @@ -1055,8 +911,7 @@ public class ELNComponentIdealTransformer extends return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -1075,20 +930,13 @@ public class ELNComponentIdealTransformer extends if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - ratio = Double.parseDouble(elt - .getAttribute("ratio")); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + ratio = Double.parseDouble(elt.getAttribute("ratio")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setRatio(ratio); setPosition(position); setFv_0_2(fv_0_2); @@ -1106,8 +954,7 @@ public class ELNComponentIdealTransformer extends } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -1238,8 +1085,7 @@ public class ELNComponentIdealTransformer extends if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -1252,7 +1098,6 @@ public class ELNComponentIdealTransformer extends myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java index edfe1b00493ffd31070d1ebe35d5fd44e8c5f377..131db85538ab05d3cae4637b05c4073114c13695 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java @@ -51,16 +51,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** - * Class ELNComponentIndependentCurrentSource Independent current source to be - * used in ELN diagrams Creation: 15/06/2018 - * + * Class ELNComponentIndependentCurrentSource + * Independent current source to be used in ELN diagrams + * Creation: 15/06/2018 * @version 1.0 15/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentIndependentCurrentSource extends - TGCScalableWithInternalComponent implements ActionListener, - SwallowedTGComponent, ELNComponent { +public class ELNComponentIndependentCurrentSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -71,20 +69,16 @@ public class ELNComponentIndependentCurrentSource extends private double dtextX = 0.0; protected int decPoint = 3; - private double initValue, offset, amplitude, frequency, phase, acAmplitude, - acPhase, acNoiseAmplitude; + private double initValue, offset, amplitude, frequency, phase, acAmplitude, acPhase, acNoiseAmplitude; private String delay; private String unit0; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public 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); @@ -125,10 +119,8 @@ public class ELNComponentIndependentCurrentSource extends public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "p"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "n"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); } public Color getMyColor() { @@ -142,10 +134,7 @@ public class ELNComponentIndependentCurrentSource extends if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -198,12 +187,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 3 + width / 6, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -216,13 +202,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + 2 * width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + 2 * width / 3 + width / 6, y + height - + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -235,12 +217,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 3 + width / 6, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -253,13 +232,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + 2 * width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + 2 * width / 3 + width / 6, y + height - + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh0); } } } else if (position == 1) { @@ -294,12 +269,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 3 + height / 6 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 3 + height / 6 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -312,14 +285,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + 2 * height / 3 + height / 6 - + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + 2 * height / 3 + height / 6 - + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + 2 * height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -332,12 +301,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 3 + height / 6 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 3 + height / 6 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -350,14 +317,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + 2 * height / 3 + height / 6 - + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + 2 * height / 3 + height / 6 - + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + 2 * height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh1); } } } else if (position == 2) { @@ -390,13 +353,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + 2 * width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + 2 * width / 3 + width / 6, y + height - + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -409,12 +368,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 3 + width / 6, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -427,13 +383,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(2.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + 2 * width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + 2 * width / 3 + width / 6, y + height - + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + 2 * width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + 2 * width / 3 + width / 6, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -446,12 +398,9 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 3.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 3 + width / 6, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 3 + width / 6, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 3 + width / 6, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 3 + width / 6, + y + height + sh1); } } } else if (position == 3) { @@ -486,14 +435,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + 2 * height / 3 + height / 6 - + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + 2 * height / 3 + height / 6 - + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + 2 * height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -506,12 +451,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 3 + height / 6 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 3 + height / 6 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -524,14 +467,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(2.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + 2 * height / 3 + height / 6 - + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + 2 * height / 3 + height / 6 - + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + 2 * height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + 2 * height / 3 + height / 6 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -544,12 +483,10 @@ public class ELNComponentIndependentCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 3.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 3 + height / 6 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 3 + height / 6 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 3 + height / 6 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 3 + height / 6 + sh0); } } } @@ -569,27 +506,20 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, 2 * width / 3, height / 2); - int[] ptx3 = { x + 2 * width / 3 + width / 6, - x + 2 * width / 3 + width / 6, - x + 2 * width / 3 + width / 6 - width / 12, - x + 2 * width / 3 + width / 6, - x + 2 * width / 3 + width / 6 + width / 12, - x + 2 * width / 3 + width / 6 }; - int[] pty3 = { y + height / 4, y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8, y + 3 * height / 4, - y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8 }; + int[] ptx3 = { x + 2 * width / 3 + width / 6, x + 2 * width / 3 + width / 6, + x + 2 * width / 3 + width / 6 - width / 12, x + 2 * width / 3 + width / 6, + x + 2 * width / 3 + width / 6 + width / 12, x + 2 * width / 3 + width / 6 }; + int[] pty3 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, + y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); g.drawOval(x + width / 3 - width / 12, y, width / 6, height / 8); g.setColor(Color.WHITE); g.fillOval(x + width / 3 - width / 12, y, width / 6, height / 8); g.setColor(c); - g.drawOval(x + width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.drawOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.fillOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(c); } @@ -605,14 +535,10 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, 2 * width / 3, height / 2); - int[] ptx3 = { x + 2 * width / 3 + width / 6, - x + 2 * width / 3 + width / 6, - x + 2 * width / 3 + width / 6 - width / 12, - x + 2 * width / 3 + width / 6, - x + 2 * width / 3 + width / 6 + width / 12, - x + 2 * width / 3 + width / 6 }; - int[] pty3 = { y + 3 * height / 4, y + height / 4 + height / 8, - y + height / 4 + height / 8, y + height / 4, + int[] ptx3 = { x + 2 * width / 3 + width / 6, x + 2 * width / 3 + width / 6, + x + 2 * width / 3 + width / 6 - width / 12, x + 2 * width / 3 + width / 6, + x + 2 * width / 3 + width / 6 + width / 12, x + 2 * width / 3 + width / 6 }; + int[] pty3 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); @@ -620,11 +546,9 @@ public class ELNComponentIndependentCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x + width / 3 - width / 12, y, width / 6, height / 8); g.setColor(c); - g.drawOval(x + width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.drawOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.fillOval(x + width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(c); } @@ -640,11 +564,9 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 3, y + height / 4, 2 * width / 3, height / 2); - int[] ptx3 = { x + width / 6, x + width / 6, - x + width / 6 - width / 12, x + width / 6, + int[] ptx3 = { x + width / 6, x + width / 6, x + width / 6 - width / 12, x + width / 6, x + width / 6 + width / 12, x + width / 6 }; - int[] pty3 = { y + 3 * height / 4, y + height / 4 + height / 8, - y + height / 4 + height / 8, y + height / 4, + int[] pty3 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); @@ -652,11 +574,9 @@ public class ELNComponentIndependentCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x + 2 * width / 3 - width / 12, y, width / 6, height / 8); g.setColor(c); - g.drawOval(x + 2 * width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.drawOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + 2 * width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.fillOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(c); } @@ -672,24 +592,19 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 3, y + height / 4, 2 * width / 3, height / 2); - int[] ptx3 = { x + width / 6, x + width / 6, - x + width / 6 - width / 12, x + width / 6, + int[] ptx3 = { x + width / 6, x + width / 6, x + width / 6 - width / 12, x + width / 6, x + width / 6 + width / 12, x + width / 6 }; - int[] pty3 = { y + height / 4, y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8, y + 3 * height / 4, - y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8 }; + int[] pty3 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, + y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); g.drawOval(x + 2 * width / 3 - width / 12, y, width / 6, height / 8); g.setColor(Color.WHITE); g.fillOval(x + 2 * width / 3 - width / 12, y, width / 6, height / 8); g.setColor(c); - g.drawOval(x + 2 * width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.drawOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + 2 * width / 3 - width / 12, y + height - height / 8, - width / 6, height / 8); + g.fillOval(x + 2 * width / 3 - width / 12, y + height - height / 8, width / 6, height / 8); g.setColor(c); } @@ -705,26 +620,20 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y, y + 2 * height / 3 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, 2 * height / 3); - int[] ptx3 = { x + 3 * width / 4, x + width / 4 + width / 8, - x + width / 4 + width / 8, x + width / 4, + int[] ptx3 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty3 = { y + 2 * height / 3 + height / 6, - y + 2 * height / 3 + height / 6, - y + 2 * height / 3 + height / 6 - height / 12, - y + 2 * height / 3 + height / 6, - y + 2 * height / 3 + height / 6 + height / 12, - y + 2 * height / 3 + height / 6 }; + int[] pty3 = { y + 2 * height / 3 + height / 6, y + 2 * height / 3 + height / 6, + y + 2 * height / 3 + height / 6 - height / 12, y + 2 * height / 3 + height / 6, + y + 2 * height / 3 + height / 6 + height / 12, y + 2 * height / 3 + height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); g.drawOval(x, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); g.fillOval(x, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(c); - g.drawOval(x + width - width / 8, y + height / 3 - height / 12, - width / 8, height / 6); + g.drawOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height / 3 - height / 12, - width / 8, height / 6); + g.fillOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(c); } @@ -740,26 +649,20 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y + height / 3, y + height }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y + height / 3, width / 2, 2 * height / 3); - int[] ptx3 = { x + 3 * width / 4, x + width / 4 + width / 8, - x + width / 4 + width / 8, x + width / 4, + int[] ptx3 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty3 = { y + height / 3 - height / 6, - y + height / 3 - height / 6, - y + height / 3 - height / 6 - height / 12, - y + height / 3 - height / 6, - y + height / 3 - height / 6 + height / 12, - y + height / 3 - height / 6 }; + int[] pty3 = { y + height / 3 - height / 6, y + height / 3 - height / 6, + y + height / 3 - height / 6 - height / 12, y + height / 3 - height / 6, + y + height / 3 - height / 6 + height / 12, y + height / 3 - height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); g.drawOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); g.fillOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(c); - g.drawOval(x + width - width / 8, y + 2 * height / 3 - height / 12, - width / 8, height / 6); + g.drawOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + 2 * height / 3 - height / 12, - width / 8, height / 6); + g.fillOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(c); } @@ -775,26 +678,20 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y + height / 3, y + height }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y + height / 3, width / 2, 2 * height / 3); - int[] ptx3 = { x + width / 4, x + 3 * width / 4 - width / 8, - x + 3 * width / 4 - width / 8, x + 3 * width / 4, + int[] ptx3 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty3 = { y + height / 3 - height / 6, - y + height / 3 - height / 6, - y + height / 3 - height / 6 - height / 12, - y + height / 3 - height / 6, - y + height / 3 - height / 6 + height / 12, - y + height / 3 - height / 6 }; + int[] pty3 = { y + height / 3 - height / 6, y + height / 3 - height / 6, + y + height / 3 - height / 6 - height / 12, y + height / 3 - height / 6, + y + height / 3 - height / 6 + height / 12, y + height / 3 - height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); g.drawOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); g.fillOval(x, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(c); - g.drawOval(x + width - width / 8, y + 2 * height / 3 - height / 12, - width / 8, height / 6); + g.drawOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + 2 * height / 3 - height / 12, - width / 8, height / 6); + g.fillOval(x + width - width / 8, y + 2 * height / 3 - height / 12, width / 8, height / 6); g.setColor(c); } @@ -810,26 +707,20 @@ public class ELNComponentIndependentCurrentSource extends int[] pty2 = { y, y + 2 * height / 3 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, 2 * height / 3); - int[] ptx3 = { x + width / 4, x + 3 * width / 4 - width / 8, - x + 3 * width / 4 - width / 8, x + 3 * width / 4, + int[] ptx3 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty3 = { y + 2 * height / 3 + height / 6, - y + 2 * height / 3 + height / 6, - y + 2 * height / 3 + height / 6 - height / 12, - y + 2 * height / 3 + height / 6, - y + 2 * height / 3 + height / 6 + height / 12, - y + 2 * height / 3 + height / 6 }; + int[] pty3 = { y + 2 * height / 3 + height / 6, y + 2 * height / 3 + height / 6, + y + 2 * height / 3 + height / 6 - height / 12, y + 2 * height / 3 + height / 6, + y + 2 * height / 3 + height / 6 + height / 12, y + 2 * height / 3 + height / 6 }; g.drawPolygon(ptx3, pty3, 6); g.fillPolygon(ptx3, pty3, 6); g.drawOval(x, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); g.fillOval(x, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(c); - g.drawOval(x + width - width / 8, y + height / 3 - height / 12, - width / 8, height / 6); + g.drawOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height / 3 - height / 12, - width / 8, height / 6); + g.fillOval(x + width - width / 8, y + height / 3 - height / 12, width / 8, height / 6); g.setColor(c); } @@ -845,8 +736,7 @@ public class ELNComponentIndependentCurrentSource extends } public boolean editOndoubleClick(JFrame frame) { - JDialogELNComponentIndependentCurrentSource jde = new JDialogELNComponentIndependentCurrentSource( - this); + JDialogELNComponentIndependentCurrentSource jde = new JDialogELNComponentIndependentCurrentSource(this); jde.setVisible(true); return true; } @@ -891,8 +781,7 @@ public class ELNComponentIndependentCurrentSource extends return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -913,36 +802,22 @@ public class ELNComponentIndependentCurrentSource extends if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - initValue = Double.parseDouble(elt - .getAttribute("init_value")); - offset = Double.parseDouble(elt - .getAttribute("offset")); - amplitude = Double.parseDouble(elt - .getAttribute("amplitude")); - frequency = Double.parseDouble(elt - .getAttribute("frequency")); + initValue = Double.parseDouble(elt.getAttribute("init_value")); + offset = Double.parseDouble(elt.getAttribute("offset")); + amplitude = Double.parseDouble(elt.getAttribute("amplitude")); + frequency = Double.parseDouble(elt.getAttribute("frequency")); unit0 = elt.getAttribute("unit0"); - phase = Double.parseDouble(elt - .getAttribute("phase")); + phase = Double.parseDouble(elt.getAttribute("phase")); delay = elt.getAttribute("delay"); - acAmplitude = Double.parseDouble(elt - .getAttribute("ac_amplitude")); - acPhase = Double.parseDouble(elt - .getAttribute("ac_phase")); - acNoiseAmplitude = Double.parseDouble(elt - .getAttribute("ac_noise_amplitude")); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + acAmplitude = Double.parseDouble(elt.getAttribute("ac_amplitude")); + acPhase = Double.parseDouble(elt.getAttribute("ac_phase")); + acNoiseAmplitude = Double.parseDouble(elt.getAttribute("ac_noise_amplitude")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setInitValue(initValue); setOffset(offset); setAmplitude(amplitude); @@ -969,8 +844,7 @@ public class ELNComponentIndependentCurrentSource extends } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -1173,8 +1047,7 @@ public class ELNComponentIndependentCurrentSource extends if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -1187,7 +1060,6 @@ public class ELNComponentIndependentCurrentSource extends myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java index 859d15414aeb698e1f67c5f7fe994e56024899b8..8ba943f6f7d7553f17c34f743697b28d5c877d01 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java @@ -51,16 +51,14 @@ 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, - SwallowedTGComponent, ELNComponent { +public class ELNComponentIndependentVoltageSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -71,20 +69,16 @@ public class ELNComponentIndependentVoltageSource extends private double dtextX = 0.0; protected int decPoint = 3; - private double initValue, offset, amplitude, frequency, phase, acAmplitude, - acPhase, acNoiseAmplitude; + private double initValue, offset, amplitude, frequency, phase, acAmplitude, acPhase, acNoiseAmplitude; private String delay; private String unit0; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public ELNComponentIndependentVoltageSource(int _x, int _y, int _minX, - int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, - TDiagramPanel _tdp) { + public ELNComponentIndependentVoltageSource(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(40, 80); @@ -125,10 +119,8 @@ public class ELNComponentIndependentVoltageSource extends public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "p"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "n"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); } public Color getMyColor() { @@ -142,10 +134,7 @@ public class ELNComponentIndependentVoltageSource extends if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -198,12 +187,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -216,12 +202,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -234,12 +217,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -252,12 +232,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } } else if (position == 1) { @@ -292,12 +269,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -310,12 +285,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -328,12 +301,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -346,12 +317,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } } else if (position == 2) { @@ -384,12 +353,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -402,12 +368,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -420,12 +383,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -438,12 +398,9 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 4, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 4, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 4, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 4, + y + height + sh1); } } } else if (position == 3) { @@ -478,12 +435,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -496,12 +451,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw1, y + height / 2 + height / 4 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw1, + y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 4 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -514,12 +467,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -532,12 +483,10 @@ public class ELNComponentIndependentVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw0, y + height / 2 + height / 4 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 4 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw0, + y + height / 2 + height / 4 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 4 + sh1); } } } @@ -550,31 +499,24 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width / 2 + width / 4, - x + width / 2 + width / 4 + width / 8, - x + width / 2 + width / 4 + width / 8, - x + width / 2 + width / 4 + width / 8, + int[] ptx1 = { x + width / 2 + width / 4, x + width / 2 + width / 4 + width / 8, + 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 + height / 4 - height / 8, - y + height / 4 - height / 8, - y + height / 4 - height / 8 - width / 8, - y + height / 4 - height / 8 + width / 8, + int[] pty1 = { y + height / 4 - height / 8, y + height / 4 - height / 8, + y + height / 4 - height / 8 - width / 8, y + height / 4 - height / 8 + width / 8, y + height / 4 - height / 8, y + height / 4 - height / 8 }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 2 + width / 4, x + width }; - int[] pty2 = { y + 3 * height / 4 + height / 8, - y + 3 * height / 4 + height / 8 }; + int[] pty2 = { y + 3 * height / 4 + height / 8, y + 3 * height / 4 + height / 8 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, width, height / 2); g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 8); g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); g.setColor(c); - g.drawOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(c); } @@ -583,17 +525,12 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width / 2 + width / 4, - x + width / 2 + width / 4 + width / 8, - x + width / 2 + width / 4 + width / 8, - x + width / 2 + width / 4 + width / 8, + int[] ptx1 = { x + width / 2 + width / 4, x + width / 2 + width / 4 + width / 8, + 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, - y + 3 * height / 4 + height / 8 }; + 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, y + 3 * height / 4 + height / 8 }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 2 + width / 4, x + width }; int[] pty2 = { y + height / 8, y + height / 8 }; @@ -603,11 +540,9 @@ public class ELNComponentIndependentVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); g.setColor(c); - g.drawOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(c); } @@ -616,17 +551,12 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width / 2 - width / 4, - x + width / 2 - width / 4 - width / 8, - x + width / 2 - width / 4 - width / 8, - x + width / 2 - width / 4 - width / 8, + int[] ptx1 = { x + width / 2 - width / 4, x + width / 2 - width / 4 - width / 8, + x + width / 2 - width / 4 - width / 8, x + width / 2 - width / 4 - width / 8, x + width / 2 - width / 4 - width / 8, x }; - 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, - y + 3 * height / 4 + height / 8 }; + 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, y + 3 * height / 4 + height / 8 }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 2 - width / 4, x }; int[] pty2 = { y + height / 4 - height / 8, y + height / 4 - height / 8 }; @@ -636,11 +566,9 @@ public class ELNComponentIndependentVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); g.setColor(c); - g.drawOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(c); } @@ -649,29 +577,23 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x + width / 2, x + width / 2 }; int[] pty0 = { y, y + height }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width / 2 - width / 4, - x + width / 2 - width / 4 - width / 8, - x + width / 2 - width / 4 - width / 8, - x + width / 2 - width / 4 - width / 8, + int[] ptx1 = { x + width / 2 - width / 4, x + width / 2 - width / 4 - width / 8, + x + width / 2 - width / 4 - width / 8, x + width / 2 - width / 4 - width / 8, x + width / 2 - width / 4 - width / 8, x }; - int[] pty1 = { y + height / 8, y + height / 8, - y + height / 8 + width / 8, y + height / 8 - width / 8, + int[] pty1 = { y + height / 8, y + height / 8, y + height / 8 + width / 8, y + height / 8 - width / 8, y + height / 8, y + height / 8 }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 2 - width / 4, x }; - int[] pty2 = { y + 3 * height / 4 + height / 8, - y + 3 * height / 4 + height / 8 }; + int[] pty2 = { y + 3 * height / 4 + height / 8, y + 3 * height / 4 + height / 8 }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x, y + height / 4, width, height / 2); g.drawOval(x + width / 2 - width / 8, y, width / 4, height / 8); g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 8, y, width / 4, height / 8); g.setColor(c); - g.drawOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.drawOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 8, y + height - height / 8, - width / 4, height / 8); + g.fillOval(x + width / 2 - width / 8, y + height - height / 8, width / 4, height / 8); g.setColor(c); } @@ -680,14 +602,10 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; 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 / 2 + height / 4, - y + height / 2 + height / 4 + height / 8, - y + height / 2 + height / 4 + height / 8, - y + height / 2 + height / 4 + height / 8, + 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 / 2 + height / 4, y + height / 2 + height / 4 + height / 8, + y + height / 2 + height / 4 + height / 8, y + height / 2 + height / 4 + height / 8, y + height / 2 + height / 4 + height / 8, y + height }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 8, x + width / 8 }; @@ -698,11 +616,9 @@ public class ELNComponentIndependentVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); - g.drawOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); } @@ -711,13 +627,10 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; 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[] 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 }; g.drawPolygon(ptx1, pty1, 6); int[] ptx2 = { x + width / 8, x + width / 8 }; int[] pty2 = { y + height / 4, y }; @@ -727,11 +640,9 @@ public class ELNComponentIndependentVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); - g.drawOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); } @@ -740,18 +651,13 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width / 4 - width / 8, x + width / 4 - width / 8, - x + width / 4 - width / 8 - height / 8, - x + width / 4 - width / 8 + height / 8, - x + width / 4 - width / 8, x + width / 4 - width / 8 }; - int[] pty1 = { y + height / 2 - height / 4, - y + height / 2 - height / 4 - height / 8, - y + height / 2 - height / 4 - height / 8, - y + height / 2 - height / 4 - height / 8, + int[] ptx1 = { x + width / 4 - width / 8, x + width / 4 - width / 8, x + width / 4 - width / 8 - height / 8, + x + width / 4 - width / 8 + height / 8, x + width / 4 - width / 8, x + width / 4 - width / 8 }; + int[] pty1 = { y + height / 2 - height / 4, y + height / 2 - height / 4 - height / 8, + y + height / 2 - height / 4 - height / 8, y + height / 2 - height / 4 - height / 8, y + height / 2 - height / 4 - height / 8, y }; g.drawPolygon(ptx1, pty1, 6); - int[] ptx2 = { x + 3 * width / 4 + width / 8, - x + 3 * width / 4 + width / 8 }; + int[] ptx2 = { x + 3 * width / 4 + width / 8, x + 3 * width / 4 + width / 8 }; int[] pty2 = { y + height / 2 - height / 4, y }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, height); @@ -759,11 +665,9 @@ public class ELNComponentIndependentVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); - g.drawOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); } @@ -772,18 +676,13 @@ public class ELNComponentIndependentVoltageSource extends int[] ptx0 = { x, x + width }; int[] pty0 = { y + height / 2, y + height / 2 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width / 4 - width / 8, x + width / 4 - width / 8, - x + width / 4 - width / 8 - height / 8, - x + width / 4 - width / 8 + height / 8, - x + width / 4 - width / 8, x + width / 4 - width / 8 }; - int[] pty1 = { y + height / 2 + height / 4, - y + height / 2 + height / 4 + height / 8, - y + height / 2 + height / 4 + height / 8, - y + height / 2 + height / 4 + height / 8, + int[] ptx1 = { x + width / 4 - width / 8, x + width / 4 - width / 8, x + width / 4 - width / 8 - height / 8, + x + width / 4 - width / 8 + height / 8, x + width / 4 - width / 8, x + width / 4 - width / 8 }; + int[] pty1 = { y + height / 2 + height / 4, y + height / 2 + height / 4 + height / 8, + y + height / 2 + height / 4 + height / 8, y + height / 2 + height / 4 + height / 8, y + height / 2 + height / 4 + height / 8, y + height }; g.drawPolygon(ptx1, pty1, 6); - int[] ptx2 = { x + 3 * width / 4 + width / 8, - x + 3 * width / 4 + width / 8 }; + int[] ptx2 = { x + 3 * width / 4 + width / 8, x + 3 * width / 4 + width / 8 }; int[] pty2 = { y + height / 2 + height / 4, y + height }; g.drawPolygon(ptx2, pty2, 2); g.drawOval(x + width / 4, y, width / 2, height); @@ -791,11 +690,9 @@ public class ELNComponentIndependentVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); - g.drawOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.drawOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height / 2 - height / 8, - width / 8, height / 4); + g.fillOval(x + width - width / 8, y + height / 2 - height / 8, width / 8, height / 4); g.setColor(c); } @@ -811,8 +708,7 @@ public class ELNComponentIndependentVoltageSource extends } public boolean editOndoubleClick(JFrame frame) { - JDialogELNComponentIndependentVoltageSource jde = new JDialogELNComponentIndependentVoltageSource( - this); + JDialogELNComponentIndependentVoltageSource jde = new JDialogELNComponentIndependentVoltageSource(this); jde.setVisible(true); return true; } @@ -859,8 +755,7 @@ public class ELNComponentIndependentVoltageSource extends return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -881,40 +776,24 @@ public class ELNComponentIndependentVoltageSource extends if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - initValue = Double.parseDouble(elt - .getAttribute("init_value")); - offset = Double.parseDouble(elt - .getAttribute("offset")); - amplitude = Double.parseDouble(elt - .getAttribute("amplitude")); - frequency = Double.parseDouble(elt - .getAttribute("frequency")); + initValue = Double.parseDouble(elt.getAttribute("init_value")); + offset = Double.parseDouble(elt.getAttribute("offset")); + amplitude = Double.parseDouble(elt.getAttribute("amplitude")); + frequency = Double.parseDouble(elt.getAttribute("frequency")); unit0 = elt.getAttribute("unit0"); - phase = Double.parseDouble(elt - .getAttribute("phase")); + phase = Double.parseDouble(elt.getAttribute("phase")); delay = elt.getAttribute("delay"); - acAmplitude = Double.parseDouble(elt - .getAttribute("ac_amplitude")); - acPhase = Double.parseDouble(elt - .getAttribute("ac_phase")); - acNoiseAmplitude = Double.parseDouble(elt - .getAttribute("ac_noise_amplitude")); - position = Integer.parseInt(elt - .getAttribute("position")); - width = Integer.parseInt(elt - .getAttribute("width")); - height = Integer.parseInt(elt - .getAttribute("height")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + acAmplitude = Double.parseDouble(elt.getAttribute("ac_amplitude")); + acPhase = Double.parseDouble(elt.getAttribute("ac_phase")); + acNoiseAmplitude = Double.parseDouble(elt.getAttribute("ac_noise_amplitude")); + position = Integer.parseInt(elt.getAttribute("position")); + width = Integer.parseInt(elt.getAttribute("width")); + height = Integer.parseInt(elt.getAttribute("height")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setInitValue(initValue); setOffset(offset); setAmplitude(amplitude); @@ -943,8 +822,7 @@ public class ELNComponentIndependentVoltageSource extends } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -1147,8 +1025,7 @@ public class ELNComponentIndependentVoltageSource extends if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -1161,7 +1038,6 @@ public class ELNComponentIndependentVoltageSource extends myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java index 17837dbea581286258bf24d62c742be43f900fb9..456ac441c141e2257fed609ff23f36e9ca01ed9a 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java @@ -52,15 +52,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** - * Class ELNComponentInductor Inductor to be used in ELN diagrams Creation: - * 12/06/2018 - * + * Class ELNComponentInductor + * Inductor to be used in ELN diagrams + * Creation: 12/06/2018 * @version 1.0 12/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentInductor extends TGCScalableWithInternalComponent - implements ActionListener, SwallowedTGComponent, ELNComponent { +public class ELNComponentInductor extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -75,14 +74,11 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent private String unit0, unit1; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public ELNComponentInductor(int _x, int _y, int _minX, int _maxX, - int _minY, int _maxY, boolean _pos, TGComponent _father, - TDiagramPanel _tdp) { + public ELNComponentInductor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(100, 20); @@ -117,10 +113,8 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "p"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "n"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); } public Color getMyColor() { @@ -134,10 +128,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -192,12 +183,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -210,12 +199,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -228,12 +215,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -246,12 +231,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } } else if (position == 1) { @@ -284,12 +267,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -302,12 +282,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -320,12 +297,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -338,12 +312,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } } else if (position == 2) { @@ -378,12 +349,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -396,12 +365,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -414,12 +381,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -432,12 +397,10 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } } else if (position == 3) { @@ -470,12 +433,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -488,12 +448,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -506,12 +463,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -525,12 +479,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } } @@ -549,11 +500,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(c); - g.drawOval(x + width - width / 10, y + height / 2 - height / 4, - width / 10, height / 2); + g.drawOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height / 2 - height / 4, - width / 10, height / 2); + g.fillOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(c); } @@ -568,11 +517,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(c); - g.drawOval(x + width - width / 10, y + height / 2 - height / 4, - width / 10, height / 2); + g.drawOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height / 2 - height / 4, - width / 10, height / 2); + g.fillOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(c); } @@ -587,11 +534,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 4, y, width / 2, height / 10); g.setColor(c); - g.drawOval(x + width / 2 - width / 4, y + height - height / 10, - width / 2, height / 10); + g.drawOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 4, y + height - height / 10, - width / 2, height / 10); + g.fillOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); g.setColor(c); } @@ -606,11 +551,9 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 4, y, width / 2, height / 10); g.setColor(c); - g.drawOval(x + width / 2 - width / 4, y + height - height / 10, - width / 2, height / 10); + g.drawOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 4, y + height - height / 10, - width / 2, height / 10); + g.fillOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); g.setColor(c); } @@ -667,8 +610,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -688,24 +630,16 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - value = Double.parseDouble(elt - .getAttribute("value")); - phi0 = Double.parseDouble(elt - .getAttribute("phi0")); + value = Double.parseDouble(elt.getAttribute("value")); + phi0 = Double.parseDouble(elt.getAttribute("phi0")); unit0 = elt.getAttribute("unit0"); unit1 = elt.getAttribute("unit1"); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setVal(value); setPhi0(phi0); setUnit0(unit0); @@ -726,8 +660,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -882,8 +815,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -896,7 +828,6 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java index 563075d0771944c693a25a04978cc4c57a2a2e55..2bd837b8f3aaf7bc5435f5be8c9f70694c7147c3 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java @@ -53,15 +53,14 @@ 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 */ -public class ELNComponentNodeRef extends TGCScalableWithInternalComponent - implements ActionListener, SwallowedTGComponent { +public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -73,13 +72,11 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent protected int decPoint = 3; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public 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); @@ -109,8 +106,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent public void initConnectingPoint(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, - 0.0, 0.0); + connectingPoint[0] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.0); } public Color getMyColor() { @@ -124,10 +120,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -354,37 +347,29 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent } private void rotateTop(Graphics g) { - int[] ptx = { x + width / 2, x + width / 2, x, x, x + width, x + width, - x + width / 2 }; - int[] pty = { y, y + height / 2, y + height / 2, y + height, - y + height, y + height / 2, y + height / 2 }; + int[] ptx = { x + width / 2, x + width / 2, x, x, x + width, x + width, x + width / 2 }; + int[] pty = { y, y + height / 2, y + height / 2, y + height, y + height, y + height / 2, y + height / 2 }; g.drawPolygon(ptx, pty, 7); g.fillPolygon(ptx, pty, 7); } private void rotateBottom(Graphics g) { - int[] ptx = { x + width / 2, x + width / 2, x, x, x + width, x + width, - x + width / 2 }; - int[] pty = { y + height, y + height / 2, y + height / 2, y, y, - y + height / 2, y + height / 2 }; + int[] ptx = { x + width / 2, x + width / 2, x, x, x + width, x + width, x + width / 2 }; + int[] pty = { y + height, y + height / 2, y + height / 2, y, y, y + height / 2, y + height / 2 }; g.drawPolygon(ptx, pty, 7); g.fillPolygon(ptx, pty, 7); } private void rotateRight(Graphics g) { - int[] ptx = { x + width, x + width / 2, x + width / 2, x, x, - x + width / 2, x + width / 2 }; - int[] pty = { y + height / 2, y + height / 2, y, y, y + height, - y + height, y + height / 2 }; + int[] ptx = { x + width, x + width / 2, x + width / 2, x, x, x + width / 2, x + width / 2 }; + int[] pty = { y + height / 2, y + height / 2, y, y, y + height, y + height, y + height / 2 }; g.drawPolygon(ptx, pty, 7); g.fillPolygon(ptx, pty, 7); } private void rotateLeft(Graphics g) { - int[] ptx = { x, x + width / 2, x + width / 2, x + width, x + width, - x + width / 2, x + width / 2 }; - int[] pty = { y + height / 2, y + height / 2, y, y, y + height, - y + height, y + height / 2 }; + int[] ptx = { x, x + width / 2, x + width / 2, x + width, x + width, x + width / 2, x + width / 2 }; + int[] pty = { y + height / 2, y + height / 2, y, y, y + height, y + height, y + height / 2 }; g.drawPolygon(ptx, pty, 7); g.fillPolygon(ptx, pty, 7); } @@ -419,8 +404,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -438,18 +422,12 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setPosition(position); setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); @@ -466,8 +444,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -590,8 +567,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -604,7 +580,6 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java index 4e1ee9799bd393526e329e858c0dc44253ace057..0ccf10ab14caaeaee579baae6343f094e5d97652 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java @@ -51,15 +51,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** - * Class ELNComponentResistor Resistor to be used in ELN diagrams Creation: - * 12/06/2018 - * + * Class ELNComponentResistor + * Resistor to be used in ELN diagrams + * Creation: 12/06/2018 * @version 1.0 12/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentResistor extends TGCScalableWithInternalComponent - implements ActionListener, SwallowedTGComponent, ELNComponent { +public class ELNComponentResistor extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -74,14 +73,11 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent private String unit; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public ELNComponentResistor(int _x, int _y, int _minX, int _maxX, - int _minY, int _maxY, boolean _pos, TGComponent _father, - TDiagramPanel _tdp) { + public ELNComponentResistor(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(100, 20); @@ -114,10 +110,8 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "p"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "n"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); } public Color getMyColor() { @@ -131,10 +125,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -190,12 +181,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -207,12 +196,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -224,12 +211,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -241,12 +226,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } } else if (position == 1) { @@ -280,12 +263,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -297,12 +277,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -314,12 +291,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -331,12 +305,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } @@ -373,12 +344,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -390,12 +359,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -407,12 +374,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height / 2 + height / 2 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height / 2 + height / 2 + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -424,12 +389,10 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(0.5); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height / 2 + height / 2 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height / 2 + height / 2 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height / 2 + height / 2 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height / 2 + height / 2 + sh1); } } } else if (position == 3) { @@ -463,12 +426,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -480,12 +440,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -497,12 +454,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(0.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -514,12 +468,9 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent ((ELNPortTerminal) connectingPoint[1]).setW(0.5); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width / 2 + width / 2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width / 2 + width / 2, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width / 2 + width / 2, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width / 2 + width / 2, + y + height + sh1); } } } @@ -529,43 +480,35 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent private void rotateTopBottom(Graphics g) { Color c = g.getColor(); - int[] ptx = { x, x + width / 5, x + width / 5, x + 4 * width / 5, - x + 4 * width / 5, x + width, x + 4 * width / 5, - x + 4 * width / 5, x + width / 5, x + width / 5 }; - int[] pty = { y + height / 2, y + height / 2, y, y, y + height / 2, - y + height / 2, y + height / 2, y + height, y + height, - y + height / 2 }; + int[] ptx = { x, x + width / 5, x + width / 5, x + 4 * width / 5, x + 4 * width / 5, x + width, + x + 4 * width / 5, x + 4 * width / 5, x + width / 5, x + width / 5 }; + int[] pty = { y + height / 2, y + height / 2, y, y, y + height / 2, y + height / 2, y + height / 2, y + height, + y + height, y + height / 2 }; g.drawPolygon(ptx, pty, 10); g.drawOval(x, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(Color.WHITE); g.fillOval(x, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(c); - g.drawOval(x + width - width / 10, y + height / 2 - height / 4, - width / 10, height / 2); + g.drawOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 10, y + height / 2 - height / 4, - width / 10, height / 2); + g.fillOval(x + width - width / 10, y + height / 2 - height / 4, width / 10, height / 2); g.setColor(c); } private void rotateRightLeft(Graphics g) { Color c = g.getColor(); - int[] ptx = { x + width / 2, x + width / 2, x, x, x + width / 2, - x + width / 2, x + width / 2, x + width, x + width, - x + width / 2 }; - int[] pty = { y, y + height / 5, y + height / 5, y + 4 * height / 5, - y + 4 * height / 5, y + height, y + 4 * height / 5, - y + 4 * height / 5, y + height / 5, y + height / 5 }; + int[] ptx = { x + width / 2, x + width / 2, x, x, x + width / 2, x + width / 2, x + width / 2, x + width, + x + width, x + width / 2 }; + int[] pty = { y, y + height / 5, y + height / 5, y + 4 * height / 5, y + 4 * height / 5, y + height, + y + 4 * height / 5, y + 4 * height / 5, y + height / 5, y + height / 5 }; g.drawPolygon(ptx, pty, 10); g.drawOval(x + width / 2 - width / 4, y, width / 2, height / 10); g.setColor(Color.WHITE); g.fillOval(x + width / 2 - width / 4, y, width / 2, height / 10); g.setColor(c); - g.drawOval(x + width / 2 - width / 4, y + height - height / 10, - width / 2, height / 10); + g.drawOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); g.setColor(Color.WHITE); - g.fillOval(x + width / 2 - width / 4, y + height - height / 10, - width / 2, height / 10); + g.fillOval(x + width / 2 - width / 4, y + height - height / 10, width / 2, height / 10); g.setColor(c); } @@ -622,8 +565,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -643,21 +585,14 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - value = Double.parseDouble(elt - .getAttribute("value")); + value = Double.parseDouble(elt.getAttribute("value")); unit = elt.getAttribute("unit"); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setVal(value); setUnit(unit); setPosition(position); @@ -676,8 +611,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -816,8 +750,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -830,7 +763,6 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java b/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java index 9c774cc53dd882fb83cbccb062a848fb3d6683fe..541ebc0b1e399992c239dcef948b1f0ca0141c17 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java @@ -49,18 +49,17 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; /** - * Class ELNComponentTransmissionLine Transmission line to be used in ELN - * diagrams Creation: 15/06/2018 - * + * Class ELNComponentTransmissionLine + * Transmission line to be used in ELN diagrams + * Creation: 15/06/2018 * @version 1.0 15/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentTransmissionLine extends - TGCScalableWithInternalComponent implements ActionListener, - SwallowedTGComponent, ELNComponent { +public class ELNComponentTransmissionLine extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -76,14 +75,11 @@ public class ELNComponentTransmissionLine extends private String unit0, unit2; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public ELNComponentTransmissionLine(int _x, int _y, int _minX, int _maxX, - int _minY, int _maxY, boolean _pos, TGComponent _father, - TDiagramPanel _tdp) { + public ELNComponentTransmissionLine(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(120, 80); @@ -119,14 +115,10 @@ public class ELNComponentTransmissionLine extends public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "a1"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "a2"); - connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "b1"); - connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "b2"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "a1"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "a2"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "b1"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "b2"); } public Color getMyColor() { @@ -140,10 +132,7 @@ public class ELNComponentTransmissionLine extends if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -207,18 +196,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 16 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 16 + sh3); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -234,18 +217,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 16 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 16 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -261,18 +238,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 16 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 16 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -288,18 +259,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 16 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 16 + sh0); } } } else if (position == 1) { @@ -343,18 +308,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -370,18 +329,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -397,18 +350,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -424,18 +371,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, + y + height + sh2); } } } else if (position == 2) { @@ -479,18 +420,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 16 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 16 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -506,18 +441,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 16 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 16 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -533,18 +462,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 16 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 16 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -560,18 +483,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 16 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 16 + sh3); } } } else if (position == 3) { @@ -615,18 +532,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, + y + height + sh2); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -642,18 +553,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -669,18 +574,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -696,18 +595,12 @@ public class ELNComponentTransmissionLine extends ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, + y + height + sh1); } } } @@ -717,18 +610,24 @@ public class ELNComponentTransmissionLine extends private void rotateTopBottom(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 24, x + width / 6, x + 5 * width / 6, - x + width - width / 24, x + 5 * width / 6, x + width / 6 }; - int[] pty0 = { y + height / 16, y + height / 2 - height / 8, - y + height / 2 - height / 8, y + height / 16, + int[] ptx0 = { x + width / 24, x + width / 6, x + 5 * width / 6, x + width - width / 24, x + 5 * width / 6, + x + width / 6 }; + int[] pty0 = { y + height / 16, y + height / 2 - height / 8, y + height / 2 - height / 8, y + height / 16, y + height / 2 - height / 8, y + height / 2 - height / 8 }; g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + width / 24, x + width / 6, x + 5 * width / 6, - x + width - width / 24, x + 5 * width / 6, x + width / 6 }; - int[] pty1 = { y + height - height / 16, y + height / 2 + height / 8, - y + height / 2 + height / 8, y + height - height / 16, - y + height / 2 + height / 8, y + height / 2 + height / 8 }; + int[] ptx1 = { x + width / 24, x + width / 6, x + 5 * width / 6, x + width - width / 24, x + 5 * width / 6, + x + width / 6 }; + int[] pty1 = { y + height - height / 16, y + height / 2 + height / 8, y + height / 2 + height / 8, + y + height - height / 16, y + height / 2 + height / 8, y + height / 2 + height / 8 }; g.drawPolygon(ptx1, pty1, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -741,28 +640,32 @@ public class ELNComponentTransmissionLine extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } private void rotateRightLeft(Graphics g) { Color c = g.getColor(); - int[] ptx0 = { x + width / 16, x + width / 2 - width / 8, - x + width / 2 - width / 8, x + width / 16, + int[] ptx0 = { x + width / 16, x + width / 2 - width / 8, x + width / 2 - width / 8, x + width / 16, x + width / 2 - width / 8, x + width / 2 - width / 8 }; - int[] pty0 = { y + height / 24, y + height / 6, y + 5 * height / 6, - y + height - height / 24, y + 5 * height / 6, y + height / 6 }; + int[] pty0 = { y + height / 24, y + height / 6, y + 5 * height / 6, y + height - height / 24, + y + 5 * height / 6, y + height / 6 }; g.drawPolygon(ptx0, pty0, 6); - int[] ptx1 = { x + width - width / 16, x + width / 2 + width / 8, - x + width / 2 + width / 8, x + width - width / 16, - x + width / 2 + width / 8, x + width / 2 + width / 8 }; - int[] pty1 = { y + height / 24, y + height / 6, y + 5 * height / 6, - y + height - height / 24, y + 5 * height / 6, y + height / 6 }; + int[] ptx1 = { x + width - width / 16, x + width / 2 + width / 8, x + width / 2 + width / 8, + x + width - width / 16, x + width / 2 + width / 8, x + width / 2 + width / 8 }; + int[] pty1 = { y + height / 24, y + height / 6, y + 5 * height / 6, y + height - height / 24, + y + 5 * height / 6, y + height / 6 }; g.drawPolygon(ptx1, pty1, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -775,11 +678,9 @@ public class ELNComponentTransmissionLine extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -795,8 +696,7 @@ public class ELNComponentTransmissionLine extends } public boolean editOndoubleClick(JFrame frame) { - JDialogELNComponentTransmissionLine jde = new JDialogELNComponentTransmissionLine( - this); + JDialogELNComponentTransmissionLine jde = new JDialogELNComponentTransmissionLine(this); jde.setVisible(true); return true; } @@ -839,8 +739,7 @@ public class ELNComponentTransmissionLine extends return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -864,21 +763,14 @@ public class ELNComponentTransmissionLine extends z0 = Double.parseDouble(elt.getAttribute("z0")); unit0 = elt.getAttribute("unit0"); delay = elt.getAttribute("delay"); - delta0 = Double.parseDouble(elt - .getAttribute("delta0")); + delta0 = Double.parseDouble(elt.getAttribute("delta0")); unit2 = elt.getAttribute("unit2"); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setZ0(z0); setUnit0(unit0); setDelay(delay); @@ -900,8 +792,7 @@ public class ELNComponentTransmissionLine extends } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -1064,8 +955,7 @@ public class ELNComponentTransmissionLine extends if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -1078,7 +968,6 @@ public class ELNComponentTransmissionLine extends myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java index f018abd886c3f9234cd402b8853308f7cf741420..d4f1594945cadb81053e70fe3ce33ca0f3700e57 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java @@ -49,18 +49,17 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; /** - * Class ELNComponentVoltageControlledCurrentSource Voltage controlled current - * source to be used in ELN diagrams Creation: 13/06/2018 - * + * Class ELNComponentVoltageControlledCurrentSource + * Voltage controlled current source to be used in ELN diagrams + * Creation: 13/06/2018 * @version 1.0 13/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentVoltageControlledCurrentSource extends - TGCScalableWithInternalComponent implements ActionListener, - SwallowedTGComponent, ELNComponent { +public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -75,14 +74,11 @@ public class ELNComponentVoltageControlledCurrentSource extends private String unit; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public ELNComponentVoltageControlledCurrentSource(int _x, int _y, - int _minX, int _maxX, int _minY, int _maxY, boolean _pos, - TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentVoltageControlledCurrentSource(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(120, 80); @@ -115,14 +111,10 @@ public class ELNComponentVoltageControlledCurrentSource extends public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "ncp"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "np"); - connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "ncn"); - connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "nn"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncp"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "np"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncn"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "nn"); } public Color getMyColor() { @@ -136,10 +128,7 @@ public class ELNComponentVoltageControlledCurrentSource extends if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -202,18 +191,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 16 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 16 + sh3); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -230,18 +213,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 16 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 16 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -258,18 +235,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 16 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 16 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -286,18 +257,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 16 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 16 + sh0); } } } else if (position == 1) { @@ -340,18 +305,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -368,18 +327,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -396,18 +349,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -424,18 +371,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, + y + height + sh2); } } } else if (position == 2) { @@ -478,18 +419,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 16 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 16 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -506,18 +441,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 16 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 16 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -534,18 +463,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 16 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 16 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -562,18 +485,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 16 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 16 + sh3); } } } else if (position == 3) { @@ -616,18 +533,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, + y + height + sh2); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -644,18 +555,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -672,18 +577,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -700,18 +599,12 @@ public class ELNComponentVoltageControlledCurrentSource extends ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, + y + height + sh1); } } } @@ -727,42 +620,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x, x + 2 * width / 6 }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, - x + 3 * width / 6, x + 4 * width / 6, x + 4 * width / 6, - x + width, x + 4 * width / 6, x + 4 * width / 6, - x + 5 * width / 6, x + 3 * width / 6, x + 5 * width / 6, - x + 4 * width / 6, x + 4 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + 3 * height / 4, - y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, - y + height / 4, y + height / 16 }; + int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, x + 3 * width / 6, x + 4 * width / 6, + x + 4 * width / 6, x + width, x + 4 * width / 6, x + 4 * width / 6, x + 5 * width / 6, + x + 3 * width / 6, x + 5 * width / 6, x + 4 * width / 6, x + 4 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height - height / 16, y + height - height / 16, y + height - height / 16, y + 3 * height / 4, + y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, y + height / 4, y + height / 16 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, + int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, + x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height / 4, y + height / 4, - y + height / 4 - height / 16, y + height / 4 + height / 16, + int[] pty3 = { y + height / 4, y + height / 4, y + height / 4 - height / 16, y + height / 4 + height / 16, y + height / 4, y + height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 24 }; + int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; int[] pty4 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12, - x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 6, - x + 5 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8, y + 3 * height / 4, - y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8 }; + int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, x + 5 * width / 6 + width / 12 + width / 24, + x + 5 * width / 6 + width / 12, x + 5 * width / 6 + width / 12 + width / 24, + x + 5 * width / 6 + width / 6, x + 5 * width / 6 + width / 12 + width / 24 }; + int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, + y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -775,11 +663,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -791,42 +677,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x, x + 2 * width / 6 }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, - x + 3 * width / 6, x + 4 * width / 6, x + 4 * width / 6, - x + width, x + 4 * width / 6, x + 4 * width / 6, - x + 5 * width / 6, x + 3 * width / 6, x + 5 * width / 6, - x + 4 * width / 6, x + 4 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + 3 * height / 4, - y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, - y + height / 4, y + height / 16 }; + int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, x + 3 * width / 6, x + 4 * width / 6, + x + 4 * width / 6, x + width, x + 4 * width / 6, x + 4 * width / 6, x + 5 * width / 6, + x + 3 * width / 6, x + 5 * width / 6, x + 4 * width / 6, x + 4 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height - height / 16, y + height - height / 16, y + height - height / 16, y + 3 * height / 4, + y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, y + height / 4, y + height / 16 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, + int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, + x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height - height / 4, y + height - height / 4, - y + height - height / 4 + height / 16, - y + height - height / 4 - height / 16, y + height - height / 4, - y + height - height / 4 }; + int[] pty3 = { y + height - height / 4, y + height - height / 4, y + height - height / 4 + height / 16, + y + height - height / 4 - height / 16, y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 24 }; + int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; int[] pty4 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12, - x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 6, - x + 5 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, - y + height / 4 + height / 8, y + height / 4, + int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, x + 5 * width / 6 + width / 12 + width / 24, + x + 5 * width / 6 + width / 12, x + 5 * width / 6 + width / 12 + width / 24, + x + 5 * width / 6 + width / 6, x + 5 * width / 6 + width / 12 + width / 24 }; + int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -839,11 +720,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -855,41 +734,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x + 4 * width / 6, x + width }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, - x + 2 * width / 6, x + 2 * width / 6, x, x + 2 * width / 6, - x + 2 * width / 6, x + 3 * width / 6, x + width / 6, - x + 3 * width / 6, x + 2 * width / 6, x + 2 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + 3 * height / 4, - y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, - y + height / 4, y + height / 16 }; + int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, x + 2 * width / 6, x + 2 * width / 6, x, + x + 2 * width / 6, x + 2 * width / 6, x + 3 * width / 6, x + width / 6, x + 3 * width / 6, + x + 2 * width / 6, x + 2 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height - height / 16, y + height - height / 16, y + height - height / 16, y + 3 * height / 4, + y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, y + height / 4, y + height / 16 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, + int[] ptx3 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty3 = { y + height - height / 4, y + height - height / 4, - y + height - height / 4 + height / 16, - y + height - height / 4 - height / 16, y + height - height / 4, - y + height - height / 4 }; + int[] pty3 = { y + height - height / 4, y + height - height / 4, y + height - height / 4 + height / 16, + y + height - height / 4 - height / 16, y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12 + width / 24 }; + int[] ptx4 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty4 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12, - x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 6, + int[] ptx5 = { x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 12 - width / 24, + x + width / 6 - width / 12, x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 6, x + width / 6 - width / 12 - width / 24 }; - int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, - y + height / 4 + height / 8, y + height / 4, + int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -902,11 +777,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -918,41 +791,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x + 4 * width / 6, x + width }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, - x + 2 * width / 6, x + 2 * width / 6, x, x + 2 * width / 6, - x + 2 * width / 6, x + 3 * width / 6, x + width / 6, - x + 3 * width / 6, x + 2 * width / 6, x + 2 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + 3 * height / 4, - y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, - y + height / 4, y + height / 16 }; + int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, x + 2 * width / 6, x + 2 * width / 6, x, + x + 2 * width / 6, x + 2 * width / 6, x + 3 * width / 6, x + width / 6, x + 3 * width / 6, + x + 2 * width / 6, x + 2 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height - height / 16, y + height - height / 16, y + height - height / 16, y + 3 * height / 4, + y + 2 * height / 4, y + 2 * height / 4, y + 2 * height / 4, y + height / 4, y + height / 16 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, + int[] ptx3 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty3 = { y + height / 4, y + height / 4, - y + height / 4 - height / 16, y + height / 4 + height / 16, + int[] pty3 = { y + height / 4, y + height / 4, y + height / 4 - height / 16, y + height / 4 + height / 16, y + height / 4, y + height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12 + width / 24 }; + int[] ptx4 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty4 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12, - x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 6, + int[] ptx5 = { x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 12 - width / 24, + x + width / 6 - width / 12, x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 6, x + width / 6 - width / 12 - width / 24 }; - int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8, y + 3 * height / 4, - y + 3 * height / 4 - height / 8, - y + 3 * height / 4 - height / 8 }; + int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, + y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -965,11 +834,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -981,43 +848,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, - x + 3 * width / 4, x + 2 * width / 4, x + 2 * width / 4, - x + 2 * width / 4, x + width / 4, x + width / 16 }; - int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, - y + 3 * height / 6, y + 4 * height / 6, y + 4 * height / 6, - y + height, y + 4 * height / 6, y + 4 * height / 6, - y + 5 * height / 6, y + 3 * height / 6, y + 5 * height / 6, - y + 4 * height / 6, y + 4 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width - width / 16, x + width - width / 16, x + width - width / 16, x + 3 * width / 4, + x + 2 * width / 4, x + 2 * width / 4, x + 2 * width / 4, x + width / 4, x + width / 16 }; + int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, y + 3 * height / 6, y + 4 * height / 6, + y + 4 * height / 6, y + height, y + 4 * height / 6, y + 4 * height / 6, y + 5 * height / 6, + y + 3 * height / 6, y + 5 * height / 6, y + 4 * height / 6, y + 4 * height / 6 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + width - width / 4, x + width - width / 4, - x + width - width / 4 + width / 16, - x + width - width / 4 - width / 16, x + width - width / 4, - x + width - width / 4 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, + int[] ptx3 = { x + width - width / 4, x + width - width / 4, x + width - width / 4 + width / 16, + x + width - width / 4 - width / 16, x + width - width / 4, x + width - width / 4 }; + int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, + y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width / 4, x + width / 4 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 24 }; + int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, - x + width / 4 + width / 8, x + width / 4, + int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12, - y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 6, - y + 5 * height / 6 + height / 12 + height / 24 }; + int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, y + 5 * height / 6 + height / 12 + height / 24, + y + 5 * height / 6 + height / 12, y + 5 * height / 6 + height / 12 + height / 24, + y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -1030,11 +891,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1046,43 +905,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, - x + 3 * width / 4, x + 2 * width / 4, x + 2 * width / 4, - x + 2 * width / 4, x + width / 4, x + width / 16 }; - int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, - y + height / 6, y + 2 * height / 6, y + 2 * height / 6, y, - y + 2 * height / 6, y + 2 * height / 6, y + 3 * height / 6, - y + height / 6, y + 3 * height / 6, y + 2 * height / 6, - y + 2 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width - width / 16, x + width - width / 16, x + width - width / 16, x + 3 * width / 4, + x + 2 * width / 4, x + 2 * width / 4, x + 2 * width / 4, x + width / 4, x + width / 16 }; + int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, y + height / 6, y + 2 * height / 6, + y + 2 * height / 6, y, y + 2 * height / 6, y + 2 * height / 6, y + 3 * height / 6, y + height / 6, + y + 3 * height / 6, y + 2 * height / 6, y + 2 * height / 6 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + width - width / 4, x + width - width / 4, - x + width - width / 4 + width / 16, - x + width - width / 4 - width / 16, x + width - width / 4, - x + width - width / 4 }; - int[] pty3 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, + int[] ptx3 = { x + width - width / 4, x + width - width / 4, x + width - width / 4 + width / 16, + x + width - width / 4 - width / 16, x + width - width / 4, x + width - width / 4 }; + int[] pty3 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, + y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width / 4, x + width / 4 }; - int[] pty4 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] pty4 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, - x + width / 4 + width / 8, x + width / 4, + int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty5 = { y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12, - y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 6, + int[] pty5 = { y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 12 - height / 24, + y + height / 6 - height / 12, y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 6, y + height / 6 - height / 12 - height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -1095,11 +948,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1111,42 +962,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, - x + 3 * width / 4, x + 2 * width / 4, x + 2 * width / 4, - x + 2 * width / 4, x + width / 4, x + width / 16 }; - int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, - y + height / 6, y + 2 * height / 6, y + 2 * height / 6, y, - y + 2 * height / 6, y + 2 * height / 6, y + 3 * height / 6, - y + height / 6, y + 3 * height / 6, y + 2 * height / 6, - y + 2 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width - width / 16, x + width - width / 16, x + width - width / 16, x + 3 * width / 4, + x + 2 * width / 4, x + 2 * width / 4, x + 2 * width / 4, x + width / 4, x + width / 16 }; + int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, y + height / 6, y + 2 * height / 6, + y + 2 * height / 6, y, y + 2 * height / 6, y + 2 * height / 6, y + 3 * height / 6, y + height / 6, + y + 3 * height / 6, y + 2 * height / 6, y + 2 * height / 6 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + width / 4, x + width / 4, - x + width / 4 - width / 16, x + width / 4 + width / 16, + int[] ptx3 = { x + width / 4, x + width / 4, x + width / 4 - width / 16, x + width / 4 + width / 16, x + width / 4, x + width / 4 }; - int[] pty3 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, + int[] pty3 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, + y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width - width / 4, x + width - width / 4 }; - int[] pty4 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] pty4 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, - x + 3 * width / 4 - width / 8, x + 3 * width / 4, + int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty5 = { y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12, - y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 6, + int[] pty5 = { y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 12 - height / 24, + y + height / 6 - height / 12, y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 6, y + height / 6 - height / 12 - height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -1159,11 +1005,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1175,42 +1019,37 @@ public class ELNComponentVoltageControlledCurrentSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, - x + 3 * width / 4, x + 2 * width / 4, x + 2 * width / 4, - x + 2 * width / 4, x + width / 4, x + width / 16 }; - int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, - y + 3 * height / 6, y + 4 * height / 6, y + 4 * height / 6, - y + height, y + 4 * height / 6, y + 4 * height / 6, - y + 5 * height / 6, y + 3 * height / 6, y + 5 * height / 6, - y + 4 * height / 6, y + 4 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width - width / 16, x + width - width / 16, x + width - width / 16, x + 3 * width / 4, + x + 2 * width / 4, x + 2 * width / 4, x + 2 * width / 4, x + width / 4, x + width / 16 }; + int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, y + 3 * height / 6, y + 4 * height / 6, + y + 4 * height / 6, y + height, y + 4 * height / 6, y + 4 * height / 6, y + 5 * height / 6, + y + 3 * height / 6, y + 5 * height / 6, y + 4 * height / 6, y + 4 * height / 6 }; g.drawPolygon(ptx2, pty2, 14); - int[] ptx3 = { x + width / 4, x + width / 4, - x + width / 4 - width / 16, x + width / 4 + width / 16, + int[] ptx3 = { x + width / 4, x + width / 4, x + width / 4 - width / 16, x + width / 4 + width / 16, x + width / 4, x + width / 4 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, + int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, + y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width - width / 4, x + width - width / 4 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 24 }; + int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, - x + 3 * width / 4 - width / 8, x + 3 * width / 4, + int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12, - y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 6, - y + 5 * height / 6 + height / 12 + height / 24 }; + int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, y + 5 * height / 6 + height / 12 + height / 24, + y + 5 * height / 6 + height / 12, y + 5 * height / 6 + height / 12 + height / 24, + y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); g.fillPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -1223,11 +1062,9 @@ public class ELNComponentVoltageControlledCurrentSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1281,8 +1118,7 @@ public class ELNComponentVoltageControlledCurrentSource extends return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -1302,21 +1138,14 @@ public class ELNComponentVoltageControlledCurrentSource extends if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - value = Double.parseDouble(elt - .getAttribute("value")); + value = Double.parseDouble(elt.getAttribute("value")); unit = elt.getAttribute("unit"); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setVal(value); setUnit(unit); setPosition(position); @@ -1335,8 +1164,7 @@ public class ELNComponentVoltageControlledCurrentSource extends } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -1475,8 +1303,7 @@ public class ELNComponentVoltageControlledCurrentSource extends if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -1489,7 +1316,6 @@ public class ELNComponentVoltageControlledCurrentSource extends myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java index d145271d59d746628916631a145abc337291ecf9..785e9ceaab58ebe3acf25bfe15747357ac2ec652 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java @@ -49,18 +49,17 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; /** - * Class ELNComponentVoltageControlledVoltageSource Voltage controlled voltage - * source to be used in ELN diagrams Creation: 13/06/2018 - * + * Class ELNComponentVoltageControlledVoltageSource + * Voltage controlled voltage source to be used in ELN diagrams + * Creation: 13/06/2018 * @version 1.0 13/06/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentVoltageControlledVoltageSource extends - TGCScalableWithInternalComponent implements ActionListener, - SwallowedTGComponent, ELNComponent { +public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -74,14 +73,11 @@ public class ELNComponentVoltageControlledVoltageSource extends private double val; private int position = 0; - private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, - fh_1_3 = false; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; private int old; private boolean first; - public ELNComponentVoltageControlledVoltageSource(int _x, int _y, - int _minX, int _maxX, int _minY, int _maxY, boolean _pos, - TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentVoltageControlledVoltageSource(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); initScaling(120, 80); @@ -113,14 +109,10 @@ public class ELNComponentVoltageControlledVoltageSource extends public void initPortTerminal(int nb) { nbConnectingPoint = nb; connectingPoint = new TGConnectingPoint[nb]; - connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "ncp"); - connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "np"); - connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "ncn"); - connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, - 0.0, "nn"); + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncp"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "np"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "ncn"); + connectingPoint[3] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "nn"); } public Color getMyColor() { @@ -134,10 +126,7 @@ public class ELNComponentVoltageControlledVoltageSource extends if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; - int maxCurrentFontSize = Math.max( - 0, - Math.min(this.height, - (int) (this.maxFontSize * this.tdp.getZoom()))); + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); f = f.deriveFont((float) maxCurrentFontSize); while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { @@ -200,18 +189,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 16 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 16 + sh3); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -228,18 +211,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 16 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 16 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -256,18 +233,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 16 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 16 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -284,18 +255,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 16 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 16 + sh0); } } } else if (position == 1) { @@ -338,18 +303,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, + y + height + sh1); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -366,18 +325,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -394,18 +347,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -422,18 +369,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, + y + height + sh2); } } } else if (position == 2) { @@ -476,18 +417,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[0]).setW(1.0); ((ELNPortTerminal) connectingPoint[0]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y + height + height / 16 + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 16 + sh0); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -504,18 +439,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(1.0); ((ELNPortTerminal) connectingPoint[1]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y + height + height / 16 + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y + height + height / 16 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 16 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 16 + sh1); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -532,18 +461,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[2]).setW(1.0); ((ELNPortTerminal) connectingPoint[2]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - sw1, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - sw3, y + height + height / 16 + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width, y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - sw3, + y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height + height / 16 + sh2); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -560,18 +483,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[3]).setW(1.0); ((ELNPortTerminal) connectingPoint[3]).setH(15.0 / 16.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - sw0, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width, y - height / 16); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - sw2, y + height + height / 16 + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width, y + height + height / 16 + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 16); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height + height / 16 + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width, + y + height + height / 16 + sh3); } } } else if (position == 3) { @@ -614,18 +531,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[2]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[2]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y + height + sh0); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, + y + height + sh2); } } if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -642,18 +553,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[3]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[3]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - - width / 16 - sw0, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - - width / 16 - sw1, y + height + sh1); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - + width + width / 16, y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 16 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x + width + width / 16, + y + height + sh3); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -670,18 +575,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[0]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[0]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y + height + sh2); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, + y + height + sh2); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); } } if ((fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) @@ -698,18 +597,12 @@ public class ELNComponentVoltageControlledVoltageSource extends ((ELNPortTerminal) connectingPoint[1]).setW(15.0 / 16.0); ((ELNPortTerminal) connectingPoint[1]).setH(1.0); if (mgui.getHidden() == false) { - g.drawString( - ((ELNPortTerminal) connectingPoint[2]).getName(), x - - width / 16 - sw2, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[0]).getName(), x - + width + width / 16, y); - g.drawString( - ((ELNPortTerminal) connectingPoint[3]).getName(), x - - width / 16 - sw3, y + height + sh3); - g.drawString( - ((ELNPortTerminal) connectingPoint[1]).getName(), x - + width + width / 16, y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - width / 16 - sw2, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, y); + g.drawString(((ELNPortTerminal) connectingPoint[3]).getName(), x - width / 16 - sw3, + y + height + sh3); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 16, + y + height + sh1); } } } @@ -725,40 +618,39 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x, x + 2 * width / 6 }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, - x + 3 * width / 6, x + 4 * width / 6, x + 4 * width / 6, - x + 5 * width / 6, x + 4 * width / 6, x + 4 * width / 6, - x + width, x + 4 * width / 6, x + 4 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + height / 16 }; + int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, x + 3 * width / 6, x + 4 * width / 6, + x + 4 * width / 6, x + 5 * width / 6, x + 4 * width / 6, x + 4 * width / 6, x + width, + x + 4 * width / 6, x + 4 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height / 4, y + 2 * height / 4, y + 3 * height / 4, y + height - height / 16, + y + height - height / 16, y + height - height / 16, y + height / 16 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, + int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, + x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height / 4, y + height / 4, - y + height / 4 - height / 16, y + height / 4 + height / 16, + int[] pty3 = { y + height / 4, y + height / 4, y + height / 4 - height / 16, y + height / 4 + height / 16, y + height / 4, y + height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 24 }; + int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; int[] pty4 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, + int[] ptx5 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + height / 4, y + height / 4, - y + height / 4 - height / 16, y + height / 4 + height / 16, + int[] pty5 = { y + height / 4, y + height / 4, y + height / 4 - height / 16, y + height / 4 + height / 16, y + height / 4, y + height / 4 }; g.drawPolygon(ptx5, pty5, 6); - int[] ptx6 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12 + width / 24 }; + int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx6, pty6, 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -771,11 +663,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -787,42 +677,39 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x, x + 2 * width / 6 }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, - x + 3 * width / 6, x + 4 * width / 6, x + 4 * width / 6, - x + 5 * width / 6, x + 4 * width / 6, x + 4 * width / 6, - x + width, x + 4 * width / 6, x + 4 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + height / 16 }; + int[] ptx2 = { x + width, x + 4 * width / 6, x + 4 * width / 6, x + 3 * width / 6, x + 4 * width / 6, + x + 4 * width / 6, x + 5 * width / 6, x + 4 * width / 6, x + 4 * width / 6, x + width, + x + 4 * width / 6, x + 4 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height / 4, y + 2 * height / 4, y + 3 * height / 4, y + height - height / 16, + y + height - height / 16, y + height - height / 16, y + height / 16 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, + int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, + x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height - height / 4, y + height - height / 4, - y + height - height / 4 + height / 16, - y + height - height / 4 - height / 16, y + height - height / 4, - y + height - height / 4 }; + int[] pty3 = { y + height - height / 4, y + height - height / 4, y + height - height / 4 + height / 16, + y + height - height / 4 - height / 16, y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 24 }; + int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; int[] pty4 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, + int[] ptx5 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + height - height / 4, y + height - height / 4, - y + height - height / 4 + height / 16, - y + height - height / 4 - height / 16, y + height - height / 4, - y + height - height / 4 }; + int[] pty5 = { y + height - height / 4, y + height - height / 4, y + height - height / 4 + height / 16, + y + height - height / 4 - height / 16, y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx5, pty5, 6); - int[] ptx6 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12 + width / 24 }; + int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx6, pty6, 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -835,11 +722,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -851,42 +736,38 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x + 4 * width / 6, x + width }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, - x + 2 * width / 6, x + 2 * width / 6, x + 3 * width / 6, - x + 2 * width / 6, x + 2 * width / 6, x, x + 2 * width / 6, - x + 2 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + height / 16 }; + int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, x + 2 * width / 6, x + 2 * width / 6, + x + 3 * width / 6, x + 2 * width / 6, x + 2 * width / 6, x, x + 2 * width / 6, x + 2 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height / 4, y + 2 * height / 4, y + 3 * height / 4, y + height - height / 16, + y + height - height / 16, y + height - height / 16, y + height / 16 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, + int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, + x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height - height / 4, y + height - height / 4, - y + height - height / 4 + height / 16, - y + height - height / 4 - height / 16, y + height - height / 4, - y + height - height / 4 }; + int[] pty3 = { y + height - height / 4, y + height - height / 4, y + height - height / 4 + height / 16, + y + height - height / 4 - height / 16, y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 24 }; + int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; int[] pty4 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, + int[] ptx5 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + height - height / 4, y + height - height / 4, - y + height - height / 4 + height / 16, - y + height - height / 4 - height / 16, y + height - height / 4, - y + height - height / 4 }; + int[] pty5 = { y + height - height / 4, y + height - height / 4, y + height - height / 4 + height / 16, + y + height - height / 4 - height / 16, y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx5, pty5, 6); - int[] ptx6 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12 + width / 24 }; + int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height / 4, y + height / 4 }; g.drawPolygon(ptx6, pty6, 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -899,11 +780,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -915,40 +794,38 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x + 4 * width / 6, x + width }; int[] pty1 = { y + height - height / 16, y + height - height / 16 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, - x + 2 * width / 6, x + 2 * width / 6, x + 3 * width / 6, - x + 2 * width / 6, x + 2 * width / 6, x, x + 2 * width / 6, - x + 2 * width / 6 }; - int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, y + height / 4, - y + 2 * height / 4, y + 3 * height / 4, - y + height - height / 16, y + height - height / 16, - y + height - height / 16, y + height / 16 }; + int[] ptx2 = { x, x + 2 * width / 6, x + 2 * width / 6, x + width / 6, x + 2 * width / 6, x + 2 * width / 6, + x + 3 * width / 6, x + 2 * width / 6, x + 2 * width / 6, x, x + 2 * width / 6, x + 2 * width / 6 }; + int[] pty2 = { y + height / 16, y + height / 16, y + height / 4, y + 2 * height / 4, y + 3 * height / 4, + y + height / 4, y + 2 * height / 4, y + 3 * height / 4, y + height - height / 16, + y + height - height / 16, y + height - height / 16, y + height / 16 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, + int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, + x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height / 4, y + height / 4, - y + height / 4 - height / 16, y + height / 4 + height / 16, + int[] pty3 = { y + height / 4, y + height / 4, y + height / 4 - height / 16, y + height / 4 + height / 16, y + height / 4, y + height / 4 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, - x + 2 * width / 6 - width / 24 }; + int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; int[] pty4 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, + int[] ptx5 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + height / 4, y + height / 4, - y + height / 4 - height / 16, y + height / 4 + height / 16, + int[] pty5 = { y + height / 4, y + height / 4, y + height / 4 - height / 16, y + height / 4 + height / 16, y + height / 4, y + height / 4 }; g.drawPolygon(ptx5, pty5, 6); - int[] ptx6 = { x + 4 * width / 6 + width / 24, - x + 4 * width / 6 + width / 12 + width / 24 }; + int[] ptx6 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; int[] pty6 = { y + height - height / 4, y + height - height / 4 }; g.drawPolygon(ptx6, pty6, 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 24, y - height / 16, width - width / 12, height + height / 8, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 12, height / 8); g.setColor(Color.WHITE); g.fillOval(x, y, width / 12, height / 8); @@ -961,11 +838,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 8, width / 12, height / 8); g.setColor(c); - g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.drawOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, - height / 8); + g.fillOval(x + width - width / 12, y + height - height / 8, width / 12, height / 8); g.setColor(c); } @@ -977,45 +852,39 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, x + width / 16 }; - int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, - y + 3 * height / 6, y + 4 * height / 6, y + 4 * height / 6, - y + 5 * height / 6, y + 4 * height / 6, y + 4 * height / 6, - y + height, y + 4 * height / 6, y + 4 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width / 4, x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, x + width - width / 16, + x + width - width / 16, x + width / 16 }; + int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, y + 3 * height / 6, y + 4 * height / 6, + y + 4 * height / 6, y + 5 * height / 6, y + 4 * height / 6, y + 4 * height / 6, y + height, + y + 4 * height / 6, y + 4 * height / 6 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + width - width / 4, x + width - width / 4, - x + width - width / 4 + width / 16, - x + width - width / 4 - width / 16, x + width - width / 4, - x + width - width / 4 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, + int[] ptx3 = { x + width - width / 4, x + width - width / 4, x + width - width / 4 + width / 16, + x + width - width / 4 - width / 16, x + width - width / 4, x + width - width / 4 }; + int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, + y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width / 4, x + width / 4 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 24 }; + int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width - width / 4, x + width - width / 4, - x + width - width / 4 + width / 16, - x + width - width / 4 - width / 16, x + width - width / 4, - x + width - width / 4 }; - int[] pty5 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, + int[] ptx5 = { x + width - width / 4, x + width - width / 4, x + width - width / 4 + width / 16, + x + width - width / 4 - width / 16, x + width - width / 4, x + width - width / 4 }; + int[] pty5 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, + y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); int[] ptx6 = { x + width / 4, x + width / 4 }; - int[] pty6 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -1028,11 +897,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1044,44 +911,38 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, x + width / 16 }; - int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, - y + height / 6, y + 2 * height / 6, y + 2 * height / 6, - y + 3 * height / 6, y + 2 * height / 6, y + 2 * height / 6, y, - y + 2 * height / 6, y + 2 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width / 4, x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, x + width - width / 16, + x + width - width / 16, x + width / 16 }; + int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, y + height / 6, y + 2 * height / 6, + y + 2 * height / 6, y + 3 * height / 6, y + 2 * height / 6, y + 2 * height / 6, y, y + 2 * height / 6, + y + 2 * height / 6 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + width - width / 4, x + width - width / 4, - x + width - width / 4 + width / 16, - x + width - width / 4 - width / 16, x + width - width / 4, - x + width - width / 4 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, + int[] ptx3 = { x + width - width / 4, x + width - width / 4, x + width - width / 4 + width / 16, + x + width - width / 4 - width / 16, x + width - width / 4, x + width - width / 4 }; + int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, + y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width / 4, x + width / 4 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 24 }; + int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width - width / 4, x + width - width / 4, - x + width - width / 4 + width / 16, - x + width - width / 4 - width / 16, x + width - width / 4, - x + width - width / 4 }; - int[] pty5 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, + int[] ptx5 = { x + width - width / 4, x + width - width / 4, x + width - width / 4 + width / 16, + x + width - width / 4 - width / 16, x + width - width / 4, x + width - width / 4 }; + int[] pty5 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, + y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + int[] ptx6 = { x + width / 4, x + width / 4 }; - int[] pty6 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); @@ -1095,11 +956,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1111,43 +970,39 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y + 4 * height / 6, y + height }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, x + width / 16 }; - int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, - y + height / 6, y + 2 * height / 6, y + 2 * height / 6, - y + 3 * height / 6, y + 2 * height / 6, y + 2 * height / 6, y, - y + 2 * height / 6, y + 2 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width / 4, x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, x + width - width / 16, + x + width - width / 16, x + width / 16 }; + int[] pty2 = { y, y + 2 * height / 6, y + 2 * height / 6, y + height / 6, y + 2 * height / 6, + y + 2 * height / 6, y + 3 * height / 6, y + 2 * height / 6, y + 2 * height / 6, y, y + 2 * height / 6, + y + 2 * height / 6 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + width / 4, x + width / 4, - x + width / 4 - width / 16, x + width / 4 + width / 16, + int[] ptx3 = { x + width / 4, x + width / 4, x + width / 4 - width / 16, x + width / 4 + width / 16, x + width / 4, x + width / 4 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, + int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, + y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width - width / 4, x + width - width / 4 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 24 }; + int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + width / 4, - x + width / 4 - width / 16, x + width / 4 + width / 16, + int[] ptx5 = { x + width / 4, x + width / 4, x + width / 4 - width / 16, x + width / 4 + width / 16, x + width / 4, x + width / 4 }; - int[] pty5 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, + int[] pty5 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, + y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); int[] ptx6 = { x + width - width / 4, x + width - width / 4 }; - int[] pty6 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -1160,11 +1015,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1176,43 +1029,39 @@ public class ELNComponentVoltageControlledVoltageSource extends int[] ptx1 = { x + width - width / 16, x + width - width / 16 }; int[] pty1 = { y, y + 2 * height / 6 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width / 4, - x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, - x + width - width / 16, x + width - width / 16, x + width / 16 }; - int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, - y + 3 * height / 6, y + 4 * height / 6, y + 4 * height / 6, - y + 5 * height / 6, y + 4 * height / 6, y + 4 * height / 6, - y + height, y + 4 * height / 6, y + 4 * height / 6 }; + int[] ptx2 = { x + width / 16, x + width / 16, x + width / 4, x + 2 * width / 4, x + 3 * width / 4, + x + width / 4, x + 2 * width / 4, x + 3 * width / 4, x + width - width / 16, x + width - width / 16, + x + width - width / 16, x + width / 16 }; + int[] pty2 = { y + height, y + 4 * height / 6, y + 4 * height / 6, y + 3 * height / 6, y + 4 * height / 6, + y + 4 * height / 6, y + 5 * height / 6, y + 4 * height / 6, y + 4 * height / 6, y + height, + y + 4 * height / 6, y + 4 * height / 6 }; g.drawPolygon(ptx2, pty2, 12); - int[] ptx3 = { x + width / 4, x + width / 4, - x + width / 4 - width / 16, x + width / 4 + width / 16, + int[] ptx3 = { x + width / 4, x + width / 4, x + width / 4 - width / 16, x + width / 4 + width / 16, x + width / 4, x + width / 4 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, + int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, + y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx3, pty3, 6); int[] ptx4 = { x + width - width / 4, x + width - width / 4 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, - y + 2 * height / 6 - height / 24 }; + int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + width / 4, - x + width / 4 - width / 16, x + width / 4 + width / 16, + int[] ptx5 = { x + width / 4, x + width / 4, x + width / 4 - width / 16, x + width / 4 + width / 16, x + width / 4, x + width / 4 }; - int[] pty5 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, + int[] pty5 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, + y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx5, pty5, 6); int[] ptx6 = { x + width - width / 4, x + width - width / 4 }; - int[] pty6 = { y + 4 * height / 6 + height / 24, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] pty6 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; g.drawPolygon(ptx6, pty6, 2); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 16, y + height / 24, width + width / 8, height - height / 12, + 10, 10)); + g2d.dispose(); + g.drawOval(x, y, width / 8, height / 12); g.setColor(Color.WHITE); g.fillOval(x, y, width / 8, height / 12); @@ -1225,11 +1074,9 @@ public class ELNComponentVoltageControlledVoltageSource extends g.setColor(Color.WHITE); g.fillOval(x, y + height - height / 12, width / 8, height / 12); g.setColor(c); - g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.drawOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(Color.WHITE); - g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, - height / 12); + g.fillOval(x + width - width / 8, y + height - height / 12, width / 8, height / 12); g.setColor(c); } @@ -1265,8 +1112,7 @@ public class ELNComponentVoltageControlledVoltageSource extends return new String(sb); } - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) - throws MalformedModelingException { + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { try { NodeList nli; Node n1, n2; @@ -1285,20 +1131,13 @@ public class ELNComponentVoltageControlledVoltageSource extends if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("attributes")) { - value = Double.parseDouble(elt - .getAttribute("value")); - position = Integer.parseInt(elt - .getAttribute("position")); - fv_0_2 = Boolean.parseBoolean(elt - .getAttribute("fv_0_2")); - fv_1_3 = Boolean.parseBoolean(elt - .getAttribute("fv_1_3")); - fh_0_2 = Boolean.parseBoolean(elt - .getAttribute("fh_0_2")); - fh_1_3 = Boolean.parseBoolean(elt - .getAttribute("fh_1_3")); - first = Boolean.parseBoolean(elt - .getAttribute("first")); + value = Double.parseDouble(elt.getAttribute("value")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); setVal(value); setPosition(position); setFv_0_2(fv_0_2); @@ -1316,8 +1155,7 @@ public class ELNComponentVoltageControlledVoltageSource extends } } - public void addActionToPopupMenu(JPopupMenu componentMenu, - ActionListener menuAL, int x, int y) { + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); @@ -1448,8 +1286,7 @@ public class ELNComponentVoltageControlledVoltageSource extends if ((father != null) && (father instanceof ELNModule)) { resizeToFatherSize(); - setCdRectangle(0, father.getWidth() - getWidth(), 0, - father.getHeight() - getHeight()); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); setMoveCd(x, y); } } @@ -1462,7 +1299,6 @@ public class ELNComponentVoltageControlledVoltageSource extends myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); - setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), - tdp.getMaxY()); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } } \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java index 51c4325473ef2026e4e112462f7db17af55a96dc..2d8694d2de7d427a161d8e356d8c288ddfe1acce 100644 --- a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java @@ -39,27 +39,27 @@ package ui.eln.sca_eln_sca_tdf; 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.JDialogELNComponentCurrentSinkTDF; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; /** * Class ELNComponentCurrentSinkTDF * Converts current to a TDF output signal to be used in ELN diagrams - * Creation: 29/06/2018 - * @version 1.0 29/06/2018 + * Creation: 17/07/2018 + * @version 1.0 17/07/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent implements ActionListener { +public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -77,11 +77,10 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent private int old; private boolean first; - public ELNComponentCurrentSinkTDF(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, - boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentCurrentSinkTDF(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(80, 80); + initScaling(100, 100); dtextX = textX * oldScaleFactor; textX = (int) dtextX; @@ -90,6 +89,8 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent minWidth = 1; minHeight = 1; + initPortTerminal(3); + addTGConnectingPointsComment(); moveable = true; @@ -105,12 +106,13 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent 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.0, "p"); -// connectingPoint[1] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 1.0, "n"); -// } + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "outp"); + } public Color getMyColor() { return myColor; @@ -119,6 +121,7 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent public void internalDrawing(Graphics g) { Font f = g.getFont(); Font fold = f; + MainGUI mgui = getTDiagramPanel().getMainGUI(); if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; @@ -158,11 +161,15 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("outp"); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 4); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -170,52 +177,76 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent || (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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } 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); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } } else if (position == 1) { if (first == false) { @@ -230,11 +261,14 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 6); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -242,52 +276,74 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent || (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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, - y + height + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } 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(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, - y + height + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } } else if (position == 2) { if (first == false) { @@ -302,11 +358,15 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("outp"); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 4); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -314,52 +374,76 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent || (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(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } 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); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } } else if (position == 3) { if (first == false) { @@ -374,11 +458,14 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 6); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -386,52 +473,74 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent || (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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, - y + height + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } 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(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, - y + height + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } } g.setColor(c); @@ -439,203 +548,239 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent } private void rotateTop(Graphics g) { - int[] ptx0 = { x, x + 2 * width / 6 }; - int[] pty0 = { y, y }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x, x + 2 * width / 6 }; - int[] pty1 = { y + height, y + height }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height / 8, y + height / 8, y + height / 16, y + height / 8 + height / 16, y + height / 8, - y + height / 8 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; - int[] pty4 = { y + height - height / 8, y + height - height / 8 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 6, x + 5 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, - y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + 2 * width / 5 - width / 20, x + 2 * width / 5, x + 2 * width / 5 + width / 20 }; + int[] pty1 = { y + height / 2, y + height / 2 + height / 20, y + height / 2 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateTopFlip(Graphics g) { - int[] ptx0 = { x, x + 2 * width / 6 }; - int[] pty0 = { y, y }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x, x + 2 * width / 6 }; - int[] pty1 = { y + height, y + height }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height - height / 8, y + height - height / 8, y + height - height / 16, - y + height - height / 8 - height / 16, y + height - height / 8, y + height - height / 8 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; - int[] pty4 = { y + height / 8, y + height / 8 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 6, x + 5 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, - y + height / 4 + height / 8, y + height / 4 + height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + 2 * width / 5 - width / 20, x + 2 * width / 5, x + 2 * width / 5 + width / 20 }; + int[] pty1 = { y + height / 2, y + height / 2 - height / 20, y + height / 2 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateBottom(Graphics g) { - int[] ptx0 = { x + 4 * width / 6, x + width }; - int[] pty0 = { y, y }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + 4 * width / 6, x + width }; - int[] pty1 = { y + height, y + height }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty3 = { y + height - height / 8, y + height - height / 8, y + height - height / 16, - y + height - height / 8 - height / 16, y + height - height / 8, y + height - height / 8 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty4 = { y + height / 8, y + height / 8 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12, x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 6, - x + width / 6 - width / 12 - width / 24 }; - int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, - y + height / 4 + height / 8, y + height / 4 + height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + width, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + 3 * width / 5 - width / 20, x + 3 * width / 5, x + 3 * width / 5 + width / 20 }; + int[] pty1 = { y + height / 2, y + height / 2 - height / 20, y + height / 2 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateBottomFlip(Graphics g) { - int[] ptx0 = { x + 4 * width / 6, x + width }; - int[] pty0 = { y, y }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + 4 * width / 6, x + width }; - int[] pty1 = { y + height, y + height }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty3 = { y + height / 8, y + height / 8, y + height / 16, y + height / 8 + height / 16, y + height / 8, - y + height / 8 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty4 = { y + height - height / 8, y + height - height / 8 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12, x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 6, - x + width / 6 - width / 12 - width / 24 }; - int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, - y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + width, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + 3 * width / 5 - width / 20, x + 3 * width / 5, x + 3 * width / 5 + width / 20 }; + int[] pty1 = { y + height / 2, y + height / 2 + height / 20, y + height / 2 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateRight(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y, y + 2 * height / 6 }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y, y + 2 * height / 6 }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width - width / 8, x + width - width / 8, x + width - width / 16, - x + width - width / 8 - width / 16, x + width - width / 8, x + width - width / 8 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 24 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width / 8, x + width / 8 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, - x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + width / 2, x + width / 2 - width / 20, x + width / 2 }; + int[] pty1 = { y + 2 * height / 5 - height / 20, y + 2 * height / 5, y + 2 * height / 5 + height / 20 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); } private void rotateRightFlip(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y + 4 * height / 6, y + height }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y + 4 * height / 6, y + height }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width - width / 8, x + width - width / 8, x + width - width / 16, - x + width - width / 8 - width / 16, x + width - width / 8, x + width - width / 8 }; - int[] pty3 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width / 8, x + width / 8 }; - int[] pty4 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, - x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty5 = { y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12, y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 6, - y + height / 6 - height / 12 - height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + height, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + width / 2, x + width / 2 - width / 20, x + width / 2 }; + int[] pty1 = { y + 3 * height / 5 - height / 20, y + 3 * height / 5, y + 3 * height / 5 + height / 20 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateLeft(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y + 4 * height / 6, y + height }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y + 4 * height / 6, y + height }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width / 8, x + width / 8, x + width / 16, x + width / 8 + width / 16, x + width / 8, - x + width / 8 }; - int[] pty3 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width - width / 8, x + width - width / 8 }; - int[] pty4 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, - x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty5 = { y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12, y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 6, - y + height / 6 - height / 12 - height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + height, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + width / 2, x + width / 2 + width / 20, x + width / 2 }; + int[] pty1 = { y + 3 * height / 5 - height / 20, y + 3 * height / 5, y + 3 * height / 5 + height / 20 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateLeftFlip(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y, y + 2 * height / 6 }; - g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y, y + 2 * height / 6 }; - g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width / 8, x + width / 8, x + width / 16, x + width / 8 + width / 16, x + width / 8, - x + width / 8 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 24 }; - g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width - width / 8, x + width - width / 8 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; - g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, - x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + width / 2, x + width / 2 + width / 20, x + width / 2 }; + int[] pty1 = { y + 2 * height / 5 - height / 20, y + 2 * height / 5, y + 2 * height / 5 + height / 20 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -659,8 +804,6 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<attributes scale=\"" + scale); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -678,7 +821,7 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent Element elt; double scale; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -692,8 +835,6 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent if (elt.getTagName().equals("attributes")) { scale = Double.parseDouble(elt.getAttribute("scale")); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); @@ -701,8 +842,6 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent first = Boolean.parseBoolean(elt.getAttribute("first")); setScale(scale); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -721,11 +860,11 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); - JMenuItem rotateright = new JMenuItem("Rotate right 90°"); + JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); rotateright.addActionListener(this); componentMenu.add(rotateright); - JMenuItem rotateleft = new JMenuItem("Rotate left 90°"); + JMenuItem rotateleft = new JMenuItem("Rotate left 90\u00b0"); rotateleft.addActionListener(this); componentMenu.add(rotateleft); @@ -741,12 +880,12 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent } public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("Rotate right 90°")) { + if (e.getActionCommand().equals("Rotate right 90\u00b0")) { position++; position %= 4; first = false; } - if (e.getActionCommand().equals("Rotate left 90°")) { + if (e.getActionCommand().equals("Rotate left 90\u00b0")) { position = position + 3; position %= 4; first = false; @@ -801,47 +940,67 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent 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 void resizeWithFather() { + if ((father != null) && (father instanceof ELNModule)) { + resizeToFatherSize(); + + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setMoveCd(x, y); + } + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } -} +} \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java index 0e6f725396fbeab98d8909199edbe5ea948acb16..701abb53ac55dcc92ff20a1c345a7559ae9843d8 100644 --- a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java @@ -39,28 +39,28 @@ package ui.eln.sca_eln_sca_tdf; 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.JDialogELNComponentVoltageSinkTDF; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; /** * Class ELNComponentVoltageSinkTDF * Converts voltage to a TDF output signal to be used in ELN diagrams - * Creation: 29/06/2018 - * @version 1.0 29/06/2018 + * Creation: 17/07/2018 + * @version 1.0 17/07/2018 * @author Irina Kit Yan LEE */ -public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent implements ActionListener { +public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { protected Color myColor; protected int orientation; private int maxFontSize = 14; @@ -78,11 +78,10 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent private int old; private boolean first; - public ELNComponentVoltageSinkTDF(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, - boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + public ELNComponentVoltageSinkTDF(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(80, 80); + initScaling(100, 100); dtextX = textX * oldScaleFactor; textX = (int) dtextX; @@ -91,6 +90,8 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent minWidth = 1; minHeight = 1; + initPortTerminal(3); + addTGConnectingPointsComment(); moveable = true; @@ -106,12 +107,13 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent 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.0, "p"); -// connectingPoint[1] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 1.0, "n"); -// } + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "n"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, 0.0, "outp"); + } public Color getMyColor() { return myColor; @@ -120,6 +122,7 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent public void internalDrawing(Graphics g) { Font f = g.getFont(); Font fold = f; + MainGUI mgui = getTDiagramPanel().getMainGUI(); if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; @@ -159,11 +162,15 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("outp"); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 4); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -171,52 +178,76 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent || (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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } 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); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } } else if (position == 1) { if (first == false) { @@ -231,11 +262,14 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 6); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -243,52 +277,74 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent || (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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, - y + height + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } 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(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, - y + height + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } } else if (position == 2) { if (first == false) { @@ -303,11 +359,15 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("outp"); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 4); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -315,52 +375,76 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent || (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(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } 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); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + height / 8, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + height / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 5 + sh2); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - height / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - height / 8 - sw1, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 5 + sh2); + } } } else if (position == 3) { if (first == false) { @@ -375,11 +459,14 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent int sh0 = g.getFontMetrics().getAscent(); int sw1 = g.getFontMetrics().stringWidth("n"); int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); int w = g.getFontMetrics().stringWidth(value); g.setFont(f.deriveFont((float) attributeFontSize)); g.setFont(f); g.setFont(f.deriveFont(Font.BOLD)); - g.drawString(value, x + (width - w) / 2, y - height / 6); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } g.setFont(f.deriveFont(Font.PLAIN)); if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) @@ -387,52 +474,74 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent || (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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, - y + height + sh0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, - y + height + sh1); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } 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(0.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 8 - sw0, y); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } 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(1.0); - ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, - y + height + sh1); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, - y + height + sh0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, y); + } } 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.0); - ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); - ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); - g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 8 - sw1, y); - g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 8, y); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNPortTerminal) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNPortTerminal) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNPortTerminal) connectingPoint[2]).getName(), x + width / 2 + width / 5, + y + height + sh2); + } } } g.setColor(c); @@ -440,203 +549,331 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent } private void rotateTop(Graphics g) { - int[] ptx0 = { x, x + 2 * width / 6 }; - int[] pty0 = { y, y }; + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5 - width / 10 }; + int[] pty0 = { y + height / 20, y + height / 20 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x, x + 2 * width / 6 }; - int[] pty1 = { y + height, y + height }; + int[] ptx1 = { x, x + 2 * width / 5 - width / 10 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height / 8, y + height / 8, y + height / 16, y + height / 8 + height / 16, y + height / 8, - y + height / 8 }; + int[] ptx3 = { x + width / 5 - width / 20, x + width / 5, x + width / 5, x + width / 5, x + width / 5, + x + width / 5 + width / 20 }; + int[] pty3 = { y + height / 10 + height / 20, y + height / 10 + height / 20, y + height / 10, y + height / 5, + y + height / 10 + height / 20, y + height / 10 + height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; - int[] pty4 = { y + height - height / 8, y + height - height / 8 }; + int[] ptx4 = { x + width / 5 - width / 20, x + width / 5 + width / 20 }; + int[] pty4 = { y + height - height / 10 - height / 20, y + height - height / 10 - height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 6, x + 5 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, - y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 - width / 20, + x + 2 * width / 5 + width / 20, x + 2 * width / 5 }; + int[] pty5 = { y + height / 20, y + height - height / 20, y + height - height / 10, y + height - height / 10, + y + height - height / 20 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateTopFlip(Graphics g) { - int[] ptx0 = { x, x + 2 * width / 6 }; - int[] pty0 = { y, y }; + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5 - width / 10 }; + int[] pty0 = { y + height / 20, y + height / 20 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x, x + 2 * width / 6 }; - int[] pty1 = { y + height, y + height }; + int[] ptx1 = { x, x + 2 * width / 5 - width / 10 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, x + 2 * width / 6 - width / 12, - x + 2 * width / 6 - width / 24 }; - int[] pty3 = { y + height - height / 8, y + height - height / 8, y + height - height / 16, - y + height - height / 8 - height / 16, y + height - height / 8, y + height - height / 8 }; + int[] ptx3 = { x + width / 5 - width / 20, x + width / 5, x + width / 5, x + width / 5, x + width / 5, + x + width / 5 + width / 20 }; + int[] pty3 = { y + height - height / 10 - height / 20, y + height - height / 10 - height / 20, + y + height - 2 * height / 10, y + height - height / 10, y + height - height / 10 - height / 20, + y + height - height / 10 - height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 2 * width / 6 - width / 12 - width / 24, x + 2 * width / 6 - width / 24 }; - int[] pty4 = { y + height / 8, y + height / 8 }; + int[] ptx4 = { x + width / 5 - width / 20, x + width / 5 + width / 20 }; + int[] pty4 = { y + height / 10 + height / 20, y + height / 10 + height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 5 * width / 6 + width / 12 + width / 24, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 12, x + 5 * width / 6 + width / 12 + width / 24, - x + 5 * width / 6 + width / 6, x + 5 * width / 6 + width / 12 + width / 24 }; - int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, - y + height / 4 + height / 8, y + height / 4 + height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 - width / 20, + x + 2 * width / 5 + width / 20, x + 2 * width / 5 }; + int[] pty5 = { y + height - height / 20, y + height / 20, y + height / 10, y + height / 10, y + height / 20 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateBottom(Graphics g) { - int[] ptx0 = { x + 4 * width / 6, x + width }; - int[] pty0 = { y, y }; + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5 + width / 10 }; + int[] pty0 = { y + height / 20, y + height / 20 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + 4 * width / 6, x + width }; - int[] pty1 = { y + height, y + height }; + int[] ptx1 = { x + height, x + 3 * width / 5 + width / 10 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty3 = { y + height - height / 8, y + height - height / 8, y + height - height / 16, - y + height - height / 8 - height / 16, y + height - height / 8, y + height - height / 8 }; + int[] ptx3 = { x + 4 * width / 5 - width / 20, x + 4 * width / 5, x + 4 * width / 5, x + 4 * width / 5, + x + 4 * width / 5, x + 4 * width / 5 + width / 20 }; + int[] pty3 = { y + height - height / 10 - height / 20, y + height - height / 10 - height / 20, + y + height - 2 * height / 10, y + height - height / 10, y + height - height / 10 - height / 20, + y + height - height / 10 - height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty4 = { y + height / 8, y + height / 8 }; + int[] ptx4 = { x + 4 * width / 5 - width / 20, x + 4 * width / 5 + width / 20 }; + int[] pty4 = { y + height / 10 + height / 20, y + height / 10 + height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12, x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 6, - x + width / 6 - width / 12 - width / 24 }; - int[] pty5 = { y + 3 * height / 4, y + height / 4 + height / 8, y + height / 4 + height / 8, y + height / 4, - y + height / 4 + height / 8, y + height / 4 + height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 + width / 20, + x + 3 * width / 5 - width / 20, x + 3 * width / 5 }; + int[] pty5 = { y + height - height / 20, y + height / 20, y + height / 10, y + height / 10, y + height / 20 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateBottomFlip(Graphics g) { - int[] ptx0 = { x + 4 * width / 6, x + width }; - int[] pty0 = { y, y }; + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5 + width / 10 }; + int[] pty0 = { y + height / 20, y + height / 20 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + 4 * width / 6, x + width }; - int[] pty1 = { y + height, y + height }; + int[] ptx1 = { x + height, x + 3 * width / 5 + width / 10 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12, x + 4 * width / 6 + width / 12, - x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty3 = { y + height / 8, y + height / 8, y + height / 16, y + height / 8 + height / 16, y + height / 8, - y + height / 8 }; + int[] ptx3 = { x + 4 * width / 5 - width / 20, x + 4 * width / 5, x + 4 * width / 5, x + 4 * width / 5, + x + 4 * width / 5, x + 4 * width / 5 + width / 20 }; + int[] pty3 = { y + height / 10 + height / 20, y + height / 10 + height / 20, y + height / 10, y + height / 5, + y + height / 10 + height / 20, y + height / 10 + height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + 4 * width / 6 + width / 24, x + 4 * width / 6 + width / 12 + width / 24 }; - int[] pty4 = { y + height - height / 8, y + height - height / 8 }; + int[] ptx4 = { x + 4 * width / 5 - width / 20, x + 4 * width / 5 + width / 20 }; + int[] pty4 = { y + height - height / 10 - height / 20, y + height - height / 10 - height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 12 - width / 24, - x + width / 6 - width / 12, x + width / 6 - width / 12 - width / 24, x + width / 6 - width / 6, - x + width / 6 - width / 12 - width / 24 }; - int[] pty5 = { y + height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8, - y + 3 * height / 4, y + 3 * height / 4 - height / 8, y + 3 * height / 4 - height / 8 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 + width / 20, + x + 3 * width / 5 - width / 20, x + 3 * width / 5 }; + int[] pty5 = { y + height / 20, y + height - height / 20, y + height - height / 10, y + height - height / 10, + y + height - height / 20 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 * width / 5 + width / 10 - width / 20, + height + height / 10, 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateRight(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y, y + 2 * height / 6 }; + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y, y + 2 * height / 6 }; + int[] ptx1 = { x + width - width / 20, x + width - width / 20 }; + int[] pty1 = { y, y + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width - width / 8, x + width - width / 8, x + width - width / 16, - x + width - width / 8 - width / 16, x + width - width / 8, x + width - width / 8 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 24 }; + int[] ptx3 = { x + width - width / 10 - width / 20, x + width - width / 10 - width / 20, + x + width - width / 10 - width / 10, x + width - width / 10, x + width - width / 10 - width / 20, + x + width - width / 10 - width / 20 }; + int[] pty3 = { y + height / 5 - height / 20, y + height / 5, y + height / 5, y + height / 5, y + height / 5, + y + height / 5 + height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width / 8, x + width / 8 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; + int[] ptx4 = { x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty4 = { y + height / 5 - height / 20, y + height / 5 + height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, - x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + width - width / 20, x + width / 20, x + width / 10, x + width / 10, x + width / 20 }; + int[] pty5 = { y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 - height / 20, + y + 2 * height / 5 + height / 20, y + 2 * height / 5 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); } private void rotateRightFlip(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y + 4 * height / 6, y + height }; + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5 + height / 10 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y + 4 * height / 6, y + height }; + int[] ptx1 = { x + width - width / 20, x + width - width / 20 }; + int[] pty1 = { y + height, y + 3 * height / 5 + height / 10 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width - width / 8, x + width - width / 8, x + width - width / 16, - x + width - width / 8 - width / 16, x + width - width / 8, x + width - width / 8 }; - int[] pty3 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] ptx3 = { x + width - width / 10 - width / 20, x + width - width / 10 - width / 20, + x + width - width / 10 - width / 10, x + width - width / 10, x + width - width / 10 - width / 20, + x + width - width / 10 - width / 20 }; + int[] pty3 = { y + 4 * height / 5 - height / 20, y + 4 * height / 5, y + 4 * height / 5, y + 4 * height / 5, + y + 4 * height / 5, y + 4 * height / 5 + height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width / 8, x + width / 8 }; - int[] pty4 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; + int[] ptx4 = { x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty4 = { y + 4 * height / 5 - height / 20, y + 4 * height / 5 + height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + 3 * width / 4, x + width / 4 + width / 8, x + width / 4 + width / 8, x + width / 4, - x + width / 4 + width / 8, x + width / 4 + width / 8 }; - int[] pty5 = { y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12, y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 6, - y + height / 6 - height / 12 - height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + width - width / 20, x + width / 20, x + width / 10, x + width / 10, x + width / 20 }; + int[] pty5 = { y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 + height / 20, + y + 3 * height / 5 - height / 20, y + 3 * height / 5 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateLeft(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y + 4 * height / 6, y + height }; + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5 + height / 10 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y + 4 * height / 6, y + height }; + int[] ptx1 = { x + width - width / 20, x + width - width / 20 }; + int[] pty1 = { y + height, y + 3 * height / 5 + height / 10 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width / 8, x + width / 8, x + width / 16, x + width / 8 + width / 16, x + width / 8, - x + width / 8 }; - int[] pty3 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, y + 4 * height / 6 + height / 12, - y + 4 * height / 6 + height / 12 + height / 24 }; + int[] ptx3 = { x + width / 10 + width / 20, x + width / 10 + width / 20, x + width / 10, x + width / 5, + x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty3 = { y + 4 * height / 5 - height / 20, y + 4 * height / 5, y + 4 * height / 5, y + 4 * height / 5, + y + 4 * height / 5, y + 4 * height / 5 + height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width - width / 8, x + width - width / 8 }; - int[] pty4 = { y + 4 * height / 6 + height / 24, y + 4 * height / 6 + height / 12 + height / 24 }; + int[] ptx4 = { x + width - width / 10 - width / 20, x + width - width / 10 - width / 20 }; + int[] pty4 = { y + 4 * height / 5 - height / 20, y + 4 * height / 5 + height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, - x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty5 = { y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 12 - height / 24, - y + height / 6 - height / 12, y + height / 6 - height / 12 - height / 24, y + height / 6 - height / 6, - y + height / 6 - height / 12 - height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + width / 20, x + width - width / 20, x + width - width / 10, x + width - width / 10, + x + width - width / 20 }; + int[] pty5 = { y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 + height / 20, + y + 3 * height / 5 - height / 20, y + 3 * height / 5 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, width / 10, height / 10); + g.setColor(c); } private void rotateLeftFlip(Graphics g) { - int[] ptx0 = { x, x }; - int[] pty0 = { y, y + 2 * height / 6 }; + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx0, pty0, 2); - int[] ptx1 = { x + width, x + width }; - int[] pty1 = { y, y + 2 * height / 6 }; + int[] ptx1 = { x + width - width / 20, x + width - width / 20 }; + int[] pty1 = { y, y + 2 * height / 5 - height / 10 }; g.drawPolygon(ptx1, pty1, 2); - int[] ptx3 = { x + width / 8, x + width / 8, x + width / 16, x + width / 8 + width / 16, x + width / 8, - x + width / 8 }; - int[] pty3 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, y + 2 * height / 6 - height / 12, - y + 2 * height / 6 - height / 24 }; + int[] ptx3 = { x + width / 10 + width / 20, x + width / 10 + width / 20, x + width / 10, x + width / 5, + x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty3 = { y + height / 5 - height / 20, y + height / 5, y + height / 5, y + height / 5, y + height / 5, + y + height / 5 + height / 20 }; g.drawPolygon(ptx3, pty3, 6); - int[] ptx4 = { x + width - width / 8, x + width - width / 8 }; - int[] pty4 = { y + 2 * height / 6 - height / 12 - height / 24, y + 2 * height / 6 - height / 24 }; + int[] ptx4 = { x + width - width / 10 - width / 20, x + width - width / 10 - width / 20 }; + int[] pty4 = { y + height / 5 - height / 20, y + height / 5 + height / 20 }; g.drawPolygon(ptx4, pty4, 2); - int[] ptx5 = { x + width / 4, x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8, x + 3 * width / 4, - x + 3 * width / 4 - width / 8, x + 3 * width / 4 - width / 8 }; - int[] pty5 = { y + 5 * height / 6 + height / 12 + height / 24, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 12, y + 5 * height / 6 + height / 12 + height / 24, - y + 5 * height / 6 + height / 6, y + 5 * height / 6 + height / 12 + height / 24 }; - g.drawPolygon(ptx5, pty5, 6); - g.fillPolygon(ptx5, pty5, 6); + int[] ptx5 = { x + width / 20, x + width - width / 20, x + width - width / 10, x + width - width / 10, + x + width - width / 20 }; + int[] pty5 = { y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 - height / 20, + y + 2 * height / 5 + height / 20, y + 2 * height / 5 }; + g.drawPolygon(ptx5, pty5, 5); + g.fillPolygon(ptx5, pty5, 5); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, width + width / 10, + 4 * height / 5 + height / 10 - height / 20, 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); } public TGComponent isOnOnlyMe(int _x, int _y) { @@ -660,8 +897,6 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<attributes scale=\"" + scale); sb.append("\" position=\"" + position); - sb.append("\" width=\"" + width); - sb.append("\" height=\"" + height); sb.append("\" fv_0_2=\"" + fv_0_2); sb.append("\" fv_1_3=\"" + fv_1_3); sb.append("\" fh_0_2=\"" + fh_0_2); @@ -679,7 +914,7 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent Element elt; double scale; - int position, width, height; + int position; boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; for (int i = 0; i < nl.getLength(); i++) { @@ -693,8 +928,6 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent if (elt.getTagName().equals("attributes")) { scale = Double.parseDouble(elt.getAttribute("scale")); position = Integer.parseInt(elt.getAttribute("position")); - width = Integer.parseInt(elt.getAttribute("width")); - height = Integer.parseInt(elt.getAttribute("height")); fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); @@ -702,8 +935,6 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent first = Boolean.parseBoolean(elt.getAttribute("first")); setScale(scale); setPosition(position); - this.width = width; - this.height = height; setFv_0_2(fv_0_2); setFv_1_3(fv_1_3); setFh_0_2(fh_0_2); @@ -722,11 +953,11 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { componentMenu.addSeparator(); - JMenuItem rotateright = new JMenuItem("Rotate right 90°"); + JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); rotateright.addActionListener(this); componentMenu.add(rotateright); - JMenuItem rotateleft = new JMenuItem("Rotate left 90°"); + JMenuItem rotateleft = new JMenuItem("Rotate left 90\u00b0"); rotateleft.addActionListener(this); componentMenu.add(rotateleft); @@ -742,12 +973,12 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent } public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("Rotate right 90°")) { + if (e.getActionCommand().equals("Rotate right 90\u00b0")) { position++; position %= 4; first = false; } - if (e.getActionCommand().equals("Rotate left 90°")) { + if (e.getActionCommand().equals("Rotate left 90\u00b0")) { position = position + 3; position %= 4; first = false; @@ -802,47 +1033,67 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent 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 void resizeWithFather() { + if ((father != null) && (father instanceof ELNModule)) { + resizeToFatherSize(); + + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setMoveCd(x, y); + } + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } -} +} \ No newline at end of file diff --git a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java index 0280a3ee7ffbcf9ebf29e42a6f36a760814e7190..ec11c83c40cd2a3873e75760254448a477274438 100755 --- a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -146,10 +146,17 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene protected JTextField stateFileName; protected JTextField benchmarkFileName; protected JComboBox<String> cpus, busses, mems, tasks, chans; - private Map<String, List<Integer>> channelIDMap= new HashMap<String, List<Integer>>(); + private Map<String, List<Integer>> origChannelIDMap= new HashMap<String, List<Integer>>(); + private Map<String, List<Integer>> destChannelIDMap= new HashMap<String, List<Integer>>(); private String[] cpuIDs, busIDs, memIDs, taskIDs, chanIDs; private List<String> simtraces= new ArrayList<String>(); + + //Find matching channels + public Map<String, List<Integer>> channelMsgIdMap = new HashMap<String, List<Integer>>(); + public Map<Integer, String> msgIdStartTimeMap = new HashMap<Integer, String>(); + public Map<Integer, String> msgIdEndTimeMap = new HashMap<Integer, String>(); + // Status elements private JLabel status, time, info; @@ -1383,7 +1390,11 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void resetSimTrace(){ msgTimes.clear(); chanId=0; - channelIDMap.clear(); + channelMsgIdMap.clear(); + msgIdStartTimeMap.clear(); + msgIdEndTimeMap.clear(); + origChannelIDMap.clear(); + destChannelIDMap.clear(); simtraces.clear(); simIndex=0; } @@ -1563,21 +1574,31 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene msgTimes.put(tran.channelName, new ArrayList<String>()); } if (!msgTimes.get(tran.channelName).contains(tran.endTime)){ - if (channelIDMap.containsKey(tran.channelName) && channelIDMap.get(tran.channelName).size()>0){ - msgId=channelIDMap.get(tran.channelName).remove(0); - } - else { - if (!channelIDMap.containsKey(tran.channelName)){ - channelIDMap.put(tran.channelName, new ArrayList<Integer>()); - } - channelIDMap.get(tran.channelName).add(msgId); - chanId++; - } String trace=""; if (command.equals("Write")){ + if (destChannelIDMap.containsKey(tran.channelName) && destChannelIDMap.get(tran.channelName).size()>0){ + msgId=destChannelIDMap.get(tran.channelName).remove(0); + } + else { + if (!origChannelIDMap.containsKey(tran.channelName)){ + origChannelIDMap.put(tran.channelName, new ArrayList<Integer>()); + } + origChannelIDMap.get(tran.channelName).add(msgId); + chanId++; + } trace = "time=" + tran.endTime+ " block="+ originTask.getName() + " type="+asynchType+ " blockdestination="+ destTask.getName() + " channel="+tran.channelName+" msgid="+ msgId + " params=\"" +chan.getSize()+"\""; } else { + if (origChannelIDMap.containsKey(tran.channelName) && origChannelIDMap.get(tran.channelName).size()>0){ + msgId=origChannelIDMap.get(tran.channelName).remove(0); + } + else { + if (!destChannelIDMap.containsKey(tran.channelName)){ + destChannelIDMap.put(tran.channelName, new ArrayList<Integer>()); + } + destChannelIDMap.get(tran.channelName).add(msgId); + chanId++; + } trace = "time=" + tran.endTime+ " block="+ destTask.getName() + " type="+asynchType+ " blockdestination="+ destTask.getName() + " channel="+tran.channelName+" msgid="+ msgId + " params=\"" +chan.getSize()+"\""; } // @@ -1611,21 +1632,31 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene msgTimes.put(tran.channelName, new ArrayList<String>()); } if (!msgTimes.get(tran.channelName).contains(tran.endTime)){ - if (channelIDMap.containsKey(tran.channelName) && channelIDMap.get(tran.channelName).size()>0){ - msgId=channelIDMap.get(tran.channelName).remove(0); - } - else { - if (!channelIDMap.containsKey(tran.channelName)){ - channelIDMap.put(tran.channelName, new ArrayList<Integer>()); - } - channelIDMap.get(tran.channelName).add(msgId); - chanId++; - } String trace=""; if (command.equals("Send")){ + if (destChannelIDMap.containsKey(tran.channelName) && destChannelIDMap.get(tran.channelName).size()>0){ + msgId=destChannelIDMap.get(tran.channelName).remove(0); + } + else { + if (!origChannelIDMap.containsKey(tran.channelName)){ + origChannelIDMap.put(tran.channelName, new ArrayList<Integer>()); + } + origChannelIDMap.get(tran.channelName).add(msgId); + chanId++; + } trace = "time=" + tran.endTime+ " block="+ originTask.getName() + " type="+asynchType+ " blockdestination="+ destTask.getName() + " channel="+tran.channelName+" msgid="+ msgId + " params=\""; } else { + if (origChannelIDMap.containsKey(tran.channelName) && origChannelIDMap.get(tran.channelName).size()>0){ + msgId=origChannelIDMap.get(tran.channelName).remove(0); + } + else { + if (!destChannelIDMap.containsKey(tran.channelName)){ + destChannelIDMap.put(tran.channelName, new ArrayList<Integer>()); + } + destChannelIDMap.get(tran.channelName).add(msgId); + chanId++; + } trace = "time=" + tran.endTime+ " block="+ destTask.getName() + " type="+asynchType+ " blockdestination="+ destTask.getName() + " channel="+tran.channelName+" msgid="+ msgId + " params=\""; } // @@ -1666,25 +1697,47 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene int msgId=chanId; if (!msgTimes.containsKey(tran.channelName)){ msgTimes.put(tran.channelName, new ArrayList<String>()); + } + if (!channelMsgIdMap.containsKey(tran.channelName)){ + channelMsgIdMap.put(tran.channelName, new ArrayList<Integer>()); } + + + if (!msgTimes.get(tran.channelName).contains(tran.endTime)){ - if (channelIDMap.containsKey(tran.channelName) && channelIDMap.get(tran.channelName).size()>0){ - msgId=channelIDMap.get(tran.channelName).remove(0); - } - else { - if (!channelIDMap.containsKey(tran.channelName)){ - channelIDMap.put(tran.channelName, new ArrayList<Integer>()); - } - channelIDMap.get(tran.channelName).add(msgId); - chanId++; - } + + String trace=""; if (command.equals("Request")){ + if (destChannelIDMap.containsKey(tran.channelName) && destChannelIDMap.get(tran.channelName).size()>0){ + msgId=destChannelIDMap.get(tran.channelName).remove(0); + } + else { + if (!origChannelIDMap.containsKey(tran.channelName)){ + origChannelIDMap.put(tran.channelName, new ArrayList<Integer>()); + } + origChannelIDMap.get(tran.channelName).add(msgId); + chanId++; + } trace = "time=" + tran.endTime+ " block="+ tran.taskName + " type="+asynchType+ " blockdestination="+ destTask.getName() + " channel="+tran.channelName+" msgid="+ msgId + " params=\""; + msgIdStartTimeMap.put(msgId, tran.endTime); } else { + if (origChannelIDMap.containsKey(tran.channelName) && origChannelIDMap.get(tran.channelName).size()>0){ + msgId=origChannelIDMap.get(tran.channelName).remove(0); + } + else { + if (!destChannelIDMap.containsKey(tran.channelName)){ + destChannelIDMap.put(tran.channelName, new ArrayList<Integer>()); + } + destChannelIDMap.get(tran.channelName).add(msgId); + chanId++; + } trace = "time=" + tran.endTime+ " block="+ destTask.getName() + " type="+asynchType+ " blockdestination="+ destTask.getName() + " channel="+tran.channelName+" msgid="+ msgId + " params=\""; + msgIdEndTimeMap.put(msgId, tran.endTime); } + + channelMsgIdMap.get(tran.channelName).add(msgId); // if (!simtraces.contains(trace)){ simtraces.add(trace); @@ -1727,6 +1780,73 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } + public void calculateCorrespondingTimes(){ + for (String channel: channelMsgIdMap.keySet()){ + List<Integer> minTimes = new ArrayList<Integer>(); + for (int msgId: channelMsgIdMap.get(channel)){ + String startTime = msgIdStartTimeMap.get(msgId); + String endTime = msgIdEndTimeMap.get(msgId); + if (startTime!=null && endTime !=null){ + int diff = Integer.valueOf(endTime) - Integer.valueOf(startTime); + minTimes.add(diff); + } + } + SimulationLatency sl = new SimulationLatency(); + sl.setTransaction1("Send Req: " + channel); + sl.setTransaction2("Corresponding Wait Req " + channel); + + + + + sl.setMinTime("??"); + sl.setMaxTime("??"); + sl.setAverageTime("??"); + sl.setStDev("??"); + boolean found=false; + for (Object o:latencies){ + SimulationLatency s = (SimulationLatency) o; + if (s.getTransaction1().equals(sl.getTransaction1()) && s.getTransaction2().equals(sl.getTransaction2())){ + sl = s; + found=true; + } + } + if (!found){ + latencies.add(sl); + } + if (minTimes.size()>0){ + int sum=0; + sl.setMinTime(Integer.toString(Collections.min(minTimes))); + sl.setMaxTime(Integer.toString(Collections.max(minTimes))); + for (int time: minTimes){ + sum+=time; + } + double average = (double) sum/ (double) minTimes.size(); + double stdev =0.0; + for (int time:minTimes){ + stdev +=(time - average)*(time-average); + } + stdev= stdev/minTimes.size(); + stdev = Math.sqrt(stdev); + sl.setAverageTime(String.format("%.1f",average)); + sl.setStDev(String.format("%.1f",stdev)); + } + + + //updateLatency(); + // if (latm !=null && latencies.size()>0){ + // latm.setData(latencies); + // } + + + } + + + + //System.out.println(channelMsgIdMap); + //System.out.println(msgIdStartTimeMap); + //System.out.println(msgIdEndTimeMap); + } + protected void addStatusToNode(String status, String task){ mgui.addStatus(task,status); } @@ -2681,10 +2801,12 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene //calcuate response + checkpoint 1 id + checkpoint 2 id List<String> id1List = nameIdMap.get(sl.getTransaction1()); List<String> id2List = nameIdMap.get(sl.getTransaction2()); - for (String id1: id1List){ - for (String id2: id2List){ - sendCommand("cl " + id1 + " " + id2); - } + if (id1List!=null && id2List!=null){ + for (String id1: id1List){ + for (String id2: id2List){ + sendCommand("cl " + id1 + " " + id2); + } + } } } } @@ -2704,21 +2826,23 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene List<String> ids2 = nameIdMap.get(sl.getTransaction2()); List<Integer> times1 = new ArrayList<Integer>(); List<Integer> times2 = new ArrayList<Integer>(); - for (String id1: ids1){ - if (transTimes.containsKey(id1)){ - for(String time1: transTimes.get(id1)){ - times1.add(Integer.valueOf(time1)); - } + if (ids1!=null && ids2!=null){ + for (String id1: ids1){ + if (transTimes.containsKey(id1)){ + for(String time1: transTimes.get(id1)){ + times1.add(Integer.valueOf(time1)); + } + } } - } - for (String id2: ids2){ - if (transTimes.containsKey(id2)){ - ArrayList<Integer> minTimes = new ArrayList<Integer>(); - for (String time2: transTimes.get(id2)){ - times2.add(Integer.valueOf(time2)); - } - } - } + for (String id2: ids2){ + if (transTimes.containsKey(id2)){ + ArrayList<Integer> minTimes = new ArrayList<Integer>(); + for (String time2: transTimes.get(id2)){ + times2.add(Integer.valueOf(time2)); + } + } + } + } // // List<Integer> minTimes = new ArrayList<Integer>(); @@ -2756,6 +2880,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } } + calculateCorrespondingTimes(); if (latm!=null && latencies.size()>0){ latm.setData(latencies); } @@ -3449,7 +3574,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene checkedTransactions.add(compName+" (ID: " + tgc.getDIPLOID() + ")"); if (!nameIdMap.containsKey(compName)){ nameIdMap.put(compName,new ArrayList<String>()); - checkedTransactions.add(compName); + checkedTransactions.add(compName + " (all instances)"); } nameIdMap.get(compName).add(Integer.toString(tgc.getDIPLOID())); nameIdMap.put(compName+" (ID: " + tgc.getDIPLOID() + ")",new ArrayList<String>()); diff --git a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java index 27d8481ad52df9b47eaddac8170e978b9b810433..32c7c5c1c40f4f9a9ce5a4c4a39d25d29b4320ea 100644 --- a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java +++ b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java @@ -67,7 +67,6 @@ public class SysCAMSComponentTaskDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); - mgui.actions[TGUIAction.CAMS_CONNECTOR].setEnabled(b); mgui.actions[TGUIAction.CAMS_BLOCK_TDF].setEnabled(b); mgui.actions[TGUIAction.CAMS_BLOCK_DE].setEnabled(b); mgui.actions[TGUIAction.CAMS_PORT_TDF].setEnabled(b); @@ -123,11 +122,6 @@ public class SysCAMSComponentTaskDiagramToolBar extends TToolBar { this.addSeparator(); - button = this.add(mgui.actions[TGUIAction.CAMS_CONNECTOR]); - button.addMouseListener(mgui.mouseHandler); - - this.addSeparator(); - button = this.add(mgui.actions[TGUIAction.CAMS_GENCODE]); button.addMouseListener(mgui.mouseHandler); } diff --git a/src/main/java/ui/syscams/SysCAMSPortConnector.java b/src/main/java/ui/syscams/SysCAMSPortConnector.java index b29d7867c5efdc417745a1445f6232c3ec598a9d..9ddb509913e270e21e53137fe6f4aa8f335dc45f 100644 --- a/src/main/java/ui/syscams/SysCAMSPortConnector.java +++ b/src/main/java/ui/syscams/SysCAMSPortConnector.java @@ -45,6 +45,9 @@ import java.awt.*; import java.awt.geom.Point2D; import java.util.Vector; +import javax.swing.JDialog; +import javax.swing.JOptionPane; + import myutil.GraphicLib; /** @@ -97,8 +100,8 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo } } if ((pt1.port != null) && (pt2.port != null)) { - if ((pt1.port.getFather() instanceof SysCAMSBlockTDF) && (pt2.port.getFather() instanceof SysCAMSBlockGPIO2VCI) - || (pt2.port.getFather() instanceof SysCAMSBlockTDF) && (pt1.port.getFather() instanceof SysCAMSBlockGPIO2VCI)) { + if ((pt1.port instanceof SysCAMSPortConverter) && (pt2.port instanceof SysCAMSPortDE) + || (pt2.port instanceof SysCAMSPortConverter) && (pt1.port instanceof SysCAMSPortDE)) { if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); g.setStroke(dashed); @@ -108,7 +111,8 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo g.setStroke(dashed); GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); } - } else { + } else if ((pt1.port instanceof SysCAMSPortTDF) && (pt2.port instanceof SysCAMSPortTDF) + || (pt2.port instanceof SysCAMSPortTDF) && (pt1.port instanceof SysCAMSPortTDF)) { if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); } else { diff --git a/src/main/java/ui/util/DefaultText.java b/src/main/java/ui/util/DefaultText.java index 6055f7ac2d009b1ba6110dd12d03f949a4a2dd4a..6b79fe3a3f8b1df7da8cd6931b94a8dc4e878a6c 100755 --- a/src/main/java/ui/util/DefaultText.java +++ b/src/main/java/ui/util/DefaultText.java @@ -50,8 +50,8 @@ package ui.util; */ public class DefaultText { - public static String BUILD = "12697"; - public static String DATE = "2018/07/16 02:01:34 CET"; + public static String BUILD = "12699"; + public static String DATE = "2018/07/18 08:55:28 CET"; public static StringBuffer sbAbout = makeAbout(); diff --git a/src/main/java/ui/window/JDialogELNComponentCurrentControlledCurrentSource.java b/src/main/java/ui/window/JDialogELNComponentCurrentControlledCurrentSource.java deleted file mode 100644 index e8c8cb6df453cb58d253356dc5b7e95f01a392a9..0000000000000000000000000000000000000000 --- a/src/main/java/ui/window/JDialogELNComponentCurrentControlledCurrentSource.java +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille - * - * ludovic.apvrille AT enst.fr - * - * This software is a computer program whose purpose is to allow the - * edition of TURTLE analysis, design and deployment diagrams, to - * allow the generation of RT-LOTOS or Java code from this diagram, - * and at last to allow the analysis of formal validation traces - * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP - * from INRIA Rhone-Alpes. - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - -package ui.window; - -import ui.eln.sca_eln.ELNComponentCurrentControlledCurrentSource; -import ui.util.IconManager; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractAction; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.KeyStroke; - -/** - * Class JDialogELNComponentCurrentControlledCurrentSource - * Dialog for managing of ELN current controlled current source - * Creation: 13/06/2018 - * @version 1.0 13/06/2018 - * @author Irina Kit Yan LEE -*/ - -@SuppressWarnings("serial") - -public class JDialogELNComponentCurrentControlledCurrentSource extends JDialog implements ActionListener { - - /** Access to ActionPerformed **/ - private JTextField nameTextField; - private JTextField valueTextField; - - /** Parameters **/ - private ELNComponentCurrentControlledCurrentSource cccs; - - /** Constructor **/ - public JDialogELNComponentCurrentControlledCurrentSource(ELNComponentCurrentControlledCurrentSource _cccs) { - /** Set JDialog **/ - setTitle("Setting the current controlled current source"); - setLocationRelativeTo(null); - setVisible(true); - setAlwaysOnTop(true); - setResizable(false); - - /** Parameters **/ - cccs = _cccs; - - getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - getRootPane().getActionMap().put("close", new AbstractAction() { - public void actionPerformed(ActionEvent e) { - dispose(); - } - }); - - dialog(); - } - - public void dialog() { - /** JPanel **/ - JPanel mainPanel = new JPanel(new BorderLayout()); - this.add(mainPanel); - - JPanel attributesMainPanel = new JPanel(new GridLayout()); - mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - - // Left Side - Box box = Box.createVerticalBox(); - box.setBorder(BorderFactory.createTitledBorder("Setting current controlled current source attributes")); - - GridBagLayout gridBag = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - JPanel boxPanel = new JPanel(); - boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - boxPanel.setLayout(gridBag); - - JLabel labelName = new JLabel("nm : "); - constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(labelName, constraints); - boxPanel.add(labelName); - - nameTextField = new JTextField(cccs.getValue().toString(), 10); // name not empty - constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(nameTextField, constraints); - boxPanel.add(nameTextField); - - JLabel ratioLabel = new JLabel("value : "); - constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(ratioLabel, constraints); - boxPanel.add(ratioLabel); - - valueTextField = new JTextField("" + cccs.getVal(), 10); // name not empty - constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(valueTextField, constraints); - boxPanel.add(valueTextField); - - box.add(boxPanel); // add border to box - attributesMainPanel.add(box); // add grid to grid - - // Down Side - JPanel downPanel = new JPanel(new FlowLayout()); - - JButton saveCloseButton = new JButton("Save and close"); - saveCloseButton.setIcon(IconManager.imgic25); - saveCloseButton.setActionCommand("Save_Close"); - saveCloseButton.addActionListener(this); - saveCloseButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(saveCloseButton); - - JButton cancelButton = new JButton("Cancel"); - cancelButton.setIcon(IconManager.imgic27); - cancelButton.setActionCommand("Cancel"); - cancelButton.addActionListener(this); - cancelButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(cancelButton); - - mainPanel.add(downPanel, BorderLayout.CENTER); - pack(); - this.getRootPane().setDefaultButton(saveCloseButton); - } - - public void actionPerformed(ActionEvent e) { - if ("Save_Close".equals(e.getActionCommand())) { - cccs.setValue(new String(nameTextField.getText())); - - if (!(valueTextField.getText().isEmpty())) { - Boolean valValueDouble = false; - try { - Double.parseDouble(valueTextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "The scale coefficient of the control current is not a Double", "Warning !", - JOptionPane.WARNING_MESSAGE); - valValueDouble = true; - } - if (valValueDouble == false) { - cccs.setVal(Double.parseDouble(valueTextField.getText())); - } - } else { - cccs.setVal(1.0); - } - - this.dispose(); - } - - if ("Cancel".equals(e.getActionCommand())) { - this.dispose(); - } - } -} diff --git a/src/main/java/ui/window/JDialogELNComponentCurrentControlledVoltageSource.java b/src/main/java/ui/window/JDialogELNComponentCurrentControlledVoltageSource.java deleted file mode 100644 index 8c22a22071d2b55c527d3d9ce173d5df361b130c..0000000000000000000000000000000000000000 --- a/src/main/java/ui/window/JDialogELNComponentCurrentControlledVoltageSource.java +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille - * - * ludovic.apvrille AT enst.fr - * - * This software is a computer program whose purpose is to allow the - * edition of TURTLE analysis, design and deployment diagrams, to - * allow the generation of RT-LOTOS or Java code from this diagram, - * and at last to allow the analysis of formal validation traces - * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP - * from INRIA Rhone-Alpes. - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - -package ui.window; - -import ui.eln.sca_eln.ELNComponentCurrentControlledVoltageSource; -import ui.util.IconManager; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractAction; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.KeyStroke; - -/** - * Class JDialogELNComponentCurrentControlledVoltageSource - * Dialog for managing of ELN current controlled voltage source - * Creation: 13/06/2018 - * @version 1.0 13/06/2018 - * @author Irina Kit Yan LEE -*/ - -@SuppressWarnings("serial") - -public class JDialogELNComponentCurrentControlledVoltageSource extends JDialog implements ActionListener { - - /** Access to ActionPerformed **/ - private JTextField nameTextField; - private JTextField valueTextField; - private String valueListString[]; - private JComboBox<String> valueComboBoxString; - - /** Parameters **/ - private ELNComponentCurrentControlledVoltageSource ccvs; - - /** Constructor **/ - public JDialogELNComponentCurrentControlledVoltageSource(ELNComponentCurrentControlledVoltageSource _ccvs) { - /** Set JDialog **/ - setTitle("Setting the current controlled voltage source"); - setLocationRelativeTo(null); - setVisible(true); - setAlwaysOnTop(true); - setResizable(false); - - /** Parameters **/ - ccvs = _ccvs; - - getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - getRootPane().getActionMap().put("close", new AbstractAction() { - public void actionPerformed(ActionEvent e) { - dispose(); - } - }); - - dialog(); - } - - public void dialog() { - /** JPanel **/ - JPanel mainPanel = new JPanel(new BorderLayout()); - this.add(mainPanel); - - JPanel attributesMainPanel = new JPanel(new GridLayout()); - mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - - // Left Side - Box box = Box.createVerticalBox(); - box.setBorder(BorderFactory.createTitledBorder("Setting current controlled voltage source attributes")); - - GridBagLayout gridBag = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - JPanel boxPanel = new JPanel(); - boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - boxPanel.setLayout(gridBag); - - JLabel labelName = new JLabel("nm : "); - constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(labelName, constraints); - boxPanel.add(labelName); - - nameTextField = new JTextField(ccvs.getValue().toString(), 10); // name not empty - constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(nameTextField, constraints); - boxPanel.add(nameTextField); - - JLabel valueLabel = new JLabel("value : "); - constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(valueLabel, constraints); - boxPanel.add(valueLabel); - - valueTextField = new JTextField("" + ccvs.getVal(), 10); // name not empty - constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(valueTextField, constraints); - boxPanel.add(valueTextField); - - valueListString = new String[9]; - valueListString[0] = "G\u03A9"; - valueListString[1] = "M\u03A9"; - valueListString[2] = "k\u03A9"; - valueListString[3] = "\u03A9"; - valueListString[4] = "m\u03A9"; - valueListString[5] = "\u03BC\u03A9"; - valueListString[6] = "n\u03A9"; - valueListString[7] = "p\u03A9"; - valueListString[8] = "f\u03A9"; - valueComboBoxString = new JComboBox<String>(valueListString); - if (ccvs.getUnit().equals("G\u03A9")) { - valueComboBoxString.setSelectedIndex(0); - } else if (ccvs.getUnit().equals("M\u03A9")) { - valueComboBoxString.setSelectedIndex(1); - } else if (ccvs.getUnit().equals("k\u03A9")) { - valueComboBoxString.setSelectedIndex(2); - } else if (ccvs.getUnit().equals("\u03A9")) { - valueComboBoxString.setSelectedIndex(3); - } else if (ccvs.getUnit().equals("m\u03A9")) { - valueComboBoxString.setSelectedIndex(4); - } else if (ccvs.getUnit().equals("\u03BC\u03A9")) { - valueComboBoxString.setSelectedIndex(5); - } else if (ccvs.getUnit().equals("n\u03A9")) { - valueComboBoxString.setSelectedIndex(6); - } else if (ccvs.getUnit().equals("p\u03A9")) { - valueComboBoxString.setSelectedIndex(7); - } else if (ccvs.getUnit().equals("f\u03A9")) { - valueComboBoxString.setSelectedIndex(8); - } - valueComboBoxString.addActionListener(this); - constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(valueComboBoxString, constraints); - boxPanel.add(valueComboBoxString); - - box.add(boxPanel); // add border to box - attributesMainPanel.add(box); // add grid to grid - - // Down Side - JPanel downPanel = new JPanel(new FlowLayout()); - - JButton saveCloseButton = new JButton("Save and close"); - saveCloseButton.setIcon(IconManager.imgic25); - saveCloseButton.setActionCommand("Save_Close"); - saveCloseButton.addActionListener(this); - saveCloseButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(saveCloseButton); - - JButton cancelButton = new JButton("Cancel"); - cancelButton.setIcon(IconManager.imgic27); - cancelButton.setActionCommand("Cancel"); - cancelButton.addActionListener(this); - cancelButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(cancelButton); - - mainPanel.add(downPanel, BorderLayout.CENTER); - pack(); - this.getRootPane().setDefaultButton(saveCloseButton); - } - - public void actionPerformed(ActionEvent e) { - if ("Save_Close".equals(e.getActionCommand())) { - ccvs.setValue(new String(nameTextField.getText())); - - if (!(valueTextField.getText().isEmpty())) { - Boolean valValueDouble = false; - try { - Double.parseDouble(valueTextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "The scale coefficient of the control current is not a Double", "Warning !", - JOptionPane.WARNING_MESSAGE); - valValueDouble = true; - } - if (valValueDouble == false) { - ccvs.setVal(Double.parseDouble(valueTextField.getText())); - } - } else { - ccvs.setVal(1.0); - } - ccvs.setUnit((String) valueComboBoxString.getSelectedItem()); - - this.dispose(); - } - - if ("Cancel".equals(e.getActionCommand())) { - this.dispose(); - } - } -} diff --git a/src/main/java/ui/window/JDialogELNComponentGyrator.java b/src/main/java/ui/window/JDialogELNComponentGyrator.java deleted file mode 100644 index 5a34c734e2a055fb24f34da842d0f8c039f55fec..0000000000000000000000000000000000000000 --- a/src/main/java/ui/window/JDialogELNComponentGyrator.java +++ /dev/null @@ -1,330 +0,0 @@ -/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille - * - * ludovic.apvrille AT enst.fr - * - * This software is a computer program whose purpose is to allow the - * edition of TURTLE analysis, design and deployment diagrams, to - * allow the generation of RT-LOTOS or Java code from this diagram, - * and at last to allow the analysis of formal validation traces - * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP - * from INRIA Rhone-Alpes. - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - -package ui.window; - -import ui.eln.sca_eln.ELNComponentGyrator; -import ui.util.IconManager; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractAction; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.KeyStroke; - -/** - * Class JDialogELNComponentGyrator - * Dialog for managing of ELN gyrator - * Creation: 14/06/2018 - * @version 1.0 14/06/2018 - * @author Irina Kit Yan LEE -*/ - -@SuppressWarnings("serial") - -public class JDialogELNComponentGyrator extends JDialog implements ActionListener { - - /** Access to ActionPerformed **/ - private JTextField nameTextField; - private JTextField gyra1TextField; - private String gyra1ListString[]; - private JComboBox<String> gyra1ComboBoxString; - private JTextField gyra2TextField; - private String gyra2ListString[]; - private JComboBox<String> gyra2ComboBoxString; - - /** Parameters **/ - private ELNComponentGyrator gyrator; - - /** Constructor **/ - public JDialogELNComponentGyrator(ELNComponentGyrator _gyrator) { - /** Set JDialog **/ - setTitle("Setting the gyrator"); - setLocationRelativeTo(null); - setVisible(true); - setAlwaysOnTop(true); - setResizable(false); - - /** Parameters **/ - gyrator = _gyrator; - - getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - getRootPane().getActionMap().put("close", new AbstractAction() { - public void actionPerformed(ActionEvent e) { - dispose(); - } - }); - - dialog(); - } - - public void dialog() { - /** JPanel **/ - JPanel mainPanel = new JPanel(new BorderLayout()); - this.add(mainPanel); - - JPanel attributesMainPanel = new JPanel(new GridLayout()); - mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - - // Left Side - Box box = Box.createVerticalBox(); - box.setBorder(BorderFactory.createTitledBorder("Setting gyrator attributes")); - - GridBagLayout gridBag = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - JPanel boxPanel = new JPanel(); - boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - boxPanel.setLayout(gridBag); - - JLabel labelName = new JLabel("nm : "); - constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(labelName, constraints); - boxPanel.add(labelName); - - nameTextField = new JTextField(gyrator.getValue().toString(), 10); - constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(nameTextField, constraints); - boxPanel.add(nameTextField); - - JLabel gyra1Label = new JLabel("g1 : "); - constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(gyra1Label, constraints); - boxPanel.add(gyra1Label); - - gyra1TextField = new JTextField("" + gyrator.getG1(), 10); - constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(gyra1TextField, constraints); - boxPanel.add(gyra1TextField); - - gyra1ListString = new String[9]; - gyra1ListString[0] = "GS"; - gyra1ListString[1] = "MS"; - gyra1ListString[2] = "kS"; - gyra1ListString[3] = "S"; - gyra1ListString[4] = "mS"; - gyra1ListString[5] = "\u03BCS"; - gyra1ListString[6] = "nS"; - gyra1ListString[7] = "pS"; - gyra1ListString[8] = "fS"; - gyra1ComboBoxString = new JComboBox<String>(gyra1ListString); - if (gyrator.getUnit1().equals("GS")) { - gyra1ComboBoxString.setSelectedIndex(0); - } else if (gyrator.getUnit1().equals("MS")) { - gyra1ComboBoxString.setSelectedIndex(1); - } else if (gyrator.getUnit1().equals("kS")) { - gyra1ComboBoxString.setSelectedIndex(2); - } else if (gyrator.getUnit1().equals("S")) { - gyra1ComboBoxString.setSelectedIndex(3); - } else if (gyrator.getUnit1().equals("mS")) { - gyra1ComboBoxString.setSelectedIndex(4); - } else if (gyrator.getUnit1().equals("\u03BCS")) { - gyra1ComboBoxString.setSelectedIndex(5); - } else if (gyrator.getUnit1().equals("nS")) { - gyra1ComboBoxString.setSelectedIndex(6); - } else if (gyrator.getUnit1().equals("pS")) { - gyra1ComboBoxString.setSelectedIndex(7); - } else if (gyrator.getUnit1().equals("fS")) { - gyra1ComboBoxString.setSelectedIndex(8); - } - gyra1ComboBoxString.addActionListener(this); - constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(gyra1ComboBoxString, constraints); - boxPanel.add(gyra1ComboBoxString); - - JLabel gyra2Label = new JLabel("g2 : "); - constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(gyra2Label, constraints); - boxPanel.add(gyra2Label); - - gyra2TextField = new JTextField("" + gyrator.getG2(), 10); // name not empty - constraints = new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(gyra2TextField, constraints); - boxPanel.add(gyra2TextField); - - gyra2ListString = new String[9]; - gyra2ListString[0] = "GS"; - gyra2ListString[1] = "MS"; - gyra2ListString[2] = "kS"; - gyra2ListString[3] = "S"; - gyra2ListString[4] = "mS"; - gyra2ListString[5] = "\u03BCS"; - gyra2ListString[6] = "nS"; - gyra2ListString[7] = "pS"; - gyra2ListString[8] = "fS"; - gyra2ComboBoxString = new JComboBox<String>(gyra2ListString); - if (gyrator.getUnit2().equals("GS")) { - gyra2ComboBoxString.setSelectedIndex(0); - } else if (gyrator.getUnit2().equals("MS")) { - gyra2ComboBoxString.setSelectedIndex(1); - } else if (gyrator.getUnit2().equals("kS")) { - gyra2ComboBoxString.setSelectedIndex(2); - } else if (gyrator.getUnit2().equals("S")) { - gyra2ComboBoxString.setSelectedIndex(3); - } else if (gyrator.getUnit2().equals("mS")) { - gyra2ComboBoxString.setSelectedIndex(4); - } else if (gyrator.getUnit2().equals("\u03BCS")) { - gyra2ComboBoxString.setSelectedIndex(5); - } else if (gyrator.getUnit2().equals("nS")) { - gyra2ComboBoxString.setSelectedIndex(6); - } else if (gyrator.getUnit2().equals("pS")) { - gyra2ComboBoxString.setSelectedIndex(7); - } else if (gyrator.getUnit2().equals("fS")) { - gyra2ComboBoxString.setSelectedIndex(8); - } - gyra2ComboBoxString.addActionListener(this); - constraints = new GridBagConstraints(2, 2, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(gyra2ComboBoxString, constraints); - boxPanel.add(gyra2ComboBoxString); - - box.add(boxPanel); // add border to box - attributesMainPanel.add(box); // add grid to grid - - // Down Side - JPanel downPanel = new JPanel(new FlowLayout()); - - JButton saveCloseButton = new JButton("Save and close"); - saveCloseButton.setIcon(IconManager.imgic25); - saveCloseButton.setActionCommand("Save_Close"); - saveCloseButton.addActionListener(this); - saveCloseButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(saveCloseButton); - - JButton cancelButton = new JButton("Cancel"); - cancelButton.setIcon(IconManager.imgic27); - cancelButton.setActionCommand("Cancel"); - cancelButton.addActionListener(this); - cancelButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(cancelButton); - - mainPanel.add(downPanel, BorderLayout.CENTER); - pack(); - this.getRootPane().setDefaultButton(saveCloseButton); - } - - public void actionPerformed(ActionEvent e) { - if ("Save_Close".equals(e.getActionCommand())) { - gyrator.setValue(new String(nameTextField.getText())); - - if (!(gyra1TextField.getText().isEmpty())) { - Boolean valValueDouble = false; - try { - Double.parseDouble(gyra1TextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "The gyration conductance is not a Double", "Warning !", - JOptionPane.WARNING_MESSAGE); - valValueDouble = true; - } - if (valValueDouble == false) { - gyrator.setG1(Double.parseDouble(gyra1TextField.getText())); - } - } else { - gyrator.setG1(1.0); - } - gyrator.setUnit1((String) gyra1ComboBoxString.getSelectedItem()); - - if (!(gyra2TextField.getText().isEmpty())) { - Boolean valValueDouble = false; - try { - Double.parseDouble(gyra2TextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "The gyration conductance is not a Double", "Warning !", - JOptionPane.WARNING_MESSAGE); - valValueDouble = true; - } - if (valValueDouble == false) { - gyrator.setG2(Double.parseDouble(gyra2TextField.getText())); - } - } else { - gyrator.setG2(1.0); - } - gyrator.setUnit2((String) gyra2ComboBoxString.getSelectedItem()); - - this.dispose(); - } - - if ("Cancel".equals(e.getActionCommand())) { - this.dispose(); - } - } -} diff --git a/src/main/java/ui/window/JDialogELNComponentNullor.java b/src/main/java/ui/window/JDialogELNMidPortTerminal.java similarity index 52% rename from src/main/java/ui/window/JDialogELNComponentNullor.java rename to src/main/java/ui/window/JDialogELNMidPortTerminal.java index c64b3ab9a5c25398553cb1e6e621971910a22354..98854f0f3672939bff8936830086497a68b523e8 100644 --- a/src/main/java/ui/window/JDialogELNComponentNullor.java +++ b/src/main/java/ui/window/JDialogELNMidPortTerminal.java @@ -1,176 +1,151 @@ -/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille - * - * ludovic.apvrille AT enst.fr - * - * This software is a computer program whose purpose is to allow the - * edition of TURTLE analysis, design and deployment diagrams, to - * allow the generation of RT-LOTOS or Java code from this diagram, - * and at last to allow the analysis of formal validation traces - * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP - * from INRIA Rhone-Alpes. - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - -package ui.window; - -import ui.eln.sca_eln.ELNComponentNullor; -import ui.util.IconManager; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractAction; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.KeyStroke; - -/** - * Class JDialogELNComponentNullor - * Dialog for managing of ELN nullor - * Creation: 13/06/2018 - * @version 1.0 13/06/2018 - * @author Irina Kit Yan LEE -*/ - -@SuppressWarnings("serial") - -public class JDialogELNComponentNullor extends JDialog implements ActionListener { - - /** Access to ActionPerformed **/ - private JTextField nameTextField; - - /** Parameters **/ - private ELNComponentNullor nullor; - - /** Constructor **/ - public JDialogELNComponentNullor(ELNComponentNullor _nullor) { - /** Set JDialog **/ - setTitle("Setting the nullor"); - setLocationRelativeTo(null); - setVisible(true); - setAlwaysOnTop(true); - setResizable(false); - - /** Parameters **/ - nullor = _nullor; - - getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - getRootPane().getActionMap().put("close", new AbstractAction() { - public void actionPerformed(ActionEvent e) { - dispose(); - } - }); - - dialog(); - } - - public void dialog() { - /** JPanel **/ - JPanel mainPanel = new JPanel(new BorderLayout()); - this.add(mainPanel); - - JPanel attributesMainPanel = new JPanel(new GridLayout()); - mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - - // Left Side - Box box = Box.createVerticalBox(); - box.setBorder(BorderFactory.createTitledBorder("Setting nullor attributes")); - - GridBagLayout gridBag = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - JPanel boxPanel = new JPanel(); - boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - boxPanel.setLayout(gridBag); - - JLabel labelName = new JLabel("nm : "); - constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(labelName, constraints); - boxPanel.add(labelName); - - nameTextField = new JTextField(nullor.getValue().toString(), 10); // name not empty - constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(nameTextField, constraints); - boxPanel.add(nameTextField); - - box.add(boxPanel); // add border to box - attributesMainPanel.add(box); // add grid to grid - - // Down Side - JPanel downPanel = new JPanel(new FlowLayout()); - - JButton saveCloseButton = new JButton("Save and close"); - saveCloseButton.setIcon(IconManager.imgic25); - saveCloseButton.setActionCommand("Save_Close"); - saveCloseButton.addActionListener(this); - saveCloseButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(saveCloseButton); - - JButton cancelButton = new JButton("Cancel"); - cancelButton.setIcon(IconManager.imgic27); - cancelButton.setActionCommand("Cancel"); - cancelButton.addActionListener(this); - cancelButton.setPreferredSize(new Dimension(200, 30)); - downPanel.add(cancelButton); - - mainPanel.add(downPanel, BorderLayout.CENTER); - pack(); - this.getRootPane().setDefaultButton(saveCloseButton); - } - - public void actionPerformed(ActionEvent e) { - if ("Save_Close".equals(e.getActionCommand())) { - nullor.setValue(new String(nameTextField.getText())); - - this.dispose(); - } - - if ("Cancel".equals(e.getActionCommand())) { - this.dispose(); - } - } -} +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package ui.window; + +import ui.eln.ELNMidPortTerminal; +import ui.util.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * Class JDialogELNMidPortTerminal + * Dialog for managing of ELN mid port terminal + * Creation: 17/07/2018 + * @version 1.0 17/07/2018 + * @author Irina Kit Yan LEE + */ + +@SuppressWarnings("serial") + +public class JDialogELNMidPortTerminal extends JDialog implements ActionListener { + + private JTextField nameTextField; + + private ELNMidPortTerminal term; + + public JDialogELNMidPortTerminal(ELNMidPortTerminal term) { + this.setTitle("Setting Mid Port Terminal Attributes"); + this.setLocationRelativeTo(null); + this.setVisible(true); + this.setAlwaysOnTop(true); + this.setResizable(false); + + this.term = term; + + getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); + getRootPane().getActionMap().put("close", new AbstractAction() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + + dialog(); + } + + public void dialog() { + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + JPanel attributesMainPanel = new JPanel(); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + attributesMainPanel.setLayout(new BorderLayout()); + + Box attributesBox = Box.createVerticalBox(); + attributesBox.setBorder(BorderFactory.createTitledBorder("Setting mid port terminal attributes")); + + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel attributesBoxPanel = new JPanel(); + attributesBoxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + attributesBoxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("Name : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(15, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + attributesBoxPanel.add(labelName); + + if (term.getValue().toString().equals("")) { + nameTextField = new JTextField(10); + } else { + nameTextField = new JTextField(term.getValue().toString(), 10); + } + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(15, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + attributesBoxPanel.add(nameTextField); + + attributesBox.add(attributesBoxPanel); + + attributesMainPanel.add(attributesBox, BorderLayout.NORTH); + + JPanel downPanel = new JPanel(new FlowLayout()); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + saveCloseButton.setPreferredSize(new Dimension(200, 30)); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + cancelButton.setPreferredSize(new Dimension(200, 30)); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + pack(); + this.getRootPane().setDefaultButton(saveCloseButton); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + term.setValue(new String(nameTextField.getText())); + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} \ No newline at end of file