Mercurial > laserkard
comparison onlypaths/js/vmlrenderer_mini.js @ 46:26c2b3ad21c7 laserkard
[svn r47] saving progresswww.cinemassacre.com/new/?page_id=30
author | rlm |
---|---|
date | Sun, 31 Jan 2010 12:33:33 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
45:bff96abdddfa | 46:26c2b3ad21c7 |
---|---|
1 /*---------------------------------------------------------------------------- | |
2 VMLRENDERER 1.0 | |
3 VML Renderer For RichDraw | |
4 ----------------------------------------------------------------------------- | |
5 Created by Mark Finkle (mark.finkle@gmail.com) | |
6 Implementation of VML based renderer. | |
7 ----------------------------------------------------------------------------- | |
8 Copyright (c) 2006 Mark Finkle | |
9 | |
10 This program is free software; you can redistribute it and/or modify it | |
11 under the terms of the MIT License. | |
12 | |
13 Permission is hereby granted, free of charge, to any person obtaining a | |
14 copy of this software and associated documentation files (the "Software"), | |
15 to deal in the Software without restriction, including without limitation | |
16 the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
17 and/or sell copies of the Software, and to permit persons to whom the | |
18 Software is furnished to do so, subject to the following conditions: | |
19 The above copyright notice and this permission notice shall be included in | |
20 all copies or substantial portions of the Software. | |
21 | |
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
27 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
28 DEALINGS IN THE SOFTWARE. | |
29 ----------------------------------------------------------------------------- | |
30 Dependencies: | |
31 History: | |
32 2006-04-05 | Created | |
33 --------------------------------------------------------------------------*/ | |
34 | |
35 | |
36 | |
37 function VMLRenderer() { | |
38 this.base = AbstractRenderer; | |
39 } | |
40 | |
41 | |
42 VMLRenderer.prototype = new AbstractRenderer; | |
43 | |
44 | |
45 VMLRenderer.prototype.init = function(elem) | |
46 { | |
47 this.container = elem; | |
48 // this.container.style.overflow = 'hidden'; | |
49 this.container.unselectable = "on"; | |
50 // Add VML includes and namespace | |
51 elem.ownerDocument.namespaces.add("v", "urn:schemas-microsoft-com:vml"); | |
52 var style = elem.ownerDocument.createStyleSheet(); | |
53 style.addRule('v\\:*', "behavior: url(#default#VML); display:inline-block"); | |
54 //NOT VML biewBox | |
55 //http://blogs.msdn.com/ie/archive/2008/03/18/webbrowser-control-rendering-modes-in-ie8.aspx | |
56 } | |
57 | |
58 VMLRenderer.prototype.view = function(left,top,width,height,viewBox) { | |
59 if(mode=='preview') | |
60 { | |
61 | |
62 var tokens = viewBox.split(' '); | |
63 var prx=100; | |
64 this.container.style.top =(parseInt(document.getElementById('FRONT').style.height)-height)/2+'px' | |
65 this.container.style.left =(parseInt(document.getElementById('FRONT').style.width)-width)/2+'px' | |
66 | |
67 this.container.style.width = width;//document.getElementById('FRONT').style.width; | |
68 this.container.style.height =height;//document.getElementById('FRONT').style.height; | |
69 | |
70 | |
71 canvasLeft = left; | |
72 canvasTop = top; | |
73 canvasWidth = width; | |
74 canvasHeight = height; | |
75 zoominit = viewBox; | |
76 zoominit1 = viewBox; | |
77 zoominit2 = viewBox; | |
78 var tokens = zoominit.split(' '); | |
79 proporx = width/tokens[2]; | |
80 propory = height/tokens[3]; | |
81 /* var x=parseFloat(tokens[0])-prx; | |
82 var y=parseFloat(tokens[1])-prx; | |
83 var w=parseFloat(tokens[2])+prx; | |
84 var h=parseFloat(tokens[3])+prx; | |
85 workspace= x+''+y+''+w+''+h; | |
86 //zoominit = workspace; | |
87 */ | |
88 //VMLviewBox('',left,top,width,height) | |
89 } | |
90 else | |
91 { | |
92 | |
93 // | |
94 this.container.style.top =0+'px'; | |
95 | |
96 var tokens = viewBox.split(' '); | |
97 proporImage= (parseFloat(tokens[2])-parseFloat(tokens[0]))/(parseFloat(tokens[3])-parseFloat(tokens[1])); | |
98 var marginx=(parseInt(document.getElementById('FRONT').style.width)-(parseFloat(tokens[2])-parseFloat(tokens[0])))/2; | |
99 var marginy=(parseInt(document.getElementById('FRONT').style.height)-(parseFloat(tokens[3])-parseFloat(tokens[1])))/2; | |
100 var x=(parseFloat(tokens[0])-marginx); | |
101 var y=(parseFloat(tokens[1])-marginy); | |
102 var w=(parseFloat(tokens[2])+marginx*2); | |
103 var h=(parseFloat(tokens[3])+marginy*2); | |
104 //alert(tokens[3]+' '+tokens[1]+' / '+(parseFloat(tokens[3])-parseFloat(tokens[1]))+' '+parseInt(document.getElementById('FRONT').style.height)+' /'+h+' '+height); | |
105 //if(h>=parseInt(document.getElementById('FRONT').style.height)){h=parseInt(document.getElementById('FRONT').style.height);} | |
106 //if(h>=parseInt(document.getElementById('FRONT').style.height)){y=0;h=600;}//parseInt(document.getElementById('FRONT').style.height)*2} | |
107 //zoominit = x+' '+y+' '+w+' '+h; | |
108 canvasLeft = 0; | |
109 canvasTop = 0; | |
110 canvasWidth = w; | |
111 canvasHeight = h; | |
112 //proporx = w/tokens[2]; | |
113 //propory = h/tokens[3]; | |
114 | |
115 this.container.style.left =canvasLeft+'px' | |
116 this.container.style.top =canvasTop+'px' | |
117 | |
118 this.container.style.width = canvasWidth;//document.getElementById('FRONT').style.width; | |
119 this.container.style.height =canvasHeight;//document.getElementById('FRONT').style.height; | |
120 zoominit1 = canvasLeft+' '+canvasTop+' '+canvasWidth+' '+canvasHeight; | |
121 zoominit2= x+' '+y+' '+w+' '+h; | |
122 //VMLviewBox('',x,canvasTop,w,h) | |
123 //this.rectCanvas(x,y,w,h,zoominit) | |
124 // this.rectCanvas(x,y,canvasWidth,canvasHeight,zoominit2) | |
125 // zoominit = viewBox; | |
126 } | |
127 } | |
128 | |
129 VMLRenderer.prototype.zoomFrame = function(zoom){ | |
130 myOPF.viewBox=zoom; | |
131 load(myOPF,c); | |
132 document.getElementById("source").value=myOPF.toJSONString(); | |
133 } | |
134 VMLRenderer.prototype.rectDoc = function(viewBox) { | |
135 var tokens2 = zoominit2.split(' '); | |
136 var tokens = zoominit.split(' '); | |
137 var shape = document.getElementById('rectDoc'); | |
138 if (shape) { | |
139 this.remove(shape); | |
140 } | |
141 var rect=this.container.ownerDocument.createElement('v:rect'); | |
142 rect.id='rectDoc'; | |
143 rect.style.position = 'absolute'; | |
144 rect.style.left =-parseInt(tokens2[0]); | |
145 rect.style.top = -parseInt(tokens2[1]); | |
146 rect.style.width = parseInt(tokens[2]); | |
147 rect.style.height = parseInt(tokens[3]); | |
148 rect.setAttribute('filled', 'false'); | |
149 rect.setAttribute('stroked', 'true'); | |
150 rect.setAttribute('strokeweight', 2); | |
151 rect.setAttribute('strokecolor',"#ff0000"); | |
152 this.container.appendChild(rect); | |
153 //this.container.insertBefore(rect, this.container.firstChild ); | |
154 //alert(docx+' '+docy+' '+docw+' '+doch+' '+viewBox) | |
155 } | |
156 VMLRenderer.prototype.rectCanvas = function(docx,docy,docw,doch,viewBox) { | |
157 | |
158 var tokens = zoominit1.split(' '); | |
159 var shape = document.getElementById('rectCanvas'); | |
160 if (shape) { | |
161 this.remove(shape); | |
162 } | |
163 | |
164 var rect=this.container.ownerDocument.createElement('v:rect'); | |
165 rect.id='rectBackground'; | |
166 rect.style.position = 'absolute'; | |
167 rect.style.left = tokens[0] ; | |
168 rect.style.top =tokens[1]; | |
169 rect.style.width=tokens[2]; | |
170 rect.style.height= tokens[3] ; | |
171 rect.setAttribute('filled', 'true'); | |
172 rect.setAttribute('fillcolor',"#666666"); | |
173 rect.setAttribute('stroked', 'false'); | |
174 | |
175 this.container.insertBefore(rect, this.container.firstChild ); | |
176 | |
177 } | |
178 | |
179 VMLRenderer.prototype.removeAll = function(){ | |
180 while (this.container.hasChildNodes()) { | |
181 this.container.removeChild(this.container.firstChild); | |
182 } | |
183 } | |
184 | |
185 function VMLviewBox(container,left,top,width,height){ | |
186 var tokens = zoominit2.split(' '); | |
187 left *= proporx; | |
188 left = left - parseFloat(tokens[0]); | |
189 top *= propory; | |
190 top = top - parseFloat(tokens[1]); | |
191 width *= proporx; | |
192 height *= propory; | |
193 | |
194 return {"x":parseFloat(Math.round(left)), "y":parseFloat(Math.round(top)), "w":parseFloat(Math.round(width)), "h":parseFloat(Math.round(height))}; | |
195 } | |
196 function VMLviewBox1(container,left,top,width,height){ | |
197 var tokens = zoominit2.split(' '); | |
198 left *= proporx; | |
199 left = left - parseFloat(tokens[0]); | |
200 top *= propory; | |
201 top = top - parseFloat(tokens[1]); | |
202 width *= proporx; | |
203 height *= propory; | |
204 | |
205 return {"x":parseFloat(Math.round(left)), "y":parseFloat(Math.round(top)), "w":parseFloat(Math.round(width)), "h":parseFloat(Math.round(height))}; | |
206 } | |
207 | |
208 VMLRenderer.prototype.create = function(shape, fillColor, lineColor, fillOpac, lineOpac, lineWidth, left, top, width, height, textMessaje, textSize, textFamily, imageHref, points, transform, parent) { | |
209 var tokens = zoominit2.split(' '); | |
210 var zoom=VMLviewBox(this.container,left,top,width,height); | |
211 left=zoom.x; | |
212 top=zoom.y; | |
213 width=zoom.w; | |
214 height=zoom.h; | |
215 | |
216 var zoom=VMLviewBox(this.container,left,top,textSize,textSize); | |
217 if(zoom.w<1){zoom.w=1} | |
218 textSize=zoom.h; | |
219 | |
220 var zoom=VMLviewBox(this.container,left,top,lineWidth*2/3,lineWidth); | |
221 if(zoom.w<1){zoom.w=1} | |
222 lineWidth=zoom.w; | |
223 | |
224 | |
225 var vml; | |
226 | |
227 var shap=1; | |
228 if (shape == 'rect') { | |
229 vml = this.container.ownerDocument.createElement('v:rect'); | |
230 vml.style.position = 'absolute'; | |
231 vml.style.left = left; | |
232 vml.style.top = top; | |
233 vml.style.width = width; | |
234 vml.style.height = height; | |
235 } | |
236 else if (shape == 'roundrect') { | |
237 vml = this.container.ownerDocument.createElement('v:roundrect'); | |
238 vml.style.position = 'absolute'; | |
239 vml.style.left = left; | |
240 vml.style.top = top; | |
241 vml.style.width = width; | |
242 vml.style.height = height; | |
243 vml.setAttribute('arcsize', '20%'); | |
244 | |
245 } | |
246 else if (shape == 'ellipse') { | |
247 vml = this.container.ownerDocument.createElement('v:oval'); | |
248 vml.style.left = left; | |
249 vml.style.top = top; | |
250 vml.style.width = width; | |
251 vml.style.height = height; | |
252 vml.style.position = 'absolute'; | |
253 } | |
254 else if (shape == 'line') { | |
255 vml = this.container.ownerDocument.createElement('v:line'); | |
256 vml.style.position = 'absolute'; | |
257 vml.setAttribute('from', left-80 + 'px,' + top + 'px'); | |
258 vml.setAttribute('to', (left-80+width) + 'px,' + (top+height) + 'px'); | |
259 | |
260 } | |
261 else if (shape == 'polyline') { | |
262 vml = this.container.ownerDocument.createElement('v:polyline'); | |
263 vml.setAttribute("points", points); | |
264 | |
265 } | |
266 else if (shape == 'path') | |
267 { | |
268 vml = this.container.ownerDocument.createElement('v:shape'); | |
269 var tokens = zoominit1.split(' '); | |
270 var tokens1 = zoominit1.split(' '); | |
271 var tokens2 = zoominit2.split(' '); | |
272 tokens[0]=0; | |
273 tokens[1]=0; | |
274 var path=points; | |
275 path=path.replace(/, /g, ','); | |
276 path=path.replace(/ ,/g, ','); | |
277 var ps =path.split(" ") | |
278 var pcc = ""; | |
279 | |
280 var re = /^[-]?\d*\.?\d*$/; | |
281 var contArc=0; | |
282 var isArc=false; | |
283 for(var i = 0; i < ps.length; i++) | |
284 { | |
285 if(ps[i].indexOf(',')>0){ | |
286 | |
287 var point =ps[i].split(","); | |
288 var char1=point[0].substring(0,1); | |
289 | |
290 if (!char1.match(re)) | |
291 { | |
292 var num0= parseFloat(point[0].substring(1)); | |
293 var zoom=VMLviewBox(this.container,num0+(parseInt(tokens2[0])*proporx),0,parseInt(tokens2[2]),parseInt(tokens2[3])); | |
294 num0=zoom.x; | |
295 | |
296 var text=char1; | |
297 }else{ | |
298 var num0= parseFloat(point[0]); | |
299 var zoom=VMLviewBox(this.container,num0+(parseInt(tokens2[0])*proporx),0,parseInt(tokens2[2]),parseInt(tokens2[3])); | |
300 num0=zoom.x; | |
301 | |
302 } | |
303 point[1]= parseFloat(point[1]); | |
304 var zoom=VMLviewBox(this.container,0,point[1],parseInt(tokens2[2]),parseInt(tokens2[3])); | |
305 point[1]=zoom.y; | |
306 var cx=num0; | |
307 var cy=point[1]+parseInt(tokens2[1]); | |
308 pcc+=text+cx+','+cy+' '; | |
309 } | |
310 else | |
311 { | |
312 pcc+=ps[i]+' '; | |
313 } | |
314 | |
315 } | |
316 //////////////////// | |
317 var thispath=pcc; | |
318 thispath=thispath.replace(/M/g,'m'); | |
319 thispath=thispath.replace(/C/g,'c'); | |
320 thispath=thispath.replace(/L/g,'l'); | |
321 thispath=thispath.replace(/z/g,'x'); | |
322 | |
323 //document.getElementById('source').value=points+'\r\n'+thispath +'\r\n'+'________'+'\r\n' | |
324 var zoom=VMLviewBox(this.container,tokens[0],tokens[1],tokens[2],tokens[3]); | |
325 | |
326 vml.style.position="absolute"; | |
327 vml.style.width= zoom.w+"px"; | |
328 vml.style.height=zoom.h+"px"; | |
329 vml.style.left=zoom.x+"px"; | |
330 vml.style.top=zoom.y+"px"; | |
331 vml.setAttribute('coordsize', zoom.w+','+zoom.h); | |
332 | |
333 var path01 = this.container.ownerDocument.createElement('v:path'); | |
334 path01.setAttribute("v", thispath+' e'); | |
335 | |
336 | |
337 | |
338 vml.appendChild(path01) | |
339 | |
340 } | |
341 | |
342 else if (shape == 'controlpath') | |
343 { | |
344 | |
345 vml = this.container.ownerDocument.createElement('v:shape'); | |
346 vml.style.position="absolute"; | |
347 vml.style.width= 700+"px"; | |
348 vml.style.height=500+"px"; | |
349 vml.style.left=left+"px"; | |
350 vml.style.top=top+"px"; | |
351 vml.setAttribute('coordsize', '700,500'); | |
352 | |
353 var path01 = this.container.ownerDocument.createElement('v:path'); | |
354 path01.setAttribute('v', 'm '+left+','+top+' c'+(left+1)+','+(top+1)+' e '); | |
355 | |
356 vml.appendChild(path01) | |
357 } | |
358 else if (shape == 'image') { | |
359 var data =imageHref;//document.forms[0].option_text_message.value; | |
360 vml = this.container.ownerDocument.createElement('v:image'); | |
361 vml.setAttribute('src',imageHref); | |
362 vml.style.position="absolute"; | |
363 vml.style.width=width+"px"; | |
364 vml.style.height=height+"px"; | |
365 vml.style.left=left+"px"; | |
366 vml.style.top=top+"px"; | |
367 vml.style.margin=0+"px"; | |
368 vml.style.padding=0+"px"; | |
369 if (fillColor != '' || fillColor != 'none') { | |
370 vml.setAttribute('filled', 'false'); | |
371 vml.setAttribute('fillcolor', fillColor); | |
372 } | |
373 else { | |
374 vml.setAttribute('filled', 'false'); | |
375 } | |
376 vml.setAttribute('strokeweight','0px');// parseFloat(lineWidth)+'px'); | |
377 vml.setAttribute('stroked', 'false'); | |
378 vml.setAttribute('strokecolor','#000000');//lineColor); | |
379 | |
380 | |
381 } | |
382 | |
383 else if (shape == 'text') | |
384 { | |
385 | |
386 var data =textMessaje; | |
387 vml = this.container.ownerDocument.createElement('v:shape'); | |
388 vml.style.position="absolute"; | |
389 //vml.setAttribute('coordorigin',left+', '+top); | |
390 //vml.style.coorsize= ''; | |
391 coordorigin="0, 0" | |
392 vml.style.width= textSize+'px';//tokens[2]+'px' | |
393 vml.style.height=textSize+'px'; | |
394 vml.style.left=(left+"px"); | |
395 vml.style.top=(top-(textSize*1/4)+"px"); | |
396 vml.style.margin=0+"px"; | |
397 vml.style.padding=0+"px"; | |
398 vml.setAttribute('path','m '+0+' '+0+' r '+(textSize*data.length)+' '+0+' e'); | |
399 var textPathObj = this.container.ownerDocument.createElement("v:textpath"); | |
400 textPathObj.setAttribute('string', data); | |
401 textPathObj.setAttribute('fitshape','false'); | |
402 textPathObj.setAttribute('trim', 'false'); | |
403 textPathObj.setAttribute('fitpath', 'false'); | |
404 textPathObj.setAttribute('on','true'); | |
405 textPathObj.style.fontFamily=textFamily; | |
406 textPathObj.style.fontSize=textSize+'px'; | |
407 textPathObj.setAttribute('vTextKern','true'); | |
408 textPathObj.setAttribute('text-align','center'); | |
409 | |
410 var pathObj = this.container.ownerDocument.createElement("v:path"); | |
411 pathObj.setAttribute('textpathok', 'true'); | |
412 vml.appendChild(textPathObj); | |
413 vml.appendChild(pathObj); | |
414 | |
415 | |
416 } | |
417 | |
418 | |
419 | |
420 else if (shape == 'texto') | |
421 { | |
422 vml = this.container.ownerDocument.createElement('v:shape'); | |
423 vml.style.position="absolute"; | |
424 | |
425 vml.style.coordsize=1000+', '+1000; | |
426 vml.style.width= 1000; | |
427 vml.style.height=1000; | |
428 vml.style.left=left; | |
429 vml.style.top=top-parseFloat(textSize); | |
430 | |
431 vml.style.padding=0; | |
432 var textBox = this.container.ownerDocument.createElement("v:textbox"); | |
433 textBox.setAttribute('mso-rotate-with-shape',true) | |
434 var divtext = this.container.ownerDocument.createElement("div"); | |
435 divtext.style.coordorigin=0+', '+(0); | |
436 divtext.style.margin=0; | |
437 divtext.style.fontFamily=textFamily; | |
438 divtext.style.margin=0; | |
439 divtext.style.padding=0; | |
440 divtext.style.vRotateLetters=true; | |
441 divtext.style.fontSize=parseFloat(textSize); | |
442 | |
443 | |
444 | |
445 | |
446 | |
447 | |
448 divtext.style.color=fillColor; | |
449 | |
450 | |
451 | |
452 | |
453 | |
454 //divtext.setAttribute('v-rotate-letters','true'); | |
455 if(transform.indexOf('rotate')>=0) | |
456 { | |
457 | |
458 myRotate1=transform.split('rotate('); | |
459 myRotate2=myRotate1[1].split(')'); | |
460 myRotate3=myRotate2[0].split(','); | |
461 | |
462 //divtext.setAttribute('mso-rotate',myRotate3[0]); | |
463 //textBox.style.msoRotate= myRotate3[0]; | |
464 //textBox.style.centerX=myRotate3[1]; | |
465 //textBox.style.centerY=myRotate3[2]; | |
466 //vml.style.rotation= myRotate3[0]; | |
467 //vml.style.centerX=myRotate3[1]; | |
468 //vml.style.centerY=myRotate3[2]; | |
469 vml.setAttribute('rotation',myRotate3[0]+'Deg'); | |
470 } | |
471 | |
472 divtext.innerHTML=textMessaje; | |
473 textBox.appendChild(divtext); | |
474 | |
475 vml.appendChild(textBox); | |
476 | |
477 } | |
478 else if (shape == 'group') { | |
479 vml = this.container.ownerDocument.createElement('v:group'); | |
480 vml.style.left=left+"px"; | |
481 vml.style.top=top+"px"; | |
482 } | |
483 | |
484 if(shape == 'zoom') | |
485 { | |
486 | |
487 }else | |
488 { | |
489 if(transform.indexOf('rotate')>=0) | |
490 { | |
491 myRotate1=transform.split('rotate('); | |
492 myRotate2=myRotate1[1].split(')'); | |
493 myRotate3=myRotate2[0].split(','); | |
494 | |
495 vml.style.rotation= myRotate3[0]+'Deg'; | |
496 vml.style.centerX=myRotate3[1]; | |
497 vml.style.centerY=myRotate3[2]; | |
498 | |
499 } | |
500 | |
501 if(shape != 'image' ) | |
502 { | |
503 | |
504 if (fillColor != '' || fillColor != 'none') | |
505 { | |
506 vml.setAttribute('filled', 'true'); | |
507 vml.setAttribute('fillcolor', fillColor); | |
508 | |
509 } | |
510 else | |
511 { | |
512 vml.setAttribute('filled', 'false'); | |
513 } | |
514 | |
515 | |
516 if(lineWidth==0 || lineWidth=='none' || lineColor== 'none' ) | |
517 { | |
518 vml.setAttribute('stroked', 'false'); | |
519 } | |
520 else | |
521 { | |
522 | |
523 vml.setAttribute('stroked', 'true'); | |
524 vml.setAttribute('strokecolor', lineColor); | |
525 vml.setAttribute('strokeweight', lineWidth); | |
526 var stroke = this.container.ownerDocument.createElement('v:stroke'); | |
527 stroke.setAttribute("opacity", parseFloat(lineOpac)); | |
528 vml.appendChild(stroke); | |
529 } | |
530 | |
531 if (fillOpac != '') | |
532 { | |
533 if (fillOpac == 'none' || fillColor=='none'){fillOpac=0;} | |
534 var fill = this.container.ownerDocument.createElement('v:fill'); | |
535 fill.setAttribute("opacity",parseFloat(fillOpac)); | |
536 //alert(fillOpac) | |
537 vml.appendChild(fill); | |
538 } | |
539 } | |
540 } | |
541 if(parent==''){ | |
542 this.container.appendChild(vml); | |
543 }else{ | |
544 var parentShape = document.getElementById(parent); | |
545 parentShape.appendChild(vml); | |
546 } | |
547 //var parentDoc = document.getElementById('mydraw'); | |
548 //parentDoc.appendChild(vml); | |
549 return vml; | |
550 }; | |
551 | |
552 | |
553 VMLRenderer.prototype.zoom = function(clicx,clicy) | |
554 { | |
555 } | |
556 | |
557 VMLRenderer.prototype.datacreate = function(fillColor, lineColor, fillOpac, lineOpac, lineWidth, left, top, width, height, textMessaje, textSize, textFamily, imageHref, transform) | |
558 { | |
559 } | |
560 | |
561 VMLRenderer.prototype.duplicate = function(shape) | |
562 { | |
563 var vml; | |
564 vml =shape.cloneNode(false); | |
565 //vml.setAttribute('fillcolor', "#aa00aa"); | |
566 //vml.setAttribute('filled', "false"); | |
567 this.container.appendChild(vml); | |
568 return vml; | |
569 | |
570 }; | |
571 | |
572 | |
573 | |
574 VMLRenderer.prototype.index = function(shape,order) { | |
575 | |
576 if(order==-1) | |
577 { | |
578 this.container.appendChild( shape ); | |
579 } | |
580 if(order==0){ | |
581 | |
582 this.container.insertBefore( shape, shape.parentNode.firstChild ); | |
583 } | |
584 | |
585 if(order==1 || order==2) | |
586 { | |
587 var id=shape.getAttribute('id'); | |
588 //alert(id); | |
589 | |
590 | |
591 var numNodes=this.container.childNodes.length; | |
592 //alert(numNodes); | |
593 | |
594 var num=0; | |
595 for(var i = 1; i < numNodes; i++) | |
596 { | |
597 | |
598 var etiq=this.container.childNodes[i].getAttribute('id'); | |
599 if (etiq==id) | |
600 { | |
601 num=i; | |
602 | |
603 } | |
604 } | |
605 //alert(num); | |
606 if(order==1) | |
607 { | |
608 if((num-1)>=-1) | |
609 { | |
610 this.container.insertBefore( shape, this.container.childNodes[num-1]); | |
611 } | |
612 } | |
613 if(order==2){ | |
614 if((num+1)<numNodes) | |
615 { | |
616 this.container.insertBefore( shape, this.container.childNodes[num+2]); | |
617 } | |
618 } | |
619 | |
620 } | |
621 | |
622 | |
623 | |
624 } | |
625 VMLRenderer.prototype.remove = function(shape) { | |
626 if(shape!=null){ shape.removeNode(true); } | |
627 } | |
628 | |
629 | |
630 VMLRenderer.prototype.copy = function(shape) | |
631 { | |
632 var vml; | |
633 vml =shape.cloneNode(false); | |
634 //vml.setAttribute('fillcolor', "#aa00aa"); | |
635 return vml; | |
636 }; | |
637 | |
638 | |
639 VMLRenderer.prototype.paste = function(clipboard,left,top) | |
640 { | |
641 this.container.appendChild(clipboard); | |
642 return clipboard; | |
643 }; | |
644 | |
645 | |
646 | |
647 VMLRenderer.prototype.undo = function() | |
648 { | |
649 this.container.removeChild( this.container.lastChild ); | |
650 }; | |
651 | |
652 | |
653 var xshe=0; | |
654 var yshe=0; | |
655 var isArc=false; | |
656 var contArc=0; | |
657 | |
658 VMLRenderer.prototype.move = function(shape, left, top,fromX,FromY) { | |
659 var box = this.bounds(shape); | |
660 var angle=0; | |
661 var dist=0; | |
662 var rotated=false; | |
663 | |
664 | |
665 | |
666 | |
667 | |
668 //contmove++; | |
669 if (shape.tagName == 'line') { | |
670 shape.style.marginLeft = left; | |
671 shape.style.marginTop = top; | |
672 } | |
673 if (shape.tagName == 'polyline') { | |
674 shape.style.marginLeft = left; | |
675 shape.style.marginTop = top; | |
676 | |
677 } | |
678 if (shape.tagName == 'oval') { | |
679 shape.style.left = left; | |
680 shape.style.top = top; | |
681 } | |
682 if (shape.tagName == 'rect') { | |
683 shape.style.left = left; | |
684 shape.style.top = top; | |
685 } | |
686 | |
687 if (shape.tagName == 'image') { | |
688 shape.style.left = left; | |
689 shape.style.top = top; | |
690 } | |
691 if (shape.tagName == 'shape') { | |
692 | |
693 shape.style.left=left+"px"; | |
694 shape.style.top=top+"px"; | |
695 | |
696 } | |
697 | |
698 | |
699 }; | |
700 | |
701 | |
702 VMLRenderer.prototype.track = function(shape) { | |
703 // TODO | |
704 }; | |
705 | |
706 VMLRenderer.prototype.clic = function(shape) { | |
707 var end=''; | |
708 if(data_path_close==true){end=' ';} | |
709 | |
710 var thispath='m '+setPoints[0]+' l'; | |
711 var maxcont=setPoints.length; | |
712 | |
713 for(var conta=1;conta< maxcont;conta++){ | |
714 thispath+=setPoints[conta]+' '; | |
715 | |
716 | |
717 } | |
718 var path=thispath+end+' e'; | |
719 shape.style.position="absolute"; | |
720 shape.style.width= 700+"px"; | |
721 shape.style.height=500+"px"; | |
722 shape.style.left="0px"; | |
723 shape.style.top="0px"; | |
724 | |
725 | |
726 shape.children[0].setAttribute("v",path); | |
727 document.forms[0].control_codebase.value=path; | |
728 | |
729 } | |
730 | |
731 | |
732 VMLRenderer.prototype.resize = function(shape, fromX, fromY, toX, toY) { | |
733 //var vml; | |
734 var deltaX = toX - fromX; | |
735 var deltaY = toY - fromY; | |
736 var shap=1; | |
737 if (shape.tagName == 'line') { shap=0; } | |
738 if (shape.tagName == 'polyline') { shap=2; } | |
739 | |
740 if (shape.tagName == 'line') { | |
741 shape.setAttribute('to', toX + 'px,' + toY + 'px'); | |
742 } | |
743 if (shap == 1) { | |
744 if (deltaX < 0) { | |
745 shape.style.left = toX + 'px'; | |
746 shape.style.width = -deltaX + 'px'; | |
747 } | |
748 else { | |
749 shape.style.width = deltaX + 'px'; | |
750 } | |
751 | |
752 if (deltaY < 0) { | |
753 shape.style.top = toY + 'px'; | |
754 shape.style.height = -deltaY + 'px'; | |
755 } | |
756 else { | |
757 shape.style.height = deltaY + 'px'; | |
758 } | |
759 } | |
760 if (shap == 2) { | |
761 xpArray.push(toX); | |
762 ypArray.push(toY); | |
763 | |
764 //xpArray.push(finetoX); | |
765 //ypArray.push(finetoY); | |
766 | |
767 var thispath=' '+xpArray[1]+','+ypArray[1]; | |
768 var maxcont=xpArray.length; | |
769 //alert(maxcont); | |
770 for(var conta=2;conta< maxcont;conta++){ | |
771 thispath+=' '+xpArray[conta]+','+ypArray[conta]; | |
772 } | |
773 //alert(shape.points[1]); | |
774 //shape.setAttribute("points",thispath); | |
775 shape.points.Value = thispath; | |
776 | |
777 /* | |
778 var thispath=''+xpArray[0]+','+ypArray[0]; | |
779 var thispatho=new Array(); | |
780 thispatho.push(toX); | |
781 thispatho.push(toY); | |
782 var maxcont=xpArray.length; | |
783 //alert(maxcont); | |
784 for(var conta=2;conta< maxcont;conta++){ | |
785 thispath+=','+xpArray[conta]+','+ypArray[conta]; | |
786 } | |
787 //alert(shape.points[1]); | |
788 shape.setAttribute("points",thispath); | |
789 */ | |
790 } | |
791 if(shape.tagName == 'shape') | |
792 { | |
793 | |
794 if (selectmode == 'controlpath') | |
795 { | |
796 | |
797 var end=''; | |
798 if(data_path_close==true){end=' ';} | |
799 | |
800 var thispath='m '+setPoints[0]+' l'; | |
801 var maxcont=setPoints.length; | |
802 | |
803 for(var conta=1;conta< maxcont;conta++){ | |
804 thispath+=setPoints[conta]+' '; | |
805 | |
806 | |
807 } | |
808 var path=thispath+toX+','+toY+end+' e'; | |
809 | |
810 shape.style.position="absolute"; | |
811 shape.style.width= 700+"px"; | |
812 shape.style.height=500+"px"; | |
813 shape.style.left="0px"; | |
814 shape.style.top="0px"; | |
815 | |
816 shape.children[0].setAttribute("v",path); | |
817 document.forms[0].control_codebase.value=path; | |
818 | |
819 | |
820 } | |
821 else | |
822 { | |
823 | |
824 xpArray.push(toX); | |
825 ypArray.push(toY); | |
826 | |
827 //xpArray.push(finetoX); | |
828 //ypArray.push(finetoY); | |
829 var thispath2=''; | |
830 var thispath1=' '+xpArray[1]+','+ypArray[1]; | |
831 var maxcont=xpArray.length; | |
832 //alert(maxcont); | |
833 for(var conta=2;conta< maxcont ;conta++){ | |
834 thispath2+=''+xpArray[conta]+','+ypArray[conta]+','; | |
835 if((conta+2)%3==0){thispath2+='';} | |
836 } | |
837 thispath2+=''+xpArray[maxcont]+','+ypArray[maxcont]+''; | |
838 | |
839 //alert(shape.points[1]); | |
840 //appendChild(path01) | |
841 //var path01=shape.getFirstChild(); | |
842 var path01 = this.container.ownerDocument.createElement('v:path'); | |
843 path01.setAttribute("v", "m"+thispath1+" l"+ thispath2+" e"); | |
844 //shape.margin-left="300px"; | |
845 //shape.margin-top="200px"; | |
846 | |
847 //shape.setAttribute('path','m '+thispath1+ ' c'+thispath2+' e'); | |
848 if(shape.children[0].tagName=='textpath') | |
849 { | |
850 var path01 = this.container.ownerDocument.createElement('v:path'); | |
851 path01.setAttribute("v", 'm 100 100 l 600 100 e'); | |
852 | |
853 //if(xpArray.length>1) | |
854 //{ shap.style.position="absolute"; | |
855 shape.style.width=100+"px"; | |
856 shape.style.height=100+"px"; | |
857 shape.style.left=toX+"px"; | |
858 shape.style.top=toY+"px"; | |
859 shape.style.margin=0+"px"; | |
860 shape.style.padding=0+"px"; | |
861 shape.appendChild(path01); | |
862 //} | |
863 } | |
864 else | |
865 { | |
866 shape.style.position="absolute"; | |
867 shape.style.width= 700+"px"; | |
868 shape.style.height=500+"px"; | |
869 shape.style.left="0px"; | |
870 shape.style.top="0px"; | |
871 //shape.setAttribute('coordsize', '700,500'); | |
872 shape.appendChild(path01); | |
873 } | |
874 | |
875 //shape.setAttribute('position', 'absolute'); | |
876 //shape.translate(xpArray[conta+1]+','+ypArray[conta+1]); | |
877 //shape.setAttribute('coordsize', '700,500'); | |
878 // shape.v.Value ='M '+thispath1+ ' C'+thispath2+' x e'; | |
879 //shape.v.Value = 'M '+thispath+ ' c '+thispath2; | |
880 //shape.setAttribute("v", 'M '+thispath+ ' C '+thispath2); | |
881 //shape.setAttribute('path','M '+thispath+ ' C '+thispath2); | |
882 } | |
883 } | |
884 | |
885 }; | |
886 | |
887 | |
888 VMLRenderer.prototype.tocurve = function() { | |
889 | |
890 | |
891 }; | |
892 | |
893 | |
894 VMLRenderer.prototype.info = function(shape) | |
895 { | |
896 var shInfo = {}; | |
897 shInfo.id = shape.id; | |
898 shInfo.type = shape.tagName; | |
899 if (shape.tagName == 'rect') | |
900 { | |
901 shInfo.left = parseFloat(shape.getAttribute( 'x')); | |
902 shInfo.top = parseFloat(shape.getAttribute( 'y')); | |
903 shInfo.width = parseFloat(shape.getAttribute('width')); | |
904 shInfo.height = parseFloat(shape.getAttribute('height')); | |
905 //++ | |
906 //shInfo.rotate = parseFloat(shape.getAttribute('rotation')); | |
907 } | |
908 else if (shape.tagName == 'oval') | |
909 { | |
910 shInfo.width = parseFloat(shape.getAttribute('rx'))*2; | |
911 shInfo.height = parseFloat(shape.getAttribute('ry'))*2; | |
912 shInfo.left = (shInfo.width * 2) - parseFloat(shape.getAttribute('rx')); | |
913 shInfo.top = (shInfo.height * 2) - parseFloat(shape.getAttribute('ry')); | |
914 | |
915 } | |
916 else if (shape.tagName == 'roundrect') | |
917 { | |
918 shInfo.left = parseFloat(shape.getAttribute('x')); | |
919 shInfo.top = parseFloat(shape.getAttribute('y')); | |
920 shInfo.width = parseFloat(shape.getAttribute('width')); | |
921 shInfo.height = parseFloat(shape.getAttribute('height')); | |
922 | |
923 } | |
924 else if (shape.tagName == 'line') | |
925 { | |
926 shInfo.left = parseFloat(shape.getAttribute('x1')); | |
927 shInfo.top = parseFloat(shape.getAttribute('y1')); | |
928 | |
929 } | |
930 else if (shape.tagName == 'polyline') | |
931 { | |
932 shInfo.points = shape.getAttribute('points'); | |
933 } | |
934 else if (shape.tagName == 'image') | |
935 { | |
936 shInfo.left = parseFloat(shape.getAttribute('x')); | |
937 shInfo.top = parseFloat(shape.getAttribute('y')); | |
938 shInfo.width = parseFloat(shape.getAttribute('width')); | |
939 shInfo.height = parseFloat(shape.getAttribute('height')); | |
940 shInfo.src = shape.getAttribute('src'); | |
941 } | |
942 else | |
943 | |
944 if (shape.tagName == 'shape') | |
945 { | |
946 if(shape.children[0].tagName=='path') { | |
947 shInfo.d = shape.getAttribute('v'); | |
948 this.editor.log(shape.getAttribute('v')); | |
949 | |
950 } | |
951 if(shape.children[0].tagName=='textpath') { | |
952 shInfo['font-family'] = shape.children[0].getAttribute('font-family') | |
953 shInfo['font-size'] = parseInt(shape.children[0].getAttribute('font-size')) | |
954 shInfo.top = parseFloat(shape.children[0].getAttribute('y')) | |
955 shInfo.left = parseFloat(shape.children[0].getAttribute('x')) | |
956 shInfo.text = shape.textContent | |
957 | |
958 } | |
959 } | |
960 return shInfo; | |
961 | |
962 | |
963 } | |
964 VMLRenderer.prototype.transformShape = function(shape,data,transform) | |
965 { | |
966 | |
967 if(shape.tagName == 'rect') | |
968 { | |
969 | |
970 var box = this.bounds(shape); | |
971 var sdata=data.split(';'); | |
972 | |
973 //alert(data[0]); | |
974 shape.style.top = parseFloat(sdata[0]) + 'px'; | |
975 shape.style.left = parseFloat(sdata[1]) + 'px'; | |
976 shape.style.width = parseFloat(sdata[2]) + 'px'; | |
977 shape.style.height = parseFloat(sdata[3]) + 'px'; | |
978 | |
979 | |
980 | |
981 // var centerx=parseFloat(sdata[0])+parseFloat(box.width/2); | |
982 // var centery=parseFloat(sdata[1])+parseFloat(box.height/2); | |
983 shape.style.rotation=parseFloat(sdata[4]); | |
984 | |
985 //shape.nodparseFloatue=data; | |
986 } | |
987 else | |
988 if(shape.tagName == 'text') | |
989 { | |
990 if(data.indexOf('<;>',0)==-1 ) | |
991 { | |
992 shape.textContent = data; | |
993 } | |
994 else | |
995 { | |
996 var sdata=data.split('<;>'); //????????? | |
997 shape.textContent = sdata[0]; | |
998 shape.setAttribute('font-size',parseFloat(sdata[1])); | |
999 shape.setAttribute('font-family',sdata[2]); | |
1000 } | |
1001 //shape.nodparseFloatue=data; | |
1002 } | |
1003 else | |
1004 if (shape.tagName == 'polyline') | |
1005 { | |
1006 shape.setAttribute('points',data); | |
1007 } | |
1008 else | |
1009 if (shape.tagName == 'image') | |
1010 { | |
1011 //alert(data); | |
1012 if(data.indexOf(';',0)==-1 ) | |
1013 { | |
1014 shape.setAttribute('src',data); | |
1015 } | |
1016 else | |
1017 { | |
1018 var box = this.bounds(shape); | |
1019 var sdata=data.split(';'); | |
1020 shape.style.top = parseFloat(sdata[0]) + 'px'; | |
1021 shape.style.left = parseFloat(sdata[1]) + 'px'; | |
1022 shape.style.width = parseFloat(sdata[2]) + 'px'; | |
1023 shape.style.height = parseFloat(sdata[3]) + 'px'; | |
1024 var centerx=parseFloat(sdata[0])+parseFloat(box.width/2); | |
1025 var centery=parseFloat(sdata[1])+parseFloat(box.height/2); | |
1026 shape.style.rotation=parseFloat(sdata[4]); | |
1027 | |
1028 | |
1029 } | |
1030 | |
1031 } | |
1032 else | |
1033 if (shape.tagName == 'path') | |
1034 { | |
1035 if(data.indexOf(';',0)==-1 ) | |
1036 { | |
1037 //shape.setAttribute( 'd', data); //???????? | |
1038 //shape.setAttribute( 'transform', transform); | |
1039 } | |
1040 else | |
1041 { | |
1042 var box = this.bounds(shape); | |
1043 var sdata=data.split(';'); | |
1044 var centerx=parseFloat(sdata[0])+parseFloat(box.width/2); | |
1045 var centery=parseFloat(sdata[1])+parseFloat(box.height/2); | |
1046 //++shape.setAttribute( 'transform','scale('+parseFloat(sdata[2])+','+parseFloat(sdata[3])+')'+' rotate('+parseFloat(sdata[4])+','+centerx+','+centery+')'+' translate('+parseFloat(sdata[0])+','+parseFloat(sdata[1])+')'); | |
1047 | |
1048 | |
1049 } | |
1050 } | |
1051 | |
1052 | |
1053 } | |
1054 VMLRenderer.prototype.editShape = function(shape,data) | |
1055 { | |
1056 if(shape.tagName == 'text'){ | |
1057 shape.textContent = data | |
1058 }else | |
1059 if (shape.tagName == 'polyline') | |
1060 { | |
1061 shape.setAttribute('points',data); | |
1062 } | |
1063 else | |
1064 | |
1065 if (shape.tagName == 'path') | |
1066 { | |
1067 shape.setAttribute('v', data); | |
1068 | |
1069 } | |
1070 | |
1071 | |
1072 } | |
1073 VMLRenderer.prototype.editCommand = function(shape, cmd, value) | |
1074 { | |
1075 if (shape != null) { | |
1076 if (cmd == 'fillcolor') { | |
1077 if (value != '') { | |
1078 shape.filled = 'true'; | |
1079 shape.fillcolor = value; | |
1080 } | |
1081 else { | |
1082 shape.filled = 'false'; | |
1083 shape.fillcolor = ''; | |
1084 } | |
1085 } | |
1086 else if (cmd == 'linecolor') { | |
1087 if (value != '') { | |
1088 shape.stroked = 'true'; | |
1089 shape.strokecolor = value; | |
1090 } | |
1091 else { | |
1092 shape.stroked = 'false'; | |
1093 shape.strokecolor = ''; | |
1094 } | |
1095 } | |
1096 else if (cmd == 'linewidth') { | |
1097 shape.strokeweight = parseInt(value) + 'px'; | |
1098 } | |
1099 else if (cmd == 'fillopacity') { | |
1100 | |
1101 shape.fill.opacity= parseFloat(value); | |
1102 //shape.style.fill.setAttribute("opacity", parseFloat(value)); | |
1103 | |
1104 } | |
1105 } | |
1106 } | |
1107 | |
1108 | |
1109 VMLRenderer.prototype.queryCommand = function(shape, cmd) | |
1110 { | |
1111 if (shape != null) { | |
1112 if (cmd == 'fillcolor') { | |
1113 if (shape.filled == 'false') | |
1114 return ''; | |
1115 else | |
1116 return shape.fillcolor; | |
1117 } | |
1118 else if (cmd == 'linecolor') { | |
1119 if (shape.stroked == 'false') | |
1120 return ''; | |
1121 else | |
1122 return shape.strokecolor; | |
1123 } | |
1124 else if (cmd == 'linewidth') { | |
1125 if (shape.stroked == 'false') { | |
1126 return ''; | |
1127 } | |
1128 else { | |
1129 // VML always transforms the pixels to points, so we have to convert them back | |
1130 return (parseFloat(shape.strokeweight) * (screen.logicalXDPI / 72)) + 'px'; | |
1131 } | |
1132 } | |
1133 } | |
1134 } | |
1135 | |
1136 VMLRenderer.prototype.getProperties = function(shape) | |
1137 { | |
1138 var result = ''; | |
1139 | |
1140 if (shape != null) | |
1141 { | |
1142 result = shape.getAttribute('fillcolor'); | |
1143 if (result == 'none') | |
1144 { | |
1145 mefillColor.visible = 'hidden'; | |
1146 mefillColor.hex = '#000000'; | |
1147 filldraw=true; | |
1148 setbe(1,'img_okfill'); | |
1149 } | |
1150 else | |
1151 { | |
1152 //alert(mefillColor.hex+' '+result); | |
1153 mefillColor.visible = 'visible'; | |
1154 mefillColor.hex = result; | |
1155 var rgb=hex2rgb(result) | |
1156 mefillColor.r=rgb[0]; | |
1157 mefillColor.g=rgb[1]; | |
1158 mefillColor.b=rgb[2]; | |
1159 filldraw=false; | |
1160 setbe(1,'img_okfill'); | |
1161 | |
1162 } | |
1163 | |
1164 result = shape.getAttribute('strokecolor'); | |
1165 if (result == 'none') | |
1166 { | |
1167 mestrokeColor.visible = 'hidden'; | |
1168 mestrokeColor.hex = '#000000'; | |
1169 mestrokeColor.width = 0; | |
1170 strokedraw=true; | |
1171 setbe(2,'img_okstroke'); | |
1172 | |
1173 } | |
1174 else | |
1175 { | |
1176 mestrokeColor.visible = 'visible'; | |
1177 mestrokeColor.hex = result; | |
1178 var rgb=hex2rgb(result) | |
1179 mestrokeColor.r=rgb[0]; | |
1180 mestrokeColor.g=rgb[1]; | |
1181 mestrokeColor.b=rgb[2]; | |
1182 strokedraw=false; | |
1183 setbe(2,'img_okstroke'); | |
1184 | |
1185 } | |
1186 | |
1187 result = shape.getAttribute('strokeweight'); | |
1188 mestrokeColor.width = result; | |
1189 | |
1190 result = shape.fill.getAttribute('opacity'); | |
1191 mefillColor.opacity = result; | |
1192 | |
1193 result = shape.stroke.getAttribute('opacity'); | |
1194 mestrokeColor.opacity = result; | |
1195 | |
1196 setProperties(); | |
1197 } | |
1198 } | |
1199 | |
1200 | |
1201 VMLRenderer.prototype.showMultiSelect = function(iniX,iniY) { | |
1202 var tracker = document.getElementById('trackerMultiSelect'); | |
1203 if (tracker) { | |
1204 this.remove(tracker); | |
1205 } | |
1206 var coord=this.editor.inputxy; | |
1207 toX=parseFloat(coord[0]); | |
1208 toY=parseFloat(coord[1]); | |
1209 | |
1210 tracker = this.container.ownerDocument.createElement('v:rect'); | |
1211 | |
1212 tracker.style.position = 'relative'; | |
1213 tracker.style.left = iniX; | |
1214 tracker.style.top = iniY; | |
1215 tracker.style.width = toX ; | |
1216 tracker.style.height = toY; | |
1217 tracker.setAttribute('filled', 'false'); | |
1218 tracker.setAttribute('stroked', 'true'); | |
1219 tracker.setAttribute('strokecolor', 'blue'); | |
1220 tracker.setAttribute('strokeweight', '1px'); | |
1221 | |
1222 this.container.appendChild(tracker); | |
1223 } | |
1224 | |
1225 function mouseCoord() | |
1226 { | |
1227 var coord=this.editor.inputxy; | |
1228 coord[0]=parseFloat(coord[0]); | |
1229 coord[1]=parseFloat(coord[1]); | |
1230 return coord | |
1231 } | |
1232 | |
1233 var memoNode=null; | |
1234 var memoPrevControl=new Array(); | |
1235 var memoNextControl=new Array(); | |
1236 VMLRenderer.prototype.nodeMove = function(newx,newy) { | |
1237 var mypath=$('control_codebase').value; | |
1238 var x= $('option_path_x').value; | |
1239 var y= $('option_path_y').value; | |
1240 var precoord=x+','+y; | |
1241 | |
1242 $('option_path_x').value=newx; | |
1243 $('option_path_y').value=newy; | |
1244 | |
1245 var cadx= newx; | |
1246 var cady= newy; | |
1247 | |
1248 var coord=cadx+','+cady; | |
1249 var cad1=new RegExp(precoord,"g"); | |
1250 | |
1251 | |
1252 var result=mypath.replace(cad1, coord); | |
1253 | |
1254 | |
1255 $('control_codebase').value=result; | |
1256 | |
1257 $('someinfo').value=precoord; | |
1258 setShape(); | |
1259 | |
1260 } | |
1261 | |
1262 function drawNodeControl(vml,numId){ | |
1263 var color1='#0066ff'; | |
1264 // if(parseInt(memoNode.id)==a){ | |
1265 | |
1266 var pointprev=memoPrevControl[numId].split(','); | |
1267 var controlNode1 = this.container.ownerDocument.createElement('v:rect'); | |
1268 controlNode1.setAttribute('x', pointprev[0]-2); | |
1269 controlNode1.setAttribute('y', pointprev[1]-2); | |
1270 | |
1271 controlNode1.setAttribute('width', 4); | |
1272 controlNode1.setAttribute('height', 4); | |
1273 controlNode1.setAttribute('fillcolor', color1); | |
1274 controlNode1.setAttribute('strokecolor', '#000000'); | |
1275 controlNode1.setAttribute('strokeweight', '0'); | |
1276 controlNode1.setAttribute('id', 'controlNode1'); | |
1277 controlNode1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttribute('strokeweight', 0 );} memoNode=this; this.setAttribute('fillcolor', '#ffff00' );this.setAttribute('strokeweight', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttribute('x'))+2; $('option_path_y').value=parseFloat(this.getAttribute('y'))+2; }, false); | |
1278 vml.appendChild(controlNode1); | |
1279 | |
1280 var pointnext=memoNextControl[numId].split(','); | |
1281 | |
1282 | |
1283 var controlNode2 =this.container.ownerDocument.createElement('v:rect'); | |
1284 controlNode2.setAttribute('x', pointnext[0]-2); | |
1285 controlNode2.setAttribute('y', pointnext[1]-2); | |
1286 | |
1287 controlNode2.setAttribute('width', 4); | |
1288 controlNode2.setAttribute('height', 4); | |
1289 controlNode2.setAttribute('fillcolor', color1); | |
1290 controlNode2.setAttribute('strokecolor', '#000000'); | |
1291 controlNode2.setAttribute('strokeweight', '0'); | |
1292 controlNode2.setAttribute('id', 'controlNode1'); | |
1293 controlNode2.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttribute('strokeweight', 0 );} memoNode=this; this.setAttribute('fillcolor', '#ffff00' );this.setAttribute('strokeweight', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttribute('x'))+2; $('option_path_y').value=parseFloat(this.getAttribute('y'))+2; }, false); | |
1294 vml.appendChild(controlNode2); | |
1295 | |
1296 //} | |
1297 | |
1298 | |
1299 } | |
1300 | |
1301 VMLRenderer.prototype.showNodesCurve = function(path){ | |
1302 var points=path.split('c'); | |
1303 var chain=''; | |
1304 var segment=' '; | |
1305 var numpoints=points.length-1; | |
1306 for(var a=1;a<numpoints;a++) | |
1307 { | |
1308 segment=points[a].split(' '); | |
1309 chain+=segment[0]+' '; | |
1310 } | |
1311 | |
1312 $('someinfo').value=numpoints+ ' nodes '; | |
1313 return chain; | |
1314 | |
1315 }; | |
1316 | |
1317 | |
1318 | |
1319 VMLRenderer.prototype.showTracker = function(shape) { | |
1320 var box = this.bounds(shape); | |
1321 var trshape = parseFloat(shape.getAttribute('rotation')); | |
1322 var tracker = document.getElementById('tracker'); | |
1323 if (tracker) { | |
1324 this.remove(tracker); | |
1325 } | |
1326 | |
1327 if (shape.tagName == 'shape') | |
1328 { | |
1329 shap=2; | |
1330 if(shape.children[0].tagName == 'path') | |
1331 { | |
1332 | |
1333 /* $('option_path_trx').value= box.x; | |
1334 $('option_path_try').value= box.y; | |
1335 $('option_path_sclx').value= box.width; | |
1336 $('option_path_scly').value= box.height; | |
1337 $('option_path_rot').value= shape.style.rotation; | |
1338 */ | |
1339 var path=shape.children[0].getAttribute('v'); | |
1340 $('control_codebase').value=path; | |
1341 } | |
1342 } | |
1343 if (shape.tagName == 'rect') { | |
1344 | |
1345 $('option_rect_rot').value= shape.getAttribute('rotation'); | |
1346 $('option_rect_trx').value= box.x; | |
1347 $('option_rect_try').value= box.y; | |
1348 $('option_rect_sclx').value= box.width; | |
1349 $('option_rect_scly').value= box.height; | |
1350 | |
1351 } | |
1352 | |
1353 if (shape.tagName == 'image'){ | |
1354 /* $('option_img_trx').value= box.x; | |
1355 $('option_img_try').value= box.y; | |
1356 $('option_img_sclx').value= box.width; | |
1357 $('option_img_scly').value= box.height; | |
1358 $('option_img_rot').value= T.b* (Math.PI * 2 / 360); | |
1359 */ | |
1360 } | |
1361 if (shape.tagName == 'text'){ | |
1362 /* f$('option_text_trx').value= box.x; | |
1363 $('option_text_try').value= box.y; | |
1364 $('option_text_sclx').value= box.width; | |
1365 $('option_text_scly').value= box.height; | |
1366 $('option_text_rot').value= T.b* (Math.PI * 2 / 360); | |
1367 */ | |
1368 } | |
1369 if (shape.tagName == 'line'){ | |
1370 /* | |
1371 $('option_line_trx').value= box.x; | |
1372 $('option_line_try').value= box.y; | |
1373 */ | |
1374 } | |
1375 if (shape.tagName == 'oval'){ | |
1376 /*$('option_ellipse_trx').value= putx; | |
1377 $('option_ellipse_try').value= puty; | |
1378 $('option_ellipse_sclx').value= box.width; | |
1379 $('option_ellipse_scly').value= box.height; | |
1380 $('option_ellipse_rot').value= T.b* (Math.PI * 2 / 360); | |
1381 */ | |
1382 } | |
1383 | |
1384 | |
1385 | |
1386 /*var matrix = shape.getScreenCTM(); | |
1387 var trshape= shape.getAttribute('transform'); | |
1388 var shap=1; | |
1389 if (shape.tagName == 'path') { shap=2; | |
1390 | |
1391 | |
1392 | |
1393 } | |
1394 */ | |
1395 //if (shape.getAttribute('transform') ) { shap=2; } | |
1396 //var svgNamespace = 'http://www.w3.org/2000/svg'; | |
1397 | |
1398 tracker = this.container.ownerDocument.createElement('v:group'); | |
1399 tracker.id = 'tracker'; | |
1400 //tracker.setAttribute('rotation',trshape); | |
1401 tracker.setAttribute('coordorigin','0, 0'); | |
1402 //tracker.setAttribute('wrapcoords',true); | |
1403 | |
1404 | |
1405 tracker.setAttribute('coordsize',box.width+','+ box.height); | |
1406 tracker.style.position = 'absolute'; | |
1407 tracker.style.left = box.x ; | |
1408 tracker.style.top = box.y; | |
1409 tracker.style.width = box.width ; | |
1410 tracker.style.height = box.height ; | |
1411 | |
1412 | |
1413 | |
1414 | |
1415 | |
1416 | |
1417 | |
1418 | |
1419 | |
1420 //////////////// | |
1421 | |
1422 /* | |
1423 | |
1424 var trshape='translate (0,0) rotate(0) translate(0,0) '; | |
1425 var trshape_split=trshape.split(') '); | |
1426 | |
1427 // get_between (trshape, s1, s2) ; | |
1428 if(shape.getAttribute('transform')){ | |
1429 var trshape=shape.getAttribute('transform') ; | |
1430 //var spl=trshape.replace(', ',' '); | |
1431 //var spl1=spl.replace(')',' '); | |
1432 var trshape_split=trshape.split(') '); | |
1433 | |
1434 | |
1435 } | |
1436 */ | |
1437 | |
1438 var corners = []; | |
1439 var point = createPoint(box.x, box.y, box.width, box.height); | |
1440 //point = {x:box.x, y:box.y, width: box.width, height:box.height}; | |
1441 //point = createPoint(box.x, box.y, box.width, box.height); | |
1442 //1 | |
1443 corners.push( createPoint(box.x + box.width, box.y, box.width, box.height) ); | |
1444 point.x = box.x + box.width; | |
1445 point.y = box.y; | |
1446 //2 | |
1447 corners.push( createPoint(box.x + box.width, box.y + box.height, box.width, box.height) ); | |
1448 point.x = box.x + box.width; | |
1449 point.y = box.y + box.height; | |
1450 //3 | |
1451 //corners.push( point.matrixTransform(matrix) ); | |
1452 corners.push( createPoint(box.x , box.y + box.height, box.width, box.height) ); | |
1453 point.x = box.x; | |
1454 point.y = box.y + box.height; | |
1455 //4 | |
1456 corners.push( createPoint(box.x + box.width, box.y, box.width, box.height) ); | |
1457 | |
1458 var max = createPoint(corners[0].x, corners[0].y); | |
1459 var min = createPoint(corners[0].x, corners[0].y); | |
1460 | |
1461 // identify the new corner coordinates of the | |
1462 // fully transformed bounding box | |
1463 | |
1464 for (var i = 1; i < corners.length; i++) { | |
1465 var x = corners[i].x; | |
1466 var y = corners[i].y; | |
1467 if (x < min.x) { | |
1468 min.x = x; | |
1469 } | |
1470 else if (x > max.x) { | |
1471 max.x = x; | |
1472 } | |
1473 if (y < min.y) { | |
1474 min.y = y; | |
1475 } | |
1476 else if (y > max.y) { | |
1477 max.y = y; | |
1478 } | |
1479 } | |
1480 | |
1481 | |
1482 var border_square = this.container.ownerDocument.createElement('v:rect'); | |
1483 | |
1484 border_square.style.position = 'relative'; | |
1485 border_square.style.left = 0 - 10; | |
1486 border_square.style.top = 0 - 10; | |
1487 border_square.style.width = box.width + 20; | |
1488 border_square.style.height = box.height + 20; | |
1489 border_square.setAttribute('filled', 'false'); | |
1490 border_square.setAttribute('stroked', 'true'); | |
1491 border_square.setAttribute('strokecolor', 'blue'); | |
1492 border_square.setAttribute('strokeweight', '1px'); | |
1493 | |
1494 | |
1495 var border_angle = this.container.ownerDocument.createElement('v:polyline'); | |
1496 border_angle.style.position = 'relative'; | |
1497 | |
1498 //border_angle.setAttribute('from',(box.width+10) + 'px,' + (box.height/2) + 'px'); | |
1499 //border_angle.setAttribute('to', (box.width+10+25) + 'px,' + (box.width+10) + 'px'); | |
1500 border_angle.setAttribute('filled', 'false'); | |
1501 border_angle.setAttribute('stroked', 'true'); | |
1502 border_angle.setAttribute('strokecolor', 'blue'); | |
1503 border_angle.setAttribute('strokeweight', '1px'); | |
1504 border_angle.setAttribute("points", (box.width+10)+","+((box.height/2))+", " | |
1505 +(box.width+10+25)+","+((box.height/2)) ); | |
1506 | |
1507 | |
1508 /* var path01 = this.container.ownerDocument.createElement('v:path'); | |
1509 //path01.setAttribute("v", "m "+thispath+" c"+ thispath2+" e "); | |
1510 path01.setAttribute("v", "m"+(min.x-10)+","+ (min.y-10)+" r"+(box.width+20)+","+(0)+" r"+(0)+","+(box.height+20)+" r"+(-box.width-20)+','+(0)+"x e m"+(box.x+box.width+10)+","+ (box.y+(box.height/2))+" r"+(25)+",0 e "); | |
1511 border.appendChild(path01) | |
1512 */ | |
1513 //border.setAttribute('stroke-width', '1'); | |
1514 | |
1515 // createRect(min.x, min.y, max.x - min.x, max.y - min.y); | |
1516 | |
1517 | |
1518 /* tracker = this.container.ownerDocument.createElement('v:rect'); | |
1519 tracker.id = 'tracker'; | |
1520 tracker.style.position = 'absolute'; | |
1521 tracker.style.left = box.x - 10; | |
1522 tracker.style.top = box.y - 10; | |
1523 tracker.style.width = box.width + 20; | |
1524 tracker.style.height = box.height + 20; | |
1525 tracker.setAttribute('filled', 'false'); | |
1526 tracker.setAttribute('stroked', 'true'); | |
1527 tracker.setAttribute('strokecolor', 'blue'); | |
1528 tracker.setAttribute('strokeweight', '1px'); | |
1529 this.container.appendChild(tracker); | |
1530 */ | |
1531 var circle1 = this.container.ownerDocument.createElement('v:oval'); | |
1532 circle1.style.position = 'relative'; | |
1533 circle1.style.left = ( (box.width+40)-5); | |
1534 circle1.style.top = ( (box.height / 2) -5); | |
1535 circle1.style.width = (10); | |
1536 circle1.style.height = (10); | |
1537 circle1.setAttribute('filled', 'true'); | |
1538 circle1.setAttribute('stroked', 'true'); | |
1539 circle1.setAttribute('fillcolor', '#ffffff'); | |
1540 circle1.setAttribute('strokecolor', 'green'); | |
1541 circle1.setAttribute('strokeweight', '1px'); | |
1542 | |
1543 | |
1544 var rect1 = this.container.ownerDocument.createElement('v:rect'); | |
1545 rect1.style.position = 'relative'; | |
1546 rect1.style.left = - 10-5; | |
1547 rect1.style.top = - 10-5; | |
1548 rect1.style.width = 10; | |
1549 rect1.style.height = 10; | |
1550 rect1.setAttribute('filled', 'true'); | |
1551 rect1.setAttribute('stroked', 'true'); | |
1552 rect1.setAttribute('fillcolor', '#ffffff'); | |
1553 rect1.setAttribute('strokecolor', 'green'); | |
1554 rect1.setAttribute('strokeweight', '1px'); | |
1555 | |
1556 | |
1557 var rect2 = this.container.ownerDocument.createElement('v:rect'); | |
1558 rect2.style.position = 'relative'; | |
1559 rect2.style.left = box.width +5; | |
1560 rect2.style.top = -10 -5; | |
1561 rect2.style.width = 10; | |
1562 rect2.style.height = 10; | |
1563 rect2.setAttribute('filled', 'true'); | |
1564 rect2.setAttribute('stroked', 'true'); | |
1565 rect2.setAttribute('fillcolor', '#ffffff'); | |
1566 rect2.setAttribute('strokecolor', 'green'); | |
1567 rect2.setAttribute('strokeweight', '1px'); | |
1568 | |
1569 | |
1570 var rect3 = this.container.ownerDocument.createElement('v:rect'); | |
1571 rect3.style.position = 'relative'; | |
1572 rect3.style.left = box.width+5; | |
1573 rect3.style.top = box.height+5; | |
1574 rect3.style.width = 10; | |
1575 rect3.style.height = 10; | |
1576 rect3.setAttribute('filled', 'true'); | |
1577 rect3.setAttribute('stroked', 'true'); | |
1578 rect3.setAttribute('fillcolor', '#ffffff'); | |
1579 rect3.setAttribute('strokecolor', 'green'); | |
1580 rect3.setAttribute('strokeweight', '1px'); | |
1581 | |
1582 var rect4 = this.container.ownerDocument.createElement('v:rect'); | |
1583 rect4.style.position = 'relative'; | |
1584 rect4.style.left = -10-5; | |
1585 rect4.style.top = box.height+5; | |
1586 rect4.style.width = 10; | |
1587 rect4.style.height = 10; | |
1588 rect4.setAttribute('filled', 'true'); | |
1589 rect4.setAttribute('stroked', 'true'); | |
1590 rect4.setAttribute('fillcolor', '#ffffff'); | |
1591 rect4.setAttribute('strokecolor', 'green'); | |
1592 rect4.setAttribute('strokeweight', '1px'); | |
1593 | |
1594 | |
1595 | |
1596 var rectmid12 = this.container.ownerDocument.createElement('v:rect'); | |
1597 rectmid12.style.position = 'relative'; | |
1598 rectmid12.style.left = (box.width/2) -5; | |
1599 rectmid12.style.top =- 10-5; | |
1600 rectmid12.style.width = 10; | |
1601 rectmid12.style.height = 10; | |
1602 rectmid12.setAttribute('filled', 'true'); | |
1603 rectmid12.setAttribute('stroked', 'true'); | |
1604 rectmid12.setAttribute('fillcolor', '#ffffff'); | |
1605 rectmid12.setAttribute('strokecolor', 'green'); | |
1606 rectmid12.setAttribute('strokeweight', '1px'); | |
1607 | |
1608 var rectmid23 = this.container.ownerDocument.createElement('v:rect'); | |
1609 rectmid23.style.position = 'relative'; | |
1610 rectmid23.style.left = box.width +5; | |
1611 rectmid23.style.top = (box.height/2)-5; | |
1612 rectmid23.style.width = 10; | |
1613 rectmid23.style.height = 10; | |
1614 rectmid23.setAttribute('filled', 'true'); | |
1615 rectmid23.setAttribute('stroked', 'true'); | |
1616 rectmid23.setAttribute('fillcolor', '#ffffff'); | |
1617 rectmid23.setAttribute('strokecolor', 'green'); | |
1618 rectmid23.setAttribute('strokeweight', '1px'); | |
1619 | |
1620 var rectmid34 = this.container.ownerDocument.createElement('v:rect'); | |
1621 rectmid34.style.position = 'relative'; | |
1622 rectmid34.style.left = (box.width/2)-5; | |
1623 rectmid34.style.top = box.height+5; | |
1624 rectmid34.style.width = 10; | |
1625 rectmid34.style.height = 10; | |
1626 rectmid34.setAttribute('filled', 'true'); | |
1627 rectmid34.setAttribute('stroked', 'true'); | |
1628 rectmid34.setAttribute('fillcolor', '#ffffff'); | |
1629 rectmid34.setAttribute('strokecolor', 'green'); | |
1630 rectmid34.setAttribute('strokeweight', '1px'); | |
1631 | |
1632 | |
1633 var rectmid41 = this.container.ownerDocument.createElement('v:rect'); | |
1634 rectmid41.style.position = 'relative'; | |
1635 rectmid41.style.left = -10-5 ; | |
1636 rectmid41.style.top =(box.height/2)-5; | |
1637 rectmid41.style.width = 10; | |
1638 rectmid41.style.height = 10; | |
1639 rectmid41.setAttribute('filled', 'true'); | |
1640 rectmid41.setAttribute('stroked', 'true'); | |
1641 rectmid41.setAttribute('fillcolor', '#ffffff'); | |
1642 rectmid41.setAttribute('strokecolor', 'green'); | |
1643 rectmid41.setAttribute('strokeweight', '1px'); | |
1644 | |
1645 | |
1646 | |
1647 | |
1648 var colorin="#ff0000"; | |
1649 var colorout="#ffffff" | |
1650 | |
1651 circle1.attachEvent("onmouseover", function(event) {circle1.style.cursor= 's-resize'; circle1.setAttribute('fillcolor', colorin ); typeTransform='Rotate'; scaleType='nw'; }, false); | |
1652 circle1.attachEvent("onmouseout", function(event) {circle1.style.cursor= 'default'; circle1.setAttribute('fillcolor', colorout ); typeTransform='Rotate'; }, false); //typeTransform='rotate' | |
1653 | |
1654 | |
1655 rect1.attachEvent("onmouseover", function(event) {rect1.style.cursor= 'nw-resize'; rect1.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='nw'; }, false); | |
1656 rect1.attachEvent("onmouseout", function(event) {rect1.style.cursor= 'default'; rect1.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); //typeTransform='rotate' | |
1657 | |
1658 rect2.attachEvent("onmouseover", function(event) {rect2.style.cursor= 'ne-resize'; rect2.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='ne';}, false); | |
1659 rect2.attachEvent("onmouseout", function(event) {rect2.style.cursor= 'default'; rect2.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); | |
1660 | |
1661 rect3.attachEvent("onmouseover", function(event) {rect3.style.cursor= 'se-resize'; rect3.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='se';}, false); | |
1662 rect3.attachEvent("onmouseout", function(event) {rect3.style.cursor= 'default'; rect3.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); | |
1663 | |
1664 rect4.attachEvent("onmouseover", function(event) {rect4.style.cursor= 'sw-resize'; rect4.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='sw';}, false); | |
1665 rect4.attachEvent("onmouseout", function(event) {rect4.style.cursor= 'default'; rect4.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); | |
1666 | |
1667 rectmid12.attachEvent("onmouseover", function(event) {rectmid12.style.cursor= 'n-resize'; rectmid12.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='n';}, false); | |
1668 rectmid12.attachEvent("onmouseout", function(event) {rectmid12.style.cursor= 'default'; rectmid12.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); | |
1669 | |
1670 rectmid23.attachEvent("onmouseover", function(event) {rectmid23.style.cursor= 'e-resize'; rectmid23.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='e';}, false); | |
1671 rectmid23.attachEvent("onmouseout", function(event) {rectmid23.style.cursor= 'default'; rectmid23.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); | |
1672 | |
1673 rectmid34.attachEvent("onmouseover", function(event) {rectmid34.style.cursor= 's-resize'; rectmid34.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='s';}, false); | |
1674 rectmid34.attachEvent("onmouseout", function(event) {rectmid34.style.cursor= 'default'; rectmid34.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); | |
1675 | |
1676 rectmid41.attachEvent("onmouseover", function(event) {rectmid41.style.cursor= 'w-resize'; rectmid41.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='w'; }, false); | |
1677 rectmid41.attachEvent("onmouseout", function(event) {rectmid41.style.cursor= 'default'; rectmid41.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); | |
1678 //tracker.setAttribute('transform',trshape); | |
1679 | |
1680 | |
1681 | |
1682 tracker.appendChild(border_square); | |
1683 tracker.appendChild(border_angle); | |
1684 | |
1685 tracker.appendChild(circle1); | |
1686 | |
1687 tracker.appendChild(rect1); | |
1688 tracker.appendChild(rect2); | |
1689 tracker.appendChild(rect3); | |
1690 tracker.appendChild(rect4); | |
1691 tracker.appendChild(rectmid12); | |
1692 tracker.appendChild(rectmid23); | |
1693 tracker.appendChild(rectmid34); | |
1694 tracker.appendChild(rectmid41); | |
1695 | |
1696 /* | |
1697 | |
1698 | |
1699 | |
1700 */ | |
1701 | |
1702 | |
1703 this.container.appendChild(tracker); | |
1704 | |
1705 | |
1706 | |
1707 } | |
1708 | |
1709 | |
1710 | |
1711 | |
1712 | |
1713 | |
1714 | |
1715 | |
1716 | |
1717 | |
1718 VMLRenderer.prototype.getMarkup = function() { | |
1719 | |
1720 return this.container.innerHTML; | |
1721 } | |
1722 | |
1723 | |
1724 | |
1725 ///////////////////////////////// | |
1726 | |
1727 | |
1728 | |
1729 var rotatexxx=0; | |
1730 | |
1731 var scaleType=''; | |
1732 var xrot=0; | |
1733 var yrot=0; | |
1734 | |
1735 var point = {x:0, y:0, width: 0, height:0}; | |
1736 | |
1737 function createPoint (x, y, width, height) { | |
1738 //var point = {x:34, y:22, width: 22, height:23}; | |
1739 //point.x = x; | |
1740 //point.y = y; | |
1741 point = {x:x, y:y, width: width, height:height}; | |
1742 return point; | |
1743 } | |
1744 | |
1745 | |
1746 ///////////////////////////////// | |
1747 | |
1748 VMLRenderer.prototype.restruct= function(shape) | |
1749 { | |
1750 }; | |
1751 | |
1752 | |
1753 | |
1754 VMLRenderer.prototype.transform = function() { | |
1755 | |
1756 }; | |
1757 | |
1758 VMLRenderer.prototype.scaleShape = function(shape, previus,toX, toY) { | |
1759 // document.forms[0].code.value="escala"; | |
1760 | |
1761 //document.forms[0].code.value="escala"; | |
1762 var box = this.bounds(shape); | |
1763 var prevbox=this.bounds(previus); | |
1764 var centerx= box.x+(box.width/2); | |
1765 var centery= box.y+(box.height/2); | |
1766 var coord=this.editor.inputxy; | |
1767 toX=parseFloat(coord[0]); | |
1768 toY=parseFloat(coord[1]); | |
1769 var d2p_center=dist2p(centerx,centery,toX,toY); | |
1770 | |
1771 var d2p=dist2p(box.x,box.y,toX,toY); | |
1772 | |
1773 var shareScale=box.width/d2p; | |
1774 | |
1775 var trans_ShareScale=''; | |
1776 var tx, ty, tw, yh; | |
1777 | |
1778 if(scaleType.length==1){ | |
1779 if(scaleType== 'w') | |
1780 { | |
1781 trans_ShareScale=shareScale+",1"; | |
1782 tx=toX; | |
1783 ty=prevbox.y; | |
1784 var dist=prevbox.x-toX; | |
1785 var w=dist+prevbox.width; | |
1786 if(w<1){w=1;} | |
1787 tw=w; | |
1788 th=prevbox.height; | |
1789 //document.forms[0].code.value=box.x+' '+toX+' '+dist+''; | |
1790 } | |
1791 if(scaleType== 'e') | |
1792 { | |
1793 trans_ShareScale=shareScale+",1"; | |
1794 tx=prevbox.x; | |
1795 ty=prevbox.y; | |
1796 var dist=toX-(prevbox.x+prevbox.width); //dist2p(toX,b,c,d); | |
1797 var w=dist+prevbox.width; | |
1798 if(w<1){w=1;} | |
1799 tw=w; | |
1800 th=prevbox.height; | |
1801 | |
1802 } | |
1803 if(scaleType== 'n') | |
1804 { | |
1805 trans_ShareScale="1,"+shareScale; | |
1806 | |
1807 tx=prevbox.x; | |
1808 ty=toY; | |
1809 var dist=prevbox.y-toY; | |
1810 var h=dist+prevbox.height; | |
1811 if(h<1){h=1;} | |
1812 tw=prevbox.width; | |
1813 th=h; | |
1814 | |
1815 } | |
1816 if( scaleType== 's') | |
1817 { | |
1818 trans_ShareScale="1,"+shareScale; | |
1819 | |
1820 tx=prevbox.x; | |
1821 ty=prevbox.y; | |
1822 var dist=toY-(prevbox.y+prevbox.height); //dist2p(toX,b,c,d); | |
1823 var h=dist+prevbox.height; | |
1824 if(h<1){h=1;} | |
1825 tw=prevbox.width; | |
1826 th=h; | |
1827 | |
1828 } | |
1829 } | |
1830 if(scaleType.length==2){ | |
1831 if(scaleType== 'nw'){ | |
1832 trans_ShareScale=shareScale+","+shareScale; | |
1833 | |
1834 //var angle_diagonal=getAngle(prevbox.width,prevbox.height); | |
1835 var angle_diagonal=ang2v(prevbox.x,prevbox.y,prevbox.x+prevbox.width,prevbox.y+prevbox.height) | |
1836 | |
1837 var ax= prevbox.x; | |
1838 var ay= prevbox.y; | |
1839 var bx= prevbox.x+prevbox.width; | |
1840 var by= prevbox.y+prevbox.height; | |
1841 | |
1842 var cx= toX; | |
1843 var cy= toY; | |
1844 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); | |
1845 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); | |
1846 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
1847 this.editor.log(angle_diagonal* 180 / Math.PI); | |
1848 | |
1849 var tx= section_a[1]; | |
1850 var ty= section_a[2]; | |
1851 | |
1852 var ax= section_a[1]; | |
1853 var ay= section_a[2]; | |
1854 var bx= 0; | |
1855 var by= section_a[2] ; | |
1856 | |
1857 var cx=prevbox.x+prevbox.width; | |
1858 var cy= prevbox.y; | |
1859 | |
1860 var dx= prevbox.x+prevbox.width; | |
1861 var dy= 0; | |
1862 | |
1863 | |
1864 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
1865 | |
1866 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); | |
1867 | |
1868 var ax= section_a[1]; | |
1869 var ay= section_a[2]; | |
1870 var bx= section_a[1] | |
1871 var by= 0; | |
1872 | |
1873 var cx= prevbox.x; | |
1874 var cy= prevbox.y+prevbox.height; | |
1875 | |
1876 var dx= 0; | |
1877 var dy= prevbox.y+prevbox.height; | |
1878 | |
1879 | |
1880 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
1881 | |
1882 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); | |
1883 | |
1884 | |
1885 | |
1886 | |
1887 | |
1888 if(distx<1){distx=1;} | |
1889 | |
1890 | |
1891 if(disty<1){disty=1;} | |
1892 //document.forms[0].code.value=distx+' '+disty; | |
1893 tw=distx; | |
1894 th=disty; | |
1895 | |
1896 | |
1897 } | |
1898 | |
1899 //////////////////// SE | |
1900 | |
1901 if( scaleType== 'se'){ | |
1902 trans_ShareScale=shareScale+","+shareScale; | |
1903 | |
1904 | |
1905 //var angle_diagonal=getAngle(prevbox.width,prevbox.height); | |
1906 var angle_diagonal=ang2v(prevbox.x,prevbox.y,prevbox.x+prevbox.width,prevbox.y+prevbox.height) | |
1907 | |
1908 | |
1909 | |
1910 var ax= prevbox.x; | |
1911 var ay= prevbox.y; | |
1912 var bx= prevbox.x+prevbox.width; | |
1913 var by= prevbox.y+prevbox.height; | |
1914 | |
1915 var cx= toX; | |
1916 var cy= toY; | |
1917 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); | |
1918 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); | |
1919 | |
1920 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
1921 | |
1922 | |
1923 | |
1924 ////////// | |
1925 var tx= prevbox.x; | |
1926 var ty= prevbox.y; | |
1927 | |
1928 var ax= section_a[1]; | |
1929 var ay= section_a[2]; | |
1930 var bx= 0; | |
1931 var by= section_a[2] ; | |
1932 | |
1933 var cx=prevbox.x; | |
1934 var cy= prevbox.y; | |
1935 | |
1936 var dx= prevbox.x; | |
1937 var dy= 0; | |
1938 | |
1939 | |
1940 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
1941 | |
1942 ///////////////// | |
1943 | |
1944 | |
1945 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); | |
1946 | |
1947 | |
1948 var ax= section_a[1]; | |
1949 var ay= section_a[2]; | |
1950 var bx= section_a[1] | |
1951 var by= 0; | |
1952 | |
1953 var cx= prevbox.x; | |
1954 var cy= prevbox.y; | |
1955 | |
1956 var dx=0; | |
1957 var dy= prevbox.y; | |
1958 | |
1959 | |
1960 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
1961 | |
1962 /////////////// | |
1963 | |
1964 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); | |
1965 | |
1966 | |
1967 | |
1968 if(distx<1){distx=1;} | |
1969 | |
1970 | |
1971 if(disty<1){disty=1;} | |
1972 | |
1973 tw=distx; | |
1974 th=disty; | |
1975 | |
1976 | |
1977 } | |
1978 | |
1979 if(scaleType== 'ne'){ | |
1980 | |
1981 trans_ShareScale=shareScale+","+shareScale; | |
1982 | |
1983 var angle_diagonal=ang2v(prevbox.x,prevbox.y+prevbox.height,prevbox.x+prevbox.width,prevbox.y) | |
1984 //var angle_diagonal=getAngle(prevbox.width,prevbox.height); | |
1985 | |
1986 | |
1987 | |
1988 | |
1989 var ax= prevbox.x; | |
1990 var ay= prevbox.y+prevbox.height; | |
1991 var bx= prevbox.x+prevbox.width; | |
1992 var by= prevbox.y; | |
1993 | |
1994 var cx= toX; | |
1995 var cy= toY; | |
1996 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); | |
1997 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); | |
1998 | |
1999 | |
2000 this.editor.log(angle_diagonal); | |
2001 | |
2002 | |
2003 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
2004 | |
2005 | |
2006 | |
2007 ////////// | |
2008 var tx= prevbox.x; | |
2009 var ty= section_a[2]; | |
2010 | |
2011 var ax= section_a[1]; | |
2012 var ay= section_a[2]; | |
2013 var bx= 0; | |
2014 var by= section_a[2] ; | |
2015 | |
2016 var cx=prevbox.x; | |
2017 var cy= prevbox.y; | |
2018 | |
2019 var dx= prevbox.x; | |
2020 var dy= 0; | |
2021 | |
2022 | |
2023 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
2024 | |
2025 ///////////////// | |
2026 | |
2027 | |
2028 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); | |
2029 | |
2030 | |
2031 var ax= section_a[1]; | |
2032 var ay= section_a[2]; | |
2033 var bx= section_a[1]; | |
2034 var by= 0; | |
2035 | |
2036 var cx= prevbox.x; | |
2037 var cy= prevbox.y+prevbox.height; | |
2038 | |
2039 var dx=0; | |
2040 var dy= prevbox.y+prevbox.height; | |
2041 | |
2042 | |
2043 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
2044 | |
2045 /////////////// | |
2046 | |
2047 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); | |
2048 | |
2049 | |
2050 | |
2051 if(distx<1){distx=1;} | |
2052 | |
2053 | |
2054 if(disty<1){disty=1;} | |
2055 //document.forms[0].code.value=distx+' '+disty; | |
2056 tw=distx; | |
2057 th=disty; | |
2058 | |
2059 | |
2060 | |
2061 | |
2062 | |
2063 } | |
2064 if(scaleType== 'sw'){ | |
2065 trans_ShareScale=shareScale+","+shareScale; | |
2066 | |
2067 | |
2068 | |
2069 | |
2070 var angle_diagonal=ang2v(prevbox.x,prevbox.y+prevbox.height,prevbox.x+prevbox.width,prevbox.y) | |
2071 //var angle_diagonal=getAngle(prevbox.width,prevbox.height); | |
2072 | |
2073 | |
2074 | |
2075 | |
2076 var ax= prevbox.x; | |
2077 var ay= prevbox.y+prevbox.height; | |
2078 var bx= prevbox.x+prevbox.width; | |
2079 var by= prevbox.y; | |
2080 | |
2081 var cx= toX; | |
2082 var cy= toY; | |
2083 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); | |
2084 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); | |
2085 | |
2086 | |
2087 this.editor.log(angle_diagonal); | |
2088 | |
2089 | |
2090 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
2091 | |
2092 | |
2093 ////////// | |
2094 var tx= section_a[1]; | |
2095 var ty= prevbox.y; | |
2096 | |
2097 var ax= section_a[1]; | |
2098 var ay= section_a[2]; | |
2099 var bx= 0; | |
2100 var by= section_a[2] ; | |
2101 | |
2102 var cx=prevbox.x+prevbox.width; | |
2103 var cy= prevbox.y+prevbox.height; | |
2104 | |
2105 var dx= prevbox.x+prevbox.width; | |
2106 var dy= 0; | |
2107 | |
2108 | |
2109 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
2110 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); | |
2111 | |
2112 ///////////////// | |
2113 var ax= section_a[1]; | |
2114 var ay= section_a[2]; | |
2115 var bx= section_a[1]; | |
2116 var by= 0; | |
2117 | |
2118 var cx= prevbox.x; | |
2119 var cy= prevbox.y; | |
2120 | |
2121 var dx=0; | |
2122 var dy= prevbox.y; | |
2123 | |
2124 | |
2125 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); | |
2126 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); | |
2127 /////////////// | |
2128 | |
2129 | |
2130 | |
2131 if(distx<1){distx=1;} | |
2132 | |
2133 | |
2134 if(disty<1){disty=1;} | |
2135 //document.forms[0].code.value=distx+' '+disty; | |
2136 tw=distx; | |
2137 th=disty; | |
2138 | |
2139 } | |
2140 | |
2141 } | |
2142 | |
2143 | |
2144 | |
2145 if(shape.tagName == 'rect') | |
2146 { | |
2147 //alert(data[0]); | |
2148 | |
2149 | |
2150 shape.style.left = tx + 'px'; | |
2151 shape.style.top = ty + 'px'; | |
2152 shape.style.height = th + 'px'; | |
2153 shape.style.width = tw + 'px'; | |
2154 | |
2155 } | |
2156 else | |
2157 if(shape.tagName == 'text') | |
2158 { | |
2159 /* | |
2160 shape.setAttribute('x',tx); | |
2161 shape.setAttribute('y',ty); | |
2162 shape.setAttribute('width', tw); | |
2163 shape.setAttribute('height', th); | |
2164 | |
2165 //previus.setAttribute('transform', "scale("+trans_ShareScale+")"); | |
2166 shape.setAttribute('x', tx + 'px'); | |
2167 shape.setAttribute('y', ty + 'px'); | |
2168 | |
2169 shape.setAttribute('textLength', parseInt(Math.round(tw))); | |
2170 | |
2171 */ | |
2172 } | |
2173 else | |
2174 if(shape.tagName == 'oval') | |
2175 { | |
2176 //shape.getAttribute('transform) | |
2177 | |
2178 shape.style.left = tx + 'px'; | |
2179 shape.style.top = ty + 'px'; | |
2180 shape.style.height = th + 'px'; | |
2181 shape.style.width = tw + 'px'; | |
2182 | |
2183 | |
2184 } | |
2185 else | |
2186 if(shape.tagName == 'line') | |
2187 { | |
2188 shape.setAttribute('to',tx + 'px,' + ty + 'px'); | |
2189 shape.setAttribute('from', tw + 'px,' + th + 'px'); | |
2190 | |
2191 | |
2192 } | |
2193 else | |
2194 if (shape.tagName == 'polyline') | |
2195 { | |
2196 | |
2197 } | |
2198 else | |
2199 if (shape.tagName == 'image') | |
2200 { | |
2201 | |
2202 shape.style.left = tx + 'px'; | |
2203 shape.style.top = ty + 'px'; | |
2204 shape.style.height = th + 'px'; | |
2205 shape.style.width = tw + 'px'; | |
2206 | |
2207 } | |
2208 else | |
2209 if (shape.tagName == 'shape') | |
2210 { | |
2211 | |
2212 shape.style.left = tx + 'px'; | |
2213 shape.style.top = ty + 'px'; | |
2214 shape.style.height = th + 'px'; | |
2215 shape.style.width = tw + 'px'; | |
2216 | |
2217 //document.forms[0].code.value=''; | |
2218 //shape.setAttribute('transform', "scale("+trans_ShareScale+")"); | |
2219 | |
2220 } | |
2221 | |
2222 | |
2223 | |
2224 | |
2225 | |
2226 }; | |
2227 | |
2228 | |
2229 | |
2230 VMLRenderer.prototype.rotateShape = function(shape, previus,toX, toY) { | |
2231 | |
2232 | |
2233 | |
2234 //document.forms[0].code.value=$('xyinput').innerHTML; | |
2235 //document.getElementById('richdraw').style.cursor='e-resize'; | |
2236 var box = this.bounds(shape); | |
2237 var prevbox=this.bounds(previus); | |
2238 var centerx= box.x+(box.width/2); | |
2239 var centery= box.y+(box.height/2); | |
2240 var coord=this.editor.inputxy; | |
2241 | |
2242 var actual_angle=ang2v(centerx,centery,coord[0], coord[1]); | |
2243 | |
2244 if(xrot<toX) { rotatexxx+=1;}else{rotatexxx-=1;} | |
2245 xrot=toX; | |
2246 yrot=toY; | |
2247 | |
2248 var xtr=0; | |
2249 var ytr=0; | |
2250 | |
2251 //var box= shape.getBBox(); | |
2252 var tr1x= box.x; | |
2253 var tr1y= box.y; | |
2254 | |
2255 | |
2256 | |
2257 toX+=xtr; | |
2258 toY+=xtr; | |
2259 | |
2260 //var trax=parseFloat(toX-box.x); var tray= parseFloat(toY-box.y); | |
2261 var trax=parseFloat(box.x/2); var tray= parseFloat(box.y/2); | |
2262 var angler=Math.atan2(toX,toY); | |
2263 var angle=angler*180/Math.PI; | |
2264 // var T = shape.getCTM(); | |
2265 //var rotini=T.a*(180 / Math.PI); | |
2266 //var angle=rotini*180/Math.PI; | |
2267 //var rot_angle=actual_angle*180/Math.PI; | |
2268 //document.forms[0].code.value=centerx+' '+centery+' '+coord[0]+' '+coord[1]+'____ '+rot_angle+' '+actual_angle*180/Math.PI; | |
2269 | |
2270 | |
2271 // matrix( a, b, c, d, e, f ) | |
2272 // a c e | |
2273 // b d f | |
2274 // 0 0 1 | |
2275 //a scale factor of 2, a rotation of 30 deg and a translation of (500,50) | |
2276 //T 1.732 -1 500 1 1.732 50 0 0 1 | |
2277 //T 1 ad-bc d -c -de+cf -b a be-df 0 0 1 | |
2278 | |
2279 //shape.setAttribute('transform', "translate("+(-xshe)+","+(-yshe)+")"); | |
2280 | |
2281 // shape.setAttribute("transform", " matrix( a, b, c, d, e, f )"); | |
2282 // shape.setAttribute('transform', "translate("+(box.x+(box.width/2))+","+(box.y+(box.height/2))+") rotate("+rotatexxx+") "); | |
2283 //shape.setAttribute('transform', "translate("+(box.x+(box.width/2))+","+(box.y+(box.height/2))+") rotate("+rotatexxx+") translate("+(-box.x-(box.width/2))+","+(-box.y-(box.height/2))+") "); | |
2284 //shape.setAttribute('transform', "rotate("+rotatexxx+","+(box.x+(box.width/2))+","+(box.y+(box.height/2))+")"); | |
2285 //shape.setAttribute('transform', "rotate("+rotatexxx+","+(prevbox.x+(prevbox.width/2))+","+(prevbox.y+(prevbox.height/2))+")"); | |
2286 //shape.setAttribute('rotation', rot_angle); | |
2287 shape.setAttribute('rotation', angle); | |
2288 //(prevbox.x+(prevbox.width/2))+","+(prevbox.y+(prevbox.height/2))+")"); | |
2289 | |
2290 | |
2291 | |
2292 } | |
2293 | |
2294 ////////////////////////////// | |
2295 /*H = 0; | |
2296 W = 0; | |
2297 LX = new Array(); | |
2298 S = new Array(); | |
2299 i = 0; | |
2300 b = true; | |
2301 | |
2302 function SVG2VML(i){ | |
2303 l = L[i]; | |
2304 if(l.indexOf(" d=")>0){ | |
2305 p = l.indexOf("fill:")+6; | |
2306 C = l.substring(p,p+7); | |
2307 p = l.indexOf(" d=")+4; | |
2308 q = l.lastIndexOf("z")-1; | |
2309 l = l.substring(p,q); | |
2310 l = l.replace(/M/g,"m"); | |
2311 l = l.replace(/c/g,"v"); | |
2312 l = l.replace(/l/g,"r"); | |
2313 S = l.split(" "); | |
2314 l=""; | |
2315 for(var j in S){ | |
2316 c = S[j]; | |
2317 p = c.substring(0,1); | |
2318 d = p>"9"?p:""; | |
2319 n = Math.round(c.substring(d!="") * 100); | |
2320 l+= (d+n+" "); | |
2321 } | |
2322 LX[i] = l; | |
2323 code = '<v:shape coordsize="'+(W*100)+','+(H*100)+'" class=vml strokeweight="2" strokecolor="'+C+'" filled="false" fillcolor = "'+C+'"/>'; | |
2324 VML.insertAdjacentHTML("beforeEnd",code); | |
2325 } else { | |
2326 L[i] = LX[i] = "" | |
2327 VML.insertAdjacentHTML("beforeEnd","<span></span>"); | |
2328 } | |
2329 } | |
2330 */ | |
2331 //http://msdn2.microsoft.com/en-us/library/bb263897(VS.85).aspx | |
2332 //http://www.w3.org/TR/NOTE-VML | |
2333 //http://trac.openlayers.org/changeset/5285 | |
2334 //http://vectorconverter.sourceforge.net/index.html | |
2335 //http://www.dhteumeuleu.com/colorsyntax/viewJS.php?src=svg2vml1.html | |
2336 | |
2337 | |
2338 VMLRenderer.prototype.getshapes = function(){ | |
2339 return this.container.childNodes; | |
2340 } | |
2341 | |
2342 | |
2343 VMLRenderer.prototype.reflect = function(HorV) { | |
2344 }; | |
2345 | |
2346 | |
2347 | |
2348 |