view 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
line wrap: on
line source
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
10 This program is free software; you can redistribute it and/or modify it
11 under the terms of the MIT License.
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.
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 --------------------------------------------------------------------------*/
37 function VMLRenderer() {
38 this.base = AbstractRenderer;
39 }
42 VMLRenderer.prototype = new AbstractRenderer;
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 }
58 VMLRenderer.prototype.view = function(left,top,width,height,viewBox) {
59 if(mode=='preview')
60 {
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'
67 this.container.style.width = width;//document.getElementById('FRONT').style.width;
68 this.container.style.height =height;//document.getElementById('FRONT').style.height;
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 {
93 //
94 this.container.style.top =0+'px';
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];
115 this.container.style.left =canvasLeft+'px'
116 this.container.style.top =canvasTop+'px'
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 }
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) {
158 var tokens = zoominit1.split(' ');
159 var shape = document.getElementById('rectCanvas');
160 if (shape) {
161 this.remove(shape);
162 }
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');
175 this.container.insertBefore(rect, this.container.firstChild );
177 }
179 VMLRenderer.prototype.removeAll = function(){
180 while (this.container.hasChildNodes()) {
181 this.container.removeChild(this.container.firstChild);
182 }
183 }
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;
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;
205 return {"x":parseFloat(Math.round(left)), "y":parseFloat(Math.round(top)), "w":parseFloat(Math.round(width)), "h":parseFloat(Math.round(height))};
206 }
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;
216 var zoom=VMLviewBox(this.container,left,top,textSize,textSize);
217 if(zoom.w<1){zoom.w=1}
218 textSize=zoom.h;
220 var zoom=VMLviewBox(this.container,left,top,lineWidth*2/3,lineWidth);
221 if(zoom.w<1){zoom.w=1}
222 lineWidth=zoom.w;
225 var vml;
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%');
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');
260 }
261 else if (shape == 'polyline') {
262 vml = this.container.ownerDocument.createElement('v:polyline');
263 vml.setAttribute("points", points);
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 = "";
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){
287 var point =ps[i].split(",");
288 var char1=point[0].substring(0,1);
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;
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;
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 }
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');
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]);
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);
333 var path01 = this.container.ownerDocument.createElement('v:path');
334 path01.setAttribute("v", thispath+' e');
338 vml.appendChild(path01)
340 }
342 else if (shape == 'controlpath')
343 {
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');
353 var path01 = this.container.ownerDocument.createElement('v:path');
354 path01.setAttribute('v', 'm '+left+','+top+' c'+(left+1)+','+(top+1)+' e ');
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);
381 }
383 else if (shape == 'text')
384 {
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');
410 var pathObj = this.container.ownerDocument.createElement("v:path");
411 pathObj.setAttribute('textpathok', 'true');
412 vml.appendChild(textPathObj);
413 vml.appendChild(pathObj);
416 }
420 else if (shape == 'texto')
421 {
422 vml = this.container.ownerDocument.createElement('v:shape');
423 vml.style.position="absolute";
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);
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);
448 divtext.style.color=fillColor;
454 //divtext.setAttribute('v-rotate-letters','true');
455 if(transform.indexOf('rotate')>=0)
456 {
458 myRotate1=transform.split('rotate(');
459 myRotate2=myRotate1[1].split(')');
460 myRotate3=myRotate2[0].split(',');
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 }
472 divtext.innerHTML=textMessaje;
473 textBox.appendChild(divtext);
475 vml.appendChild(textBox);
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 }
484 if(shape == 'zoom')
485 {
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(',');
495 vml.style.rotation= myRotate3[0]+'Deg';
496 vml.style.centerX=myRotate3[1];
497 vml.style.centerY=myRotate3[2];
499 }
501 if(shape != 'image' )
502 {
504 if (fillColor != '' || fillColor != 'none')
505 {
506 vml.setAttribute('filled', 'true');
507 vml.setAttribute('fillcolor', fillColor);
509 }
510 else
511 {
512 vml.setAttribute('filled', 'false');
513 }
516 if(lineWidth==0 || lineWidth=='none' || lineColor== 'none' )
517 {
518 vml.setAttribute('stroked', 'false');
519 }
520 else
521 {
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 }
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 };
553 VMLRenderer.prototype.zoom = function(clicx,clicy)
554 {
555 }
557 VMLRenderer.prototype.datacreate = function(fillColor, lineColor, fillOpac, lineOpac, lineWidth, left, top, width, height, textMessaje, textSize, textFamily, imageHref, transform)
558 {
559 }
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;
570 };
574 VMLRenderer.prototype.index = function(shape,order) {
576 if(order==-1)
577 {
578 this.container.appendChild( shape );
579 }
580 if(order==0){
582 this.container.insertBefore( shape, shape.parentNode.firstChild );
583 }
585 if(order==1 || order==2)
586 {
587 var id=shape.getAttribute('id');
588 //alert(id);
591 var numNodes=this.container.childNodes.length;
592 //alert(numNodes);
594 var num=0;
595 for(var i = 1; i < numNodes; i++)
596 {
598 var etiq=this.container.childNodes[i].getAttribute('id');
599 if (etiq==id)
600 {
601 num=i;
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 }
620 }
624 }
625 VMLRenderer.prototype.remove = function(shape) {
626 if(shape!=null){ shape.removeNode(true); }
627 }
630 VMLRenderer.prototype.copy = function(shape)
631 {
632 var vml;
633 vml =shape.cloneNode(false);
634 //vml.setAttribute('fillcolor', "#aa00aa");
635 return vml;
636 };
639 VMLRenderer.prototype.paste = function(clipboard,left,top)
640 {
641 this.container.appendChild(clipboard);
642 return clipboard;
643 };
647 VMLRenderer.prototype.undo = function()
648 {
649 this.container.removeChild( this.container.lastChild );
650 };
653 var xshe=0;
654 var yshe=0;
655 var isArc=false;
656 var contArc=0;
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;
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;
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 }
687 if (shape.tagName == 'image') {
688 shape.style.left = left;
689 shape.style.top = top;
690 }
691 if (shape.tagName == 'shape') {
693 shape.style.left=left+"px";
694 shape.style.top=top+"px";
696 }
699 };
702 VMLRenderer.prototype.track = function(shape) {
703 // TODO
704 };
706 VMLRenderer.prototype.clic = function(shape) {
707 var end='';
708 if(data_path_close==true){end=' ';}
710 var thispath='m '+setPoints[0]+' l';
711 var maxcont=setPoints.length;
713 for(var conta=1;conta< maxcont;conta++){
714 thispath+=setPoints[conta]+' ';
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";
726 shape.children[0].setAttribute("v",path);
727 document.forms[0].control_codebase.value=path;
729 }
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; }
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 }
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);
764 //xpArray.push(finetoX);
765 //ypArray.push(finetoY);
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;
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 {
794 if (selectmode == 'controlpath')
795 {
797 var end='';
798 if(data_path_close==true){end=' ';}
800 var thispath='m '+setPoints[0]+' l';
801 var maxcont=setPoints.length;
803 for(var conta=1;conta< maxcont;conta++){
804 thispath+=setPoints[conta]+' ';
807 }
808 var path=thispath+toX+','+toY+end+' e';
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";
816 shape.children[0].setAttribute("v",path);
817 document.forms[0].control_codebase.value=path;
820 }
821 else
822 {
824 xpArray.push(toX);
825 ypArray.push(toY);
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]+'';
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";
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');
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 }
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 }
885 };
888 VMLRenderer.prototype.tocurve = function() {
891 };
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'));
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'));
923 }
924 else if (shape.tagName == 'line')
925 {
926 shInfo.left = parseFloat(shape.getAttribute('x1'));
927 shInfo.top = parseFloat(shape.getAttribute('y1'));
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
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'));
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
958 }
959 }
960 return shInfo;
963 }
964 VMLRenderer.prototype.transformShape = function(shape,data,transform)
965 {
967 if(shape.tagName == 'rect')
968 {
970 var box = this.bounds(shape);
971 var sdata=data.split(';');
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';
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]);
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]);
1001 //shape.nodparseFloatue=data;
1003 else
1004 if (shape.tagName == 'polyline')
1006 shape.setAttribute('points',data);
1008 else
1009 if (shape.tagName == 'image')
1011 //alert(data);
1012 if(data.indexOf(';',0)==-1 )
1014 shape.setAttribute('src',data);
1016 else
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]);
1032 else
1033 if (shape.tagName == 'path')
1035 if(data.indexOf(';',0)==-1 )
1037 //shape.setAttribute( 'd', data); //????????
1038 //shape.setAttribute( 'transform', transform);
1040 else
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])+')');
1054 VMLRenderer.prototype.editShape = function(shape,data)
1056 if(shape.tagName == 'text'){
1057 shape.textContent = data
1058 }else
1059 if (shape.tagName == 'polyline')
1061 shape.setAttribute('points',data);
1063 else
1065 if (shape.tagName == 'path')
1067 shape.setAttribute('v', data);
1073 VMLRenderer.prototype.editCommand = function(shape, cmd, value)
1075 if (shape != null) {
1076 if (cmd == 'fillcolor') {
1077 if (value != '') {
1078 shape.filled = 'true';
1079 shape.fillcolor = value;
1081 else {
1082 shape.filled = 'false';
1083 shape.fillcolor = '';
1086 else if (cmd == 'linecolor') {
1087 if (value != '') {
1088 shape.stroked = 'true';
1089 shape.strokecolor = value;
1091 else {
1092 shape.stroked = 'false';
1093 shape.strokecolor = '';
1096 else if (cmd == 'linewidth') {
1097 shape.strokeweight = parseInt(value) + 'px';
1099 else if (cmd == 'fillopacity') {
1101 shape.fill.opacity= parseFloat(value);
1102 //shape.style.fill.setAttribute("opacity", parseFloat(value));
1109 VMLRenderer.prototype.queryCommand = function(shape, cmd)
1111 if (shape != null) {
1112 if (cmd == 'fillcolor') {
1113 if (shape.filled == 'false')
1114 return '';
1115 else
1116 return shape.fillcolor;
1118 else if (cmd == 'linecolor') {
1119 if (shape.stroked == 'false')
1120 return '';
1121 else
1122 return shape.strokecolor;
1124 else if (cmd == 'linewidth') {
1125 if (shape.stroked == 'false') {
1126 return '';
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';
1136 VMLRenderer.prototype.getProperties = function(shape)
1138 var result = '';
1140 if (shape != null)
1142 result = shape.getAttribute('fillcolor');
1143 if (result == 'none')
1145 mefillColor.visible = 'hidden';
1146 mefillColor.hex = '#000000';
1147 filldraw=true;
1148 setbe(1,'img_okfill');
1150 else
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');
1164 result = shape.getAttribute('strokecolor');
1165 if (result == 'none')
1167 mestrokeColor.visible = 'hidden';
1168 mestrokeColor.hex = '#000000';
1169 mestrokeColor.width = 0;
1170 strokedraw=true;
1171 setbe(2,'img_okstroke');
1174 else
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');
1187 result = shape.getAttribute('strokeweight');
1188 mestrokeColor.width = result;
1190 result = shape.fill.getAttribute('opacity');
1191 mefillColor.opacity = result;
1193 result = shape.stroke.getAttribute('opacity');
1194 mestrokeColor.opacity = result;
1196 setProperties();
1201 VMLRenderer.prototype.showMultiSelect = function(iniX,iniY) {
1202 var tracker = document.getElementById('trackerMultiSelect');
1203 if (tracker) {
1204 this.remove(tracker);
1206 var coord=this.editor.inputxy;
1207 toX=parseFloat(coord[0]);
1208 toY=parseFloat(coord[1]);
1210 tracker = this.container.ownerDocument.createElement('v:rect');
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');
1222 this.container.appendChild(tracker);
1225 function mouseCoord()
1227 var coord=this.editor.inputxy;
1228 coord[0]=parseFloat(coord[0]);
1229 coord[1]=parseFloat(coord[1]);
1230 return coord
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;
1242 $('option_path_x').value=newx;
1243 $('option_path_y').value=newy;
1245 var cadx= newx;
1246 var cady= newy;
1248 var coord=cadx+','+cady;
1249 var cad1=new RegExp(precoord,"g");
1252 var result=mypath.replace(cad1, coord);
1255 $('control_codebase').value=result;
1257 $('someinfo').value=precoord;
1258 setShape();
1262 function drawNodeControl(vml,numId){
1263 var color1='#0066ff';
1264 // if(parseInt(memoNode.id)==a){
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);
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);
1280 var pointnext=memoNextControl[numId].split(',');
1283 var controlNode2 =this.container.ownerDocument.createElement('v:rect');
1284 controlNode2.setAttribute('x', pointnext[0]-2);
1285 controlNode2.setAttribute('y', pointnext[1]-2);
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);
1296 //}
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++)
1308 segment=points[a].split(' ');
1309 chain+=segment[0]+' ';
1312 $('someinfo').value=numpoints+ ' nodes ';
1313 return chain;
1315 };
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);
1327 if (shape.tagName == 'shape')
1329 shap=2;
1330 if(shape.children[0].tagName == 'path')
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;
1343 if (shape.tagName == 'rect') {
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;
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 */
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 */
1369 if (shape.tagName == 'line'){
1370 /*
1371 $('option_line_trx').value= box.x;
1372 $('option_line_try').value= box.y;
1373 */
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 */
1386 /*var matrix = shape.getScreenCTM();
1387 var trshape= shape.getAttribute('transform');
1388 var shap=1;
1389 if (shape.tagName == 'path') { shap=2;
1394 */
1395 //if (shape.getAttribute('transform') ) { shap=2; }
1396 //var svgNamespace = 'http://www.w3.org/2000/svg';
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);
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 ;
1420 ////////////////
1422 /*
1424 var trshape='translate (0,0) rotate(0) translate(0,0) ';
1425 var trshape_split=trshape.split(') ');
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(') ');
1436 */
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) );
1458 var max = createPoint(corners[0].x, corners[0].y);
1459 var min = createPoint(corners[0].x, corners[0].y);
1461 // identify the new corner coordinates of the
1462 // fully transformed bounding box
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;
1470 else if (x > max.x) {
1471 max.x = x;
1473 if (y < min.y) {
1474 min.y = y;
1476 else if (y > max.y) {
1477 max.y = y;
1482 var border_square = this.container.ownerDocument.createElement('v:rect');
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');
1495 var border_angle = this.container.ownerDocument.createElement('v:polyline');
1496 border_angle.style.position = 'relative';
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)) );
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');
1515 // createRect(min.x, min.y, max.x - min.x, max.y - min.y);
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');
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');
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');
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');
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');
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');
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');
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');
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');
1648 var colorin="#ff0000";
1649 var colorout="#ffffff"
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'
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'
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);
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);
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);
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);
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);
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);
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);
1682 tracker.appendChild(border_square);
1683 tracker.appendChild(border_angle);
1685 tracker.appendChild(circle1);
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);
1696 /*
1700 */
1703 this.container.appendChild(tracker);
1718 VMLRenderer.prototype.getMarkup = function() {
1720 return this.container.innerHTML;
1725 /////////////////////////////////
1729 var rotatexxx=0;
1731 var scaleType='';
1732 var xrot=0;
1733 var yrot=0;
1735 var point = {x:0, y:0, width: 0, height:0};
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;
1746 /////////////////////////////////
1748 VMLRenderer.prototype.restruct= function(shape)
1750 };
1754 VMLRenderer.prototype.transform = function() {
1756 };
1758 VMLRenderer.prototype.scaleShape = function(shape, previus,toX, toY) {
1759 // document.forms[0].code.value="escala";
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);
1771 var d2p=dist2p(box.x,box.y,toX,toY);
1773 var shareScale=box.width/d2p;
1775 var trans_ShareScale='';
1776 var tx, ty, tw, yh;
1778 if(scaleType.length==1){
1779 if(scaleType== 'w')
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+'';
1791 if(scaleType== 'e')
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;
1803 if(scaleType== 'n')
1805 trans_ShareScale="1,"+shareScale;
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;
1816 if( scaleType== 's')
1818 trans_ShareScale="1,"+shareScale;
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;
1830 if(scaleType.length==2){
1831 if(scaleType== 'nw'){
1832 trans_ShareScale=shareScale+","+shareScale;
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)
1837 var ax= prevbox.x;
1838 var ay= prevbox.y;
1839 var bx= prevbox.x+prevbox.width;
1840 var by= prevbox.y+prevbox.height;
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);
1849 var tx= section_a[1];
1850 var ty= section_a[2];
1852 var ax= section_a[1];
1853 var ay= section_a[2];
1854 var bx= 0;
1855 var by= section_a[2] ;
1857 var cx=prevbox.x+prevbox.width;
1858 var cy= prevbox.y;
1860 var dx= prevbox.x+prevbox.width;
1861 var dy= 0;
1864 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
1866 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]);
1868 var ax= section_a[1];
1869 var ay= section_a[2];
1870 var bx= section_a[1]
1871 var by= 0;
1873 var cx= prevbox.x;
1874 var cy= prevbox.y+prevbox.height;
1876 var dx= 0;
1877 var dy= prevbox.y+prevbox.height;
1880 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
1882 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]);
1888 if(distx<1){distx=1;}
1891 if(disty<1){disty=1;}
1892 //document.forms[0].code.value=distx+' '+disty;
1893 tw=distx;
1894 th=disty;
1899 //////////////////// SE
1901 if( scaleType== 'se'){
1902 trans_ShareScale=shareScale+","+shareScale;
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)
1910 var ax= prevbox.x;
1911 var ay= prevbox.y;
1912 var bx= prevbox.x+prevbox.width;
1913 var by= prevbox.y+prevbox.height;
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));
1920 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
1924 //////////
1925 var tx= prevbox.x;
1926 var ty= prevbox.y;
1928 var ax= section_a[1];
1929 var ay= section_a[2];
1930 var bx= 0;
1931 var by= section_a[2] ;
1933 var cx=prevbox.x;
1934 var cy= prevbox.y;
1936 var dx= prevbox.x;
1937 var dy= 0;
1940 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
1942 /////////////////
1945 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]);
1948 var ax= section_a[1];
1949 var ay= section_a[2];
1950 var bx= section_a[1]
1951 var by= 0;
1953 var cx= prevbox.x;
1954 var cy= prevbox.y;
1956 var dx=0;
1957 var dy= prevbox.y;
1960 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
1962 ///////////////
1964 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]);
1968 if(distx<1){distx=1;}
1971 if(disty<1){disty=1;}
1973 tw=distx;
1974 th=disty;
1979 if(scaleType== 'ne'){
1981 trans_ShareScale=shareScale+","+shareScale;
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);
1989 var ax= prevbox.x;
1990 var ay= prevbox.y+prevbox.height;
1991 var bx= prevbox.x+prevbox.width;
1992 var by= prevbox.y;
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));
2000 this.editor.log(angle_diagonal);
2003 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
2007 //////////
2008 var tx= prevbox.x;
2009 var ty= section_a[2];
2011 var ax= section_a[1];
2012 var ay= section_a[2];
2013 var bx= 0;
2014 var by= section_a[2] ;
2016 var cx=prevbox.x;
2017 var cy= prevbox.y;
2019 var dx= prevbox.x;
2020 var dy= 0;
2023 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
2025 /////////////////
2028 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]);
2031 var ax= section_a[1];
2032 var ay= section_a[2];
2033 var bx= section_a[1];
2034 var by= 0;
2036 var cx= prevbox.x;
2037 var cy= prevbox.y+prevbox.height;
2039 var dx=0;
2040 var dy= prevbox.y+prevbox.height;
2043 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
2045 ///////////////
2047 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]);
2051 if(distx<1){distx=1;}
2054 if(disty<1){disty=1;}
2055 //document.forms[0].code.value=distx+' '+disty;
2056 tw=distx;
2057 th=disty;
2064 if(scaleType== 'sw'){
2065 trans_ShareScale=shareScale+","+shareScale;
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);
2076 var ax= prevbox.x;
2077 var ay= prevbox.y+prevbox.height;
2078 var bx= prevbox.x+prevbox.width;
2079 var by= prevbox.y;
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));
2087 this.editor.log(angle_diagonal);
2090 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
2093 //////////
2094 var tx= section_a[1];
2095 var ty= prevbox.y;
2097 var ax= section_a[1];
2098 var ay= section_a[2];
2099 var bx= 0;
2100 var by= section_a[2] ;
2102 var cx=prevbox.x+prevbox.width;
2103 var cy= prevbox.y+prevbox.height;
2105 var dx= prevbox.x+prevbox.width;
2106 var dy= 0;
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]);
2112 /////////////////
2113 var ax= section_a[1];
2114 var ay= section_a[2];
2115 var bx= section_a[1];
2116 var by= 0;
2118 var cx= prevbox.x;
2119 var cy= prevbox.y;
2121 var dx=0;
2122 var dy= prevbox.y;
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 ///////////////
2131 if(distx<1){distx=1;}
2134 if(disty<1){disty=1;}
2135 //document.forms[0].code.value=distx+' '+disty;
2136 tw=distx;
2137 th=disty;
2145 if(shape.tagName == 'rect')
2147 //alert(data[0]);
2150 shape.style.left = tx + 'px';
2151 shape.style.top = ty + 'px';
2152 shape.style.height = th + 'px';
2153 shape.style.width = tw + 'px';
2156 else
2157 if(shape.tagName == 'text')
2159 /*
2160 shape.setAttribute('x',tx);
2161 shape.setAttribute('y',ty);
2162 shape.setAttribute('width', tw);
2163 shape.setAttribute('height', th);
2165 //previus.setAttribute('transform', "scale("+trans_ShareScale+")");
2166 shape.setAttribute('x', tx + 'px');
2167 shape.setAttribute('y', ty + 'px');
2169 shape.setAttribute('textLength', parseInt(Math.round(tw)));
2171 */
2173 else
2174 if(shape.tagName == 'oval')
2176 //shape.getAttribute('transform)
2178 shape.style.left = tx + 'px';
2179 shape.style.top = ty + 'px';
2180 shape.style.height = th + 'px';
2181 shape.style.width = tw + 'px';
2185 else
2186 if(shape.tagName == 'line')
2188 shape.setAttribute('to',tx + 'px,' + ty + 'px');
2189 shape.setAttribute('from', tw + 'px,' + th + 'px');
2193 else
2194 if (shape.tagName == 'polyline')
2198 else
2199 if (shape.tagName == 'image')
2202 shape.style.left = tx + 'px';
2203 shape.style.top = ty + 'px';
2204 shape.style.height = th + 'px';
2205 shape.style.width = tw + 'px';
2208 else
2209 if (shape.tagName == 'shape')
2212 shape.style.left = tx + 'px';
2213 shape.style.top = ty + 'px';
2214 shape.style.height = th + 'px';
2215 shape.style.width = tw + 'px';
2217 //document.forms[0].code.value='';
2218 //shape.setAttribute('transform', "scale("+trans_ShareScale+")");
2226 };
2230 VMLRenderer.prototype.rotateShape = function(shape, previus,toX, toY) {
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;
2242 var actual_angle=ang2v(centerx,centery,coord[0], coord[1]);
2244 if(xrot<toX) { rotatexxx+=1;}else{rotatexxx-=1;}
2245 xrot=toX;
2246 yrot=toY;
2248 var xtr=0;
2249 var ytr=0;
2251 //var box= shape.getBBox();
2252 var tr1x= box.x;
2253 var tr1y= box.y;
2257 toX+=xtr;
2258 toY+=xtr;
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;
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
2279 //shape.setAttribute('transform', "translate("+(-xshe)+","+(-yshe)+")");
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))+")");
2294 //////////////////////////////
2295 /*H = 0;
2296 W = 0;
2297 LX = new Array();
2298 S = new Array();
2299 i = 0;
2300 b = true;
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+" ");
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>");
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
2338 VMLRenderer.prototype.getshapes = function(){
2339 return this.container.childNodes;
2343 VMLRenderer.prototype.reflect = function(HorV) {
2344 };