diff --git a/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentCurrentSinkDE.java b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentCurrentSinkDE.java new file mode 100644 index 0000000000000000000000000000000000000000..8b4ff23a238504154a07acc4080785d120c88022 --- /dev/null +++ b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentCurrentSinkDE.java @@ -0,0 +1,1018 @@ +/* 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.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.*; +import ui.window.JDialogELNComponentCurrentSinkDE; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; + +/** + * Class ELNComponentCurrentSinkDE + * Converts current to a TDF output signal to be used in ELN diagrams + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNComponentCurrentSinkDE extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { + protected Color myColor; + protected int orientation; + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + + private int textX = 15; + private double dtextX = 0.0; + protected int decPoint = 3; + + private double scale; + + private int position = 0; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; + private int old; + private boolean first; + + public ELNComponentCurrentSinkDE(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); + + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + initPortTerminal(3); + + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + userResizable = false; + value = tdp.findELNComponentName("DE_ISink"); + + setScale(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(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, 0.0, "n"); + connectingPoint[2] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.0, "outp"); + } + + public Color getMyColor() { + return myColor; + } + + 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; + 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(); + + if (position == 0) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + 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(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateTop(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 1) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, y); + } + } + } else if (position == 2) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + 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(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateBottom(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 3) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + y + height + sh2); + } + } + } + g.setColor(c); + g.setFont(fold); + } + + private void rotateTop(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + int[] ptx1 = { x + 2 * width / 5 - width / 20, x + 2 * width / 5, x + 2 * width / 5 + width / 20 }; + int[] pty1 = { y + height / 2, y + height / 2 + height / 20, y + height / 2 }; + g.drawPolygon(ptx1, pty1, 3); + g.fillPolygon(ptx1, pty1, 3); + g.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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) { + 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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) { + 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.ELN_DE_CURRENT_SINK; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNComponentCurrentSinkDE jde = new JDialogELNComponentCurrentSinkDE(this); + jde.setVisible(true); + return true; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<attributes scale=\"" + scale); + sb.append("\" position=\"" + position); + sb.append("\" fv_0_2=\"" + fv_0_2); + sb.append("\" fv_1_3=\"" + fv_1_3); + sb.append("\" fh_0_2=\"" + fh_0_2); + sb.append("\" fh_1_3=\"" + fh_1_3); + sb.append("\" first=\"" + first + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + try { + NodeList nli; + Node n1, n2; + Element elt; + + double scale; + int position; + boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; + + for (int i = 0; i < nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for (int j = 0; j < nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("attributes")) { + scale = Double.parseDouble(elt.getAttribute("scale")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); + setScale(scale); + setPosition(position); + setFv_0_2(fv_0_2); + setFv_1_3(fv_1_3); + setFh_0_2(fh_0_2); + setFh_1_3(fh_1_3); + setFirst(first); + } + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + + JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); + rotateright.addActionListener(this); + componentMenu.add(rotateright); + + JMenuItem rotateleft = new JMenuItem("Rotate left 90\u00b0"); + rotateleft.addActionListener(this); + componentMenu.add(rotateleft); + + componentMenu.addSeparator(); + + JMenuItem rotatevertically = new JMenuItem("Flip vertically"); + rotatevertically.addActionListener(this); + componentMenu.add(rotatevertically); + + JMenuItem rotatehorizontally = new JMenuItem("Flip horizontally"); + rotatehorizontally.addActionListener(this); + componentMenu.add(rotatehorizontally); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("Rotate right 90\u00b0")) { + position++; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Rotate left 90\u00b0")) { + position = position + 3; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Flip vertically")) { + if (position == 0 || position == 2) { + if (fv_0_2 == false) { + fv_0_2 = true; + } else { + fv_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fv_1_3 == false) { + fv_1_3 = true; + } else { + fv_1_3 = false; + } + } + } + if (e.getActionCommand().equals("Flip horizontally")) { + if (position == 0 || position == 2) { + if (fh_0_2 == false) { + fh_0_2 = true; + } else { + fh_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fh_1_3 == false) { + fh_1_3 = true; + } else { + fh_1_3 = false; + } + } + } + } + + public int getDefaultConnector() { + return TGComponentManager.ELN_CONNECTOR; + } + + public double getScale() { + return scale; + } + + public void setScale(double _scale) { + scale = _scale; + } + + public int getPosition() { + return position; + } + + public void setPosition(int _position) { + position = _position; + } + + public boolean isFv_0_2() { + return fv_0_2; + } + + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; + } + + public boolean isFv_1_3() { + return fv_1_3; + } + + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; + } + + public boolean isFh_0_2() { + return 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) { + fh_1_3 = _fh_1_3; + } + + public boolean isFirst() { + return 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()); + } +} diff --git a/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentCurrentSourceDE.java b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentCurrentSourceDE.java new file mode 100644 index 0000000000000000000000000000000000000000..441fd3750d2f3de12490202e310934323b53e4bc --- /dev/null +++ b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentCurrentSourceDE.java @@ -0,0 +1,1050 @@ +/* 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.sca_eln_sca_de; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.eln.*; +import ui.window.JDialogELNComponentCurrentSourceDE; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; + +/** + * Class ELNComponentCurrentSourceDE + * Current source driven by a TDF input signal signal to be used in ELN diagrams + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNComponentCurrentSourceDE extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { + protected Color myColor; + protected int orientation; + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + + private int textX = 15; + private double dtextX = 0.0; + protected int decPoint = 3; + + private double scale; + + private int position = 0; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; + private int old; + private boolean first; + + public ELNComponentCurrentSourceDE(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); + + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + initPortTerminal(3); + + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + userResizable = false; + value = tdp.findELNComponentName("DE_ISource"); + + setScale(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(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, 0.0, "n"); + connectingPoint[2] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.0, "inp"); + } + + public Color getMyColor() { + return myColor; + } + + 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; + 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(); + + if (position == 0) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("inp"); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateTop(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 1) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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)) { + rotateRightFlip(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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)) { + rotateLeftFlip(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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)) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + y + height + sh2); + } + } + } else if (position == 2) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("inp"); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateBottom(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 3) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + y + height + sh2); + } + } + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true)) { + rotateLeftFlip(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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)) { + rotateRightFlip(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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)) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, y); + } + } + } + g.setColor(c); + g.setFont(fold); + } + + private void rotateTop(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5 - height / 10, + y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + 2 * width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + 2 * width / 5, y + height / 2, x + 4 * width / 5, y + height / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 + width / 10, y + height / 5 + height / 10, + x + 4 * width / 5 + width / 10, y + 4 * height / 5 - height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5, y + height / 2, x + 2 * width / 5, y + height / 2, true); + g.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateTopFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + 3 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5 - height / 10, + y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + 2 * width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + 2 * width / 5, y + height / 2, x + 4 * width / 5, y + height / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 + width / 10, y + 4 * height / 5 - height / 10, + x + 4 * width / 5 + width / 10, y + height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5, y + height / 2, x + 2 * width / 5, y + height / 2, true); + g.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateBottom(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5 - height / 10, + y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 5, y + height / 2, x + 3 * width / 5, y + height / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 10, y + 4 * height / 5 - height / 10, x + width / 10, + y + height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5, y + height / 2, x + 3 * width / 5, y + height / 2, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateBottomFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height / 5 + height / 10, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x, x + 2 * width / 5, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20, y + 4 * height / 5 - height / 10, + y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 5, y + height / 2, x + 3 * width / 5, y + height / 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 10, y + height / 5 + height / 10, x + width / 10, + y + 4 * height / 5 - height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5, y + height / 2, x + 3 * width / 5, y + height / 2, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateRight(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5 - width / 10, + x + width - width / 20 }; + int[] pty1 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + 2 * height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + 2 * height / 5, x + width / 2, y + 4 * height / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 - width / 10, y + 4 * height / 5 + height / 10, + x + width / 5 + width / 10, y + 4 * height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + height / 5, x + width / 2, y + 2 * height / 5, true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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 rotateRightFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5 - width / 10, + x + width - width / 20 }; + int[] pty1 = { y, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + height / 5, x + width / 2, y + 3 * height / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5 - width / 10, y + height / 10, + x + width / 5 + width / 10, y + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + 4 * height / 5, x + width / 2, y + 3 * height / 5, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateLeft(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5 - width / 10, + x + width - width / 20 }; + int[] pty1 = { y, y + 2 * height / 5, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + height / 5, x + width / 2, y + 3 * height / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5 + width / 10, y + height / 10, + x + 4 * width / 5 - width / 10, y + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + 4 * height / 5, x + width / 2, y + 3 * height / 5, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateLeftFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + height / 5 + height / 10, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 4); + int[] ptx1 = { x + width - width / 20, x + width - width / 20, x + 4 * width / 5 - width / 10, + x + width - width / 20 }; + int[] pty1 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + 3 * height / 5 }; + g.drawPolygon(ptx1, pty1, 4); + g.drawOval(x + width / 2 - width / 5, y + 2 * height / 5, width / 5 + width / 5, height / 5 + height / 5); + g.drawLine(x + width / 2, y + 2 * height / 5, x + width / 2, y + 4 * height / 5); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5 + width / 10, y + 4 * height / 5 + height / 10, + x + 4 * width / 5 - width / 10, y + 4 * height / 5 + height / 10, true); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + height / 5, x + width / 2, y + 2 * height / 5, true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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); + } + + 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_DE_CURRENT_SOURCE; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNComponentCurrentSourceDE jde = new JDialogELNComponentCurrentSourceDE(this); + jde.setVisible(true); + return true; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<attributes scale=\"" + scale); + sb.append("\" position=\"" + position); + sb.append("\" fv_0_2=\"" + fv_0_2); + sb.append("\" fv_1_3=\"" + fv_1_3); + sb.append("\" fh_0_2=\"" + fh_0_2); + sb.append("\" fh_1_3=\"" + fh_1_3); + sb.append("\" first=\"" + first + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + try { + NodeList nli; + Node n1, n2; + Element elt; + + double scale; + int position; + boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; + + for (int i = 0; i < nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for (int j = 0; j < nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("attributes")) { + scale = Double.parseDouble(elt.getAttribute("scale")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); + setScale(scale); + setPosition(position); + setFv_0_2(fv_0_2); + setFv_1_3(fv_1_3); + setFh_0_2(fh_0_2); + setFh_1_3(fh_1_3); + setFirst(first); + } + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + + JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); + rotateright.addActionListener(this); + componentMenu.add(rotateright); + + JMenuItem rotateleft = new JMenuItem("Rotate left 90\u00b0"); + rotateleft.addActionListener(this); + componentMenu.add(rotateleft); + + componentMenu.addSeparator(); + + JMenuItem rotatevertically = new JMenuItem("Flip vertically"); + rotatevertically.addActionListener(this); + componentMenu.add(rotatevertically); + + JMenuItem rotatehorizontally = new JMenuItem("Flip horizontally"); + rotatehorizontally.addActionListener(this); + componentMenu.add(rotatehorizontally); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("Rotate right 90\u00b0")) { + position++; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Rotate left 90\u00b0")) { + position = position + 3; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Flip vertically")) { + if (position == 0 || position == 2) { + if (fv_0_2 == false) { + fv_0_2 = true; + } else { + fv_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fv_1_3 == false) { + fv_1_3 = true; + } else { + fv_1_3 = false; + } + } + } + if (e.getActionCommand().equals("Flip horizontally")) { + if (position == 0 || position == 2) { + if (fh_0_2 == false) { + fh_0_2 = true; + } else { + fh_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fh_1_3 == false) { + fh_1_3 = true; + } else { + fh_1_3 = false; + } + } + } + } + + public int getDefaultConnector() { + return TGComponentManager.ELN_CONNECTOR; + } + + public double getScale() { + return scale; + } + + public void setScale(double _scale) { + scale = _scale; + } + + public int getPosition() { + return position; + } + + public void setPosition(int _position) { + position = _position; + } + + public boolean isFv_0_2() { + return fv_0_2; + } + + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; + } + + public boolean isFv_1_3() { + return fv_1_3; + } + + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; + } + + public boolean isFh_0_2() { + return 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) { + fh_1_3 = _fh_1_3; + } + + public boolean isFirst() { + return 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()); + } +} diff --git a/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentVoltageSinkDE.java b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentVoltageSinkDE.java new file mode 100644 index 0000000000000000000000000000000000000000..77b23d9f6deb0fdac09ef04421807f4b43eeb953 --- /dev/null +++ b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentVoltageSinkDE.java @@ -0,0 +1,1110 @@ +/* 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.sca_eln_sca_de; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.eln.*; +import ui.window.JDialogELNComponentVoltageSinkDE; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; + +/** + * Class ELNComponentVoltageSinkDE + * Converts voltage to a TDF output signal to be used in ELN diagrams + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNComponentVoltageSinkDE extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { + protected Color myColor; + protected int orientation; + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + + private int textX = 15; + private double dtextX = 0.0; + protected int decPoint = 3; + + private double scale; + + private int position = 0; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; + private int old; + private boolean first; + + public ELNComponentVoltageSinkDE(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); + + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + initPortTerminal(3); + + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + userResizable = false; + value = tdp.findELNComponentName("DE_VSink"); + + setScale(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(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, 0.0, "n"); + connectingPoint[2] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.0, "outp"); + } + + public Color getMyColor() { + return myColor; + } + + 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; + 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(); + + if (position == 0) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + 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(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateTop(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 1) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, y); + } + } + } else if (position == 2) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + 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(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateBottom(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 3) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + y + height + sh2); + } + } + } + g.setColor(c); + g.setFont(fold); + } + + private void rotateTop(Graphics g) { + 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 / 5 - width / 10 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 2); + 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 + 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 + 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.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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 / 5 - width / 10 }; + int[] pty1 = { y + height - height / 20, y + height - height / 20 }; + g.drawPolygon(ptx1, pty1, 2); + 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 + 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 + 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.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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 + 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 / 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 / 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 + 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.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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 + 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 / 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 / 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 + 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.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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 - 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 / 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 / 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 + 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + 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 - 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 / 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 / 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 + 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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) { + 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 - 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 / 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 / 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 / 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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) { + 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 - width / 20, x + width - width / 20 }; + int[] pty1 = { y, y + 2 * height / 5 - height / 10 }; + g.drawPolygon(ptx1, pty1, 2); + 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 / 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 / 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.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.ELN_DE_VOLTAGE_SINK; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNComponentVoltageSinkDE jde = new JDialogELNComponentVoltageSinkDE(this); + jde.setVisible(true); + return true; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<attributes scale=\"" + scale); + sb.append("\" position=\"" + position); + sb.append("\" fv_0_2=\"" + fv_0_2); + sb.append("\" fv_1_3=\"" + fv_1_3); + sb.append("\" fh_0_2=\"" + fh_0_2); + sb.append("\" fh_1_3=\"" + fh_1_3); + sb.append("\" first=\"" + first + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + try { + NodeList nli; + Node n1, n2; + Element elt; + + double scale; + int position; + boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; + + for (int i = 0; i < nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for (int j = 0; j < nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("attributes")) { + scale = Double.parseDouble(elt.getAttribute("scale")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); + setScale(scale); + setPosition(position); + setFv_0_2(fv_0_2); + setFv_1_3(fv_1_3); + setFh_0_2(fh_0_2); + setFh_1_3(fh_1_3); + setFirst(first); + } + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + + JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); + rotateright.addActionListener(this); + componentMenu.add(rotateright); + + JMenuItem rotateleft = new JMenuItem("Rotate left 90\u00b0"); + rotateleft.addActionListener(this); + componentMenu.add(rotateleft); + + componentMenu.addSeparator(); + + JMenuItem rotatevertically = new JMenuItem("Flip vertically"); + rotatevertically.addActionListener(this); + componentMenu.add(rotatevertically); + + JMenuItem rotatehorizontally = new JMenuItem("Flip horizontally"); + rotatehorizontally.addActionListener(this); + componentMenu.add(rotatehorizontally); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("Rotate right 90\u00b0")) { + position++; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Rotate left 90\u00b0")) { + position = position + 3; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Flip vertically")) { + if (position == 0 || position == 2) { + if (fv_0_2 == false) { + fv_0_2 = true; + } else { + fv_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fv_1_3 == false) { + fv_1_3 = true; + } else { + fv_1_3 = false; + } + } + } + if (e.getActionCommand().equals("Flip horizontally")) { + if (position == 0 || position == 2) { + if (fh_0_2 == false) { + fh_0_2 = true; + } else { + fh_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fh_1_3 == false) { + fh_1_3 = true; + } else { + fh_1_3 = false; + } + } + } + } + + public int getDefaultConnector() { + return TGComponentManager.ELN_CONNECTOR; + } + + public double getScale() { + return scale; + } + + public void setScale(double _scale) { + scale = _scale; + } + + public int getPosition() { + return position; + } + + public void setPosition(int _position) { + position = _position; + } + + public boolean isFv_0_2() { + return fv_0_2; + } + + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; + } + + public boolean isFv_1_3() { + return fv_1_3; + } + + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; + } + + public boolean isFh_0_2() { + return 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) { + fh_1_3 = _fh_1_3; + } + + public boolean isFirst() { + return 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()); + } +} diff --git a/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentVoltageSourceDE.java b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentVoltageSourceDE.java new file mode 100644 index 0000000000000000000000000000000000000000..38c40fc672240290fef705e24178f329998bc205 --- /dev/null +++ b/src/main/java/ui/eln/sca_eln_sca_de/ELNComponentVoltageSourceDE.java @@ -0,0 +1,1082 @@ +/* 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.sca_eln_sca_de; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.eln.*; +import ui.window.JDialogELNComponentVoltageSourceDE; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; + +/** + * Class ELNComponentVoltageSourceDE + * Voltage source driven by a TDF input signal to be used in ELN diagrams + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNComponentVoltageSourceDE extends TGCScalableWithInternalComponent implements ActionListener, SwallowedTGComponent, ELNComponent { + protected Color myColor; + protected int orientation; + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + + private int textX = 15; + private double dtextX = 0.0; + protected int decPoint = 3; + + private double scale; + + private int position = 0; + private boolean fv_0_2 = false, fv_1_3 = false, fh_0_2 = false, fh_1_3 = false; + private int old; + private boolean first; + + public ELNComponentVoltageSourceDE(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); + + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + initPortTerminal(3); + + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + userResizable = false; + value = tdp.findELNComponentName("DE_VSource"); + + setScale(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(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, 0.0, "n"); + connectingPoint[2] = new ELNConnectingPoint(this, 0, 0, true, true, 0.0, 0.0, "inp"); + } + + public Color getMyColor() { + return myColor; + } + + 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; + 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(); + + if (position == 0) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("inp"); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateTop(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 1) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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)) { + rotateRightFlip(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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)) { + rotateLeftFlip(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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)) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + y + height + sh2); + } + } + } else if (position == 2) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sw2 = g.getFontMetrics().stringWidth("inp"); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int w = g.getFontMetrics().stringWidth(value); + g.drawString(value, x + (width - w) / 2, y - height / 5 - height / 20); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateBottom(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, + y + height + height / 20 + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + 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(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - sw0, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - sw1, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width, + y + height / 2 + height / 10 + height / 20 + 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(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width, y - height / 20); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width, + y + height + height / 20 + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x - sw2, + y + height / 2 + height / 10 + height / 20 + sh2); + } + } + } else if (position == 3) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + resizeWithFather(); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + int sw0 = g.getFontMetrics().stringWidth("p"); + int sh0 = g.getFontMetrics().getAscent(); + int sw1 = g.getFontMetrics().stringWidth("n"); + int sh1 = g.getFontMetrics().getAscent(); + int sh2 = g.getFontMetrics().getAscent(); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + int h = g.getFontMetrics().getAscent(); + g.drawString(value, x + width + width / 5 + width / 20, y + (height + h) / 2); + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == false && fh_1_3 == true) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == true && fh_1_3 == true)) { + rotateLeft(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, y); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + y + height + sh2); + } + } + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == true && fh_1_3 == false) + || (fv_0_2 == false && fv_1_3 == true && fh_0_2 == false && fh_1_3 == false) + || (fv_0_2 == true && fv_1_3 == false && fh_0_2 == true && fh_1_3 == true) + || (fv_0_2 == true && fv_1_3 == true && fh_0_2 == false && fh_1_3 == true)) { + rotateLeftFlip(g); + ((ELNConnectingPoint) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x - width / 20 - sw0, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x + width + width / 20, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, 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)) { + rotateRightFlip(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(0.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 20 - sw1, y); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 20, y); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, + 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)) { + rotateRight(g); + ((ELNConnectingPoint) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[1]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNConnectingPoint) connectingPoint[0]).setH(1.0); + ((ELNConnectingPoint) connectingPoint[2]).setW(0.5); + ((ELNConnectingPoint) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString(((ELNConnectingPoint) connectingPoint[1]).getName(), x - width / 16 - sw1, + y + height + sh1); + g.drawString(((ELNConnectingPoint) connectingPoint[0]).getName(), x + width + width / 16, + y + height + sh0); + g.drawString(((ELNConnectingPoint) connectingPoint[2]).getName(), x + width / 2 + width / 10 + width / 20, y); + } + } + } + g.setColor(c); + g.setFont(fold); + } + + private void rotateTop(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + width, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + 2 * width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + int[] ptx1 = { x + 3 * width / 5 + width / 20, x + 3 * width / 5 + width / 10, x + 3 * width / 5 + width / 10, + x + 3 * width / 5 + width / 10, x + 3 * width / 5 + width / 10, + x + 3 * width / 5 + width / 10 + width / 20 }; + int[] pty1 = { y + height / 10 + height / 20, y + height / 10 + height / 20, y + height / 10, + y + height / 10 + height / 10, y + height / 10 + height / 20, y + height / 10 + height / 20 }; + g.drawPolygon(ptx1, pty1, 6); + int[] ptx2 = { x + 3 * width / 5 + width / 20, x + 3 * width / 5 + width / 10 + width / 20 }; + int[] pty2 = { y + height - height / 10 - height / 20, y + height - height / 10 - height / 20 }; + g.drawPolygon(ptx2, pty2, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5, y + height / 2, x + 2 * width / 5, y + height / 2, true); + g.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateTopFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width, x + 3 * width / 5, x + 3 * width / 5, x + width, x + 3 * width / 5, + x + 3 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + 2 * width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + int[] ptx1 = { x + 3 * width / 5 + width / 20, x + 3 * width / 5 + width / 10, x + 3 * width / 5 + width / 10, + x + 3 * width / 5 + width / 10, x + 3 * width / 5 + width / 10, + x + 3 * width / 5 + width / 10 + width / 20 }; + int[] pty1 = { 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(ptx1, pty1, 6); + int[] ptx2 = { x + 3 * width / 5 + width / 20, x + 3 * width / 5 + width / 10 + width / 20 }; + int[] pty2 = { y + height / 10 + height / 20, y + height / 10 + height / 20 }; + g.drawPolygon(ptx2, pty2, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 5, y + height / 2, x + 2 * width / 5, y + height / 2, true); + g.setColor(Color.WHITE); + g.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateBottom(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + int[] ptx3 = { x + 2 * width / 5 - width / 10 - width / 20, x + 2 * width / 5 - width / 10, + x + 2 * width / 5 - width / 10, x + 2 * width / 5 - width / 10, x + 2 * width / 5 - width / 10, + x + 2 * 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 / 5 - width / 10 - width / 20, x + 2 * width / 5 - width / 20 }; + int[] pty4 = { y + height / 10 + height / 20, y + height / 10 + height / 20 }; + g.drawPolygon(ptx4, pty4, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5, y + height / 2, x + 3 * width / 5, y + height / 2, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateBottomFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x, x + 2 * width / 5, x + 2 * width / 5, x, x + 2 * width / 5, x + 2 * width / 5 }; + int[] pty0 = { y + height / 20, y + height / 20, y + height - height / 20, y + height - height / 20, + y + height - height / 20, y + height / 20 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + width / 5, y + height / 2 - height / 5, width / 5 + width / 5, height / 5 + height / 5); + int[] ptx3 = { x + 2 * width / 5 - width / 10 - width / 20, x + 2 * width / 5 - width / 10, + x + 2 * width / 5 - width / 10, x + 2 * width / 5 - width / 10, x + 2 * width / 5 - width / 10, + x + 2 * 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 / 5 - width / 10 - width / 20, x + 2 * width / 5 - width / 20 }; + int[] pty4 = { y + height - height / 10 - height / 20, y + height - height / 10 - height / 20 }; + g.drawPolygon(ptx4, pty4, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + 4 * width / 5, y + height / 2, x + 3 * width / 5, y + height / 2, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateRight(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + height, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + width / 2 - width / 5, y + 2 * height / 5, width / 5 + width / 5, height / 5 + height / 5); + 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 + 3 * height / 5 + height / 20, y + 3 * height / 5 + height / 10, + y + 3 * height / 5 + height / 10, y + 3 * height / 5 + height / 10, y + 3 * height / 5 + height / 10, + y + 3 * height / 5 + height / 10 + height / 20 }; + g.drawPolygon(ptx3, pty3, 6); + int[] ptx4 = { x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty4 = { y + 3 * height / 5 + height / 20, y + 3 * height / 5 + height / 10 + height / 20 }; + g.drawPolygon(ptx4, pty4, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + height / 5, x + width / 2, y + 2 * height / 5, true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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 rotateRightFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + width / 2 - width / 5, y + height / 5, width / 5 + width / 5, height / 5 + height / 5); + 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 + 2 * height / 5 - height / 10 - height / 20, y + 2 * height / 5 - height / 10, + y + 2 * height / 5 - height / 10, y + 2 * height / 5 - height / 10, y + 2 * height / 5 - height / 10, + y + 2 * height / 5 - height / 20 }; + g.drawPolygon(ptx3, pty3, 6); + int[] ptx4 = { x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty4 = { y + 2 * height / 5 - height / 20, y + 2 * height / 5 - height / 10 - height / 20 }; + g.drawPolygon(ptx4, pty4, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + 4 * height / 5, x + width / 2, y + 3 * height / 5, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateLeft(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y, y + 2 * height / 5, y + 2 * height / 5, y, y + 2 * height / 5, y + 2 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + width / 2 - width / 5, y + height / 5, width / 5 + width / 5, height / 5 + height / 5); + int[] ptx3 = { x + width / 10 + width / 20, x + width / 10 + width / 20, x + width / 10, + x + width / 10 + width / 10, x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty3 = { y + 2 * height / 5 - height / 10 - height / 20, y + 2 * height / 5 - height / 10, + y + 2 * height / 5 - height / 10, y + 2 * height / 5 - height / 10, y + 2 * height / 5 - height / 10, + y + 2 * height / 5 - height / 20 }; + g.drawPolygon(ptx3, pty3, 6); + int[] ptx4 = { x + width - width / 10 - width / 20, x + width - width / 10 - width / 20 }; + int[] pty4 = { y + 2 * height / 5 - height / 20, y + 2 * height / 5 - height / 10 - height / 20 }; + g.drawPolygon(ptx4, pty4, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + 4 * height / 5, x + width / 2, y + 3 * height / 5, + true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + g.setColor(c); + + 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 rotateLeftFlip(Graphics g) { + Color c = g.getColor(); + int[] ptx0 = { x + width / 20, x + width / 20, x + width - width / 20, x + width - width / 20, + x + width - width / 20, x + width / 20 }; + int[] pty0 = { y + height, y + 3 * height / 5, y + 3 * height / 5, y + height, y + 3 * height / 5, + y + 3 * height / 5 }; + g.drawPolygon(ptx0, pty0, 6); + g.drawOval(x + width / 2 - width / 5, y + 2 * height / 5, width / 5 + width / 5, height / 5 + height / 5); + int[] ptx3 = { x + width / 10 + width / 20, x + width / 10 + width / 20, x + width / 10, + x + width / 10 + width / 10, x + width / 10 + width / 20, x + width / 10 + width / 20 }; + int[] pty3 = { y + 3 * height / 5 + height / 20, y + 3 * height / 5 + height / 10, + y + 3 * height / 5 + height / 10, y + 3 * height / 5 + height / 10, y + 3 * height / 5 + height / 10, + y + 3 * height / 5 + height / 10 + height / 20 }; + g.drawPolygon(ptx3, pty3, 6); + int[] ptx4 = { x + width - width / 10 - width / 20, x + width - width / 10 - width / 20 }; + int[] pty4 = { y + 3 * height / 5 + height / 20, y + 3 * height / 5 + height / 10 + height / 20 }; + g.drawPolygon(ptx4, pty4, 2); + GraphicLib.arrowWithLine(g, 1, 0, 10, x + width / 2, y + height / 5, x + width / 2, y + 2 * height / 5, true); + g.setColor(Color.WHITE); + g.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + g.setColor(c); + + 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); + } + + 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_DE_VOLTAGE_SOURCE; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNComponentVoltageSourceDE jde = new JDialogELNComponentVoltageSourceDE(this); + jde.setVisible(true); + return true; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<attributes scale=\"" + scale); + sb.append("\" position=\"" + position); + sb.append("\" fv_0_2=\"" + fv_0_2); + sb.append("\" fv_1_3=\"" + fv_1_3); + sb.append("\" fh_0_2=\"" + fh_0_2); + sb.append("\" fh_1_3=\"" + fh_1_3); + sb.append("\" first=\"" + first + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + try { + NodeList nli; + Node n1, n2; + Element elt; + + double scale; + int position; + boolean fv_0_2, fv_1_3, fh_0_2, fh_1_3, first; + + for (int i = 0; i < nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for (int j = 0; j < nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("attributes")) { + scale = Double.parseDouble(elt.getAttribute("scale")); + position = Integer.parseInt(elt.getAttribute("position")); + fv_0_2 = Boolean.parseBoolean(elt.getAttribute("fv_0_2")); + fv_1_3 = Boolean.parseBoolean(elt.getAttribute("fv_1_3")); + fh_0_2 = Boolean.parseBoolean(elt.getAttribute("fh_0_2")); + fh_1_3 = Boolean.parseBoolean(elt.getAttribute("fh_1_3")); + first = Boolean.parseBoolean(elt.getAttribute("first")); + setScale(scale); + setPosition(position); + setFv_0_2(fv_0_2); + setFv_1_3(fv_1_3); + setFh_0_2(fh_0_2); + setFh_1_3(fh_1_3); + setFirst(first); + } + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + + JMenuItem rotateright = new JMenuItem("Rotate right 90\u00b0"); + rotateright.addActionListener(this); + componentMenu.add(rotateright); + + JMenuItem rotateleft = new JMenuItem("Rotate left 90\u00b0"); + rotateleft.addActionListener(this); + componentMenu.add(rotateleft); + + componentMenu.addSeparator(); + + JMenuItem rotatevertically = new JMenuItem("Flip vertically"); + rotatevertically.addActionListener(this); + componentMenu.add(rotatevertically); + + JMenuItem rotatehorizontally = new JMenuItem("Flip horizontally"); + rotatehorizontally.addActionListener(this); + componentMenu.add(rotatehorizontally); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("Rotate right 90\u00b0")) { + position++; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Rotate left 90\u00b0")) { + position = position + 3; + position %= 4; + first = false; + } + if (e.getActionCommand().equals("Flip vertically")) { + if (position == 0 || position == 2) { + if (fv_0_2 == false) { + fv_0_2 = true; + } else { + fv_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fv_1_3 == false) { + fv_1_3 = true; + } else { + fv_1_3 = false; + } + } + } + if (e.getActionCommand().equals("Flip horizontally")) { + if (position == 0 || position == 2) { + if (fh_0_2 == false) { + fh_0_2 = true; + } else { + fh_0_2 = false; + } + } + if (position == 1 || position == 3) { + if (fh_1_3 == false) { + fh_1_3 = true; + } else { + fh_1_3 = false; + } + } + } + } + + public int getDefaultConnector() { + return TGComponentManager.ELN_CONNECTOR; + } + + public double getScale() { + return scale; + } + + public void setScale(double _scale) { + scale = _scale; + } + + public int getPosition() { + return position; + } + + public void setPosition(int _position) { + position = _position; + } + + public boolean isFv_0_2() { + return fv_0_2; + } + + public void setFv_0_2(boolean _fv_0_2) { + fv_0_2 = _fv_0_2; + } + + public boolean isFv_1_3() { + return fv_1_3; + } + + public void setFv_1_3(boolean _fv_1_3) { + fv_1_3 = _fv_1_3; + } + + public boolean isFh_0_2() { + return 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) { + fh_1_3 = _fh_1_3; + } + + public boolean isFirst() { + return 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()); + } +} diff --git a/src/main/java/ui/window/JDialogELNComponentCurrentSinkDE.java b/src/main/java/ui/window/JDialogELNComponentCurrentSinkDE.java new file mode 100644 index 0000000000000000000000000000000000000000..84ec08d6629ab6ec2eb5000a67b367c3036170e6 --- /dev/null +++ b/src/main/java/ui/window/JDialogELNComponentCurrentSinkDE.java @@ -0,0 +1,183 @@ +/* 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_sca_de.ELNComponentCurrentSinkDE; +import ui.util.IconManager; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * Class JDialogELNComponentCurrentSinkDE + * Dialog for managing the conversion of a ELN current to a DE output signal + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogELNComponentCurrentSinkDE extends JDialog implements ActionListener { + private JTextField nameTextField; + private JTextField valueTextField; + + private ELNComponentCurrentSinkDE isink; + + public JDialogELNComponentCurrentSinkDE(ELNComponentCurrentSinkDE _isink) { + setTitle("Setting the conversion of current to DE output signal"); + setLocationRelativeTo(null); + setVisible(true); + setAlwaysOnTop(true); + setResizable(false); + + isink = _isink; + + 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(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting eln_de_isink 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(isink.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 valueLabel = new JLabel("scale : "); + 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("" + isink.getScale(), 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(valueTextField, constraints); + boxPanel.add(valueTextField); + + box.add(boxPanel); + attributesMainPanel.add(box); + + 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())) { + isink.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 is not a Double", "Warning !", + JOptionPane.WARNING_MESSAGE); + valValueDouble = true; + } + if (valValueDouble == false) { + isink.setScale(Double.parseDouble(valueTextField.getText())); + } + } else { + isink.setScale(1.0); + } + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} diff --git a/src/main/java/ui/window/JDialogELNComponentCurrentSourceDE.java b/src/main/java/ui/window/JDialogELNComponentCurrentSourceDE.java new file mode 100644 index 0000000000000000000000000000000000000000..c9c8623f02d508bfad918b374f6a256e0c23cc54 --- /dev/null +++ b/src/main/java/ui/window/JDialogELNComponentCurrentSourceDE.java @@ -0,0 +1,183 @@ +/* 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_sca_de.ELNComponentCurrentSourceDE; +import ui.util.IconManager; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * Class JDialogELNComponentCurrentSourceDE + * Dialog for managing the ELN current driven by a DE input signal + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogELNComponentCurrentSourceDE extends JDialog implements ActionListener { + private JTextField nameTextField; + private JTextField valueTextField; + + private ELNComponentCurrentSourceDE isource; + + public JDialogELNComponentCurrentSourceDE(ELNComponentCurrentSourceDE _isource) { + setTitle("Setting the current driven by a DE output signal"); + setLocationRelativeTo(null); + setVisible(true); + setAlwaysOnTop(true); + setResizable(false); + + isource = _isource; + + 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(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting eln_de_isource 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(isource.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 valueLabel = new JLabel("scale : "); + 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("" + isource.getScale(), 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(valueTextField, constraints); + boxPanel.add(valueTextField); + + box.add(boxPanel); + attributesMainPanel.add(box); + + 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())) { + isource.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 is not a Double", "Warning !", + JOptionPane.WARNING_MESSAGE); + valValueDouble = true; + } + if (valValueDouble == false) { + isource.setScale(Double.parseDouble(valueTextField.getText())); + } + } else { + isource.setScale(1.0); + } + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} diff --git a/src/main/java/ui/window/JDialogELNComponentVoltageSinkDE.java b/src/main/java/ui/window/JDialogELNComponentVoltageSinkDE.java new file mode 100644 index 0000000000000000000000000000000000000000..1fb4aae08df3f4968ad0da169f6bc8910639cf53 --- /dev/null +++ b/src/main/java/ui/window/JDialogELNComponentVoltageSinkDE.java @@ -0,0 +1,183 @@ +/* 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_sca_de.ELNComponentVoltageSinkDE; +import ui.util.IconManager; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * Class JDialogELNComponentVoltageSinkDE + * Dialog for managing the conversion of a ELN voltage to a DE output signal + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogELNComponentVoltageSinkDE extends JDialog implements ActionListener { + private JTextField nameTextField; + private JTextField valueTextField; + + private ELNComponentVoltageSinkDE vsink; + + public JDialogELNComponentVoltageSinkDE(ELNComponentVoltageSinkDE _vsink) { + setTitle("Setting the conversion of voltage to DE output signal"); + setLocationRelativeTo(null); + setVisible(true); + setAlwaysOnTop(true); + setResizable(false); + + vsink = _vsink; + + 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(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting eln_de_vsink 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(vsink.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 valueLabel = new JLabel("scale : "); + 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("" + vsink.getScale(), 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(valueTextField, constraints); + boxPanel.add(valueTextField); + + box.add(boxPanel); + attributesMainPanel.add(box); + + 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())) { + vsink.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 is not a Double", "Warning !", + JOptionPane.WARNING_MESSAGE); + valValueDouble = true; + } + if (valValueDouble == false) { + vsink.setScale(Double.parseDouble(valueTextField.getText())); + } + } else { + vsink.setScale(1.0); + } + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} diff --git a/src/main/java/ui/window/JDialogELNComponentVoltageSourceDE.java b/src/main/java/ui/window/JDialogELNComponentVoltageSourceDE.java new file mode 100644 index 0000000000000000000000000000000000000000..1ee3494d5dbedd15f9af07ea1431e27972dfd50c --- /dev/null +++ b/src/main/java/ui/window/JDialogELNComponentVoltageSourceDE.java @@ -0,0 +1,183 @@ +/* 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_sca_de.ELNComponentVoltageSourceDE; +import ui.util.IconManager; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * Class JDialogELNComponentVoltageSourceDE + * Dialog for managing the ELN voltage driven by a DE input signal + * Creation: 07/08/2018 + * @version 1.0 07/08/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogELNComponentVoltageSourceDE extends JDialog implements ActionListener { + private JTextField nameTextField; + private JTextField valueTextField; + + private ELNComponentVoltageSourceDE vsource; + + public JDialogELNComponentVoltageSourceDE(ELNComponentVoltageSourceDE _vsource) { + setTitle("Setting the voltage driven by a DE output signal"); + setLocationRelativeTo(null); + setVisible(true); + setAlwaysOnTop(true); + setResizable(false); + + vsource = _vsource; + + 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(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting eln_de_vsource 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(vsource.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 valueLabel = new JLabel("scale : "); + 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("" + vsource.getScale(), 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(valueTextField, constraints); + boxPanel.add(valueTextField); + + box.add(boxPanel); + attributesMainPanel.add(box); + + 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())) { + vsource.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 is not a Double", "Warning !", + JOptionPane.WARNING_MESSAGE); + valValueDouble = true; + } + if (valValueDouble == false) { + vsource.setScale(Double.parseDouble(valueTextField.getText())); + } + } else { + vsource.setScale(1.0); + } + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +}