ss.js 39 KB

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