annotate onlypaths/js/vmlrendererPrev.js @ 73:5fb0e5db5926 laserkard

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