黄色箭头.js 49 KB

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