接地.js 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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 = 15.05267*_ratio.ratioX;
  11. this._originHeight = 13.66693*_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=[4, 12,10, 12],
  36. Lib_接地Node0_0rect=ht.Default.unionPoint([{x:4,y:12},{x:10,y:12}]),
  37. Lib_接地Node0_0compspts=[];
  38. _ratio = GD.getRatioWithRotation(0, ratio);
  39. var _startratio = GD.getRatioWithRotation(3.14159265358979, ratio),
  40. _endratio = GD.getRatioWithRotation(0, 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(255,0,255,1)');
  78. Lib_接地Node0_0.a('node.borderPattern',getDashStyle("@borderPattern@"));
  79. Lib_接地Node0_0.a('node.borderColor','rgba(255,0,255,1)');
  80. Lib_接地Node0_0.a('node.background','rgba(255,0,255,1)');
  81. Lib_接地Node0_0.a('node.gradient','');
  82. Lib_接地Node0_0.a('node.gradientcolor','rgba(255,0,255,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=[2, 9,12, 9],
  144. Lib_接地Node0_1rect=ht.Default.unionPoint([{x:2,y:9},{x:12,y:9}]),
  145. Lib_接地Node0_1compspts=[];
  146. _ratio = GD.getRatioWithRotation(0, ratio);
  147. var _startratio = GD.getRatioWithRotation(3.14159265358979, ratio),
  148. _endratio = GD.getRatioWithRotation(0, 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(255,0,255,1)');
  186. Lib_接地Node0_1.a('node.borderPattern',getDashStyle("@borderPattern@"));
  187. Lib_接地Node0_1.a('node.borderColor','rgba(255,0,255,1)');
  188. Lib_接地Node0_1.a('node.background','rgba(255,0,255,1)');
  189. Lib_接地Node0_1.a('node.gradient','');
  190. Lib_接地Node0_1.a('node.gradientcolor','rgba(255,0,255,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=[0, 6,15, 6],
  252. Lib_接地Node0_2rect=ht.Default.unionPoint([{x:0,y:6},{x:15,y:6}]),
  253. Lib_接地Node0_2compspts=[];
  254. _ratio = GD.getRatioWithRotation(0, ratio);
  255. var _startratio = GD.getRatioWithRotation(3.14159265358979, ratio),
  256. _endratio = GD.getRatioWithRotation(0, 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(255,0,255,1)');
  294. Lib_接地Node0_2.a('node.borderPattern',getDashStyle("@borderPattern@"));
  295. Lib_接地Node0_2.a('node.borderColor','rgba(255,0,255,1)');
  296. Lib_接地Node0_2.a('node.background','rgba(255,0,255,1)');
  297. Lib_接地Node0_2.a('node.gradient','');
  298. Lib_接地Node0_2.a('node.gradientcolor','rgba(255,0,255,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=[7, 6,7, 0],
  360. Lib_接地Node0_3rect=ht.Default.unionPoint([{x:7,y:6},{x:7,y:0}]),
  361. Lib_接地Node0_3compspts=[];
  362. _ratio = GD.getRatioWithRotation(0, ratio);
  363. var _startratio = GD.getRatioWithRotation(1.5707963267949, ratio),
  364. _endratio = GD.getRatioWithRotation(4.71238898038469, 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(255,0,255,1)');
  402. Lib_接地Node0_3.a('node.borderPattern',getDashStyle("@borderPattern@"));
  403. Lib_接地Node0_3.a('node.borderColor','rgba(255,0,255,1)');
  404. Lib_接地Node0_3.a('node.background','rgba(255,0,255,1)');
  405. Lib_接地Node0_3.a('node.gradient','');
  406. Lib_接地Node0_3.a('node.gradientcolor','rgba(255,0,255,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. /*@GraphList@*/
  468. /*@PageInit@*/
  469. var localVarObj = this.localVarObj;
  470. var localDynamicVarObj = this.localDynamicVar();
  471. this['Lib_接地Node0_0'] = Lib_接地Node0_0;
  472. Lib_接地Node0_0.__parentLib = nodename;
  473. Lib_接地Node0_0.__parent = this;
  474. this.childNodes.push(Lib_接地Node0_0);
  475. this['Lib_接地Node0_1'] = Lib_接地Node0_1;
  476. Lib_接地Node0_1.__parentLib = nodename;
  477. Lib_接地Node0_1.__parent = this;
  478. this.childNodes.push(Lib_接地Node0_1);
  479. this['Lib_接地Node0_2'] = Lib_接地Node0_2;
  480. Lib_接地Node0_2.__parentLib = nodename;
  481. Lib_接地Node0_2.__parent = this;
  482. this.childNodes.push(Lib_接地Node0_2);
  483. this['Lib_接地Node0_3'] = Lib_接地Node0_3;
  484. Lib_接地Node0_3.__parentLib = nodename;
  485. Lib_接地Node0_3.__parent = this;
  486. this.childNodes.push(Lib_接地Node0_3);
  487. /*@ControlContextMenu@*/
  488. /*@Declare@*/
  489. this.init(x, y, width, height, angle);
  490. };
  491. ht.Default.def('ht.lib.接地', Object, {
  492. refresh10ms: function () {
  493. var localVarObj = this.localVarObj;
  494. var localDynamicVarObj = this.localDynamicVar();
  495. var Lib_接地Node0_0= this.Lib_接地Node0_0;
  496. var Lib_接地Node0_1= this.Lib_接地Node0_1;
  497. var Lib_接地Node0_2= this.Lib_接地Node0_2;
  498. var Lib_接地Node0_3= this.Lib_接地Node0_3;
  499. /*@refresh10ms@*/
  500. },
  501. refresh100ms: function () {
  502. var localVarObj = this.localVarObj;
  503. var localDynamicVarObj = this.localDynamicVar();
  504. var Lib_接地Node0_0= this.Lib_接地Node0_0;
  505. var Lib_接地Node0_1= this.Lib_接地Node0_1;
  506. var Lib_接地Node0_2= this.Lib_接地Node0_2;
  507. var Lib_接地Node0_3= this.Lib_接地Node0_3;
  508. /*@refresh100ms@*/
  509. },
  510. refresh500ms: function () {
  511. var localVarObj = this.localVarObj;
  512. var localDynamicVarObj = this.localDynamicVar();
  513. var Lib_接地Node0_0= this.Lib_接地Node0_0;
  514. var Lib_接地Node0_1= this.Lib_接地Node0_1;
  515. var Lib_接地Node0_2= this.Lib_接地Node0_2;
  516. var Lib_接地Node0_3= this.Lib_接地Node0_3;
  517. /*@refresh500ms@*/
  518. },
  519. refresh1s: function () {
  520. var Counter1s = arguments[0] || 0;
  521. var localVarObj = this.localVarObj;
  522. var localDynamicVarObj = this.localDynamicVar();
  523. var Lib_接地Node0_0= this.Lib_接地Node0_0;
  524. var Lib_接地Node0_1= this.Lib_接地Node0_1;
  525. var Lib_接地Node0_2= this.Lib_接地Node0_2;
  526. var Lib_接地Node0_3= this.Lib_接地Node0_3;
  527. /*@refresh1s@*/
  528. },
  529. refresh5s: function () {
  530. var localVarObj = this.localVarObj;
  531. var localDynamicVarObj = this.localDynamicVar();
  532. var Lib_接地Node0_0= this.Lib_接地Node0_0;
  533. var Lib_接地Node0_1= this.Lib_接地Node0_1;
  534. var Lib_接地Node0_2= this.Lib_接地Node0_2;
  535. var Lib_接地Node0_3= this.Lib_接地Node0_3;
  536. /*@refresh5s@*/
  537. },
  538. /*@PageDynamic@*/
  539. onEvent: function (e, data, type, origin, offset, objMouseOn, ctm) {
  540. var localVarObj = this.localVarObj;
  541. var localDynamicVarObj = this.localDynamicVar();
  542. var Lib_接地Node0_0= this.Lib_接地Node0_0;
  543. var Lib_接地Node0_1= this.Lib_接地Node0_1;
  544. var Lib_接地Node0_2= this.Lib_接地Node0_2;
  545. var Lib_接地Node0_3= this.Lib_接地Node0_3;
  546. if (type === 'click') {
  547. /*@EvnentClicked@*/
  548. } else if (type === 'mousedown') {
  549. mouseX=e.clientX;
  550. mouseY=e.clientY;
  551. /*@EvnentMouseDown@*/
  552. } else if (type === 'mouseup') {
  553. /*@EvnentMouseUp@*/
  554. } else if (type === 'mousemove') {
  555. var mouseX, mouseY, position, zoom;
  556. position=origin.getLogicalPoint(e);
  557. zoom = graphView.getZoom();
  558. if (origin === graphView) {
  559. mouseX= position.x + origin.tx();
  560. mouseY = position.y + origin.ty();
  561. } else {
  562. offset = offset || {x: 0, y: 0};
  563. mouseX = position.x / zoom + offset.x + origin.tx();
  564. mouseY = position.y / zoom + offset.y + origin.ty();
  565. }
  566. /*@EvnentMouseLeave@*/
  567. /*@EvnentMouseOver@*/
  568. } else if (type === 'keydown') {
  569. /*@EvnentKeyDown@*/
  570. } else if (type === 'contextmenu') {
  571. /*@Declare@*/
  572. /*@SetNodeContextMenu@*/
  573. /*@SetPageContextMenu@*/
  574. }
  575. /*@LibEvent@*/
  576. },
  577. getBaseClass: function () {
  578. return this._baseClass;
  579. },
  580. getWidth: function () {
  581. return this._width;
  582. },
  583. getHeight: function () {
  584. return this._height;
  585. },
  586. getSize: function () {
  587. return {
  588. width: this._width,
  589. height: this._height
  590. }
  591. },
  592. setWidth: function (width) {
  593. if (width === undefined || width === null || width != width) {
  594. return ;
  595. }
  596. var originWidth = this._width;
  597. var ratio = width / originWidth;
  598. var childNodes = this.childNodes, childNode, p, op = this.getPosition(), w, cw, ox, rotation = this.getRotation();
  599. for (var i = 0, len = childNodes.length; i < len; i++) {
  600. childNode = childNodes[i];
  601. p = childNode.getPosition();
  602. cw = childNode.getWidth();
  603. w = cw >=2 ? cw * ratio : cw;
  604. childNode.setWidth(w);
  605. ox = op.x + (p.x - op.x) * ratio;
  606. childNode.setPosition(ox, p.y);
  607. rotation = GD.calcRotation(rotation);
  608. if (rotation === 0 || rotation === Math.PI) {
  609. // 图元未旋转
  610. ox = op.x + (p.x - op.x)*ratio;
  611. childNode.setPosition(ox, p.y);
  612. } else if (rotation === 90 * Math.PI / 180) {
  613. // 图元旋转以后
  614. ox = op.y + (p.y - op.y)*ratio;
  615. childNode.setPosition(p.x, ox);
  616. }
  617. }
  618. this._width = width;
  619. this._originWidth = width;
  620. this._ratioX = ratio;
  621. return this;
  622. },
  623. setHeight: function (height) {
  624. if (height === undefined || height === null || height != height) {
  625. return ;
  626. }
  627. var originHeight = this._height;
  628. var ratio = height / originHeight;
  629. var childNodes = this.childNodes, childNode, p, op = this.getPosition(), h, ch, oy, rotation = this.getRotation();
  630. for (var i = 0, len = childNodes.length; i < len; i++) {
  631. childNode = childNodes[i];
  632. p = childNode.getPosition();
  633. ch = childNode.getHeight();
  634. h = ch >=2 ? ch * ratio : ch;
  635. childNode.setHeight(h);
  636. rotation = GD.calcRotation(rotation);
  637. if (rotation === 0 || rotation === Math.PI) {
  638. // 图元未旋转
  639. oy = op.y + (p.y - op.y)*ratio;
  640. childNode.setPosition(p.x, oy);
  641. } else if (rotation === 90 * Math.PI / 180) {
  642. // 图元旋转以后
  643. oy = op.x + (p.x - op.x)*ratio;
  644. childNode.setPosition(oy, p.y);
  645. }
  646. }
  647. this._height = height;
  648. this._originHeight = height;
  649. this._ratioY = ratio;
  650. return this;
  651. },
  652. setSize: function (size) {
  653. // var args = Array.prototype.slice.call(arguments, 0);
  654. // var height, width;
  655. // if (args.length === 0) {
  656. // return ;
  657. // }else if (args.length === 1) {
  658. // height = args[0].height;
  659. // width = args[0].width;
  660. // } else {
  661. // width = args[0];
  662. // height = args[1];
  663. // }
  664. // var wh = GD.getRatioWithRotation(angle, wid)
  665. // this.setHeight(height);
  666. // this.setWidth(width);
  667. // return this;
  668. var args = Array.prototype.slice.call(arguments, 0);
  669. var height, width;
  670. if (args.length === 0) {
  671. return ;
  672. }else if (args.length === 1) {
  673. height = args[0].height;
  674. width = args[0].width;
  675. angle = 0;
  676. } else if (args.length === 2) {
  677. if (typeof args[0] === 'object') {
  678. width = args[0].width;
  679. height = args[0].height;
  680. angle = args[1] || 0;
  681. } else {
  682. width = args[0];
  683. height = args[1];
  684. angle = 0;
  685. }
  686. } else if (args.length === 3) {
  687. width = args[0];
  688. height = args[1];
  689. angle = args[2] || 0;
  690. }
  691. var wh = GD.getRatioWithRotation(0, width, height);
  692. this.setHeight(wh.ratioY);
  693. this.setWidth(wh.ratioX);
  694. return this;
  695. },
  696. getPosition: function () {
  697. return {
  698. x: this._x,
  699. y: this._y
  700. }
  701. },
  702. setPosition: function () {
  703. var args = Array.prototype.slice.call(arguments, 0), x, y;
  704. if (args.length === 0) {
  705. return this;
  706. } else if (args.length === 1) {
  707. if (typeof args[0] != 'object') {
  708. return this;
  709. }
  710. x = args[0].x;
  711. y = args[0].y;
  712. } else {
  713. x = args[0];
  714. y = args[1];
  715. }
  716. if ((x !== 0 && !x) || (y !== 0 && !y)) {
  717. return this;
  718. }
  719. // var childNodes = this.childNodes, offset, childNode, p;
  720. // for (var i = 0, len = childNodes.length; i < len; i++) {
  721. // childNode = childNodes[i];
  722. // p = childNode.getPosition();
  723. // childNode.setPosition(x - (this._x-p.x)*this._ratioX, y - (this._y-p.y)*this._ratioY);
  724. // }
  725. // this._x = x;
  726. // this._y = y;
  727. // return this;
  728. var childNodes, childNode, background, offset = {}, op, cp;
  729. childNodes = this.childNodes;
  730. background = this._background;
  731. op = background.getPosition();
  732. offset.x = x - op.x;
  733. offset.y = y - op.y;
  734. for (var i = 0, len = childNodes.length; i < len; i++) {
  735. childNode = childNodes[i];
  736. cp = childNode.getPosition();
  737. childNode.setPosition(cp.x + offset.x, cp.y + offset.y);
  738. }
  739. this._x = x;
  740. this._y = y;
  741. this._position = {x: x, y: y};
  742. return this;
  743. },
  744. getStyle: function (key) {
  745. if (!key) {
  746. return undefined;
  747. }
  748. return this._styleObject[key];
  749. },
  750. setStyle: function (key, value, force) {
  751. var childNodes = this.childNodes, childNode;
  752. for (var i = 0, len = childNodes.length; i < len; i++) {
  753. childNode = childNodes[i];
  754. if (key === '2d.visible') {
  755. if (value === graphView.isVisible(childNode)) {
  756. continue;
  757. }
  758. if (!value) {
  759. childNode._savedIsVisible = graphView.isVisible(childNode);
  760. childNode.s({
  761. '2d.visible': false
  762. })
  763. } else {
  764. childNode.s({
  765. '2d.visible': childNode._savedIsVisible
  766. })
  767. }
  768. continue;
  769. }
  770. childNode.s({
  771. key: value
  772. });
  773. }
  774. this._styleObject[key] = value;
  775. return this;
  776. },
  777. calcSize: function () {
  778. var background = this._background;
  779. var position = background.getPosition(),
  780. width = background.getWidth(),
  781. height = background.getHeight();
  782. this._width = width;
  783. this._height = height;
  784. this._x = position.x;
  785. this._y = position.y;
  786. this._position = {
  787. x: this._x,
  788. y: this._y
  789. }
  790. return this;
  791. return this;
  792. },
  793. s: function (styleObj, force) {
  794. var args = Array.prototype.slice.call(arguments, 0);
  795. var styleObj;
  796. if (args.length === 0) {
  797. return this;
  798. } else if (args.length === 1) {
  799. styleObj = args[0];
  800. } else {
  801. this.setStyle(args[0], args[1]);
  802. return this;
  803. }
  804. for (var key in styleObj) {
  805. if (!styleObj.hasOwnProperty(key)) {
  806. continue;
  807. }
  808. this.setStyle(key, styleObj[key], force);
  809. }
  810. return this;
  811. },
  812. init: function (x, y, width, height, angle) {
  813. var that = this;
  814. this.calcSize();
  815. (function (width, height, angle) {
  816. // that.setSize(width, height, angle);
  817. // var wh = GD.getRatioWithRotation(angle, width, height);
  818. // width = wh.ratioX;
  819. // height = wh.ratioY;
  820. var originHeight = that._height;
  821. var originWidth = that._width;
  822. var ratioY = height / originHeight;
  823. var ratioX = width / originWidth;
  824. var childNodes = that.childNodes,
  825. childNode,p, op = that.getPosition(), h, ch, oy, w, cw, ox, name, borderRatio, borderWidth;
  826. for (var i = 0, len = childNodes.length; i < len; i++) {
  827. childNode = childNodes[i];
  828. p = childNode.getPosition();
  829. childNode.originHeight = childNode.originHeight || childNode.getHeight();
  830. ch = childNode.getHeight();
  831. cw = childNode.getWidth();
  832. if (ch > 2) {
  833. h = ch * ratioY;
  834. childNode.setHeight(h);
  835. }
  836. if (cw > 2) {
  837. w = cw * ratioX;
  838. childNode.setWidth(w);
  839. }
  840. borderRatio = (ratioX + ratioY)*0.5;
  841. if (childNode._nodeType === 'line') { // 如果是线,
  842. if (childNode.getWidth() > childNode.getHeight()) {
  843. borderRatio = ratioX;
  844. } else {
  845. borderRatio = ratioY;
  846. }
  847. }
  848. name = childNode._nodename;
  849. // if (childNode.borderWidth && name && ch > 2 && cw > 2) {
  850. // borderWidth = childNode.borderWidth / borderRatio;
  851. // if (borderWidth > ch*0.5 || borderWidth > cw *0.5) {
  852. // // borderWidth = childNode.borderWidth;
  853. // }
  854. // childNode.borderWidth = borderWidth;
  855. // childNode.a(name + '.borderwidth', borderWidth);
  856. // }
  857. }
  858. that._height = height;
  859. that._originHeight = height;
  860. that._ratioY = ratioY;
  861. that._width = width;
  862. that._originWidth = width;
  863. that._ratioX = ratioX;
  864. })(width, height, angle);
  865. that._x = width / 2;
  866. that._y = height / 2;
  867. that._rotation = 0;
  868. // that.setPosition(x, y);
  869. (function (x, y) {
  870. var childNodes = that.childNodes, offset, childNode;
  871. var w2 = that.getWidth() / 2, h2 = that.getHeight()/2;
  872. for (var i = 0, len = childNodes.length; i < len; i++) {
  873. childNode = childNodes[i];
  874. offset = childNode.getPosition();
  875. childNode.setPosition(x + offset.x * that._ratioX - w2, y + offset.y * that._ratioY - h2);
  876. }
  877. that._x = x;
  878. that._y = y;
  879. })(x, y);
  880. // setTimeout(that.addEVent, 1000);
  881. },
  882. setRotation: function (angle) {
  883. var that = this, _angle = that.getRotation();
  884. if (angle!==0 && !angle || angle === _angle) {
  885. return this;
  886. }
  887. var childNodes = this.childNodes, childNode, p = this.getPosition(), px = p.x, py = p.y;
  888. for (var i = 0, len = childNodes.length; i < len; i++) {
  889. childNode = childNodes[i];
  890. var x = childNode.getPosition().x - px;
  891. var y = childNode.getPosition().y - py;
  892. childNode.setPosition(Math.cos(angle-_angle) * x - Math.sin(angle-_angle) * y + px, Math.cos(angle-_angle) * y + Math.sin(angle-_angle) * x + py);
  893. childNode.setRotation(angle);
  894. }
  895. this._rotation = angle;
  896. return this;
  897. },
  898. getRotation: function () {
  899. return this._rotation;
  900. },
  901. setScale: function (sx, sy) {
  902. var that = this,
  903. childNodes = this.childNodes,
  904. childNode;
  905. if (sx === undefined || sx === null) return ;
  906. if (sy === undefined || sy === null) {
  907. sy = sx;
  908. }
  909. for (var i = 0, len = childNodes.length; i < len; i++) {
  910. childNode = childNodes[i];
  911. if (typeof childNode.setScale === 'function') {
  912. childNode.setScale(sx, sy);
  913. }
  914. }
  915. },
  916. getScale: function () {
  917. return this._background.getScale();
  918. },
  919. setScaleX: function (sx) {
  920. if (sx === undefined || sx === null) return;
  921. var that = this,
  922. childNodes = this.childNodes,
  923. childNode;
  924. for (var i = 0, len = childNodes.length; i < len; i++) {
  925. childNode = childNodes[i];
  926. if (typeof childNode.setScaleX === 'function') {
  927. childNode.setScaleX(sx);
  928. }
  929. }
  930. },
  931. setScaleY: function (sy) {
  932. if (sy === undefined || sy === null) return;
  933. var that = this,
  934. childNodes = this.childNodes,
  935. childNode;
  936. for (var i = 0, len = childNodes.length; i < len; i++) {
  937. childNode = childNodes[i];
  938. if (typeof childNode.setScaleY === 'function') {
  939. childNode.setScaleY(sy);
  940. }
  941. }
  942. },
  943. getScaleX: function () {
  944. return this._background.getScaleX();
  945. },
  946. getScaleY: function () {
  947. return this._background.getScaleY();
  948. },
  949. evert: function () {
  950. var that = this,
  951. childNodes = this.childNodes,
  952. background = this._background,
  953. bp = background.getPosition(),
  954. bx = bp.x,
  955. by = bp.y,
  956. childNode, distanceX, distanceY, x, y, p, nx, ny;
  957. for (var i = 0, len = childNodes.length; i < len; i++) {
  958. childNode = childNodes[i];
  959. p = childNode.getPosition();
  960. x = p.x;
  961. y = p.y;
  962. distanceX = bx - x;
  963. distanceY = by - y;
  964. nx = bx + distanceX;
  965. ny = by + distanceY;
  966. childNode.setPosition(nx, ny);
  967. if (typeof childNode.setScale === 'function') {
  968. if (!(childNode._disallowEvert === true))
  969. childNode.setScale(-1, -1);
  970. }
  971. }
  972. },
  973. evertX: function () {
  974. var that = this,
  975. childNodes = this.childNodes,
  976. background = this._background,
  977. bx = background.getPosition().x,
  978. childNode, distance, x, p, nx;
  979. for (var i = 0, len = childNodes.length; i < len; i++) {
  980. childNode = childNodes[i];
  981. p = childNode.getPosition();
  982. x = p.x;
  983. distance = bx - x;
  984. nx = bx + distance;
  985. childNode.setPosition(nx, p.y);
  986. if (typeof childNode.setScaleX === 'function') {
  987. if (!(childNode._disallowEvert === true))
  988. childNode.setScaleX(-1);
  989. }
  990. }
  991. },
  992. evertY: function () {
  993. var that = this,
  994. childNodes = this.childNodes,
  995. background = this._background,
  996. by = background.getPosition().y,
  997. childNode, distance, y, p, ny;
  998. for (var i = 0, len = childNodes.length; i < len; i++) {
  999. childNode = childNodes[i];
  1000. p = childNode.getPosition();
  1001. y = p.y;
  1002. distance = by - y;
  1003. ny = by + distance;
  1004. childNode.setPosition(p.x, ny);
  1005. if (typeof childNode.setScaleY === 'function') {
  1006. if (!(childNode._disallowEvert === true))
  1007. childNode.setScaleY(-1);
  1008. }
  1009. }
  1010. },
  1011. attr: function (key, value) {
  1012. var _attrObj = this._attrObj || {};
  1013. if (arguments.length === 1) {
  1014. return _attrObj[key];
  1015. }
  1016. var childNodes = this.childNodes, childNode;
  1017. _attrObj[key] = value;
  1018. for (var i = 0; childNode = childNodes[i++];) {
  1019. if (typeof childNode.a === 'function') {
  1020. childNode.a(key, value);
  1021. }
  1022. }
  1023. },
  1024. a: function () {
  1025. return this.attr.apply(this, arguments);
  1026. }
  1027. });
  1028. }