diff --git a/SysCAMSGenerationCode/generated_H/Block_TDF_0.h b/SysCAMSGenerationCode/generated_H/Block_TDF_0.h deleted file mode 100644 index d1415225353b232dd65eb9758c9ab62ba688bd93..0000000000000000000000000000000000000000 --- a/SysCAMSGenerationCode/generated_H/Block_TDF_0.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef BLOCK_TDF_0_H -#define BLOCK_TDF_0_H - -#include <cmath> -#include <iostream> -#include <systemc-ams> - -class Block_TDF_0 : public sca_tdf::sca_module { - -public: - - sca_tdf::sca_in<int> port2; - - sca_tdf::sca_de::sca_out<int> port1; - - explicit Block_TDF_0(sc_core::sc_module_name nm) - : port2("port2") - , port1("port1") - {} - -protected: - void processing() { - } - -}; - -#endif // BLOCK_TDF_0_H \ No newline at end of file diff --git a/SysCAMSGenerationCode/generated_H/Sine.h b/SysCAMSGenerationCode/generated_H/Sine.h new file mode 100644 index 0000000000000000000000000000000000000000..a15d89590903856b60bc9c6bfb73255a0a27fb66 --- /dev/null +++ b/SysCAMSGenerationCode/generated_H/Sine.h @@ -0,0 +1,42 @@ +#ifndef SINE_H +#define SINE_H + +#include <cmath> +#include <iostream> +#include <systemc-ams> + +class Sine : public sca_tdf::sca_module { + +public: + + sca_tdf::sca_out<double> tdf_out; + + sca_tdf::sca_de::sca_out<int> out2_de; + sca_tdf::sca_de::sca_out<int> out_de; + + explicit Sine(sc_core::sc_module_name nm) + : tdf_out("tdf_out") + , out2_de("out2_de") + , out_de("out_de") + {} + +protected: + void set_attributes() { + set_timestep(6, sc_core::SC_US + tdf_out.set_timestep(6, sc_core::SC_US); + tdf_out.set_rate(1); + out_de.set_timestep(6, sc_core::SC_US); + out_de.set_rate(1); + out_de.set_delay(0); + } + + void processing() { + double t = out_de.get_time().to_seconds(); + double x = sin(2.0 * M_PI * 5000000.0 * t); + out_de.write( (int) x); + tdf_out.write(x); + } + +}; + +#endif // SINE_H \ No newline at end of file diff --git a/SysCAMSGenerationCode/generated_H/Sink.h b/SysCAMSGenerationCode/generated_H/Sink.h new file mode 100644 index 0000000000000000000000000000000000000000..8f82858d6f50eaaf047cf5c74148162a2ef5482f --- /dev/null +++ b/SysCAMSGenerationCode/generated_H/Sink.h @@ -0,0 +1,29 @@ +#ifndef SINK_H +#define SINK_H + +#include <cmath> +#include <iostream> +#include <systemc-ams> + +class Sink : public sca_tdf::sca_module { + +public: + + sca_tdf::sca_in<double> in; + + explicit Sink(sc_core::sc_module_name nm) + : in("in") + {} + +protected: + void set_attributes() { + in.set_rate(1); + } + + void processing() { + in.read(); + } + +}; + +#endif // SINK_H \ No newline at end of file diff --git a/modeling/monoprocessor.xml b/modeling/monoprocessor.xml new file mode 100644 index 0000000000000000000000000000000000000000..47361466534e6031df4ea0b2ec9bf84a3e3ac13a --- /dev/null +++ b/modeling/monoprocessor.xml @@ -0,0 +1,742 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<TURTLEGMODELING version="1.0beta"> + +<Modeling type="AVATAR Design" nameTab="AVATAR Design" > +<AVATARBlockDiagramPanel name="Block Diagram" minX="10" maxX="1400" minY="10" maxY="900" zoom="1.0" > +<MainCode value="void __user_init() {"/> +<MainCode value="}"/> +<Optimized value="true" /> +<Validated value="" /> +<Ignored value="" /> + +<COMPONENT type="5000" id="25" > +<cdparam x="117" y="236" /> +<sizeparam width="250" height="200" minWidth="5" minHeight="2" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="Block0" value="Block0" /> +<TGConnectingPoint num="0" id="1" /> +<TGConnectingPoint num="1" id="2" /> +<TGConnectingPoint num="2" id="3" /> +<TGConnectingPoint num="3" id="4" /> +<TGConnectingPoint num="4" id="5" /> +<TGConnectingPoint num="5" id="6" /> +<TGConnectingPoint num="6" id="7" /> +<TGConnectingPoint num="7" id="8" /> +<TGConnectingPoint num="8" id="9" /> +<TGConnectingPoint num="9" id="10" /> +<TGConnectingPoint num="10" id="11" /> +<TGConnectingPoint num="11" id="12" /> +<TGConnectingPoint num="12" id="13" /> +<TGConnectingPoint num="13" id="14" /> +<TGConnectingPoint num="14" id="15" /> +<TGConnectingPoint num="15" id="16" /> +<TGConnectingPoint num="16" id="17" /> +<TGConnectingPoint num="17" id="18" /> +<TGConnectingPoint num="18" id="19" /> +<TGConnectingPoint num="19" id="20" /> +<TGConnectingPoint num="20" id="21" /> +<TGConnectingPoint num="21" id="22" /> +<TGConnectingPoint num="22" id="23" /> +<TGConnectingPoint num="23" id="24" /> +<extraparam> +<blockType data="block" color="-4072719" /> +<CryptoBlock value="false" /> +</extraparam> +</COMPONENT> + + +</AVATARBlockDiagramPanel> + +<AVATARStateMachineDiagramPanel name="Block0" minX="10" maxX="1400" minY="10" maxY="900" > +<CONNECTOR type="5102" id="32" > +<cdparam x="460" y="115" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="31" /> +<P1 x="460" y="115" id="48" /> +<P2 x="456" y="164" id="40" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="30" > +<father id="32" num="0" /> +<cdparam x="458" y="139" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="26" /> +<TGConnectingPoint num="1" id="27" /> +<TGConnectingPoint num="2" id="28" /> +<TGConnectingPoint num="3" id="29" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +<probability value="" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="5102" id="39" > +<cdparam x="407" y="70" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="null" /> +<TGConnectingPoint num="0" id="38" /> +<P1 x="407" y="70" id="83" /> +<P2 x="410" y="71" id="62" /> +<AutomaticDrawing data="true" /> +</CONNECTOR><SUBCOMPONENT type="-1" id="37" > +<father id="39" num="0" /> +<cdparam x="407" y="110" /> +<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="List of all parameters of an Avatar SMD transition" value="" /> +<TGConnectingPoint num="0" id="33" /> +<TGConnectingPoint num="1" id="34" /> +<TGConnectingPoint num="2" id="35" /> +<TGConnectingPoint num="3" id="36" /> +<extraparam> +<guard value="[ ]" /> +<afterMin value="" /> +<afterMax value="" /> +<computeMin value="" /> +<computeMax value="" /> +<probability value="" /> +</extraparam> +</SUBCOMPONENT> + +<COMPONENT type="5101" id="41" > +<cdparam x="446" y="169" /> +<sizeparam width="20" height="20" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="stop state" value="null" /> +<TGConnectingPoint num="0" id="40" /> +</COMPONENT> + +<COMPONENT type="5106" id="82" > +<cdparam x="410" y="65" /> +<sizeparam width="100" height="50" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="state0" value="state0" /> +<TGConnectingPoint num="0" id="42" /> +<TGConnectingPoint num="1" id="43" /> +<TGConnectingPoint num="2" id="44" /> +<TGConnectingPoint num="3" id="45" /> +<TGConnectingPoint num="4" id="46" /> +<TGConnectingPoint num="5" id="47" /> +<TGConnectingPoint num="6" id="48" /> +<TGConnectingPoint num="7" id="49" /> +<TGConnectingPoint num="8" id="50" /> +<TGConnectingPoint num="9" id="51" /> +<TGConnectingPoint num="10" id="52" /> +<TGConnectingPoint num="11" id="53" /> +<TGConnectingPoint num="12" id="54" /> +<TGConnectingPoint num="13" id="55" /> +<TGConnectingPoint num="14" id="56" /> +<TGConnectingPoint num="15" id="57" /> +<TGConnectingPoint num="16" id="58" /> +<TGConnectingPoint num="17" id="59" /> +<TGConnectingPoint num="18" id="60" /> +<TGConnectingPoint num="19" id="61" /> +<TGConnectingPoint num="20" id="62" /> +<TGConnectingPoint num="21" id="63" /> +<TGConnectingPoint num="22" id="64" /> +<TGConnectingPoint num="23" id="65" /> +<TGConnectingPoint num="24" id="66" /> +<TGConnectingPoint num="25" id="67" /> +<TGConnectingPoint num="26" id="68" /> +<TGConnectingPoint num="27" id="69" /> +<TGConnectingPoint num="28" id="70" /> +<TGConnectingPoint num="29" id="71" /> +<TGConnectingPoint num="30" id="72" /> +<TGConnectingPoint num="31" id="73" /> +<TGConnectingPoint num="32" id="74" /> +<TGConnectingPoint num="33" id="75" /> +<TGConnectingPoint num="34" id="76" /> +<TGConnectingPoint num="35" id="77" /> +<TGConnectingPoint num="36" id="78" /> +<TGConnectingPoint num="37" id="79" /> +<TGConnectingPoint num="38" id="80" /> +<TGConnectingPoint num="39" id="81" /> +<extraparam> +<entryCode value="printf("Hello World! \n");" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5100" id="84" > +<cdparam x="400" y="50" /> +<sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="start state" value="null" /> +<TGConnectingPoint num="0" id="83" /> +</COMPONENT> + + +</AVATARStateMachineDiagramPanel> + +</Modeling> + + + + +<Modeling type="ADD" nameTab="Avatar Deployment" > +<ADDDiagramPanel name="Deployment Diagram" minX="10" maxX="1400" minY="10" maxY="900" attributes="0" masterClockFrequency="200" > +<COMPONENT type="5365" id="109" > +<cdparam x="1177" y="513" /> +<sizeparam width="250" height="200" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="cluster1" value="cluster1" /> +<TGConnectingPoint num="0" id="85" /> +<TGConnectingPoint num="1" id="86" /> +<TGConnectingPoint num="2" id="87" /> +<TGConnectingPoint num="3" id="88" /> +<TGConnectingPoint num="4" id="89" /> +<TGConnectingPoint num="5" id="90" /> +<TGConnectingPoint num="6" id="91" /> +<TGConnectingPoint num="7" id="92" /> +<TGConnectingPoint num="8" id="93" /> +<TGConnectingPoint num="9" id="94" /> +<TGConnectingPoint num="10" id="95" /> +<TGConnectingPoint num="11" id="96" /> +<TGConnectingPoint num="12" id="97" /> +<TGConnectingPoint num="13" id="98" /> +<TGConnectingPoint num="14" id="99" /> +<TGConnectingPoint num="15" id="100" /> +<TGConnectingPoint num="16" id="101" /> +<TGConnectingPoint num="17" id="102" /> +<TGConnectingPoint num="18" id="103" /> +<TGConnectingPoint num="19" id="104" /> +<TGConnectingPoint num="20" id="105" /> +<TGConnectingPoint num="21" id="106" /> +<TGConnectingPoint num="22" id="107" /> +<TGConnectingPoint num="23" id="108" /> +<extraparam> +<info stereotype="SystemC-AMS Cluster" nodeName="cluster1" /> +<attributes index="0" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5365" id="134" > +<cdparam x="995" y="128" /> +<sizeparam width="250" height="200" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="cluster" value="cluster" /> +<TGConnectingPoint num="0" id="110" /> +<TGConnectingPoint num="1" id="111" /> +<TGConnectingPoint num="2" id="112" /> +<TGConnectingPoint num="3" id="113" /> +<TGConnectingPoint num="4" id="114" /> +<TGConnectingPoint num="5" id="115" /> +<TGConnectingPoint num="6" id="116" /> +<TGConnectingPoint num="7" id="117" /> +<TGConnectingPoint num="8" id="118" /> +<TGConnectingPoint num="9" id="119" /> +<TGConnectingPoint num="10" id="120" /> +<TGConnectingPoint num="11" id="121" /> +<TGConnectingPoint num="12" id="122" /> +<TGConnectingPoint num="13" id="123" /> +<TGConnectingPoint num="14" id="124" /> +<TGConnectingPoint num="15" id="125" /> +<TGConnectingPoint num="16" id="126" /> +<TGConnectingPoint num="17" id="127" /> +<TGConnectingPoint num="18" id="128" /> +<TGConnectingPoint num="19" id="129" /> +<TGConnectingPoint num="20" id="130" /> +<TGConnectingPoint num="21" id="131" /> +<TGConnectingPoint num="22" id="132" /> +<TGConnectingPoint num="23" id="133" /> +<extraparam> +<info stereotype="SystemC-AMS Cluster" nodeName="cluster" /> +<attributes index="0" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5363" id="159" > +<cdparam x="523" y="309" /> +<sizeparam width="250" height="50" minWidth="100" minHeight="50" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="Bus0" value="name" /> +<TGConnectingPoint num="0" id="135" /> +<TGConnectingPoint num="1" id="136" /> +<TGConnectingPoint num="2" id="137" /> +<TGConnectingPoint num="3" id="138" /> +<TGConnectingPoint num="4" id="139" /> +<TGConnectingPoint num="5" id="140" /> +<TGConnectingPoint num="6" id="141" /> +<TGConnectingPoint num="7" id="142" /> +<TGConnectingPoint num="8" id="143" /> +<TGConnectingPoint num="9" id="144" /> +<TGConnectingPoint num="10" id="145" /> +<TGConnectingPoint num="11" id="146" /> +<TGConnectingPoint num="12" id="147" /> +<TGConnectingPoint num="13" id="148" /> +<TGConnectingPoint num="14" id="149" /> +<TGConnectingPoint num="15" id="150" /> +<TGConnectingPoint num="16" id="151" /> +<TGConnectingPoint num="17" id="152" /> +<TGConnectingPoint num="18" id="153" /> +<TGConnectingPoint num="19" id="154" /> +<TGConnectingPoint num="20" id="155" /> +<TGConnectingPoint num="21" id="156" /> +<TGConnectingPoint num="22" id="157" /> +<TGConnectingPoint num="23" id="158" /> +<extraparam> +<info stereotype="VGSB" nodeName="Bus0" /> +<attributes index="0" nbOfAttachedInitiators="0" nbOfAttachedTargets="0" minLatency="10" fifoDepth="10" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5355" id="184" > +<cdparam x="218" y="386" /> +<sizeparam width="200" height="200" minWidth="100" minHeight="35" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="Memory0" value="name" /> +<TGConnectingPoint num="0" id="160" /> +<TGConnectingPoint num="1" id="161" /> +<TGConnectingPoint num="2" id="162" /> +<TGConnectingPoint num="3" id="163" /> +<TGConnectingPoint num="4" id="164" /> +<TGConnectingPoint num="5" id="165" /> +<TGConnectingPoint num="6" id="166" /> +<TGConnectingPoint num="7" id="167" /> +<TGConnectingPoint num="8" id="168" /> +<TGConnectingPoint num="9" id="169" /> +<TGConnectingPoint num="10" id="170" /> +<TGConnectingPoint num="11" id="171" /> +<TGConnectingPoint num="12" id="172" /> +<TGConnectingPoint num="13" id="173" /> +<TGConnectingPoint num="14" id="174" /> +<TGConnectingPoint num="15" id="175" /> +<TGConnectingPoint num="16" id="176" /> +<TGConnectingPoint num="17" id="177" /> +<TGConnectingPoint num="18" id="178" /> +<TGConnectingPoint num="19" id="179" /> +<TGConnectingPoint num="20" id="180" /> +<TGConnectingPoint num="21" id="181" /> +<TGConnectingPoint num="22" id="182" /> +<TGConnectingPoint num="23" id="183" /> +<extraparam> +<info stereotype="RAM" nodeName="Memory0" /> +<attributes byteDataSize="1048576" index="0" processCode="" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5354" id="209" > +<cdparam x="639" y="474" /> +<sizeparam width="250" height="200" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="TTY0" value="name" /> +<TGConnectingPoint num="0" id="185" /> +<TGConnectingPoint num="1" id="186" /> +<TGConnectingPoint num="2" id="187" /> +<TGConnectingPoint num="3" id="188" /> +<TGConnectingPoint num="4" id="189" /> +<TGConnectingPoint num="5" id="190" /> +<TGConnectingPoint num="6" id="191" /> +<TGConnectingPoint num="7" id="192" /> +<TGConnectingPoint num="8" id="193" /> +<TGConnectingPoint num="9" id="194" /> +<TGConnectingPoint num="10" id="195" /> +<TGConnectingPoint num="11" id="196" /> +<TGConnectingPoint num="12" id="197" /> +<TGConnectingPoint num="13" id="198" /> +<TGConnectingPoint num="14" id="199" /> +<TGConnectingPoint num="15" id="200" /> +<TGConnectingPoint num="16" id="201" /> +<TGConnectingPoint num="17" id="202" /> +<TGConnectingPoint num="18" id="203" /> +<TGConnectingPoint num="19" id="204" /> +<TGConnectingPoint num="20" id="205" /> +<TGConnectingPoint num="21" id="206" /> +<TGConnectingPoint num="22" id="207" /> +<TGConnectingPoint num="23" id="208" /> +<extraparam> +<info stereotype="TTY" nodeName="TTY0" /> +<attributes index="0" /> +</extraparam> +</COMPONENT> + +<COMPONENT type="5351" id="243" > +<cdparam x="113" y="44" /> +<sizeparam width="250" height="200" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> +<infoparam name="CPU0" value="name" /> +<TGConnectingPoint num="0" id="219" /> +<TGConnectingPoint num="1" id="220" /> +<TGConnectingPoint num="2" id="221" /> +<TGConnectingPoint num="3" id="222" /> +<TGConnectingPoint num="4" id="223" /> +<TGConnectingPoint num="5" id="224" /> +<TGConnectingPoint num="6" id="225" /> +<TGConnectingPoint num="7" id="226" /> +<TGConnectingPoint num="8" id="227" /> +<TGConnectingPoint num="9" id="228" /> +<TGConnectingPoint num="10" id="229" /> +<TGConnectingPoint num="11" id="230" /> +<TGConnectingPoint num="12" id="231" /> +<TGConnectingPoint num="13" id="232" /> +<TGConnectingPoint num="14" id="233" /> +<TGConnectingPoint num="15" id="234" /> +<TGConnectingPoint num="16" id="235" /> +<TGConnectingPoint num="17" id="236" /> +<TGConnectingPoint num="18" id="237" /> +<TGConnectingPoint num="19" id="238" /> +<TGConnectingPoint num="20" id="239" /> +<TGConnectingPoint num="21" id="240" /> +<TGConnectingPoint num="22" id="241" /> +<TGConnectingPoint num="23" id="242" /> +<extraparam> +<info stereotype="CPU" nodeName="CPU0" /> +<attributes nbOfIrq="6" iCacheWays="1" iCacheSets="8" iCacheWords="4" dCacheWays="1" dCacheSets="8" dCacheWords="4" /> +</extraparam> +</COMPONENT> +<SUBCOMPONENT type="5352" id="218" > +<father id="243" num="0" /> +<cdparam x="172" y="134" /> +<sizeparam width="176" height="40" minWidth="75" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="0" maxX="74" minY="0" maxY="160" /> +<infoparam name="TGComponent" value="AVATAR Design::Block0" /> +<TGConnectingPoint num="0" id="210" /> +<TGConnectingPoint num="1" id="211" /> +<TGConnectingPoint num="2" id="212" /> +<TGConnectingPoint num="3" id="213" /> +<TGConnectingPoint num="4" id="214" /> +<TGConnectingPoint num="5" id="215" /> +<TGConnectingPoint num="6" id="216" /> +<TGConnectingPoint num="7" id="217" /> +<extraparam> +<info value="AVATAR Design::Block0" taskName="Block0" referenceTaskName="AVATAR Design" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="5350" id="244" > +<cdparam x="1177" y="563" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="1177" y="563" id="95" /> +<P2 x="773" y="346" id="148" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> +<CONNECTOR type="5350" id="245" > +<cdparam x="1006" y="263" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="995" y="178" id="120" /> +<P2 x="773" y="309" id="137" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> +<CONNECTOR type="5350" id="246" > +<cdparam x="701" y="474" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="701" y="474" id="193" /> +<P2 x="648" y="359" id="141" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> +<CONNECTOR type="5350" id="247" > +<cdparam x="418" y="436" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="418" y="436" id="171" /> +<P2 x="523" y="359" id="140" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> +<CONNECTOR type="5350" id="248" > +<cdparam x="300" y="244" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="{info}" /> +<P1 x="300" y="244" id="234" /> +<P2 x="523" y="309" id="135" /> +<AutomaticDrawing data="true" /> +<extraparam> +<spy value="false" /> +</extraparam> +</CONNECTOR> + +</ADDDiagramPanel> + +</Modeling> + + + + +<Modeling type="SystemC-AMS" nameTab="SystemC_AMS" > +<SysCAMSComponentTaskDiagramPanel name="SystemC-AMS Component Diagram" minX="10" maxX="2500" minY="10" maxY="1500" TDF="true" DE="true" zoom="1.0" > +<CONNECTOR type="1601" id="386" > +<cdparam x="681" y="329" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="Connector between ports" /> +<P1 x="681" y="329" id="291" /> +<P2 x="572" y="324" id="377" /> +<AutomaticDrawing data="true" /> +</CONNECTOR> +<CONNECTOR type="1601" id="250" > +<cdparam x="733" y="410" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="Connector between ports" /> +<P1 x="811" y="410" id="281" /> +<P2 x="816" y="455" id="310" /> +<AutomaticDrawing data="true" /> +</CONNECTOR> +<CONNECTOR type="1601" id="251" > +<cdparam x="860" y="449" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="Connector between ports" /> +<P1 x="907" y="333" id="271" /> +<P2 x="1232" y="447" id="252" /> +<AutomaticDrawing data="true" /> +</CONNECTOR> +<COMPONENT type="1608" id="270" > +<cdparam x="1245" y="364" /> +<sizeparam width="200" height="150" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Primitive component - Block GPIO2VCI" value="Block_GPIO2VCI" /> +<TGConnectingPoint num="0" id="262" /> +<TGConnectingPoint num="1" id="263" /> +<TGConnectingPoint num="2" id="264" /> +<TGConnectingPoint num="3" id="265" /> +<TGConnectingPoint num="4" id="266" /> +<TGConnectingPoint num="5" id="267" /> +<TGConnectingPoint num="6" id="268" /> +<TGConnectingPoint num="7" id="269" /> +</COMPONENT> +<SUBCOMPONENT type="1605" id="261" > +<father id="270" num="0" /> +<cdparam x="1232" y="434" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port - Port DE" value="in" /> +<TGConnectingPoint num="0" id="252" /> +<TGConnectingPoint num="1" id="253" /> +<TGConnectingPoint num="2" id="254" /> +<TGConnectingPoint num="3" id="255" /> +<TGConnectingPoint num="4" id="256" /> +<TGConnectingPoint num="5" id="257" /> +<TGConnectingPoint num="6" id="258" /> +<TGConnectingPoint num="7" id="259" /> +<TGConnectingPoint num="8" id="260" /> +<extraparam> +<Prop commName="in" commType="0" origin="0" type="int" sensitive="false" sensitive_method="positive" /> +</extraparam> +</SUBCOMPONENT> + +<COMPONENT type="1607" id="356" > +<cdparam x="303" y="181" /> +<sizeparam width="808" height="458" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Composite component - Cluster" value="cluster" /> +<TGConnectingPoint num="0" id="348" /> +<TGConnectingPoint num="1" id="349" /> +<TGConnectingPoint num="2" id="350" /> +<TGConnectingPoint num="3" id="351" /> +<TGConnectingPoint num="4" id="352" /> +<TGConnectingPoint num="5" id="353" /> +<TGConnectingPoint num="6" id="354" /> +<TGConnectingPoint num="7" id="355" /> +</COMPONENT> +<SUBCOMPONENT type="1603" id="358" > +<father id="356" num="0" /> +<cdparam x="359" y="277" /> +<sizeparam width="200" height="150" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="0" maxX="608" minY="0" maxY="308" /> +<infoparam name="Primitive component - Block DE" value="Block_DE_0" /> +<TGConnectingPoint num="0" id="359" /> +<TGConnectingPoint num="1" id="360" /> +<TGConnectingPoint num="2" id="361" /> +<TGConnectingPoint num="3" id="362" /> +<TGConnectingPoint num="4" id="363" /> +<TGConnectingPoint num="5" id="364" /> +<TGConnectingPoint num="6" id="365" /> +<TGConnectingPoint num="7" id="366" /> +<extraparam> +<Attribute name_function="test" code="void test() { + test_code; +}" listStruct="" nameTemplate="" typeTemplate="int" listTypedef="" /> +</extraparam> +</SUBCOMPONENT> +<SUBCOMPONENT type="1605" id="376" > +<father id="358" num="0" /> +<cdparam x="546" y="311" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port - Port DE" value="port" /> +<TGConnectingPoint num="0" id="377" /> +<TGConnectingPoint num="1" id="378" /> +<TGConnectingPoint num="2" id="379" /> +<TGConnectingPoint num="3" id="380" /> +<TGConnectingPoint num="4" id="381" /> +<TGConnectingPoint num="5" id="382" /> +<TGConnectingPoint num="6" id="383" /> +<TGConnectingPoint num="7" id="384" /> +<TGConnectingPoint num="8" id="385" /> +<extraparam> +<Prop commName="in_de" commType="0" origin="0" type="int" sensitive="false" sensitive_method="positive" /> +</extraparam> +</SUBCOMPONENT> +<SUBCOMPONENT type="1602" id="309" > +<father id="356" num="1" /> +<cdparam x="694" y="247" /> +<sizeparam width="200" height="150" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="0" maxX="608" minY="0" maxY="308" /> +<infoparam name="Primitive component - Block TDF" value="Sine" /> +<TGConnectingPoint num="0" id="301" /> +<TGConnectingPoint num="1" id="302" /> +<TGConnectingPoint num="2" id="303" /> +<TGConnectingPoint num="3" id="304" /> +<TGConnectingPoint num="4" id="305" /> +<TGConnectingPoint num="5" id="306" /> +<TGConnectingPoint num="6" id="307" /> +<TGConnectingPoint num="7" id="308" /> +<extraparam> +<Attribute period="6" time="us" processCode="void processing() { + double t = out_de.get_time().to_seconds(); + double x = sin(2.0 * M_PI * 5000000.0 * t); + out_de.write( (int) x); + tdf_out.write(x); +} + " listStruct="" nameTemplate="" typeTemplate="int" listTypedef="" /> +</extraparam> +</SUBCOMPONENT> +<SUBCOMPONENT type="1606" id="280" > +<father id="309" num="0" /> +<cdparam x="881" y="320" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port - Port Converter" value="out_de" /> +<TGConnectingPoint num="0" id="271" /> +<TGConnectingPoint num="1" id="272" /> +<TGConnectingPoint num="2" id="273" /> +<TGConnectingPoint num="3" id="274" /> +<TGConnectingPoint num="4" id="275" /> +<TGConnectingPoint num="5" id="276" /> +<TGConnectingPoint num="6" id="277" /> +<TGConnectingPoint num="7" id="278" /> +<TGConnectingPoint num="8" id="279" /> +<extraparam> +<Prop commName="out_de" commType="0" origin="1" period="6" time="us" rate="1" delay="0" type="int" /> +</extraparam> +</SUBCOMPONENT> +<SUBCOMPONENT type="1604" id="290" > +<father id="309" num="1" /> +<cdparam x="798" y="384" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port - Port TDF" value="tdf_out" /> +<TGConnectingPoint num="0" id="281" /> +<TGConnectingPoint num="1" id="282" /> +<TGConnectingPoint num="2" id="283" /> +<TGConnectingPoint num="3" id="284" /> +<TGConnectingPoint num="4" id="285" /> +<TGConnectingPoint num="5" id="286" /> +<TGConnectingPoint num="6" id="287" /> +<TGConnectingPoint num="7" id="288" /> +<TGConnectingPoint num="8" id="289" /> +<extraparam> +<Prop commName="tdf_out" commType="0" origin="1" period="6" time="us" rate="1" delay="-1" type="double" /> +</extraparam> +</SUBCOMPONENT> +<SUBCOMPONENT type="1606" id="300" > +<father id="309" num="2" /> +<cdparam x="681" y="316" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port - Port Converter" value="out2_de" /> +<TGConnectingPoint num="0" id="291" /> +<TGConnectingPoint num="1" id="292" /> +<TGConnectingPoint num="2" id="293" /> +<TGConnectingPoint num="3" id="294" /> +<TGConnectingPoint num="4" id="295" /> +<TGConnectingPoint num="5" id="296" /> +<TGConnectingPoint num="6" id="297" /> +<TGConnectingPoint num="7" id="298" /> +<TGConnectingPoint num="8" id="299" /> +<extraparam> +<Prop commName="out2_de" commType="0" origin="1" period="-1" time="us" rate="-1" delay="-1" type="int" /> +</extraparam> +</SUBCOMPONENT> +<SUBCOMPONENT type="1602" id="328" > +<father id="356" num="2" /> +<cdparam x="705" y="468" /> +<sizeparam width="200" height="150" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="0" maxX="608" minY="0" maxY="308" /> +<infoparam name="Primitive component - Block TDF" value="Sink" /> +<TGConnectingPoint num="0" id="320" /> +<TGConnectingPoint num="1" id="321" /> +<TGConnectingPoint num="2" id="322" /> +<TGConnectingPoint num="3" id="323" /> +<TGConnectingPoint num="4" id="324" /> +<TGConnectingPoint num="5" id="325" /> +<TGConnectingPoint num="6" id="326" /> +<TGConnectingPoint num="7" id="327" /> +<extraparam> +<Attribute period="-1" time="" processCode="void processing() { + in.read(); +} + " listStruct="" nameTemplate="" typeTemplate="int" listTypedef="" /> +</extraparam> +</SUBCOMPONENT> +<SUBCOMPONENT type="1604" id="319" > +<father id="328" num="0" /> +<cdparam x="803" y="455" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port - Port TDF" value="in" /> +<TGConnectingPoint num="0" id="310" /> +<TGConnectingPoint num="1" id="311" /> +<TGConnectingPoint num="2" id="312" /> +<TGConnectingPoint num="3" id="313" /> +<TGConnectingPoint num="4" id="314" /> +<TGConnectingPoint num="5" id="315" /> +<TGConnectingPoint num="6" id="316" /> +<TGConnectingPoint num="7" id="317" /> +<TGConnectingPoint num="8" id="318" /> +<extraparam> +<Prop commName="in" commType="0" origin="0" period="-1" time="us" rate="1" delay="-1" type="double" /> +</extraparam> +</SUBCOMPONENT> + + +</SysCAMSComponentTaskDiagramPanel> + +</Modeling> + + + + +</TURTLEGMODELING> \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSSpecification.java b/src/main/java/syscamstranslator/SysCAMSSpecification.java index 1a065f57bc66c212c4928710fac8c77eebea6180..188fbb423a03a8e38bca67c677f81eac79747aa4 100644 --- a/src/main/java/syscamstranslator/SysCAMSSpecification.java +++ b/src/main/java/syscamstranslator/SysCAMSSpecification.java @@ -130,9 +130,20 @@ public class SysCAMSSpecification{ LinkedList<SysCAMSTConnector> cons = new LinkedList<SysCAMSTConnector>(); for (SysCAMSTConnector con : connectors) { if (con instanceof SysCAMSTConnector) { - if (!((con.get_p1().getComponent() instanceof SysCAMSTPortConverter && con.get_p2().getComponent() instanceof SysCAMSTPortDE) - || (con.get_p2().getComponent() instanceof SysCAMSTPortConverter && con.get_p1().getComponent() instanceof SysCAMSTPortDE))) { - cons.add(con); + if (con.get_p1().getComponent() instanceof SysCAMSTPortTDF && con.get_p2().getComponent() instanceof SysCAMSTPortTDF) { + cons.add(con); + } else if (con.get_p1().getComponent() instanceof SysCAMSTPortConverter && con.get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE() != null) { + if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null ) { + cons.add(con); + } + } + } else if (con.get_p2().getComponent() instanceof SysCAMSTPortConverter && con.get_p1().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE() != null) { + if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null ) { + cons.add(con); + } + } } } } diff --git a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java index c0ef273a672a11bb6bf33694de112c9e2b128ccc..8432aec23a17f44f85a68704ce563f5092bf195a 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java @@ -70,6 +70,7 @@ public class ClusterCode { if (cluster != null) { LinkedList<SysCAMSTBlockTDF> tdf = cluster.getBlockTDF(); + LinkedList<SysCAMSTBlockDE> de = cluster.getBlockDE(); corpsCluster = "// Simulation entry point." + CR + "int sc_main(int argc, char *argv[]) {" + CR2 + "\tusing namespace sc_core;" + CR + "\tusing namespace sca_util;" + CR2; @@ -77,26 +78,97 @@ public class ClusterCode { corpsCluster = corpsCluster + "\t// Declare signal to interconnect." + CR; for (SysCAMSTConnector c : connectors) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + "> " - + "sig_" + nb_con + "(\"" - + "sig_" + nb_con + "\");" + CR; - nb_con++; + if (c.get_p1().getComponent() instanceof SysCAMSTPortTDF) { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + "> " + + "sig_" + nb_con + "(\"" + + "sig_" + nb_con + "\");" + CR; + nb_con++; + } else if (c.get_p1().getComponent() instanceof SysCAMSTPortConverter) { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + "> " + + "sig_" + nb_con + "(\"" + + "sig_" + nb_con + "\");" + CR; + nb_con++; + } else if (c.get_p1().getComponent() instanceof SysCAMSTPortDE) { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + "> " + + "sig_" + nb_con + "(\"" + + "sig_" + nb_con + "\");" + CR; + nb_con++; + } } - + corpsCluster = corpsCluster + CR + "\t// Instantiate headers files as well as bind their ports to the signal." + CR; for (SysCAMSTBlockTDF t : tdf) { corpsCluster = corpsCluster + "\t" + t.getName() + " " + t.getName() + "_" + nb_block + "(\"" + t.getName() + "_" + nb_block + "\");" + CR; - LinkedList<SysCAMSTPortTDF> port = t.getPortTDF(); - for (SysCAMSTPortTDF p : port) { + LinkedList<SysCAMSTPortTDF> portTDF = t.getPortTDF(); + LinkedList<SysCAMSTPortConverter> portConv = t.getPortConverter(); + + for (SysCAMSTPortTDF p : portTDF) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "("; + for (int i = 0; i < connectors.size(); i++) { + nb_con = i+1; + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortTDF) { + if (((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName())) { + corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; + } else if (((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName())) { + corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; + } + } + } + } + + boolean first = false; + for (SysCAMSTPortConverter p : portConv) { + for (int i = 0; i < connectors.size(); i++) { + if (first == false) { + if ((connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter)) { + if ((((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()))) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "("; + first = true; + } + } else if ((connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter)) { + if ((((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()))) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "("; + first = true; + } + } + } + if (first == true) { + nb_con = i+1; + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter) { + if (((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName())) { + corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; + } + } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter) { + if (((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName())) { + corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; + } + } + } + } + } + corpsCluster = corpsCluster + CR; + nb_block++; + } + + for (SysCAMSTBlockDE t : de) { + corpsCluster = corpsCluster + "\t" + t.getName() + " " + t.getName() + "_" + nb_block + "(\"" + t.getName() + "_" + nb_block + "\");" + CR; + + LinkedList<SysCAMSTPortDE> portDE = t.getPortDE(); + + for (SysCAMSTPortDE p : portDE) { corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "("; for (int i = 0; i < connectors.size(); i++) { nb_con = i+1; - if (((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName())) { - corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; - } else if (((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName())) { - corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName())) { + corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; + } + } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName())) { + corpsCluster = corpsCluster + "sig_" + nb_con + ");" + CR; + } } } } @@ -109,10 +181,10 @@ public class ClusterCode { nb_con = 1; for (int i = 0; i < connectors.size(); i++) { - corpsCluster = corpsCluster + "\tsca_trace(tfp, "+ "sig_" + nb_con + ", \"" + "sig_" + nb_con + "\");"; + corpsCluster = corpsCluster + "\tsca_trace(tfp, "+ "sig_" + nb_con + ", \"" + "sig_" + nb_con + "\");" + CR; nb_con++; } - corpsCluster = corpsCluster + CR2 + "\t// Start simulation." + CR + "\tsc_start(100.0, SC_MS);" + CR2 + corpsCluster = corpsCluster + CR + "\t// Start simulation." + CR + "\tsc_start(100.0, SC_MS);" + CR2 + "\t// Close trace file and stop simulation to enable clean-up by" + CR + "\t// asking SystemC to execute all end_of_simulation() callbacks." + CR + "\tsca_close_tabular_trace_file(tfp);" + CR diff --git a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java index 00e81e49ced8524e31ac19f7603f0a877148163e..a93e4e573e12eb7c9cf5c408bdcac93f2f3471e6 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java @@ -74,7 +74,7 @@ public class PrimitiveCode { int cpt = 0; int cpt2 = 0; - if ((!tdf.getTypeTemplate().equals("")) || (!tdf.getNameTemplate().equals(""))) { + if ((!tdf.getTypeTemplate().equals("")) && (!tdf.getNameTemplate().equals(""))) { corpsPrimitiveTDF = corpsPrimitiveTDF + "template<" + tdf.getTypeTemplate() + " " + tdf.getNameTemplate() + ">" + CR; } //corpsPrimitive = "SCA_TDF_MODULE(" + tdf.getName() + ") {" + CR2; @@ -385,7 +385,7 @@ public class PrimitiveCode { int cpt = 0; int cpt2 = 0; - if ((!de.getTypeTemplate().equals("")) || (!de.getNameTemplate().equals(""))) { + if ((!de.getTypeTemplate().equals("")) && (!de.getNameTemplate().equals(""))) { corpsPrimitiveDE = corpsPrimitiveDE + "template<" + de.getTypeTemplate() + " " + de.getNameTemplate() + ">" + CR; } //corpsPrimitive = "SCA_TDF_MODULE(" + de.getName() + ") {" + CR2; diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index 4cdf8a16a3eb2bd4f424d1eb89c66440fd13ca8c..070fc05e09fb67734fe159356aa5bf5418782609 100644 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -969,6 +969,10 @@ public class ActionPerformer { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_MODULE_TERMINAL); } else if (command.equals(mgui.actions[TGUIAction.ELN_TOGGLE_ATTR].getActionCommand())){ mgui.toggleELN(); + } else if (command.equals(mgui.actions[TGUIAction.ELN_TDF_VOLTAGE_SOURCE].getActionCommand())){ + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_TDF_VOLTAGE_SOURCE); + } else if (command.equals(mgui.actions[TGUIAction.ELN_TDF_CURRENT_SOURCE].getActionCommand())){ + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_TDF_CURRENT_SOURCE); // Attack Tree Diagrams } else if (command.equals(mgui.actions[TGUIAction.ATD_BLOCK].getActionCommand())) { diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index 7c4de6ed5986dc00ad617420034b95204049e7ff..18642e4074253a8cb6e748cfe3b95d604e32b53e 100644 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -363,6 +363,8 @@ public class TGComponentManager { public static final int ELN_MODULE = 1623; public static final int ELN_MODULE_TERMINAL = 1624; public static final int ELN_MID_PORT_TERMINAL = 1625; + public static final int ELN_TDF_VOLTAGE_SOURCE = 1626; + public static final int ELN_TDF_CURRENT_SOURCE = 1627; // SMD diagram public static final int PROSMD_START_STATE = 2000; @@ -1335,6 +1337,12 @@ public class TGComponentManager { case ELN_MID_PORT_TERMINAL: tgc = new ELNMidPortTerminal(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case ELN_TDF_VOLTAGE_SOURCE: + tgc = new ELNComponentVoltageSourceTDF(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ELN_TDF_CURRENT_SOURCE: + tgc = new ELNComponentCurrentSourceTDF(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; // Communication patterns + SD case TMLCP_CHOICE: tgc = new TMLCPChoice(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -1769,6 +1777,10 @@ public class TGComponentManager { return ELN_MODULE_TERMINAL; } else if (tgc instanceof ELNMidPortTerminal) { return ELN_MID_PORT_TERMINAL; + } else if (tgc instanceof ELNComponentVoltageSourceTDF) { + return ELN_TDF_VOLTAGE_SOURCE; + } else if (tgc instanceof ELNComponentCurrentSourceTDF) { + return ELN_TDF_CURRENT_SOURCE; // Others } else if (tgc instanceof TADDeterministicDelay) { diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index 9f5f95850158f15301df04e6a991bbf8112a1ffa..f554a7f5aa4bd64301a1ec03447c15cb1cf482cd 100644 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -304,6 +304,8 @@ public class TGUIAction extends AbstractAction { public static final int ELN_MODULE = 499; public static final int ELN_MODULE_TERMINAL = 500; public static final int ELN_TOGGLE_ATTR = 501; + public static final int ELN_TDF_VOLTAGE_SOURCE = 502; + public static final int ELN_TDF_CURRENT_SOURCE = 503; public static final int EBRDD_EDIT = 271; public static final int EBRDD_CONNECTOR = 272; @@ -659,7 +661,7 @@ public class TGUIAction extends AbstractAction { public static final int MOVE_ENABLED = 463; public static final int FIRST_DIAGRAM = 464; - public static final int NB_ACTION = 502; + public static final int NB_ACTION = 504; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -1183,7 +1185,9 @@ public class TGUIAction extends AbstractAction { actions[ELN_MODULE] = new TAction("eln-module", "Add a SystemC module", IconManager.imgic8006, IconManager.imgic8006, "SystemC module", "Add a SystemC module to the currently opened ELN Diagram", 0); actions[ELN_MODULE_TERMINAL] = new TAction("eln-module-terminal", "Add a module terminal", IconManager.imgic8032, IconManager.imgic8032, "Module terminal", "Add a module terminal to the currently opened ELN Diagram", 0); actions[ELN_TOGGLE_ATTR] = new TAction("eln-toggle-attr-command", "Show / hide attributes in ELN", IconManager.imgic138, IconManager.imgic138, "Show / hide element attributes in ELN", "Show / hide attributes to the currently opened ELN Diagram", 0); - + actions[ELN_TDF_VOLTAGE_SOURCE] = new TAction("eln-tdf-vsource", "Add a voltage source driven by a TDF input signal", IconManager.imgic8033, IconManager.imgic8033, "Voltage source driven by a TDF input signal", "Add a voltage source driven by a TDF input signal to the currently opened ELN Diagram", 0); + actions[ELN_TDF_CURRENT_SOURCE] = new TAction("eln-tdf-isource", "Add a current source driven by a TDF input signal", IconManager.imgic8034, IconManager.imgic8034, "Current source driven by a TDF input signal", "Add a current source driven by a TDF input signal to the currently opened ELN Diagram", 0); + //ProActive State Machine Diagram actions[PROSMD_EDIT] = new TAction("edit-prosmd-diagram", "Edit ProActive state machine diagram", IconManager.imgic100, IconManager.imgic101, "Edit ProActive state machine diagram", "Make it possible to edit the currently opened ProActive state machine diagram", 0); actions[PROSMD_START] = new TAction("add-prosmd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened ProActive state machine diagram", 0); diff --git a/src/main/java/ui/eln/ELNDiagramToolBar.java b/src/main/java/ui/eln/ELNDiagramToolBar.java index d7ddfe3b6df88bc733a988c6aee8c6b979b4167f..69ed3db8bc1b83d259e2b7a5c8fd7e9d6007eea2 100644 --- a/src/main/java/ui/eln/ELNDiagramToolBar.java +++ b/src/main/java/ui/eln/ELNDiagramToolBar.java @@ -82,6 +82,8 @@ public class ELNDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ELN_MODULE].setEnabled(b); mgui.actions[TGUIAction.ELN_MODULE_TERMINAL].setEnabled(b); mgui.actions[TGUIAction.ELN_TOGGLE_ATTR].setEnabled(b); + mgui.actions[TGUIAction.ELN_TDF_VOLTAGE_SOURCE].setEnabled(b); + mgui.actions[TGUIAction.ELN_TDF_CURRENT_SOURCE].setEnabled(b); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); @@ -142,6 +144,12 @@ public class ELNDiagramToolBar extends TToolBar { this.addSeparator(); + button = this.add(mgui.actions[TGUIAction.ELN_TDF_VOLTAGE_SOURCE]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.ELN_TDF_CURRENT_SOURCE]); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ELN_TDF_VOLTAGE_SINK]); button.addMouseListener(mgui.mouseHandler); diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java new file mode 100644 index 0000000000000000000000000000000000000000..6fe3ec9b74ad63bfe2e80aa486cddfd99cac2d93 --- /dev/null +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java @@ -0,0 +1,1206 @@ +/* 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.JDialogELNComponentCurrentSourceTDF; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; + +/** + * Class ELNComponentCurrentSourceTDF Current source driven by a TDF input + * signal signal to be used in ELN diagrams Creation: 19/07/2018 + * + * @version 1.0 19/07/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNComponentCurrentSourceTDF 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 ELNComponentCurrentSourceTDF(int _x, int _y, int _minX, int _maxX, + int _minY, int _maxY, boolean _pos, TGComponent _father, + TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + initScaling(100, 100); + + 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("TDF_ISource"); + + setScale(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "n"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "inp"); + } + + public Color getMyColor() { + 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; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + } else if (position == 1) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 16 - sw1, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 16, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 20 - sw1, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + } else if (position == 2) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + } else if (position == 3) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 20 - sw1, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 16 - sw1, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 16, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + } + 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.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + 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_TDF_CURRENT_SOURCE; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNComponentCurrentSourceTDF jde = new JDialogELNComponentCurrentSourceTDF( + 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()); + } +} \ No newline at end of file diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSourceTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSourceTDF.java new file mode 100644 index 0000000000000000000000000000000000000000..cea74ddaabd259625e6e18c7a6adf996a6b3e878 --- /dev/null +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSourceTDF.java @@ -0,0 +1,1251 @@ +/* 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.JDialogELNComponentVoltageSourceTDF; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.RoundRectangle2D; + +/** + * Class ELNComponentVoltageSourceTDF Voltage source driven by a TDF input + * signal to be used in ELN diagrams Creation: 19/07/2018 + * + * @version 1.0 19/07/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNComponentVoltageSourceTDF 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 ELNComponentVoltageSourceTDF(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("TDF_VSource"); + + setScale(1.0); + + old = width; + width = height; + height = old; + } + + public void initPortTerminal(int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + connectingPoint[0] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "p"); + connectingPoint[1] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "n"); + connectingPoint[2] = new ELNPortTerminal(this, 0, 0, true, true, 0.0, + 0.0, "inp"); + } + + public Color getMyColor() { + 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; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + } else if (position == 1) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 16 - sw1, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 16, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 20 - sw1, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + } else if (position == 2) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y + height + height / 20 + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(0.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(0.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(1.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - sw0, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - sw1, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width, y + height / 2 + height / 5 + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0); + ((ELNPortTerminal) connectingPoint[1]).setH(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.0); + ((ELNPortTerminal) connectingPoint[2]).setH(0.5); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width, y - height / 20); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width, y + height + height / 20 + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + - sw2, y + height / 2 + height / 5 + sh2); + } + } + } else if (position == 3) { + if (first == false) { + first = true; + old = width; + width = height; + height = old; + } + + 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(); + int w = g.getFontMetrics().stringWidth(value); + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w) / 2, y - height / 5); + } + g.setFont(f.deriveFont(Font.PLAIN)); + + if ((fv_0_2 == false && fv_1_3 == false && fh_0_2 == false && fh_1_3 == false) + || (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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[0]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[1]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + - width / 20 - sw0, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + + width + width / 20, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(0.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(0.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(1.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 20 - sw1, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 20, y); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y + height + sh2); + } + } + if ((fv_0_2 == 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); + ((ELNPortTerminal) connectingPoint[1]).setW(1.0 / 20.0); + ((ELNPortTerminal) connectingPoint[1]).setH(1.0); + ((ELNPortTerminal) connectingPoint[0]).setW(19.0 / 20.0); + ((ELNPortTerminal) connectingPoint[0]).setH(1.0); + ((ELNPortTerminal) connectingPoint[2]).setW(0.5); + ((ELNPortTerminal) connectingPoint[2]).setH(0.0); + if (mgui.getHidden() == false) { + g.drawString( + ((ELNPortTerminal) connectingPoint[1]).getName(), x + - width / 16 - sw1, y + height + sh1); + g.drawString( + ((ELNPortTerminal) connectingPoint[0]).getName(), x + + width + width / 16, y + height + sh0); + g.drawString( + ((ELNPortTerminal) connectingPoint[2]).getName(), x + + width / 2 + width / 5, y); + } + } + } + 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.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 10, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 4 * width / 5, y + 2 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x + width / 20, y - height / 20, 4 + * width / 5 + width / 10 - width / 20, height + height / 10, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y + 4 * height / 5, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 20, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y, width / 10, height / 10); + g.setColor(c); + } + + private void 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.fillRect(x + 2 * width / 5, y, width / 5, height / 5); + + Graphics2D g2d = (Graphics2D) g.create(); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g2d.setStroke(dashed); + g2d.draw(new RoundRectangle2D.Double(x - width / 20, y + height / 10, + width + width / 10, 4 * height / 5 + height / 10 - height / 20, + 10, 10)); + g2d.dispose(); + + g.drawOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x, y + height - height / 10, width / 10, height / 10); + g.setColor(c); + g.drawOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(Color.WHITE); + g.fillOval(x + width - width / 10, y + height - height / 10, + width / 10, height / 10); + g.setColor(c); + } + + 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_TDF_VOLTAGE_SOURCE; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNComponentVoltageSourceTDF jde = new JDialogELNComponentVoltageSourceTDF( + 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()); + } +} \ No newline at end of file diff --git a/src/main/java/ui/util/IconManager.java b/src/main/java/ui/util/IconManager.java index 60638edfe9c20ec64f958d111763e7cad1c1b338..b54bb121219ad0ed343b1f21a3ccd9a7f951c15d 100755 --- a/src/main/java/ui/util/IconManager.java +++ b/src/main/java/ui/util/IconManager.java @@ -187,7 +187,7 @@ public class IconManager { // ELN public static ImageIcon imgic8020, imgic8021, imgic8022, imgic8023, imgic8024, imgic8025, imgic8026, imgic8027, imgic8028, imgic8029, - imgic8030, imgic8031, imgic8032; + imgic8030, imgic8031, imgic8032, imgic8033, imgic8034; //private static String icon7 = "turtle_large.gif"; private static String ttoolStringIcon = "starting_logo.gif"; @@ -692,6 +692,8 @@ public class IconManager { private static String icon8030 = "elntdfvsink.gif"; private static String icon8031 = "elntdfisink.gif"; private static String icon8032 = "elnportterminal.gif"; + private static String icon8033 = "elntdfvsource.gif"; + private static String icon8034 = "elntdfisource.gif"; public IconManager() { @@ -1206,6 +1208,8 @@ public class IconManager { imgic8030 = getIcon(icon8030); imgic8031 = getIcon(icon8031); imgic8032 = getIcon(icon8032); + imgic8033 = getIcon(icon8033); + imgic8034 = getIcon(icon8034); } } // Class diff --git a/src/main/java/ui/window/JDialogELNComponentCurrentSourceTDF.java b/src/main/java/ui/window/JDialogELNComponentCurrentSourceTDF.java new file mode 100644 index 0000000000000000000000000000000000000000..4c2c8c814e7091675422fbf8dea54692faf2a5d4 --- /dev/null +++ b/src/main/java/ui/window/JDialogELNComponentCurrentSourceTDF.java @@ -0,0 +1,203 @@ +/* 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_tdf.ELNComponentCurrentSourceTDF; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.AbstractAction; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.KeyStroke; + +/** + * Class JDialogELNComponentCurrentSourceTDF + * Dialog for managing the ELN current driven by a TDF input signal + * Creation: 19/07/2018 + * @version 1.0 19/07/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogELNComponentCurrentSourceTDF extends JDialog implements ActionListener { + private JTextField nameTextField; + private JTextField valueTextField; + + private ELNComponentCurrentSourceTDF isource; + + public JDialogELNComponentCurrentSourceTDF(ELNComponentCurrentSourceTDF _isource) { + setTitle("Setting the current driven by a TDF 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_tdf_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(); + } + } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogELNComponentVoltageSourceTDF.java b/src/main/java/ui/window/JDialogELNComponentVoltageSourceTDF.java new file mode 100644 index 0000000000000000000000000000000000000000..0e86355231187fada793fe8fb03feec16843b86d --- /dev/null +++ b/src/main/java/ui/window/JDialogELNComponentVoltageSourceTDF.java @@ -0,0 +1,203 @@ +/* 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_tdf.ELNComponentVoltageSourceTDF; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.AbstractAction; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.KeyStroke; + +/** + * Class JDialogELNComponentVoltageSourceTDF + * Dialog for managing the ELN voltage driven by a TDF input signal + * Creation: 19/07/2018 + * @version 1.0 19/07/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogELNComponentVoltageSourceTDF extends JDialog implements ActionListener { + private JTextField nameTextField; + private JTextField valueTextField; + + private ELNComponentVoltageSourceTDF vsource; + + public JDialogELNComponentVoltageSourceTDF(ELNComponentVoltageSourceTDF _vsource) { + setTitle("Setting the voltage driven by a TDF 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_tdf_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(); + } + } +} \ No newline at end of file diff --git a/src/main/resources/ui/util/elnportterminal.gif b/src/main/resources/ui/util/elnportterminal.gif index 49aa980d135e12794880392ff6e055e6dabbadb1..cd4918e69c88c620c53e794faf778768493a2417 100644 Binary files a/src/main/resources/ui/util/elnportterminal.gif and b/src/main/resources/ui/util/elnportterminal.gif differ diff --git a/src/main/resources/ui/util/elntdfisource.gif b/src/main/resources/ui/util/elntdfisource.gif new file mode 100644 index 0000000000000000000000000000000000000000..a21f0ec320d9004845b7dce508cf43f15835dbae Binary files /dev/null and b/src/main/resources/ui/util/elntdfisource.gif differ diff --git a/src/main/resources/ui/util/elntdfvsource.gif b/src/main/resources/ui/util/elntdfvsource.gif new file mode 100644 index 0000000000000000000000000000000000000000..3d24958f33002f9c6e847c9e2064be07da2d2a0d Binary files /dev/null and b/src/main/resources/ui/util/elntdfvsource.gif differ