手车.js 49 KB

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