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