fjzt.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. ht.lib = ht.lib || {};
  2. if (!ht.lib['fjzt']) {
  3. ht.lib['fjzt'] = function (x, y, width, height, angle, localVarObj, localDynamicVar, nodename) {
  4. _ratio = GD.getRatioWithRotation(0, ratio);
  5. ht.lib['fjzt'].superClass.constructor.apply(this);
  6. this.localVarObj = localVarObj;
  7. this.localDynamicVar = localDynamicVar;
  8. this.childNodes = [];
  9. this._styleObject = {};
  10. this._originWidth = 29.74234*_ratio.ratioX;
  11. this._originHeight = 42.60391*_ratio.ratioY;
  12. this._baseClass = "ht.lib.fjzt";
  13. this._background = new ht.Node();
  14. this._background.setWidth(this._originWidth);
  15. this._background.setHeight(this._originHeight);
  16. this._background.setPosition(this._originWidth/2, this._originHeight/2);
  17. this._background.setImage({
  18. width: width,
  19. height: height,
  20. clip: true,
  21. comps: [
  22. {
  23. type: 'rect',
  24. background: 'rgba(0,255,0,0)',
  25. rect: [0,0,width, height]
  26. }
  27. ]
  28. });
  29. this._background.__parentLib = nodename;
  30. this._background.isLibBackground = true;
  31. this.childNodes.push(this._background);
  32. dataModel.add(this._background);
  33. /*@PageBackgroundInit@*/
  34. /*@PageBeforeInit@*/
  35. var Lib_fjztNode0;
  36. (function () {
  37. var _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  38. var ratioX, ratioY;
  39. if ('Default' === 'False') {
  40. ratioX = 1;
  41. ratioY = 1;
  42. } else if ('Default' === 'X') {
  43. ratioX = ratioY = _ratio.ratioX;
  44. } else if ('Default' === 'Y') {
  45. ratioX = ratioY = _ratio.ratioY;
  46. } else {
  47. ratioX = _ratio.ratioX;
  48. ratioY = _ratio.ratioY;
  49. }
  50. ht.Default.setImage('imgimage//page_zmt_fjx_green0.png', PAGEROOTDIR + 'image//page_zmt_fjx_green0.png');
  51. Lib_fjztNode0 = new ht.Node();
  52. Lib_fjztNode0.setPosition(15*ratio.ratioX, 20*ratio.ratioY);
  53. Lib_fjztNode0.setSize(28*ratioX, 41*ratioY);
  54. Lib_fjztNode0.setImage('imgimage//page_zmt_fjx_green0.png');
  55. Lib_fjztNode0.setRotation(0*Math.PI/180);
  56. Lib_fjztNode0._zoomBy = 'Default';
  57. Lib_fjztNode0._nodeType = 'image';
  58. Lib_fjztNode0._disallowEvert = true;
  59. dataModel.add(Lib_fjztNode0);
  60. })();
  61. var Lib_fjztNode1 = new ht.HtmlNode();
  62. _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  63. Lib_fjztNode1.setPosition(14*ratio.ratioX, 21*ratio.ratioY);
  64. Lib_fjztNode1.setSize(28*_ratio.ratioX, 41*_ratio.ratioY);
  65. Lib_fjztNode1.setHtml("<img style='width:"+28*_ratio.ratioX+"px;height: "+41*_ratio.ratioY+"px;' src='"+PAGEROOTDIR+"image/page_zmt_fjx_blue0.gif'/>");
  66. Lib_fjztNode1.setRotation(0*Math.PI/180);
  67. Lib_fjztNode1._nodeType = 'imageAnimate';
  68. Lib_fjztNode1._disallowEvert = true;
  69. dataModel.add(Lib_fjztNode1);var Lib_fjztNode2;
  70. (function () {
  71. var _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  72. var ratioX, ratioY;
  73. if ('Default' === 'False') {
  74. ratioX = 1;
  75. ratioY = 1;
  76. } else if ('Default' === 'X') {
  77. ratioX = ratioY = _ratio.ratioX;
  78. } else if ('Default' === 'Y') {
  79. ratioX = ratioY = _ratio.ratioY;
  80. } else {
  81. ratioX = _ratio.ratioX;
  82. ratioY = _ratio.ratioY;
  83. }
  84. ht.Default.setImage('imgimage//page_zmt_fjx_red0.png', PAGEROOTDIR + 'image//page_zmt_fjx_red0.png');
  85. Lib_fjztNode2 = new ht.Node();
  86. Lib_fjztNode2.setPosition(15*ratio.ratioX, 20*ratio.ratioY);
  87. Lib_fjztNode2.setSize(28*ratioX, 41*ratioY);
  88. Lib_fjztNode2.setImage('imgimage//page_zmt_fjx_red0.png');
  89. Lib_fjztNode2.setRotation(0*Math.PI/180);
  90. Lib_fjztNode2._zoomBy = 'Default';
  91. Lib_fjztNode2._nodeType = 'image';
  92. Lib_fjztNode2._disallowEvert = true;
  93. dataModel.add(Lib_fjztNode2);
  94. })();
  95. var Lib_fjztNode3;
  96. (function () {
  97. var _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  98. var ratioX, ratioY;
  99. if ('Default' === 'False') {
  100. ratioX = 1;
  101. ratioY = 1;
  102. } else if ('Default' === 'X') {
  103. ratioX = ratioY = _ratio.ratioX;
  104. } else if ('Default' === 'Y') {
  105. ratioX = ratioY = _ratio.ratioY;
  106. } else {
  107. ratioX = _ratio.ratioX;
  108. ratioY = _ratio.ratioY;
  109. }
  110. ht.Default.setImage('imgimage//page_zmt_fjx_pink0.png', PAGEROOTDIR + 'image//page_zmt_fjx_pink0.png');
  111. Lib_fjztNode3 = new ht.Node();
  112. Lib_fjztNode3.setPosition(15*ratio.ratioX, 20*ratio.ratioY);
  113. Lib_fjztNode3.setSize(28*ratioX, 41*ratioY);
  114. Lib_fjztNode3.setImage('imgimage//page_zmt_fjx_pink0.png');
  115. Lib_fjztNode3.setRotation(0*Math.PI/180);
  116. Lib_fjztNode3._zoomBy = 'Default';
  117. Lib_fjztNode3._nodeType = 'image';
  118. Lib_fjztNode3._disallowEvert = true;
  119. dataModel.add(Lib_fjztNode3);
  120. })();
  121. var Lib_fjztNode4;
  122. (function () {
  123. var _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  124. var ratioX, ratioY;
  125. if ('Default' === 'False') {
  126. ratioX = 1;
  127. ratioY = 1;
  128. } else if ('Default' === 'X') {
  129. ratioX = ratioY = _ratio.ratioX;
  130. } else if ('Default' === 'Y') {
  131. ratioX = ratioY = _ratio.ratioY;
  132. } else {
  133. ratioX = _ratio.ratioX;
  134. ratioY = _ratio.ratioY;
  135. }
  136. ht.Default.setImage('imgimage//page_zmt_fjx_gray0.png', PAGEROOTDIR + 'image//page_zmt_fjx_gray0.png');
  137. Lib_fjztNode4 = new ht.Node();
  138. Lib_fjztNode4.setPosition(15*ratio.ratioX, 20*ratio.ratioY);
  139. Lib_fjztNode4.setSize(28*ratioX, 41*ratioY);
  140. Lib_fjztNode4.setImage('imgimage//page_zmt_fjx_gray0.png');
  141. Lib_fjztNode4.setRotation(0*Math.PI/180);
  142. Lib_fjztNode4._zoomBy = 'Default';
  143. Lib_fjztNode4._nodeType = 'image';
  144. Lib_fjztNode4._disallowEvert = true;
  145. dataModel.add(Lib_fjztNode4);
  146. })();
  147. var Lib_fjztNode5;
  148. (function () {
  149. var _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  150. var ratioX, ratioY;
  151. if ('Default' === 'False') {
  152. ratioX = 1;
  153. ratioY = 1;
  154. } else if ('Default' === 'X') {
  155. ratioX = ratioY = _ratio.ratioX;
  156. } else if ('Default' === 'Y') {
  157. ratioX = ratioY = _ratio.ratioY;
  158. } else {
  159. ratioX = _ratio.ratioX;
  160. ratioY = _ratio.ratioY;
  161. }
  162. ht.Default.setImage('imgimage//page_zmt_fjx_orange0.png', PAGEROOTDIR + 'image//page_zmt_fjx_orange0.png');
  163. Lib_fjztNode5 = new ht.Node();
  164. Lib_fjztNode5.setPosition(14*ratio.ratioX, 20*ratio.ratioY);
  165. Lib_fjztNode5.setSize(28*ratioX, 41*ratioY);
  166. Lib_fjztNode5.setImage('imgimage//page_zmt_fjx_orange0.png');
  167. Lib_fjztNode5.setRotation(0*Math.PI/180);
  168. Lib_fjztNode5._zoomBy = 'Default';
  169. Lib_fjztNode5._nodeType = 'image';
  170. Lib_fjztNode5._disallowEvert = true;
  171. dataModel.add(Lib_fjztNode5);
  172. })();
  173. _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  174. var Lib_fjztNode6type = 'rect';
  175. var Lib_fjztNode6 = new ht.Node(),
  176. Lib_fjztNode6BorderWidth = 0*2;
  177. if (Lib_fjztNode6type === 'arc') {
  178. Lib_fjztNode6BorderWidth *= 0;
  179. }
  180. Lib_fjztNode6.setImage(GD.getRectJSON(25*_ratio.ratioX, 40*_ratio.ratioY, Lib_fjztNode6type, '@arcFrom@', '@arcTo@', '@arcClose@'));
  181. Lib_fjztNode6.setPosition(12*ratio.ratioX, 20*ratio.ratioY);
  182. Lib_fjztNode6.setSize(25*_ratio.ratioX, 40*_ratio.ratioY);
  183. Lib_fjztNode6.s({
  184. 'pixelPerfect':true
  185. /*@AddPara@*/
  186. });
  187. Lib_fjztNode6.a('node.width', 25*_ratio.ratioX);
  188. Lib_fjztNode6.a('node.height', 40*_ratio.ratioY);
  189. Lib_fjztNode6.a('node.type', Lib_fjztNode6type);
  190. Lib_fjztNode6.a('node.rect', [0, 0, 25*_ratio.ratioX, 40*_ratio.ratioY]);
  191. Lib_fjztNode6.a('node.background', 'rgba(255,255,255,0.003921569)');
  192. Lib_fjztNode6.a('node.gradientcolor', '');
  193. Lib_fjztNode6.a('node.gradient', '');
  194. Lib_fjztNode6.a('node.borderwidth', Lib_fjztNode6BorderWidth);
  195. Lib_fjztNode6.a('node.color', 'rgba(0,0,0,0)');
  196. Lib_fjztNode6.a('node.fillrect', [0,0,0,0]);
  197. Lib_fjztNode6.a('node.fillbackcolor', 'rgba(0,0,0,0)');
  198. Lib_fjztNode6.a('node.fillgradientcolor', 'rgba(0,0,0,0)');
  199. Lib_fjztNode6.a('node.fillgradient', '');
  200. if (Lib_fjztNode6type !== 'rect') {
  201. Lib_fjztNode6.a('node.arcFrom', parseFloat('@arcFrom@'));
  202. Lib_fjztNode6.a('node.arcTo', parseFloat('@arcTo@'));
  203. Lib_fjztNode6.a('node.arcClose', '@arcClose@' === 'true' ? true : false);
  204. }
  205. if (Lib_fjztNode6type === 'arc') {
  206. Lib_fjztNode6.a('node.arcOval', true);
  207. }
  208. Lib_fjztNode6.setRotation(0*Math.PI/180);
  209. Lib_fjztNode6.borderWidth = Lib_fjztNode6BorderWidth;
  210. Lib_fjztNode6.borderFillwidth = Lib_fjztNode6BorderWidth;
  211. dataModel.add(Lib_fjztNode6);
  212. Lib_fjztNode6._nodename = 'Lib_fjztNode6'
  213. Lib_fjztNode6._nodeType = 'rect';
  214. zoomNodeList.push({
  215. node: Lib_fjztNode6,
  216. attr: 'node.borderwidth'
  217. });
  218. (function (node, _img) {
  219. var setWidth = node.setWidth,
  220. setHeight = node.setHeight;
  221. node.setWidth = function (width) {
  222. if (width === this.getWidth()) return ;
  223. var height = this.getHeight();
  224. this.a('node.width', width);
  225. this.a('node.rect', [0,0,width, height]);
  226. setWidth.apply(this, arguments);
  227. }
  228. node.setHeight = function (height) {
  229. if (height === this.getHeight()) return ;
  230. var width = this.getWidth();
  231. this.a('node.height', height);
  232. this.a('node.rect', [0,0,width, height]);
  233. setHeight.apply(this, arguments);
  234. }
  235. })(Lib_fjztNode6, Lib_fjztNode6.getImage());
  236. /*@GraphList@*/
  237. if(typeof(Lib_fjztNode6.borderWidth)!="undefined"){setDashStyle(Lib_fjztNode6,"Lib_fjztNode6",'NoDash',Lib_fjztNode6.borderWidth);}
  238. /*@PageInit@*/
  239. var localVarObj = this.localVarObj;
  240. var localDynamicVarObj = this.localDynamicVar();
  241. var FJZT= localVarObj.FJZT || localDynamicVarObj.FJZT;
  242. this['Lib_fjztNode0'] = Lib_fjztNode0;
  243. Lib_fjztNode0.__parentLib = nodename;
  244. Lib_fjztNode0.__parent = this;
  245. this.childNodes.push(Lib_fjztNode0);
  246. this['Lib_fjztNode1'] = Lib_fjztNode1;
  247. Lib_fjztNode1.__parentLib = nodename;
  248. Lib_fjztNode1.__parent = this;
  249. this.childNodes.push(Lib_fjztNode1);
  250. this['Lib_fjztNode2'] = Lib_fjztNode2;
  251. Lib_fjztNode2.__parentLib = nodename;
  252. Lib_fjztNode2.__parent = this;
  253. this.childNodes.push(Lib_fjztNode2);
  254. this['Lib_fjztNode3'] = Lib_fjztNode3;
  255. Lib_fjztNode3.__parentLib = nodename;
  256. Lib_fjztNode3.__parent = this;
  257. this.childNodes.push(Lib_fjztNode3);
  258. this['Lib_fjztNode4'] = Lib_fjztNode4;
  259. Lib_fjztNode4.__parentLib = nodename;
  260. Lib_fjztNode4.__parent = this;
  261. this.childNodes.push(Lib_fjztNode4);
  262. this['Lib_fjztNode5'] = Lib_fjztNode5;
  263. Lib_fjztNode5.__parentLib = nodename;
  264. Lib_fjztNode5.__parent = this;
  265. this.childNodes.push(Lib_fjztNode5);
  266. this['Lib_fjztNode6'] = Lib_fjztNode6;
  267. Lib_fjztNode6.__parentLib = nodename;
  268. Lib_fjztNode6.__parent = this;
  269. this.childNodes.push(Lib_fjztNode6);
  270. /*@ControlContextMenu@*/
  271. /*@Declare@*/
  272. this.init(x, y, width, height, angle);
  273. };
  274. ht.Default.def('ht.lib.fjzt', Object, {
  275. refresh10ms: function () {
  276. var localVarObj = this.localVarObj;
  277. var localDynamicVarObj = this.localDynamicVar();
  278. var FJZT= localVarObj.FJZT || localDynamicVarObj.FJZT;
  279. var Lib_fjztNode0= this.Lib_fjztNode0;
  280. var Lib_fjztNode1= this.Lib_fjztNode1;
  281. var Lib_fjztNode2= this.Lib_fjztNode2;
  282. var Lib_fjztNode3= this.Lib_fjztNode3;
  283. var Lib_fjztNode4= this.Lib_fjztNode4;
  284. var Lib_fjztNode5= this.Lib_fjztNode5;
  285. var Lib_fjztNode6= this.Lib_fjztNode6;
  286. /*@refresh10ms@*/
  287. },
  288. refresh100ms: function () {
  289. var localVarObj = this.localVarObj;
  290. var localDynamicVarObj = this.localDynamicVar();
  291. var FJZT= localVarObj.FJZT || localDynamicVarObj.FJZT;
  292. var Lib_fjztNode0= this.Lib_fjztNode0;
  293. var Lib_fjztNode1= this.Lib_fjztNode1;
  294. var Lib_fjztNode2= this.Lib_fjztNode2;
  295. var Lib_fjztNode3= this.Lib_fjztNode3;
  296. var Lib_fjztNode4= this.Lib_fjztNode4;
  297. var Lib_fjztNode5= this.Lib_fjztNode5;
  298. var Lib_fjztNode6= this.Lib_fjztNode6;
  299. /*@refresh100ms@*/
  300. },
  301. refresh500ms: function () {
  302. var localVarObj = this.localVarObj;
  303. var localDynamicVarObj = this.localDynamicVar();
  304. var FJZT= localVarObj.FJZT || localDynamicVarObj.FJZT;
  305. var Lib_fjztNode0= this.Lib_fjztNode0;
  306. var Lib_fjztNode1= this.Lib_fjztNode1;
  307. var Lib_fjztNode2= this.Lib_fjztNode2;
  308. var Lib_fjztNode3= this.Lib_fjztNode3;
  309. var Lib_fjztNode4= this.Lib_fjztNode4;
  310. var Lib_fjztNode5= this.Lib_fjztNode5;
  311. var Lib_fjztNode6= this.Lib_fjztNode6;
  312. if((1 )>0) {if(((getVarValue(FJZT)==0)>0 )){Lib_fjztNode0.s('2d.visible',true&&this.getStyle('2d.visible'));}else{Lib_fjztNode0.s('2d.visible',false&&this.getStyle('2d.visible'));}}
  313. if((1 )>0) {if(((getVarValue(FJZT)==1)>0 )){Lib_fjztNode1.s('2d.visible',true&&this.getStyle('2d.visible'));}else{Lib_fjztNode1.s('2d.visible',false&&this.getStyle('2d.visible'));}}
  314. if((1 )>0) {if(((getVarValue(FJZT)==2)>0 )){Lib_fjztNode2.s('2d.visible',true&&this.getStyle('2d.visible'));}else{Lib_fjztNode2.s('2d.visible',false&&this.getStyle('2d.visible'));}}
  315. if((1 )>0) {if(((getVarValue(FJZT)==5||getVarValue(FJZT)==6)>0 )){Lib_fjztNode3.s('2d.visible',true&&this.getStyle('2d.visible'));}else{Lib_fjztNode3.s('2d.visible',false&&this.getStyle('2d.visible'));}}
  316. if((1 )>0) {if(((getVarValue(FJZT)==3)>0 )){Lib_fjztNode4.s('2d.visible',true&&this.getStyle('2d.visible'));}else{Lib_fjztNode4.s('2d.visible',false&&this.getStyle('2d.visible'));}}
  317. if((1 )>0) {if(((getVarValue(FJZT)==4)>0 )){Lib_fjztNode5.s('2d.visible',true&&this.getStyle('2d.visible'));}else{Lib_fjztNode5.s('2d.visible',false&&this.getStyle('2d.visible'));}}
  318. /*@refresh500ms@*/
  319. },
  320. refresh1s: function () {
  321. var Counter1s = arguments[0] || 0;
  322. var localVarObj = this.localVarObj;
  323. var localDynamicVarObj = this.localDynamicVar();
  324. var FJZT= localVarObj.FJZT || localDynamicVarObj.FJZT;
  325. var Lib_fjztNode0= this.Lib_fjztNode0;
  326. var Lib_fjztNode1= this.Lib_fjztNode1;
  327. var Lib_fjztNode2= this.Lib_fjztNode2;
  328. var Lib_fjztNode3= this.Lib_fjztNode3;
  329. var Lib_fjztNode4= this.Lib_fjztNode4;
  330. var Lib_fjztNode5= this.Lib_fjztNode5;
  331. var Lib_fjztNode6= this.Lib_fjztNode6;
  332. /*@refresh1s@*/
  333. },
  334. refresh5s: function () {
  335. var localVarObj = this.localVarObj;
  336. var localDynamicVarObj = this.localDynamicVar();
  337. var FJZT= localVarObj.FJZT || localDynamicVarObj.FJZT;
  338. var Lib_fjztNode0= this.Lib_fjztNode0;
  339. var Lib_fjztNode1= this.Lib_fjztNode1;
  340. var Lib_fjztNode2= this.Lib_fjztNode2;
  341. var Lib_fjztNode3= this.Lib_fjztNode3;
  342. var Lib_fjztNode4= this.Lib_fjztNode4;
  343. var Lib_fjztNode5= this.Lib_fjztNode5;
  344. var Lib_fjztNode6= this.Lib_fjztNode6;
  345. /*@refresh5s@*/
  346. },
  347. /*@PageDynamic@*/
  348. onEvent: function (e, data, type, origin, offset, objMouseOn, ctm) {
  349. var localVarObj = this.localVarObj;
  350. var localDynamicVarObj = this.localDynamicVar();
  351. var FJZT= localVarObj.FJZT || localDynamicVarObj.FJZT;
  352. var Lib_fjztNode0= this.Lib_fjztNode0;
  353. var Lib_fjztNode1= this.Lib_fjztNode1;
  354. var Lib_fjztNode2= this.Lib_fjztNode2;
  355. var Lib_fjztNode3= this.Lib_fjztNode3;
  356. var Lib_fjztNode4= this.Lib_fjztNode4;
  357. var Lib_fjztNode5= this.Lib_fjztNode5;
  358. var Lib_fjztNode6= this.Lib_fjztNode6;
  359. if (type === 'click') {
  360. /*@EvnentClicked@*/
  361. } else if (type === 'mousedown') {
  362. mouseX=e.clientX;
  363. mouseY=e.clientY;
  364. /*@EvnentMouseDown@*/
  365. } else if (type === 'mouseup') {
  366. /*@EvnentMouseUp@*/
  367. } else if (type === 'mousemove') {
  368. var mouseX, mouseY, position, zoom;
  369. position=origin.getLogicalPoint(e);
  370. zoom = graphView.getZoom();
  371. if (origin === graphView) {
  372. mouseX= position.x + origin.tx();
  373. mouseY = position.y + origin.ty();
  374. } else {
  375. offset = offset || {x: 0, y: 0};
  376. mouseX = position.x / zoom + offset.x + origin.tx();
  377. mouseY = position.y / zoom + offset.y + origin.ty();
  378. }
  379. /*@EvnentMouseLeave@*/
  380. /*@EvnentMouseOver@*/
  381. } else if (type === 'keydown') {
  382. /*@EvnentKeyDown@*/
  383. } else if (type === 'contextmenu') {
  384. /*@Declare@*/
  385. /*@SetNodeContextMenu@*/
  386. /*@SetPageContextMenu@*/
  387. }
  388. /*@LibEvent@*/
  389. },
  390. getBaseClass: function () {
  391. return this._baseClass;
  392. },
  393. getWidth: function () {
  394. return this._width;
  395. },
  396. getHeight: function () {
  397. return this._height;
  398. },
  399. getSize: function () {
  400. return {
  401. width: this._width,
  402. height: this._height
  403. }
  404. },
  405. setWidth: function (width) {
  406. if (width === undefined || width === null || width != width) {
  407. return ;
  408. }
  409. var originWidth = this._width;
  410. var ratio = width / originWidth;
  411. var childNodes = this.childNodes, childNode, p, op = this.getPosition(), w, cw, ox, rotation = this.getRotation();
  412. for (var i = 0, len = childNodes.length; i < len; i++) {
  413. childNode = childNodes[i];
  414. p = childNode.getPosition();
  415. cw = childNode.getWidth();
  416. w = cw >=2 ? cw * ratio : cw;
  417. childNode.setWidth(w);
  418. ox = op.x + (p.x - op.x) * ratio;
  419. childNode.setPosition(ox, p.y);
  420. rotation = GD.calcRotation(rotation);
  421. if (rotation === 0 || rotation === Math.PI) {
  422. // 图元未旋转
  423. ox = op.x + (p.x - op.x)*ratio;
  424. childNode.setPosition(ox, p.y);
  425. } else if (rotation === 90 * Math.PI / 180) {
  426. // 图元旋转以后
  427. ox = op.y + (p.y - op.y)*ratio;
  428. childNode.setPosition(p.x, ox);
  429. }
  430. }
  431. this._width = width;
  432. this._originWidth = width;
  433. this._ratioX = ratio;
  434. return this;
  435. },
  436. setHeight: function (height) {
  437. if (height === undefined || height === null || height != height) {
  438. return ;
  439. }
  440. var originHeight = this._height;
  441. var ratio = height / originHeight;
  442. var childNodes = this.childNodes, childNode, p, op = this.getPosition(), h, ch, oy, rotation = this.getRotation();
  443. for (var i = 0, len = childNodes.length; i < len; i++) {
  444. childNode = childNodes[i];
  445. p = childNode.getPosition();
  446. ch = childNode.getHeight();
  447. h = ch >=2 ? ch * ratio : ch;
  448. childNode.setHeight(h);
  449. rotation = GD.calcRotation(rotation);
  450. if (rotation === 0 || rotation === Math.PI) {
  451. // 图元未旋转
  452. oy = op.y + (p.y - op.y)*ratio;
  453. childNode.setPosition(p.x, oy);
  454. } else if (rotation === 90 * Math.PI / 180) {
  455. // 图元旋转以后
  456. oy = op.x + (p.x - op.x)*ratio;
  457. childNode.setPosition(oy, p.y);
  458. }
  459. }
  460. this._height = height;
  461. this._originHeight = height;
  462. this._ratioY = ratio;
  463. return this;
  464. },
  465. setSize: function (size) {
  466. // var args = Array.prototype.slice.call(arguments, 0);
  467. // var height, width;
  468. // if (args.length === 0) {
  469. // return ;
  470. // }else if (args.length === 1) {
  471. // height = args[0].height;
  472. // width = args[0].width;
  473. // } else {
  474. // width = args[0];
  475. // height = args[1];
  476. // }
  477. // var wh = GD.getRatioWithRotation(angle, wid)
  478. // this.setHeight(height);
  479. // this.setWidth(width);
  480. // return this;
  481. var args = Array.prototype.slice.call(arguments, 0);
  482. var height, width;
  483. if (args.length === 0) {
  484. return ;
  485. }else if (args.length === 1) {
  486. height = args[0].height;
  487. width = args[0].width;
  488. angle = 0;
  489. } else if (args.length === 2) {
  490. if (typeof args[0] === 'object') {
  491. width = args[0].width;
  492. height = args[0].height;
  493. angle = args[1] || 0;
  494. } else {
  495. width = args[0];
  496. height = args[1];
  497. angle = 0;
  498. }
  499. } else if (args.length === 3) {
  500. width = args[0];
  501. height = args[1];
  502. angle = args[2] || 0;
  503. }
  504. var wh = GD.getRatioWithRotation(0, width, height);
  505. this.setHeight(wh.ratioY);
  506. this.setWidth(wh.ratioX);
  507. return this;
  508. },
  509. getPosition: function () {
  510. return {
  511. x: this._x,
  512. y: this._y
  513. }
  514. },
  515. setPosition: function () {
  516. var args = Array.prototype.slice.call(arguments, 0), x, y;
  517. if (args.length === 0) {
  518. return this;
  519. } else if (args.length === 1) {
  520. if (typeof args[0] != 'object') {
  521. return this;
  522. }
  523. x = args[0].x;
  524. y = args[0].y;
  525. } else {
  526. x = args[0];
  527. y = args[1];
  528. }
  529. if ((x !== 0 && !x) || (y !== 0 && !y)) {
  530. return this;
  531. }
  532. // var childNodes = this.childNodes, offset, childNode, p;
  533. // for (var i = 0, len = childNodes.length; i < len; i++) {
  534. // childNode = childNodes[i];
  535. // p = childNode.getPosition();
  536. // childNode.setPosition(x - (this._x-p.x)*this._ratioX, y - (this._y-p.y)*this._ratioY);
  537. // }
  538. // this._x = x;
  539. // this._y = y;
  540. // return this;
  541. var childNodes, childNode, background, offset = {}, op, cp;
  542. childNodes = this.childNodes;
  543. background = this._background;
  544. op = background.getPosition();
  545. offset.x = x - op.x;
  546. offset.y = y - op.y;
  547. for (var i = 0, len = childNodes.length; i < len; i++) {
  548. childNode = childNodes[i];
  549. cp = childNode.getPosition();
  550. childNode.setPosition(cp.x + offset.x, cp.y + offset.y);
  551. }
  552. this._x = x;
  553. this._y = y;
  554. this._position = {x: x, y: y};
  555. return this;
  556. },
  557. getStyle: function (key) {
  558. if (!key) {
  559. return undefined;
  560. }
  561. return this._styleObject[key];
  562. },
  563. setStyle: function (key, value, force) {
  564. var childNodes = this.childNodes, childNode;
  565. for (var i = 0, len = childNodes.length; i < len; i++) {
  566. childNode = childNodes[i];
  567. if (key === '2d.visible') {
  568. if (value === graphView.isVisible(childNode)) {
  569. continue;
  570. }
  571. if (!value) {
  572. childNode._savedIsVisible = graphView.isVisible(childNode);
  573. childNode.s({
  574. '2d.visible': false
  575. })
  576. } else {
  577. childNode.s({
  578. '2d.visible': childNode._savedIsVisible
  579. })
  580. }
  581. continue;
  582. }
  583. childNode.s({
  584. key: value
  585. });
  586. }
  587. this._styleObject[key] = value;
  588. return this;
  589. },
  590. calcSize: function () {
  591. var background = this._background;
  592. var position = background.getPosition(),
  593. width = background.getWidth(),
  594. height = background.getHeight();
  595. this._width = width;
  596. this._height = height;
  597. this._x = position.x;
  598. this._y = position.y;
  599. this._position = {
  600. x: this._x,
  601. y: this._y
  602. }
  603. return this;
  604. return this;
  605. },
  606. s: function (styleObj, force) {
  607. var args = Array.prototype.slice.call(arguments, 0);
  608. var styleObj;
  609. if (args.length === 0) {
  610. return this;
  611. } else if (args.length === 1) {
  612. styleObj = args[0];
  613. } else {
  614. this.setStyle(args[0], args[1]);
  615. return this;
  616. }
  617. for (var key in styleObj) {
  618. if (!styleObj.hasOwnProperty(key)) {
  619. continue;
  620. }
  621. this.setStyle(key, styleObj[key], force);
  622. }
  623. return this;
  624. },
  625. init: function (x, y, width, height, angle) {
  626. var that = this;
  627. this.calcSize();
  628. (function (width, height, angle) {
  629. // that.setSize(width, height, angle);
  630. // var wh = GD.getRatioWithRotation(angle, width, height);
  631. // width = wh.ratioX;
  632. // height = wh.ratioY;
  633. var originHeight = that._height;
  634. var originWidth = that._width;
  635. var ratioY = height / originHeight;
  636. var ratioX = width / originWidth;
  637. var childNodes = that.childNodes,
  638. childNode,p, op = that.getPosition(), h, ch, oy, w, cw, ox, name, borderRatio, borderWidth;
  639. for (var i = 0, len = childNodes.length; i < len; i++) {
  640. childNode = childNodes[i];
  641. p = childNode.getPosition();
  642. childNode.originHeight = childNode.originHeight || childNode.getHeight();
  643. ch = childNode.getHeight();
  644. cw = childNode.getWidth();
  645. if (ch > 2) {
  646. h = ch * ratioY;
  647. childNode.setHeight(h);
  648. }
  649. if (cw > 2) {
  650. w = cw * ratioX;
  651. childNode.setWidth(w);
  652. }
  653. borderRatio = (ratioX + ratioY)*0.5;
  654. if (childNode._nodeType === 'line') { // 如果是线,
  655. if (childNode.getWidth() > childNode.getHeight()) {
  656. borderRatio = ratioX;
  657. } else {
  658. borderRatio = ratioY;
  659. }
  660. }
  661. name = childNode._nodename;
  662. // if (childNode.borderWidth && name && ch > 2 && cw > 2) {
  663. // borderWidth = childNode.borderWidth / borderRatio;
  664. // if (borderWidth > ch*0.5 || borderWidth > cw *0.5) {
  665. // // borderWidth = childNode.borderWidth;
  666. // }
  667. // childNode.borderWidth = borderWidth;
  668. // childNode.a(name + '.borderwidth', borderWidth);
  669. // }
  670. }
  671. that._height = height;
  672. that._originHeight = height;
  673. that._ratioY = ratioY;
  674. that._width = width;
  675. that._originWidth = width;
  676. that._ratioX = ratioX;
  677. })(width, height, angle);
  678. that._x = width / 2;
  679. that._y = height / 2;
  680. that._rotation = 0;
  681. // that.setPosition(x, y);
  682. (function (x, y) {
  683. var childNodes = that.childNodes, offset, childNode;
  684. var w2 = that.getWidth() / 2, h2 = that.getHeight()/2;
  685. for (var i = 0, len = childNodes.length; i < len; i++) {
  686. childNode = childNodes[i];
  687. offset = childNode.getPosition();
  688. childNode.setPosition(x + offset.x * that._ratioX - w2, y + offset.y * that._ratioY - h2);
  689. }
  690. that._x = x;
  691. that._y = y;
  692. })(x, y);
  693. // setTimeout(that.addEVent, 1000);
  694. },
  695. setRotation: function (angle) {
  696. var that = this, _angle = that.getRotation();
  697. if (angle!==0 && !angle || angle === _angle) {
  698. return this;
  699. }
  700. var childNodes = this.childNodes, childNode, p = this.getPosition(), px = p.x, py = p.y;
  701. for (var i = 0, len = childNodes.length; i < len; i++) {
  702. childNode = childNodes[i];
  703. var x = childNode.getPosition().x - px;
  704. var y = childNode.getPosition().y - py;
  705. childNode.setPosition(Math.cos(angle-_angle) * x - Math.sin(angle-_angle) * y + px, Math.cos(angle-_angle) * y + Math.sin(angle-_angle) * x + py);
  706. childNode.setRotation(angle);
  707. }
  708. this._rotation = angle;
  709. return this;
  710. },
  711. getRotation: function () {
  712. return this._rotation;
  713. },
  714. setScale: function (sx, sy) {
  715. var that = this,
  716. childNodes = this.childNodes,
  717. childNode;
  718. if (sx === undefined || sx === null) return ;
  719. if (sy === undefined || sy === null) {
  720. sy = sx;
  721. }
  722. for (var i = 0, len = childNodes.length; i < len; i++) {
  723. childNode = childNodes[i];
  724. if (typeof childNode.setScale === 'function') {
  725. childNode.setScale(sx, sy);
  726. }
  727. }
  728. },
  729. getScale: function () {
  730. return this._background.getScale();
  731. },
  732. setScaleX: function (sx) {
  733. if (sx === undefined || sx === null) return;
  734. var that = this,
  735. childNodes = this.childNodes,
  736. childNode;
  737. for (var i = 0, len = childNodes.length; i < len; i++) {
  738. childNode = childNodes[i];
  739. if (typeof childNode.setScaleX === 'function') {
  740. childNode.setScaleX(sx);
  741. }
  742. }
  743. },
  744. setScaleY: function (sy) {
  745. if (sy === undefined || sy === null) return;
  746. var that = this,
  747. childNodes = this.childNodes,
  748. childNode;
  749. for (var i = 0, len = childNodes.length; i < len; i++) {
  750. childNode = childNodes[i];
  751. if (typeof childNode.setScaleY === 'function') {
  752. childNode.setScaleY(sy);
  753. }
  754. }
  755. },
  756. getScaleX: function () {
  757. return this._background.getScaleX();
  758. },
  759. getScaleY: function () {
  760. return this._background.getScaleY();
  761. },
  762. evert: function () {
  763. var that = this,
  764. childNodes = this.childNodes,
  765. background = this._background,
  766. bp = background.getPosition(),
  767. bx = bp.x,
  768. by = bp.y,
  769. childNode, distanceX, distanceY, x, y, p, nx, ny;
  770. for (var i = 0, len = childNodes.length; i < len; i++) {
  771. childNode = childNodes[i];
  772. p = childNode.getPosition();
  773. x = p.x;
  774. y = p.y;
  775. distanceX = bx - x;
  776. distanceY = by - y;
  777. nx = bx + distanceX;
  778. ny = by + distanceY;
  779. childNode.setPosition(nx, ny);
  780. if (typeof childNode.setScale === 'function') {
  781. if (!(childNode._disallowEvert === true))
  782. childNode.setScale(-1, -1);
  783. }
  784. }
  785. },
  786. evertX: function () {
  787. var that = this,
  788. childNodes = this.childNodes,
  789. background = this._background,
  790. bx = background.getPosition().x,
  791. childNode, distance, x, p, nx;
  792. for (var i = 0, len = childNodes.length; i < len; i++) {
  793. childNode = childNodes[i];
  794. p = childNode.getPosition();
  795. x = p.x;
  796. distance = bx - x;
  797. nx = bx + distance;
  798. childNode.setPosition(nx, p.y);
  799. if (typeof childNode.setScaleX === 'function') {
  800. if (!(childNode._disallowEvert === true))
  801. childNode.setScaleX(-1);
  802. }
  803. }
  804. },
  805. evertY: function () {
  806. var that = this,
  807. childNodes = this.childNodes,
  808. background = this._background,
  809. by = background.getPosition().y,
  810. childNode, distance, y, p, ny;
  811. for (var i = 0, len = childNodes.length; i < len; i++) {
  812. childNode = childNodes[i];
  813. p = childNode.getPosition();
  814. y = p.y;
  815. distance = by - y;
  816. ny = by + distance;
  817. childNode.setPosition(p.x, ny);
  818. if (typeof childNode.setScaleY === 'function') {
  819. if (!(childNode._disallowEvert === true))
  820. childNode.setScaleY(-1);
  821. }
  822. }
  823. },
  824. attr: function (key, value) {
  825. var _attrObj = this._attrObj || {};
  826. if (arguments.length === 1) {
  827. return _attrObj[key];
  828. }
  829. var childNodes = this.childNodes, childNode;
  830. _attrObj[key] = value;
  831. for (var i = 0; childNode = childNodes[i++];) {
  832. if (typeof childNode.a === 'function') {
  833. childNode.a(key, value);
  834. }
  835. }
  836. },
  837. a: function () {
  838. return this.attr.apply(this, arguments);
  839. }
  840. });
  841. }