黄双园.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. ht.lib = ht.lib || {};
  2. if (!ht.lib['黄双园']) {
  3. ht.lib['黄双园'] = function (x, y, width, height, angle, localVarObj, localDynamicVar, nodename) {
  4. _ratio = GD.getRatioWithRotation(0, ratio);
  5. ht.lib['黄双园'].superClass.constructor.apply(this);
  6. this.localVarObj = localVarObj;
  7. this.localDynamicVar = localDynamicVar;
  8. this.childNodes = [];
  9. this._styleObject = {};
  10. this._originWidth = 29.84125*_ratio.ratioX;
  11. this._originHeight = 49*_ratio.ratioY;
  12. this._baseClass = "ht.lib.黄双园";
  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. _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  36. var Lib_黄双园Node0type = 'oval';
  37. var Lib_黄双园Node0 = new ht.Node(),
  38. Lib_黄双园Node0BorderWidth = 2*2;
  39. if (Lib_黄双园Node0type === 'arc') {
  40. Lib_黄双园Node0BorderWidth *= 2;
  41. }
  42. Lib_黄双园Node0.setImage(GD.getRectJSON(29.84125*_ratio.ratioX, 26.18182*_ratio.ratioY, Lib_黄双园Node0type, '@arcFrom@', '@arcTo@', '@arcClose@'));
  43. Lib_黄双园Node0.setPosition(14*ratio.ratioX, 13*ratio.ratioY);
  44. Lib_黄双园Node0.setSize(29.84125*_ratio.ratioX, 26.18182*_ratio.ratioY);
  45. Lib_黄双园Node0.s({
  46. 'pixelPerfect':true
  47. /*@AddPara@*/
  48. });
  49. Lib_黄双园Node0.a('node.width', 29.84125*_ratio.ratioX);
  50. Lib_黄双园Node0.a('node.height', 26.18182*_ratio.ratioY);
  51. Lib_黄双园Node0.a('node.type', Lib_黄双园Node0type);
  52. Lib_黄双园Node0.a('node.rect', [0, 0, 29.84125*_ratio.ratioX, 26.18182*_ratio.ratioY]);
  53. Lib_黄双园Node0.a('node.background', 'rgba(255,255,255,0.003921569)');
  54. Lib_黄双园Node0.a('node.gradientcolor', '');
  55. Lib_黄双园Node0.a('node.gradient', '');
  56. Lib_黄双园Node0.a('node.borderwidth', Lib_黄双园Node0BorderWidth);
  57. Lib_黄双园Node0.a('node.color', 'rgba(255,128,0,1)');
  58. Lib_黄双园Node0.a('node.fillrect', [0,0,0,0]);
  59. Lib_黄双园Node0.a('node.fillbackcolor', 'rgba(0,0,0,0)');
  60. Lib_黄双园Node0.a('node.fillgradientcolor', 'rgba(0,0,0,0)');
  61. Lib_黄双园Node0.a('node.fillgradient', '');
  62. if (Lib_黄双园Node0type !== 'rect') {
  63. Lib_黄双园Node0.a('node.arcFrom', parseFloat('@arcFrom@'));
  64. Lib_黄双园Node0.a('node.arcTo', parseFloat('@arcTo@'));
  65. Lib_黄双园Node0.a('node.arcClose', '@arcClose@' === 'true' ? true : false);
  66. }
  67. if (Lib_黄双园Node0type === 'arc') {
  68. Lib_黄双园Node0.a('node.arcOval', true);
  69. }
  70. Lib_黄双园Node0.setRotation(0*Math.PI/180);
  71. Lib_黄双园Node0.borderWidth = Lib_黄双园Node0BorderWidth;
  72. Lib_黄双园Node0.borderFillwidth = Lib_黄双园Node0BorderWidth;
  73. dataModel.add(Lib_黄双园Node0);
  74. Lib_黄双园Node0._nodename = 'Lib_黄双园Node0'
  75. Lib_黄双园Node0._nodeType = 'rect';
  76. zoomNodeList.push({
  77. node: Lib_黄双园Node0,
  78. attr: 'node.borderwidth'
  79. });
  80. (function (node, _img) {
  81. var setWidth = node.setWidth,
  82. setHeight = node.setHeight;
  83. node.setWidth = function (width) {
  84. if (width === this.getWidth()) return ;
  85. var height = this.getHeight();
  86. this.a('node.width', width);
  87. this.a('node.rect', [0,0,width, height]);
  88. setWidth.apply(this, arguments);
  89. }
  90. node.setHeight = function (height) {
  91. if (height === this.getHeight()) return ;
  92. var width = this.getWidth();
  93. this.a('node.height', height);
  94. this.a('node.rect', [0,0,width, height]);
  95. setHeight.apply(this, arguments);
  96. }
  97. })(Lib_黄双园Node0, Lib_黄双园Node0.getImage());var Lib_黄双园Node1points=[15, 5,15, 13],
  98. Lib_黄双园Node1rect=ht.Default.unionPoint([{x:15,y:5},{x:15,y:13}]),
  99. Lib_黄双园Node1compspts=[];
  100. _ratio = GD.getRatioWithRotation(0, ratio);
  101. var _startratio = GD.getRatioWithRotation(4.71238898038469, ratio),
  102. _endratio = GD.getRatioWithRotation(7.85398163397448, ratio);
  103. for(var i=0;i<Lib_黄双园Node1points.length;i++){
  104. if(i%2==0){
  105. Lib_黄双园Node1compspts.push(Lib_黄双园Node1points[i]-Lib_黄双园Node1rect.x);
  106. }else{
  107. Lib_黄双园Node1compspts.push(Lib_黄双园Node1points[i]-Lib_黄双园Node1rect.y);
  108. }
  109. }
  110. var Lib_黄双园Node1ptslength=Lib_黄双园Node1compspts.length;
  111. if (Lib_黄双园Node1rect.height === 0) {
  112. Lib_黄双园Node1compspts[0] -= 0;
  113. Lib_黄双园Node1compspts[Lib_黄双园Node1ptslength-2] += 0;
  114. } else if (Lib_黄双园Node1rect.width === 0){
  115. Lib_黄双园Node1compspts[1] -= 0;
  116. Lib_黄双园Node1compspts[Lib_黄双园Node1ptslength-1] += 0;
  117. } else {
  118. Lib_黄双园Node1compspts[0] -= 0;
  119. Lib_黄双园Node1compspts[1] -= 0;
  120. Lib_黄双园Node1compspts[Lib_黄双园Node1ptslength-2] += 0;
  121. Lib_黄双园Node1compspts[Lib_黄双园Node1ptslength-1] += 0;
  122. }
  123. Lib_黄双园Node1 = new ht.Node();
  124. Lib_黄双园Node1.borderWidth = 2;
  125. Lib_黄双园Node1rect.width = Lib_黄双园Node1rect.width === 0 ? 0.0001 : Lib_黄双园Node1rect.width;
  126. Lib_黄双园Node1rect.height = Lib_黄双园Node1rect.height === 0 ? 0.0001 : Lib_黄双园Node1rect.height;
  127. var Lib_黄双园Node1endCompspts = [Lib_黄双园Node1compspts[Lib_黄双园Node1ptslength-2],Lib_黄双园Node1compspts[Lib_黄双园Node1ptslength-1],0,0];
  128. var Lib_黄双园Node1startCompspts = [Lib_黄双园Node1compspts[0],Lib_黄双园Node1compspts[1],0,0];
  129. Lib_黄双园Node1.setImage(GD.getPolyLineJSON());
  130. Lib_黄双园Node1.setPosition(Lib_黄双园Node1rect.x+Lib_黄双园Node1rect.width/2,Lib_黄双园Node1rect.y+Lib_黄双园Node1rect.height/2);
  131. Lib_黄双园Node1.setSize(Lib_黄双园Node1rect.width,Lib_黄双园Node1rect.height);
  132. Lib_黄双园Node1.setStyle("opacity",1);
  133. Lib_黄双园Node1.s({'pixelPerfect':true});
  134. Lib_黄双园Node1borderwidth=2;
  135. Lib_黄双园Node1.setRotation(0);
  136. dataModel.add(Lib_黄双园Node1);
  137. Lib_黄双园Node1.a('node.points',Lib_黄双园Node1compspts);
  138. Lib_黄双园Node1.a('node.segments',[1,2]);
  139. Lib_黄双园Node1.a('node.color','rgba(255,128,0,1)');
  140. Lib_黄双园Node1.a('node.borderPattern',getDashStyle("@borderPattern@"));
  141. Lib_黄双园Node1.a('node.borderColor','rgba(255,128,0,1)');
  142. Lib_黄双园Node1.a('node.background','rgba(255,128,0,1)');
  143. Lib_黄双园Node1.a('node.gradient','');
  144. Lib_黄双园Node1.a('node.gradientcolor','rgba(255,128,0,1)');
  145. Lib_黄双园Node1.a('node.endCompspts',Lib_黄双园Node1endCompspts);
  146. Lib_黄双园Node1.a('node.startCompspts',Lib_黄双园Node1startCompspts);
  147. (function (node, img, compspts, endCompspts, startCompspts) {
  148. var position = node.getPosition(),
  149. w = node.getWidth()*_ratio.ratioX,
  150. h = node.getHeight()*_ratio.ratioY;
  151. function resetPoints(rx, ry) {
  152. for (var i = 0, len = compspts.length; i < len; i++) {
  153. if (i%2 === 0) {
  154. compspts[i]*=rx;
  155. } else {
  156. compspts[i]*=ry;
  157. }
  158. }
  159. endCompspts[0] = compspts[compspts.length-2];
  160. endCompspts[1] = compspts[compspts.length-1];
  161. endCompspts[2] *= rx;
  162. endCompspts[3] *= ry;
  163. node.a('node.offsetEndY', -(endCompspts[3]*0.5));
  164. node.a('node.offsetEndX', -(endCompspts[2]*0.5));
  165. startCompspts[0] = compspts[0];
  166. startCompspts[1] = compspts[1];
  167. startCompspts[2] *= rx;
  168. startCompspts[3] *= ry;
  169. node.a('node.offsetStartY', -(startCompspts[3]*0.5));
  170. node.a('node.offsetStartX', -(startCompspts[2]*0.5));
  171. node.a('node.endRotation', GD.calcRotationByStartAndEnd(compspts[i-4], compspts[i-3], compspts[i-2], compspts[i-1]));
  172. node.a('node.startRotation', GD.calcRotationByStartAndEnd(compspts[0], compspts[1], compspts[2], compspts[3]) + Math.PI);
  173. }
  174. node.setSize(w, h);
  175. node.setPosition(position.x * ratio.ratioX, position.y * ratio.ratioY);
  176. node.a('node.width', w);
  177. node.a('node.height', h);
  178. resetPoints(_ratio.ratioX, _ratio.ratioY);
  179. node.borderWidth = 2;
  180. node.a('node.borderwidth',node.borderWidth);
  181. node._nodename = 'Lib_黄双园Node1';
  182. node._nodeType = 'line';
  183. zoomNodeList.push({
  184. node: node,
  185. attr: 'node.borderwidth'
  186. });
  187. var setWidth = node.setWidth,
  188. setHeight = node.setHeight,
  189. timer, rx = 1, ry = 1;
  190. node.setWidth = function (width) {
  191. var _width = this.getWidth();
  192. rx = width / _width;
  193. node.a('node.width', width);
  194. setWidth.apply(this, arguments);
  195. resetPoints(rx, 1);
  196. }
  197. node.setHeight = function (height) {
  198. var _height = this.getHeight();
  199. ry = height / _height;
  200. node.a('node.height', height);
  201. setHeight.apply(this, arguments);
  202. resetPoints(1, ry);
  203. }
  204. })(Lib_黄双园Node1, Lib_黄双园Node1.getImage(), Lib_黄双园Node1compspts, Lib_黄双园Node1endCompspts, Lib_黄双园Node1startCompspts);
  205. var Lib_黄双园Node2points=[14, 13,22, 18],
  206. Lib_黄双园Node2rect=ht.Default.unionPoint([{x:14,y:13},{x:22,y:18}]),
  207. Lib_黄双园Node2compspts=[];
  208. _ratio = GD.getRatioWithRotation(0, ratio);
  209. var _startratio = GD.getRatioWithRotation(3.70019196893336, ratio),
  210. _endratio = GD.getRatioWithRotation(0.558599315343562, ratio);
  211. for(var i=0;i<Lib_黄双园Node2points.length;i++){
  212. if(i%2==0){
  213. Lib_黄双园Node2compspts.push(Lib_黄双园Node2points[i]-Lib_黄双园Node2rect.x);
  214. }else{
  215. Lib_黄双园Node2compspts.push(Lib_黄双园Node2points[i]-Lib_黄双园Node2rect.y);
  216. }
  217. }
  218. var Lib_黄双园Node2ptslength=Lib_黄双园Node2compspts.length;
  219. if (Lib_黄双园Node2rect.height === 0) {
  220. Lib_黄双园Node2compspts[0] -= 0;
  221. Lib_黄双园Node2compspts[Lib_黄双园Node2ptslength-2] += 0;
  222. } else if (Lib_黄双园Node2rect.width === 0){
  223. Lib_黄双园Node2compspts[1] -= 0;
  224. Lib_黄双园Node2compspts[Lib_黄双园Node2ptslength-1] += 0;
  225. } else {
  226. Lib_黄双园Node2compspts[0] -= 0;
  227. Lib_黄双园Node2compspts[1] -= 0;
  228. Lib_黄双园Node2compspts[Lib_黄双园Node2ptslength-2] += 0;
  229. Lib_黄双园Node2compspts[Lib_黄双园Node2ptslength-1] += 0;
  230. }
  231. Lib_黄双园Node2 = new ht.Node();
  232. Lib_黄双园Node2.borderWidth = 2;
  233. Lib_黄双园Node2rect.width = Lib_黄双园Node2rect.width === 0 ? 0.0001 : Lib_黄双园Node2rect.width;
  234. Lib_黄双园Node2rect.height = Lib_黄双园Node2rect.height === 0 ? 0.0001 : Lib_黄双园Node2rect.height;
  235. var Lib_黄双园Node2endCompspts = [Lib_黄双园Node2compspts[Lib_黄双园Node2ptslength-2],Lib_黄双园Node2compspts[Lib_黄双园Node2ptslength-1],0,0];
  236. var Lib_黄双园Node2startCompspts = [Lib_黄双园Node2compspts[0],Lib_黄双园Node2compspts[1],0,0];
  237. Lib_黄双园Node2.setImage(GD.getPolyLineJSON());
  238. Lib_黄双园Node2.setPosition(Lib_黄双园Node2rect.x+Lib_黄双园Node2rect.width/2,Lib_黄双园Node2rect.y+Lib_黄双园Node2rect.height/2);
  239. Lib_黄双园Node2.setSize(Lib_黄双园Node2rect.width,Lib_黄双园Node2rect.height);
  240. Lib_黄双园Node2.setStyle("opacity",1);
  241. Lib_黄双园Node2.s({'pixelPerfect':true});
  242. Lib_黄双园Node2borderwidth=2;
  243. Lib_黄双园Node2.setRotation(0);
  244. dataModel.add(Lib_黄双园Node2);
  245. Lib_黄双园Node2.a('node.points',Lib_黄双园Node2compspts);
  246. Lib_黄双园Node2.a('node.segments',[1,2]);
  247. Lib_黄双园Node2.a('node.color','rgba(255,128,0,1)');
  248. Lib_黄双园Node2.a('node.borderPattern',getDashStyle("@borderPattern@"));
  249. Lib_黄双园Node2.a('node.borderColor','rgba(255,128,0,1)');
  250. Lib_黄双园Node2.a('node.background','rgba(255,128,0,1)');
  251. Lib_黄双园Node2.a('node.gradient','');
  252. Lib_黄双园Node2.a('node.gradientcolor','rgba(255,128,0,1)');
  253. Lib_黄双园Node2.a('node.endCompspts',Lib_黄双园Node2endCompspts);
  254. Lib_黄双园Node2.a('node.startCompspts',Lib_黄双园Node2startCompspts);
  255. (function (node, img, compspts, endCompspts, startCompspts) {
  256. var position = node.getPosition(),
  257. w = node.getWidth()*_ratio.ratioX,
  258. h = node.getHeight()*_ratio.ratioY;
  259. function resetPoints(rx, ry) {
  260. for (var i = 0, len = compspts.length; i < len; i++) {
  261. if (i%2 === 0) {
  262. compspts[i]*=rx;
  263. } else {
  264. compspts[i]*=ry;
  265. }
  266. }
  267. endCompspts[0] = compspts[compspts.length-2];
  268. endCompspts[1] = compspts[compspts.length-1];
  269. endCompspts[2] *= rx;
  270. endCompspts[3] *= ry;
  271. node.a('node.offsetEndY', -(endCompspts[3]*0.5));
  272. node.a('node.offsetEndX', -(endCompspts[2]*0.5));
  273. startCompspts[0] = compspts[0];
  274. startCompspts[1] = compspts[1];
  275. startCompspts[2] *= rx;
  276. startCompspts[3] *= ry;
  277. node.a('node.offsetStartY', -(startCompspts[3]*0.5));
  278. node.a('node.offsetStartX', -(startCompspts[2]*0.5));
  279. node.a('node.endRotation', GD.calcRotationByStartAndEnd(compspts[i-4], compspts[i-3], compspts[i-2], compspts[i-1]));
  280. node.a('node.startRotation', GD.calcRotationByStartAndEnd(compspts[0], compspts[1], compspts[2], compspts[3]) + Math.PI);
  281. }
  282. node.setSize(w, h);
  283. node.setPosition(position.x * ratio.ratioX, position.y * ratio.ratioY);
  284. node.a('node.width', w);
  285. node.a('node.height', h);
  286. resetPoints(_ratio.ratioX, _ratio.ratioY);
  287. node.borderWidth = 2;
  288. node.a('node.borderwidth',node.borderWidth);
  289. node._nodename = 'Lib_黄双园Node2';
  290. node._nodeType = 'line';
  291. zoomNodeList.push({
  292. node: node,
  293. attr: 'node.borderwidth'
  294. });
  295. var setWidth = node.setWidth,
  296. setHeight = node.setHeight,
  297. timer, rx = 1, ry = 1;
  298. node.setWidth = function (width) {
  299. var _width = this.getWidth();
  300. rx = width / _width;
  301. node.a('node.width', width);
  302. setWidth.apply(this, arguments);
  303. resetPoints(rx, 1);
  304. }
  305. node.setHeight = function (height) {
  306. var _height = this.getHeight();
  307. ry = height / _height;
  308. node.a('node.height', height);
  309. setHeight.apply(this, arguments);
  310. resetPoints(1, ry);
  311. }
  312. })(Lib_黄双园Node2, Lib_黄双园Node2.getImage(), Lib_黄双园Node2compspts, Lib_黄双园Node2endCompspts, Lib_黄双园Node2startCompspts);
  313. var Lib_黄双园Node3points=[14, 13,7, 18],
  314. Lib_黄双园Node3rect=ht.Default.unionPoint([{x:14,y:13},{x:7,y:18}]),
  315. Lib_黄双园Node3compspts=[];
  316. _ratio = GD.getRatioWithRotation(0, ratio);
  317. var _startratio = GD.getRatioWithRotation(-0.620249497259376, ratio),
  318. _endratio = GD.getRatioWithRotation(2.52134315633042, ratio);
  319. for(var i=0;i<Lib_黄双园Node3points.length;i++){
  320. if(i%2==0){
  321. Lib_黄双园Node3compspts.push(Lib_黄双园Node3points[i]-Lib_黄双园Node3rect.x);
  322. }else{
  323. Lib_黄双园Node3compspts.push(Lib_黄双园Node3points[i]-Lib_黄双园Node3rect.y);
  324. }
  325. }
  326. var Lib_黄双园Node3ptslength=Lib_黄双园Node3compspts.length;
  327. if (Lib_黄双园Node3rect.height === 0) {
  328. Lib_黄双园Node3compspts[0] -= 0;
  329. Lib_黄双园Node3compspts[Lib_黄双园Node3ptslength-2] += 0;
  330. } else if (Lib_黄双园Node3rect.width === 0){
  331. Lib_黄双园Node3compspts[1] -= 0;
  332. Lib_黄双园Node3compspts[Lib_黄双园Node3ptslength-1] += 0;
  333. } else {
  334. Lib_黄双园Node3compspts[0] -= 0;
  335. Lib_黄双园Node3compspts[1] -= 0;
  336. Lib_黄双园Node3compspts[Lib_黄双园Node3ptslength-2] += 0;
  337. Lib_黄双园Node3compspts[Lib_黄双园Node3ptslength-1] += 0;
  338. }
  339. Lib_黄双园Node3 = new ht.Node();
  340. Lib_黄双园Node3.borderWidth = 2;
  341. Lib_黄双园Node3rect.width = Lib_黄双园Node3rect.width === 0 ? 0.0001 : Lib_黄双园Node3rect.width;
  342. Lib_黄双园Node3rect.height = Lib_黄双园Node3rect.height === 0 ? 0.0001 : Lib_黄双园Node3rect.height;
  343. var Lib_黄双园Node3endCompspts = [Lib_黄双园Node3compspts[Lib_黄双园Node3ptslength-2],Lib_黄双园Node3compspts[Lib_黄双园Node3ptslength-1],0,0];
  344. var Lib_黄双园Node3startCompspts = [Lib_黄双园Node3compspts[0],Lib_黄双园Node3compspts[1],0,0];
  345. Lib_黄双园Node3.setImage(GD.getPolyLineJSON());
  346. Lib_黄双园Node3.setPosition(Lib_黄双园Node3rect.x+Lib_黄双园Node3rect.width/2,Lib_黄双园Node3rect.y+Lib_黄双园Node3rect.height/2);
  347. Lib_黄双园Node3.setSize(Lib_黄双园Node3rect.width,Lib_黄双园Node3rect.height);
  348. Lib_黄双园Node3.setStyle("opacity",1);
  349. Lib_黄双园Node3.s({'pixelPerfect':true});
  350. Lib_黄双园Node3borderwidth=2;
  351. Lib_黄双园Node3.setRotation(0);
  352. dataModel.add(Lib_黄双园Node3);
  353. Lib_黄双园Node3.a('node.points',Lib_黄双园Node3compspts);
  354. Lib_黄双园Node3.a('node.segments',[1,2]);
  355. Lib_黄双园Node3.a('node.color','rgba(255,128,0,1)');
  356. Lib_黄双园Node3.a('node.borderPattern',getDashStyle("@borderPattern@"));
  357. Lib_黄双园Node3.a('node.borderColor','rgba(255,128,0,1)');
  358. Lib_黄双园Node3.a('node.background','rgba(255,128,0,1)');
  359. Lib_黄双园Node3.a('node.gradient','');
  360. Lib_黄双园Node3.a('node.gradientcolor','rgba(255,128,0,1)');
  361. Lib_黄双园Node3.a('node.endCompspts',Lib_黄双园Node3endCompspts);
  362. Lib_黄双园Node3.a('node.startCompspts',Lib_黄双园Node3startCompspts);
  363. (function (node, img, compspts, endCompspts, startCompspts) {
  364. var position = node.getPosition(),
  365. w = node.getWidth()*_ratio.ratioX,
  366. h = node.getHeight()*_ratio.ratioY;
  367. function resetPoints(rx, ry) {
  368. for (var i = 0, len = compspts.length; i < len; i++) {
  369. if (i%2 === 0) {
  370. compspts[i]*=rx;
  371. } else {
  372. compspts[i]*=ry;
  373. }
  374. }
  375. endCompspts[0] = compspts[compspts.length-2];
  376. endCompspts[1] = compspts[compspts.length-1];
  377. endCompspts[2] *= rx;
  378. endCompspts[3] *= ry;
  379. node.a('node.offsetEndY', -(endCompspts[3]*0.5));
  380. node.a('node.offsetEndX', -(endCompspts[2]*0.5));
  381. startCompspts[0] = compspts[0];
  382. startCompspts[1] = compspts[1];
  383. startCompspts[2] *= rx;
  384. startCompspts[3] *= ry;
  385. node.a('node.offsetStartY', -(startCompspts[3]*0.5));
  386. node.a('node.offsetStartX', -(startCompspts[2]*0.5));
  387. node.a('node.endRotation', GD.calcRotationByStartAndEnd(compspts[i-4], compspts[i-3], compspts[i-2], compspts[i-1]));
  388. node.a('node.startRotation', GD.calcRotationByStartAndEnd(compspts[0], compspts[1], compspts[2], compspts[3]) + Math.PI);
  389. }
  390. node.setSize(w, h);
  391. node.setPosition(position.x * ratio.ratioX, position.y * ratio.ratioY);
  392. node.a('node.width', w);
  393. node.a('node.height', h);
  394. resetPoints(_ratio.ratioX, _ratio.ratioY);
  395. node.borderWidth = 2;
  396. node.a('node.borderwidth',node.borderWidth);
  397. node._nodename = 'Lib_黄双园Node3';
  398. node._nodeType = 'line';
  399. zoomNodeList.push({
  400. node: node,
  401. attr: 'node.borderwidth'
  402. });
  403. var setWidth = node.setWidth,
  404. setHeight = node.setHeight,
  405. timer, rx = 1, ry = 1;
  406. node.setWidth = function (width) {
  407. var _width = this.getWidth();
  408. rx = width / _width;
  409. node.a('node.width', width);
  410. setWidth.apply(this, arguments);
  411. resetPoints(rx, 1);
  412. }
  413. node.setHeight = function (height) {
  414. var _height = this.getHeight();
  415. ry = height / _height;
  416. node.a('node.height', height);
  417. setHeight.apply(this, arguments);
  418. resetPoints(1, ry);
  419. }
  420. })(Lib_黄双园Node3, Lib_黄双园Node3.getImage(), Lib_黄双园Node3compspts, Lib_黄双园Node3endCompspts, Lib_黄双园Node3startCompspts);
  421. _ratio = GD.getRatioWithRotation(0*Math.PI/180, ratio);
  422. var Lib_黄双园Node4_0type = 'oval';
  423. var Lib_黄双园Node4_0 = new ht.Node(),
  424. Lib_黄双园Node4_0BorderWidth = 2*2;
  425. if (Lib_黄双园Node4_0type === 'arc') {
  426. Lib_黄双园Node4_0BorderWidth *= 2;
  427. }
  428. Lib_黄双园Node4_0.setImage(GD.getRectJSON(29.84119*_ratio.ratioX, 26.18182*_ratio.ratioY, Lib_黄双园Node4_0type, '@arcFrom@', '@arcTo@', '@arcClose@'));
  429. Lib_黄双园Node4_0.setPosition(14*ratio.ratioX, 35*ratio.ratioY);
  430. Lib_黄双园Node4_0.setSize(29.84119*_ratio.ratioX, 26.18182*_ratio.ratioY);
  431. Lib_黄双园Node4_0.s({
  432. 'pixelPerfect':true
  433. /*@AddPara@*/
  434. });
  435. Lib_黄双园Node4_0.a('node.width', 29.84119*_ratio.ratioX);
  436. Lib_黄双园Node4_0.a('node.height', 26.18182*_ratio.ratioY);
  437. Lib_黄双园Node4_0.a('node.type', Lib_黄双园Node4_0type);
  438. Lib_黄双园Node4_0.a('node.rect', [0, 0, 29.84119*_ratio.ratioX, 26.18182*_ratio.ratioY]);
  439. Lib_黄双园Node4_0.a('node.background', 'rgba(255,255,255,0.003921569)');
  440. Lib_黄双园Node4_0.a('node.gradientcolor', '');
  441. Lib_黄双园Node4_0.a('node.gradient', '');
  442. Lib_黄双园Node4_0.a('node.borderwidth', Lib_黄双园Node4_0BorderWidth);
  443. Lib_黄双园Node4_0.a('node.color', 'rgba(255,128,0,1)');
  444. Lib_黄双园Node4_0.a('node.fillrect', [0,0,0,0]);
  445. Lib_黄双园Node4_0.a('node.fillbackcolor', 'rgba(0,0,0,0)');
  446. Lib_黄双园Node4_0.a('node.fillgradientcolor', 'rgba(0,0,0,0)');
  447. Lib_黄双园Node4_0.a('node.fillgradient', '');
  448. if (Lib_黄双园Node4_0type !== 'rect') {
  449. Lib_黄双园Node4_0.a('node.arcFrom', parseFloat('@arcFrom@'));
  450. Lib_黄双园Node4_0.a('node.arcTo', parseFloat('@arcTo@'));
  451. Lib_黄双园Node4_0.a('node.arcClose', '@arcClose@' === 'true' ? true : false);
  452. }
  453. if (Lib_黄双园Node4_0type === 'arc') {
  454. Lib_黄双园Node4_0.a('node.arcOval', true);
  455. }
  456. Lib_黄双园Node4_0.setRotation(0*Math.PI/180);
  457. Lib_黄双园Node4_0.borderWidth = Lib_黄双园Node4_0BorderWidth;
  458. Lib_黄双园Node4_0.borderFillwidth = Lib_黄双园Node4_0BorderWidth;
  459. dataModel.add(Lib_黄双园Node4_0);
  460. Lib_黄双园Node4_0._nodename = 'Lib_黄双园Node4_0'
  461. Lib_黄双园Node4_0._nodeType = 'rect';
  462. zoomNodeList.push({
  463. node: Lib_黄双园Node4_0,
  464. attr: 'node.borderwidth'
  465. });
  466. (function (node, _img) {
  467. var setWidth = node.setWidth,
  468. setHeight = node.setHeight;
  469. node.setWidth = function (width) {
  470. if (width === this.getWidth()) return ;
  471. var height = this.getHeight();
  472. this.a('node.width', width);
  473. this.a('node.rect', [0,0,width, height]);
  474. setWidth.apply(this, arguments);
  475. }
  476. node.setHeight = function (height) {
  477. if (height === this.getHeight()) return ;
  478. var width = this.getWidth();
  479. this.a('node.height', height);
  480. this.a('node.rect', [0,0,width, height]);
  481. setHeight.apply(this, arguments);
  482. }
  483. })(Lib_黄双园Node4_0, Lib_黄双园Node4_0.getImage());var Lib_黄双园Node4_1rect=ht.Default.unionPoint([{x: 10, y: 28},{x: 10, y: 28},{x: 21, y: 28},{x: 16, y: 41}]),
  484. Lib_黄双园Node4_1points=[10,28,10,28,21,28,16,41],
  485. Lib_黄双园Node4_1compsPoints=[],
  486. Lib_黄双园Node4_1SetPoints = [{x: 10, y: 28},{x: 10, y: 28},{x: 21, y: 28},{x: 16, y: 41}],
  487. Lib_黄双园Node4_1setSegments = [1,2,2,2];
  488. _ratio = GD.getRatioWithRotation(4.712389, ratio);
  489. for(var i=0;i<Lib_黄双园Node4_1points.length;i++){
  490. if(i%2==0){
  491. Lib_黄双园Node4_1compsPoints.push(Lib_黄双园Node4_1points[i]-Lib_黄双园Node4_1rect.x);
  492. }else{
  493. Lib_黄双园Node4_1compsPoints.push(Lib_黄双园Node4_1points[i]-Lib_黄双园Node4_1rect.y);
  494. }
  495. }
  496. var Lib_黄双园Node4_1 = new ht.Node();
  497. Lib_黄双园Node4_1.setImage(GD.getPolyGonJSON());
  498. Lib_黄双园Node4_1.setPosition(Lib_黄双园Node4_1rect.x + Lib_黄双园Node4_1rect.width/2, Lib_黄双园Node4_1rect.y + Lib_黄双园Node4_1rect.height/2);
  499. Lib_黄双园Node4_1.setSize(Lib_黄双园Node4_1rect.width, Lib_黄双园Node4_1rect.height);
  500. Lib_黄双园Node4_1.setRotation(4.712389);
  501. Lib_黄双园Node4_1.borderWidth=2;
  502. Lib_黄双园Node4_1.borderFillwidth=2*2;
  503. Lib_黄双园Node4_1.s({'pixelPerfect':true});
  504. dataModel.add(Lib_黄双园Node4_1);
  505. // Lib_黄双园Node4_1.a('node.width', Lib_黄双园Node4_1rect.width*_ratio.ratioX);
  506. // Lib_黄双园Node4_1.a('node.height', Lib_黄双园Node4_1rect.height*_ratio.ratioY);
  507. Lib_黄双园Node4_1.a('node.clip', function(g,width,height,data) {
  508. var clippoints = Lib_黄双园Node4_1SetPoints;
  509. if(clippoints.length<=3) return;
  510. if(Lib_黄双园Node4_1.a('Lib_黄双园Node4_1.isFill')=="false") return;
  511. var clipcompsPoints=[];
  512. var rect = ht.Default.unionPoint(clippoints);
  513. for(var i=0;i<clippoints.length;i++){
  514. clipcompsPoints.push({x:clippoints[i].x-rect.x,y:clippoints[i].y-rect.y});
  515. }
  516. var clipsegments=Lib_黄双园Node4_1setSegments;
  517. g.beginPath();
  518. drawPoints(g,clipcompsPoints,clipsegments);
  519. g.clip();
  520. })
  521. Lib_黄双园Node4_1.a('node.type', 'shape');
  522. Lib_黄双园Node4_1.a('node.comsPoints', Lib_黄双园Node4_1compsPoints);
  523. Lib_黄双园Node4_1.a('node.closePath', true);
  524. Lib_黄双园Node4_1.a('node.borderwidth', 2);
  525. Lib_黄双园Node4_1.a('node.color', 'rgba(255,128,0,1)');
  526. Lib_黄双园Node4_1.a('node.background','rgba(255,255,255,0.003921569)');
  527. Lib_黄双园Node4_1.a('node.closePath', true);
  528. Lib_黄双园Node4_1.a('node.closePath', true);
  529. Lib_黄双园Node4_1.a('node.gradient','');
  530. Lib_黄双园Node4_1.a('node.gradientcolor','');
  531. Lib_黄双园Node4_1.a('node.isFill','false');
  532. Lib_黄双园Node4_1.a('node.original',[0,0,0,0]);
  533. Lib_黄双园Node4_1.a('node.fillrect',[0,0,0,0]);
  534. Lib_黄双园Node4_1.a('node.fillbackcolor','rgba(255,255,255,0.003921569)');
  535. Lib_黄双园Node4_1.a('node.fillgradient','');
  536. Lib_黄双园Node4_1.a('node.fillgradientcolor','');
  537. Lib_黄双园Node4_1.a('node.segments',Lib_黄双园Node4_1setSegments);
  538. Lib_黄双园Node4_1.a('node.borderPattern',"");
  539. (function (node, nodecompsPoints, setPoints) {
  540. var w = node.getWidth()*_ratio.ratioX,
  541. h = node.getHeight()*_ratio.ratioY,
  542. img = node.getImage();
  543. function resetPoints(rx, ry) {
  544. for (var i = 0, len = nodecompsPoints.length; i < len; i++) {
  545. if (i%2 === 0) {
  546. nodecompsPoints[i]*=rx;
  547. } else {
  548. nodecompsPoints[i]*=ry;
  549. }
  550. if (setPoints[i]) {
  551. setPoints[i].x *= rx;
  552. setPoints[i].y *= ry;
  553. }
  554. }
  555. }
  556. node.setSize(w, h);
  557. node.a('node.width', w);
  558. node.a('node.height', h);
  559. resetPoints(_ratio.ratioX, _ratio.ratioY);
  560. var position = node.getPosition();
  561. node.setPosition(position.x * ratio.ratioX, position.y * ratio.ratioY);
  562. node._nodename = 'Lib_黄双园Node4_1';
  563. node._nodeType = 'polygon';
  564. zoomNodeList.push({
  565. node: node,
  566. attr: 'node.borderwidth'
  567. });
  568. // 重载setWidth, setHeight
  569. var setWidth = node.setWidth,
  570. setHeight = node.setHeight,
  571. timer, rx = 1, ry = 1;
  572. node.setWidth = function (width) {
  573. var _width = this.getWidth();
  574. rx = width / _width;
  575. node.a('node.width', width);
  576. setWidth.apply(this, arguments);
  577. resetPoints(rx, 1);
  578. }
  579. node.setHeight = function (height) {
  580. var _height = this.getHeight();
  581. ry = height / _height;
  582. node.a('node.height', height);
  583. setHeight.apply(this, arguments);
  584. resetPoints(1, ry);
  585. }
  586. })(Lib_黄双园Node4_1, Lib_黄双园Node4_1compsPoints, Lib_黄双园Node4_1SetPoints );
  587. /*@GraphList@*/
  588. /*@PageInit@*/
  589. var localVarObj = this.localVarObj;
  590. var localDynamicVarObj = this.localDynamicVar();
  591. this['Lib_黄双园Node0'] = Lib_黄双园Node0;
  592. Lib_黄双园Node0.__parentLib = nodename;
  593. Lib_黄双园Node0.__parent = this;
  594. this.childNodes.push(Lib_黄双园Node0);
  595. this['Lib_黄双园Node1'] = Lib_黄双园Node1;
  596. Lib_黄双园Node1.__parentLib = nodename;
  597. Lib_黄双园Node1.__parent = this;
  598. this.childNodes.push(Lib_黄双园Node1);
  599. this['Lib_黄双园Node2'] = Lib_黄双园Node2;
  600. Lib_黄双园Node2.__parentLib = nodename;
  601. Lib_黄双园Node2.__parent = this;
  602. this.childNodes.push(Lib_黄双园Node2);
  603. this['Lib_黄双园Node3'] = Lib_黄双园Node3;
  604. Lib_黄双园Node3.__parentLib = nodename;
  605. Lib_黄双园Node3.__parent = this;
  606. this.childNodes.push(Lib_黄双园Node3);
  607. this['Lib_黄双园Node4_0'] = Lib_黄双园Node4_0;
  608. Lib_黄双园Node4_0.__parentLib = nodename;
  609. Lib_黄双园Node4_0.__parent = this;
  610. this.childNodes.push(Lib_黄双园Node4_0);
  611. this['Lib_黄双园Node4_1'] = Lib_黄双园Node4_1;
  612. Lib_黄双园Node4_1.__parentLib = nodename;
  613. Lib_黄双园Node4_1.__parent = this;
  614. this.childNodes.push(Lib_黄双园Node4_1);
  615. /*@ControlContextMenu@*/
  616. /*@Declare@*/
  617. this.init(x, y, width, height, angle);
  618. };
  619. ht.Default.def('ht.lib.黄双园', Object, {
  620. refresh10ms: function () {
  621. var localVarObj = this.localVarObj;
  622. var localDynamicVarObj = this.localDynamicVar();
  623. var Lib_黄双园Node0= this.Lib_黄双园Node0;
  624. var Lib_黄双园Node1= this.Lib_黄双园Node1;
  625. var Lib_黄双园Node2= this.Lib_黄双园Node2;
  626. var Lib_黄双园Node3= this.Lib_黄双园Node3;
  627. var Lib_黄双园Node4_0= this.Lib_黄双园Node4_0;
  628. var Lib_黄双园Node4_1= this.Lib_黄双园Node4_1;
  629. /*@refresh10ms@*/
  630. },
  631. refresh100ms: function () {
  632. var localVarObj = this.localVarObj;
  633. var localDynamicVarObj = this.localDynamicVar();
  634. var Lib_黄双园Node0= this.Lib_黄双园Node0;
  635. var Lib_黄双园Node1= this.Lib_黄双园Node1;
  636. var Lib_黄双园Node2= this.Lib_黄双园Node2;
  637. var Lib_黄双园Node3= this.Lib_黄双园Node3;
  638. var Lib_黄双园Node4_0= this.Lib_黄双园Node4_0;
  639. var Lib_黄双园Node4_1= this.Lib_黄双园Node4_1;
  640. /*@refresh100ms@*/
  641. },
  642. refresh500ms: function () {
  643. var localVarObj = this.localVarObj;
  644. var localDynamicVarObj = this.localDynamicVar();
  645. var Lib_黄双园Node0= this.Lib_黄双园Node0;
  646. var Lib_黄双园Node1= this.Lib_黄双园Node1;
  647. var Lib_黄双园Node2= this.Lib_黄双园Node2;
  648. var Lib_黄双园Node3= this.Lib_黄双园Node3;
  649. var Lib_黄双园Node4_0= this.Lib_黄双园Node4_0;
  650. var Lib_黄双园Node4_1= this.Lib_黄双园Node4_1;
  651. /*@refresh500ms@*/
  652. },
  653. refresh1s: function () {
  654. var Counter1s = arguments[0] || 0;
  655. var localVarObj = this.localVarObj;
  656. var localDynamicVarObj = this.localDynamicVar();
  657. var Lib_黄双园Node0= this.Lib_黄双园Node0;
  658. var Lib_黄双园Node1= this.Lib_黄双园Node1;
  659. var Lib_黄双园Node2= this.Lib_黄双园Node2;
  660. var Lib_黄双园Node3= this.Lib_黄双园Node3;
  661. var Lib_黄双园Node4_0= this.Lib_黄双园Node4_0;
  662. var Lib_黄双园Node4_1= this.Lib_黄双园Node4_1;
  663. /*@refresh1s@*/
  664. },
  665. refresh5s: function () {
  666. var localVarObj = this.localVarObj;
  667. var localDynamicVarObj = this.localDynamicVar();
  668. var Lib_黄双园Node0= this.Lib_黄双园Node0;
  669. var Lib_黄双园Node1= this.Lib_黄双园Node1;
  670. var Lib_黄双园Node2= this.Lib_黄双园Node2;
  671. var Lib_黄双园Node3= this.Lib_黄双园Node3;
  672. var Lib_黄双园Node4_0= this.Lib_黄双园Node4_0;
  673. var Lib_黄双园Node4_1= this.Lib_黄双园Node4_1;
  674. /*@refresh5s@*/
  675. },
  676. /*@PageDynamic@*/
  677. onEvent: function (e, data, type, origin, offset, objMouseOn, ctm) {
  678. var localVarObj = this.localVarObj;
  679. var localDynamicVarObj = this.localDynamicVar();
  680. var Lib_黄双园Node0= this.Lib_黄双园Node0;
  681. var Lib_黄双园Node1= this.Lib_黄双园Node1;
  682. var Lib_黄双园Node2= this.Lib_黄双园Node2;
  683. var Lib_黄双园Node3= this.Lib_黄双园Node3;
  684. var Lib_黄双园Node4_0= this.Lib_黄双园Node4_0;
  685. var Lib_黄双园Node4_1= this.Lib_黄双园Node4_1;
  686. if (type === 'click') {
  687. /*@EvnentClicked@*/
  688. } else if (type === 'mousedown') {
  689. mouseX=e.clientX;
  690. mouseY=e.clientY;
  691. /*@EvnentMouseDown@*/
  692. } else if (type === 'mouseup') {
  693. /*@EvnentMouseUp@*/
  694. } else if (type === 'mousemove') {
  695. var mouseX, mouseY, position, zoom;
  696. position=origin.getLogicalPoint(e);
  697. zoom = graphView.getZoom();
  698. if (origin === graphView) {
  699. mouseX= position.x + origin.tx();
  700. mouseY = position.y + origin.ty();
  701. } else {
  702. offset = offset || {x: 0, y: 0};
  703. mouseX = position.x / zoom + offset.x + origin.tx();
  704. mouseY = position.y / zoom + offset.y + origin.ty();
  705. }
  706. /*@EvnentMouseLeave@*/
  707. /*@EvnentMouseOver@*/
  708. } else if (type === 'keydown') {
  709. /*@EvnentKeyDown@*/
  710. } else if (type === 'contextmenu') {
  711. /*@Declare@*/
  712. /*@SetNodeContextMenu@*/
  713. /*@SetPageContextMenu@*/
  714. }
  715. /*@LibEvent@*/
  716. },
  717. getBaseClass: function () {
  718. return this._baseClass;
  719. },
  720. getWidth: function () {
  721. return this._width;
  722. },
  723. getHeight: function () {
  724. return this._height;
  725. },
  726. getSize: function () {
  727. return {
  728. width: this._width,
  729. height: this._height
  730. }
  731. },
  732. setWidth: function (width) {
  733. if (width === undefined || width === null || width != width) {
  734. return ;
  735. }
  736. var originWidth = this._width;
  737. var ratio = width / originWidth;
  738. var childNodes = this.childNodes, childNode, p, op = this.getPosition(), w, cw, ox, rotation = this.getRotation();
  739. for (var i = 0, len = childNodes.length; i < len; i++) {
  740. childNode = childNodes[i];
  741. p = childNode.getPosition();
  742. cw = childNode.getWidth();
  743. w = cw >=2 ? cw * ratio : cw;
  744. childNode.setWidth(w);
  745. ox = op.x + (p.x - op.x) * ratio;
  746. childNode.setPosition(ox, p.y);
  747. rotation = GD.calcRotation(rotation);
  748. if (rotation === 0 || rotation === Math.PI) {
  749. // 图元未旋转
  750. ox = op.x + (p.x - op.x)*ratio;
  751. childNode.setPosition(ox, p.y);
  752. } else if (rotation === 90 * Math.PI / 180) {
  753. // 图元旋转以后
  754. ox = op.y + (p.y - op.y)*ratio;
  755. childNode.setPosition(p.x, ox);
  756. }
  757. }
  758. this._width = width;
  759. this._originWidth = width;
  760. this._ratioX = ratio;
  761. return this;
  762. },
  763. setHeight: function (height) {
  764. if (height === undefined || height === null || height != height) {
  765. return ;
  766. }
  767. var originHeight = this._height;
  768. var ratio = height / originHeight;
  769. var childNodes = this.childNodes, childNode, p, op = this.getPosition(), h, ch, oy, rotation = this.getRotation();
  770. for (var i = 0, len = childNodes.length; i < len; i++) {
  771. childNode = childNodes[i];
  772. p = childNode.getPosition();
  773. ch = childNode.getHeight();
  774. h = ch >=2 ? ch * ratio : ch;
  775. childNode.setHeight(h);
  776. rotation = GD.calcRotation(rotation);
  777. if (rotation === 0 || rotation === Math.PI) {
  778. // 图元未旋转
  779. oy = op.y + (p.y - op.y)*ratio;
  780. childNode.setPosition(p.x, oy);
  781. } else if (rotation === 90 * Math.PI / 180) {
  782. // 图元旋转以后
  783. oy = op.x + (p.x - op.x)*ratio;
  784. childNode.setPosition(oy, p.y);
  785. }
  786. }
  787. this._height = height;
  788. this._originHeight = height;
  789. this._ratioY = ratio;
  790. return this;
  791. },
  792. setSize: function (size) {
  793. // var args = Array.prototype.slice.call(arguments, 0);
  794. // var height, width;
  795. // if (args.length === 0) {
  796. // return ;
  797. // }else if (args.length === 1) {
  798. // height = args[0].height;
  799. // width = args[0].width;
  800. // } else {
  801. // width = args[0];
  802. // height = args[1];
  803. // }
  804. // var wh = GD.getRatioWithRotation(angle, wid)
  805. // this.setHeight(height);
  806. // this.setWidth(width);
  807. // return this;
  808. var args = Array.prototype.slice.call(arguments, 0);
  809. var height, width;
  810. if (args.length === 0) {
  811. return ;
  812. }else if (args.length === 1) {
  813. height = args[0].height;
  814. width = args[0].width;
  815. angle = 0;
  816. } else if (args.length === 2) {
  817. if (typeof args[0] === 'object') {
  818. width = args[0].width;
  819. height = args[0].height;
  820. angle = args[1] || 0;
  821. } else {
  822. width = args[0];
  823. height = args[1];
  824. angle = 0;
  825. }
  826. } else if (args.length === 3) {
  827. width = args[0];
  828. height = args[1];
  829. angle = args[2] || 0;
  830. }
  831. var wh = GD.getRatioWithRotation(0, width, height);
  832. this.setHeight(wh.ratioY);
  833. this.setWidth(wh.ratioX);
  834. return this;
  835. },
  836. getPosition: function () {
  837. return {
  838. x: this._x,
  839. y: this._y
  840. }
  841. },
  842. setPosition: function () {
  843. var args = Array.prototype.slice.call(arguments, 0), x, y;
  844. if (args.length === 0) {
  845. return this;
  846. } else if (args.length === 1) {
  847. if (typeof args[0] != 'object') {
  848. return this;
  849. }
  850. x = args[0].x;
  851. y = args[0].y;
  852. } else {
  853. x = args[0];
  854. y = args[1];
  855. }
  856. if ((x !== 0 && !x) || (y !== 0 && !y)) {
  857. return this;
  858. }
  859. // var childNodes = this.childNodes, offset, childNode, p;
  860. // for (var i = 0, len = childNodes.length; i < len; i++) {
  861. // childNode = childNodes[i];
  862. // p = childNode.getPosition();
  863. // childNode.setPosition(x - (this._x-p.x)*this._ratioX, y - (this._y-p.y)*this._ratioY);
  864. // }
  865. // this._x = x;
  866. // this._y = y;
  867. // return this;
  868. var childNodes, childNode, background, offset = {}, op, cp;
  869. childNodes = this.childNodes;
  870. background = this._background;
  871. op = background.getPosition();
  872. offset.x = x - op.x;
  873. offset.y = y - op.y;
  874. for (var i = 0, len = childNodes.length; i < len; i++) {
  875. childNode = childNodes[i];
  876. cp = childNode.getPosition();
  877. childNode.setPosition(cp.x + offset.x, cp.y + offset.y);
  878. }
  879. this._x = x;
  880. this._y = y;
  881. this._position = {x: x, y: y};
  882. return this;
  883. },
  884. getStyle: function (key) {
  885. if (!key) {
  886. return undefined;
  887. }
  888. return this._styleObject[key];
  889. },
  890. setStyle: function (key, value, force) {
  891. var childNodes = this.childNodes, childNode;
  892. for (var i = 0, len = childNodes.length; i < len; i++) {
  893. childNode = childNodes[i];
  894. if (key === '2d.visible') {
  895. if (value === graphView.isVisible(childNode)) {
  896. continue;
  897. }
  898. if (!value) {
  899. childNode._savedIsVisible = graphView.isVisible(childNode);
  900. childNode.s({
  901. '2d.visible': false
  902. })
  903. } else {
  904. childNode.s({
  905. '2d.visible': childNode._savedIsVisible
  906. })
  907. }
  908. continue;
  909. }
  910. childNode.s({
  911. key: value
  912. });
  913. }
  914. this._styleObject[key] = value;
  915. return this;
  916. },
  917. calcSize: function () {
  918. var background = this._background;
  919. var position = background.getPosition(),
  920. width = background.getWidth(),
  921. height = background.getHeight();
  922. this._width = width;
  923. this._height = height;
  924. this._x = position.x;
  925. this._y = position.y;
  926. this._position = {
  927. x: this._x,
  928. y: this._y
  929. }
  930. return this;
  931. return this;
  932. },
  933. s: function (styleObj, force) {
  934. var args = Array.prototype.slice.call(arguments, 0);
  935. var styleObj;
  936. if (args.length === 0) {
  937. return this;
  938. } else if (args.length === 1) {
  939. styleObj = args[0];
  940. } else {
  941. this.setStyle(args[0], args[1]);
  942. return this;
  943. }
  944. for (var key in styleObj) {
  945. if (!styleObj.hasOwnProperty(key)) {
  946. continue;
  947. }
  948. this.setStyle(key, styleObj[key], force);
  949. }
  950. return this;
  951. },
  952. init: function (x, y, width, height, angle) {
  953. var that = this;
  954. this.calcSize();
  955. (function (width, height, angle) {
  956. // that.setSize(width, height, angle);
  957. // var wh = GD.getRatioWithRotation(angle, width, height);
  958. // width = wh.ratioX;
  959. // height = wh.ratioY;
  960. var originHeight = that._height;
  961. var originWidth = that._width;
  962. var ratioY = height / originHeight;
  963. var ratioX = width / originWidth;
  964. var childNodes = that.childNodes,
  965. childNode,p, op = that.getPosition(), h, ch, oy, w, cw, ox, name, borderRatio, borderWidth;
  966. for (var i = 0, len = childNodes.length; i < len; i++) {
  967. childNode = childNodes[i];
  968. p = childNode.getPosition();
  969. childNode.originHeight = childNode.originHeight || childNode.getHeight();
  970. ch = childNode.getHeight();
  971. cw = childNode.getWidth();
  972. if (ch > 2) {
  973. h = ch * ratioY;
  974. childNode.setHeight(h);
  975. }
  976. if (cw > 2) {
  977. w = cw * ratioX;
  978. childNode.setWidth(w);
  979. }
  980. borderRatio = (ratioX + ratioY)*0.5;
  981. if (childNode._nodeType === 'line') { // 如果是线,
  982. if (childNode.getWidth() > childNode.getHeight()) {
  983. borderRatio = ratioX;
  984. } else {
  985. borderRatio = ratioY;
  986. }
  987. }
  988. name = childNode._nodename;
  989. // if (childNode.borderWidth && name && ch > 2 && cw > 2) {
  990. // borderWidth = childNode.borderWidth / borderRatio;
  991. // if (borderWidth > ch*0.5 || borderWidth > cw *0.5) {
  992. // // borderWidth = childNode.borderWidth;
  993. // }
  994. // childNode.borderWidth = borderWidth;
  995. // childNode.a(name + '.borderwidth', borderWidth);
  996. // }
  997. }
  998. that._height = height;
  999. that._originHeight = height;
  1000. that._ratioY = ratioY;
  1001. that._width = width;
  1002. that._originWidth = width;
  1003. that._ratioX = ratioX;
  1004. })(width, height, angle);
  1005. that._x = width / 2;
  1006. that._y = height / 2;
  1007. that._rotation = 0;
  1008. // that.setPosition(x, y);
  1009. (function (x, y) {
  1010. var childNodes = that.childNodes, offset, childNode;
  1011. var w2 = that.getWidth() / 2, h2 = that.getHeight()/2;
  1012. for (var i = 0, len = childNodes.length; i < len; i++) {
  1013. childNode = childNodes[i];
  1014. offset = childNode.getPosition();
  1015. childNode.setPosition(x + offset.x * that._ratioX - w2, y + offset.y * that._ratioY - h2);
  1016. }
  1017. that._x = x;
  1018. that._y = y;
  1019. })(x, y);
  1020. // setTimeout(that.addEVent, 1000);
  1021. },
  1022. setRotation: function (angle) {
  1023. var that = this, _angle = that.getRotation();
  1024. if (angle!==0 && !angle || angle === _angle) {
  1025. return this;
  1026. }
  1027. var childNodes = this.childNodes, childNode, p = this.getPosition(), px = p.x, py = p.y;
  1028. for (var i = 0, len = childNodes.length; i < len; i++) {
  1029. childNode = childNodes[i];
  1030. var x = childNode.getPosition().x - px;
  1031. var y = childNode.getPosition().y - py;
  1032. childNode.setPosition(Math.cos(angle-_angle) * x - Math.sin(angle-_angle) * y + px, Math.cos(angle-_angle) * y + Math.sin(angle-_angle) * x + py);
  1033. childNode.setRotation(angle);
  1034. }
  1035. this._rotation = angle;
  1036. return this;
  1037. },
  1038. getRotation: function () {
  1039. return this._rotation;
  1040. },
  1041. setScale: function (sx, sy) {
  1042. var that = this,
  1043. childNodes = this.childNodes,
  1044. childNode;
  1045. if (sx === undefined || sx === null) return ;
  1046. if (sy === undefined || sy === null) {
  1047. sy = sx;
  1048. }
  1049. for (var i = 0, len = childNodes.length; i < len; i++) {
  1050. childNode = childNodes[i];
  1051. if (typeof childNode.setScale === 'function') {
  1052. childNode.setScale(sx, sy);
  1053. }
  1054. }
  1055. },
  1056. getScale: function () {
  1057. return this._background.getScale();
  1058. },
  1059. setScaleX: function (sx) {
  1060. if (sx === undefined || sx === null) return;
  1061. var that = this,
  1062. childNodes = this.childNodes,
  1063. childNode;
  1064. for (var i = 0, len = childNodes.length; i < len; i++) {
  1065. childNode = childNodes[i];
  1066. if (typeof childNode.setScaleX === 'function') {
  1067. childNode.setScaleX(sx);
  1068. }
  1069. }
  1070. },
  1071. setScaleY: function (sy) {
  1072. if (sy === undefined || sy === null) return;
  1073. var that = this,
  1074. childNodes = this.childNodes,
  1075. childNode;
  1076. for (var i = 0, len = childNodes.length; i < len; i++) {
  1077. childNode = childNodes[i];
  1078. if (typeof childNode.setScaleY === 'function') {
  1079. childNode.setScaleY(sy);
  1080. }
  1081. }
  1082. },
  1083. getScaleX: function () {
  1084. return this._background.getScaleX();
  1085. },
  1086. getScaleY: function () {
  1087. return this._background.getScaleY();
  1088. },
  1089. evert: function () {
  1090. var that = this,
  1091. childNodes = this.childNodes,
  1092. background = this._background,
  1093. bp = background.getPosition(),
  1094. bx = bp.x,
  1095. by = bp.y,
  1096. childNode, distanceX, distanceY, x, y, p, nx, ny;
  1097. for (var i = 0, len = childNodes.length; i < len; i++) {
  1098. childNode = childNodes[i];
  1099. p = childNode.getPosition();
  1100. x = p.x;
  1101. y = p.y;
  1102. distanceX = bx - x;
  1103. distanceY = by - y;
  1104. nx = bx + distanceX;
  1105. ny = by + distanceY;
  1106. childNode.setPosition(nx, ny);
  1107. if (typeof childNode.setScale === 'function') {
  1108. if (!(childNode._disallowEvert === true))
  1109. childNode.setScale(-1, -1);
  1110. }
  1111. }
  1112. },
  1113. evertX: function () {
  1114. var that = this,
  1115. childNodes = this.childNodes,
  1116. background = this._background,
  1117. bx = background.getPosition().x,
  1118. childNode, distance, x, p, nx;
  1119. for (var i = 0, len = childNodes.length; i < len; i++) {
  1120. childNode = childNodes[i];
  1121. p = childNode.getPosition();
  1122. x = p.x;
  1123. distance = bx - x;
  1124. nx = bx + distance;
  1125. childNode.setPosition(nx, p.y);
  1126. if (typeof childNode.setScaleX === 'function') {
  1127. if (!(childNode._disallowEvert === true))
  1128. childNode.setScaleX(-1);
  1129. }
  1130. }
  1131. },
  1132. evertY: function () {
  1133. var that = this,
  1134. childNodes = this.childNodes,
  1135. background = this._background,
  1136. by = background.getPosition().y,
  1137. childNode, distance, y, p, ny;
  1138. for (var i = 0, len = childNodes.length; i < len; i++) {
  1139. childNode = childNodes[i];
  1140. p = childNode.getPosition();
  1141. y = p.y;
  1142. distance = by - y;
  1143. ny = by + distance;
  1144. childNode.setPosition(p.x, ny);
  1145. if (typeof childNode.setScaleY === 'function') {
  1146. if (!(childNode._disallowEvert === true))
  1147. childNode.setScaleY(-1);
  1148. }
  1149. }
  1150. },
  1151. attr: function (key, value) {
  1152. var _attrObj = this._attrObj || {};
  1153. if (arguments.length === 1) {
  1154. return _attrObj[key];
  1155. }
  1156. var childNodes = this.childNodes, childNode;
  1157. _attrObj[key] = value;
  1158. for (var i = 0; childNode = childNodes[i++];) {
  1159. if (typeof childNode.a === 'function') {
  1160. childNode.a(key, value);
  1161. }
  1162. }
  1163. },
  1164. a: function () {
  1165. return this.attr.apply(this, arguments);
  1166. }
  1167. });
  1168. }