as.js 44 KB

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