annotate onlypaths/js/svgrenderer_mini.js @ 62:3e5dd5e3566d laserkard

[svn r63] showed nick how to use SVN
author rlm
date Thu, 01 Apr 2010 19:19:08 -0400
parents 26c2b3ad21c7
children
rev   line source
rlm@46 1 /*----------------------------------------------------------------------------
rlm@46 2 SVGRENDERER 1.0
rlm@46 3 SVG Renderer For RichDraw
rlm@46 4 -----------------------------------------------------------------------------
rlm@46 5 Created by Mark Finkle (mark.finkle@gmail.com)
rlm@46 6 Implementation of SVG based renderer.
rlm@46 7 -----------------------------------------------------------------------------
rlm@46 8 */
rlm@46 9 function AbstractRenderer() {
rlm@46 10
rlm@46 11 };
rlm@46 12
rlm@46 13 AbstractRenderer.prototype.init = function(elem) {};
rlm@46 14 AbstractRenderer.prototype.bounds = function(shape) { return { x:0, y:0, width:0, height: 0 }; };
rlm@46 15
rlm@46 16 function SVGRenderer() {
rlm@46 17 this.base = AbstractRenderer;
rlm@46 18 this.svgRoot = null;
rlm@46 19 }
rlm@46 20
rlm@46 21
rlm@46 22 SVGRenderer.prototype = new AbstractRenderer;
rlm@46 23
rlm@46 24
rlm@46 25
rlm@46 26
rlm@46 27 SVGRenderer.prototype.init = function(elem) {
rlm@46 28 this.container = elem;
rlm@46 29
rlm@46 30 this.container.style.MozUserSelect = 'none';
rlm@46 31
rlm@46 32 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 33
rlm@46 34 this.svgRoot = this.container.ownerDocument.createElementNS(svgNamespace, "svg");
rlm@46 35 this.svgRoot.setAttributeNS(null,'viewBox', zoominit);
rlm@46 36 this.svgRoot.setAttributeNS(null,'preserveAspectRatio','none');
rlm@46 37 this.svgRoot.setAttributeNS(null,'space','preserve');
rlm@46 38 this.container.appendChild(this.svgRoot);
rlm@46 39 }
rlm@46 40
rlm@46 41 SVGRenderer.prototype.view = function(left,top,width,height,viewBox) {
rlm@46 42 if(mode=='preview')
rlm@46 43 {
rlm@46 44 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 45 var tokens = viewBox.split(' ');
rlm@46 46 var prx=100;
rlm@46 47 this.container.style.top =(parseInt(document.getElementById('FRONT').style.height)-height)/2+'px'
rlm@46 48
rlm@46 49 this.container.style.width = width;//document.getElementById('FRONT').style.width;
rlm@46 50 this.container.style.height =height;//document.getElementById('FRONT').style.height;
rlm@46 51 //alert(this.container.style.width+' '+width)
rlm@46 52 //alert(this.container.style.height+' '+height)
rlm@46 53 this.svgRoot.setAttributeNS(null,'x', left);
rlm@46 54 this.svgRoot.setAttributeNS(null,'y', top);
rlm@46 55 this.svgRoot.setAttributeNS(null,'width', width);
rlm@46 56 this.svgRoot.setAttributeNS(null,'height', height);
rlm@46 57
rlm@46 58 var x=parseFloat(tokens[0])-prx*4;
rlm@46 59 var y=parseFloat(tokens[1])-prx*2;
rlm@46 60 var w=parseFloat(tokens[2])+prx;
rlm@46 61 var h=parseFloat(tokens[3])+prx;
rlm@46 62 //workspace= x+''+y+''+w+''+h;
rlm@46 63 //workspace= left+''+top+''+width+''+heigth;
rlm@46 64 this.svgRoot.setAttributeNS(null,'viewBox', viewBox);
rlm@46 65 //this.svgRoot.setAttributeNS(null,'viewBox', workspace);
rlm@46 66 //zoominit = workspace;
rlm@46 67 }
rlm@46 68 else
rlm@46 69 {
rlm@46 70 this.container.style.top =0+'px';
rlm@46 71
rlm@46 72 var tokens = viewBox.split(' ');
rlm@46 73 proporImage= (parseFloat(tokens[2])-parseFloat(tokens[0]))/(parseFloat(tokens[3])-parseFloat(tokens[1]));
rlm@46 74 //alert(proporImage +' '+proporCanvas)
rlm@46 75 //if(marginx<=parseInt(document.getElementById('FRONT').style.width)){marginx=0;}
rlm@46 76 docx=parseFloat(tokens[0]);
rlm@46 77 docy=parseFloat(tokens[1]);
rlm@46 78 docw=parseFloat(tokens[2]);
rlm@46 79 doch=parseFloat(tokens[3]);
rlm@46 80
rlm@46 81 marginx=(parseInt(document.getElementById('FRONT').style.width)-(parseFloat(tokens[2])-parseFloat(tokens[0])))/2;
rlm@46 82 marginy=(parseInt(document.getElementById('FRONT').style.height)-(parseFloat(tokens[3])-parseFloat(tokens[1])))/2;
rlm@46 83 //if(marginx<=0){marginx=0;}
rlm@46 84 //if(marginy<=0){marginy=0;}
rlm@46 85 var x=(parseFloat(tokens[0])-marginx);
rlm@46 86 var y=(parseFloat(tokens[1])-marginy);
rlm@46 87 var w=(parseFloat(tokens[2])+marginx*2);
rlm@46 88 var h=(parseFloat(tokens[3])+marginy*2);
rlm@46 89 //alert(tokens[3]+' '+tokens[1]+' / '+(parseFloat(tokens[3])-parseFloat(tokens[1]))+' '+parseInt(document.getElementById('FRONT').style.height)+' /'+h+' '+height);
rlm@46 90 //if(h>=parseInt(document.getElementById('FRONT').style.height)){h=parseInt(document.getElementById('FRONT').style.height);}
rlm@46 91 //if(h>=parseInt(document.getElementById('FRONT').style.height)){y=0;h=600;}//parseInt(document.getElementById('FRONT').style.height)*2}
rlm@46 92 zoominit1 = x+' '+y+' '+w+' '+h;
rlm@46 93 //alert(this.container.style.height+' '+height+' '+h+' '+zoominit1)
rlm@46 94 this.svgRoot.setAttributeNS(null,'width', w);
rlm@46 95 this.svgRoot.setAttributeNS(null,'height', h);
rlm@46 96 this.svgRoot.setAttributeNS(null,'viewBox', zoominit1);
rlm@46 97 zoomx=x;
rlm@46 98 zoomy=y;
rlm@46 99 //this.svgRoot.setAttributeNS(null,'viewBox', zoominit;
rlm@46 100 //this.rectCanvas(x,y,w,h,zoominit)
rlm@46 101 //this.rectCanvas(left,top,width,height,viewBox)
rlm@46 102
rlm@46 103 }
rlm@46 104 }
rlm@46 105
rlm@46 106 SVGRenderer.prototype.zoomFrame = function(zoom){
rlm@46 107 this.svgRoot.setAttributeNS(null,'viewBox', zoom);
rlm@46 108 }
rlm@46 109
rlm@46 110 SVGRenderer.prototype.rectDoc = function(viewBox) {
rlm@46 111 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 112 var tokens = viewBox.split(' ');
rlm@46 113 var shape = document.getElementById('rectCanvas');
rlm@46 114 if (shape) {
rlm@46 115 this.remove(shape);
rlm@46 116 }
rlm@46 117 var rect=this.container.ownerDocument.createElementNS(svgNamespace, 'rect');
rlm@46 118 rect.setAttributeNS(null, 'id', 'rectDoc');
rlm@46 119 rect.setAttributeNS(null, 'x', tokens[0] + 'px');
rlm@46 120 rect.setAttributeNS(null, 'y', tokens[1] + 'px');
rlm@46 121 rect.setAttributeNS(null, 'width', tokens[2]+ 'px');
rlm@46 122 rect.setAttributeNS(null, 'height', tokens[3] + 'px');
rlm@46 123 rect.setAttributeNS(null, 'fill', 'none');
rlm@46 124 rect.setAttributeNS(null, 'stroke', '#000000');
rlm@46 125 rect.setAttributeNS(null, 'stroke-width', 1+'px');
rlm@46 126 // this.svgRoot.appendChild(rect)
rlm@46 127 this.svgRoot.appendChild(rect);
rlm@46 128
rlm@46 129 }
rlm@46 130 SVGRenderer.prototype.rectCanvas = function(docx,docy,docw,doch,viewBox) {
rlm@46 131
rlm@46 132 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 133
rlm@46 134 var tokens = zoominit1.split(' ');
rlm@46 135 var shape = document.getElementById('rectCanvas');
rlm@46 136 if (shape) {
rlm@46 137 this.remove(shape);
rlm@46 138 }
rlm@46 139
rlm@46 140 var rect=this.container.ownerDocument.createElementNS(svgNamespace, 'rect');
rlm@46 141 rect.setAttributeNS(null, 'id', 'rectBackground');
rlm@46 142 rect.setAttributeNS(null, 'x', tokens[0] + 'px');
rlm@46 143 rect.setAttributeNS(null, 'y', tokens[1] + 'px');
rlm@46 144 rect.setAttributeNS(null, 'width', tokens[2] + 'px');
rlm@46 145 rect.setAttributeNS(null, 'height', tokens[3] + 'px');
rlm@46 146 rect.setAttributeNS(null, 'fill', '#666666');
rlm@46 147 rect.setAttributeNS(null, 'stroke', 'none');
rlm@46 148 //this.svgRoot.appendChild(rect)
rlm@46 149 this.svgRoot.insertBefore( rect, this.svgRoot.firstChild );
rlm@46 150
rlm@46 151 //this.index('rectBackground',0);
rlm@46 152
rlm@46 153 /* var shape = document.getElementById('rectOverCanvas');
rlm@46 154 if (shape) {
rlm@46 155 this.remove(shape);
rlm@46 156 }
rlm@46 157 var rect=this.container.ownerDocument.createElementNS(svgNamespace, 'rect');
rlm@46 158 rect.setAttributeNS(null, 'id', 'rectOverCanvas');
rlm@46 159 rect.setAttributeNS(null, 'x', docx + 'px');
rlm@46 160 rect.setAttributeNS(null, 'y', docy + 'px');
rlm@46 161 rect.setAttributeNS(null, 'width', docw + 'px');
rlm@46 162 rect.setAttributeNS(null, 'height', doch + 'px');
rlm@46 163 rect.setAttributeNS(null, 'fill', 'none');
rlm@46 164 rect.setAttributeNS(null, 'stroke', '#000000');
rlm@46 165 rect.setAttributeNS(null, 'stroke-width', 1+'px');
rlm@46 166 // this.svgRoot.appendChild(rect)
rlm@46 167 this.svgRoot.insertBefore( rect, this.svgRoot.lastChild );
rlm@46 168 */
rlm@46 169 }
rlm@46 170
rlm@46 171 SVGRenderer.prototype.removeAll = function()
rlm@46 172 {
rlm@46 173 while( this.svgRoot.hasChildNodes () )
rlm@46 174 {
rlm@46 175 this.svgRoot.removeChild( this.svgRoot.firstChild );
rlm@46 176 }
rlm@46 177 }
rlm@46 178
rlm@46 179 SVGRenderer.prototype.create = function(shape, fillColor, lineColor, fillOpac, lineOpac, lineWidth, left, top, width, height, textMessaje, textSize, textFamily, imageHref, points, transform, parent) {
rlm@46 180 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 181 var xlinkNS="http://www.w3.org/1999/xlink";
rlm@46 182
rlm@46 183 var svg;
rlm@46 184
rlm@46 185 if (shape == 'rect') {
rlm@46 186 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'rect');
rlm@46 187 svg.setAttributeNS(null, 'x', left + 'px');
rlm@46 188 svg.setAttributeNS(null, 'y', top + 'px');
rlm@46 189 svg.setAttributeNS(null, 'width', width + 'px');
rlm@46 190 svg.setAttributeNS(null, 'height', height + 'px');
rlm@46 191 svg.style.position = 'absolute';
rlm@46 192 }
rlm@46 193 else if (shape == 'ellipse' || shape == 'circle') {
rlm@46 194
rlm@46 195 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'ellipse');
rlm@46 196 svg.setAttributeNS(null, 'cx', (left + width / 2) + 'px');
rlm@46 197 svg.setAttributeNS(null, 'cy', (top + height / 2) + 'px');
rlm@46 198 if(shape == 'circle'){
rlm@46 199 svg.setAttributeNS(null, 'rx', (width / 2) + 'px');
rlm@46 200 svg.setAttributeNS(null, 'ry', (width / 2) + 'px');
rlm@46 201 }else{
rlm@46 202 svg.setAttributeNS(null, 'rx', (width / 2) + 'px');
rlm@46 203 svg.setAttributeNS(null, 'ry', (height / 2) + 'px');
rlm@46 204
rlm@46 205 }
rlm@46 206 svg.style.position = 'absolute';
rlm@46 207 }
rlm@46 208 else if (shape == 'roundrect') {
rlm@46 209 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'rect');
rlm@46 210 svg.setAttributeNS(null, 'x', left + 'px');
rlm@46 211 svg.setAttributeNS(null, 'y', top + 'px');
rlm@46 212
rlm@46 213 var percent = width*20/100;
rlm@46 214 if(width<height)
rlm@46 215 var percent = width*20/100;
rlm@46 216 else
rlm@46 217 var percent = height*20/100;
rlm@46 218
rlm@46 219 svg.setAttributeNS(null, 'rx', percent+'px');
rlm@46 220 svg.setAttributeNS(null, 'ry', percent+'px');
rlm@46 221 svg.setAttributeNS(null, 'width', width + 'px');
rlm@46 222 svg.setAttributeNS(null, 'height', height + 'px');
rlm@46 223 svg.style.position = 'absolute';
rlm@46 224 }
rlm@46 225 else if (shape == 'line') {
rlm@46 226 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'line');
rlm@46 227 svg.setAttributeNS(null, 'x1', left + 'px');
rlm@46 228 svg.setAttributeNS(null, 'y1', top + 'px');
rlm@46 229 svg.setAttributeNS(null, 'x2', left + width + 'px');
rlm@46 230 svg.setAttributeNS(null, 'y2', top + height + 'px');
rlm@46 231 svg.style.position = 'absolute';
rlm@46 232 }
rlm@46 233 else if (shape == 'polyline') {
rlm@46 234 var xcenterpoly=xpArray;
rlm@46 235 var ycenterpoly=ypArray;
rlm@46 236 var thispath=''+xpArray[1]+','+ypArray[1];
rlm@46 237 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'polyline');
rlm@46 238 svg.setAttributeNS(null, 'points', points);
rlm@46 239 svg.style.position = 'absolute';
rlm@46 240 }
rlm@46 241 else if (shape == 'path')
rlm@46 242 {
rlm@46 243 var k = (Math.sqrt(2)-1)*4/3;
rlm@46 244 var circle="M 0,1 L 0.552,1 1,0.552 1,0 1,-0.552 0.552,-1 0,-1 -0.552,-1 -1,-0.552 -1,0 -1,0.552 -0.552,1 0,1z" // 4th
rlm@46 245 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'path');
rlm@46 246 svg.setAttributeNS(null, 'd', points);
rlm@46 247 svg.style.position = 'absolute';
rlm@46 248 }
rlm@46 249 else if (shape == 'controlpath')
rlm@46 250 {
rlm@46 251 var point='M '+left+','+top+' L '+(left+1)+','+(top+1)+'z' // 4th
rlm@46 252 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'path');
rlm@46 253 svg.setAttributeNS(null, 'd', point);
rlm@46 254 svg.setAttributeNS(null,'transform', "translate(0,0)");
rlm@46 255 svg.style.position = 'absolute';
rlm@46 256 }
rlm@46 257 else if (shape == 'text') {
rlm@46 258 var data = this.container.ownerDocument.createTextNode(textMessaje);
rlm@46 259 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'text');
rlm@46 260 svg.setAttributeNS(null, 'x', parseFloat(left) + 'px');
rlm@46 261 svg.setAttributeNS(null, 'y', parseFloat(top) + 'px');
rlm@46 262 svg.setAttributeNS(null, 'font-family', textFamily );
rlm@46 263 svg.setAttributeNS(null, 'font-size', parseFloat(textSize));
rlm@46 264 svg.setAttributeNS(null, 'text-anchor','middle');
rlm@46 265
rlm@46 266 svg.style.position = 'absolute';
rlm@46 267 svg.appendChild(data);
rlm@46 268 }
rlm@46 269 else if (shape == 'clipPath') {
rlm@46 270 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'clipPath');
rlm@46 271
rlm@46 272
rlm@46 273 }
rlm@46 274 else if (shape == 'linearGradient') {
rlm@46 275 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'linearGradient');
rlm@46 276 svg.setAttributeNS(null, 'x1', parseFloat(left));
rlm@46 277 svg.setAttributeNS(null, 'y1', parseFloat(top ));
rlm@46 278 svg.setAttributeNS(null, 'x2', parseFloat(width));
rlm@46 279 svg.setAttributeNS(null, 'y2', parseFloat(height));
rlm@46 280
rlm@46 281 }
rlm@46 282 else if (shape == 'stop') {
rlm@46 283 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'stop');
rlm@46 284 svg.setAttributeNS(null, 'stop-color', fillColor);
rlm@46 285 svg.setAttributeNS(null, 'stop-opacity', parseFloat(fillOpac));
rlm@46 286 svg.setAttributeNS(null, 'offset', parseFloat(lineOpac));
rlm@46 287
rlm@46 288 }
rlm@46 289 else if (shape == 'group') {
rlm@46 290 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'g');
rlm@46 291 svg.setAttributeNS(null, 'x', left + 'px');
rlm@46 292 svg.setAttributeNS(null, 'y', top + 'px');
rlm@46 293 svg.setAttributeNS(null, 'width', width + 'px');
rlm@46 294 svg.setAttributeNS(null, 'height', height + 'px');
rlm@46 295 svg.setAttributeNS(null, 'fill-opacity', parseFloat(fillOpac));
rlm@46 296 svg.setAttributeNS(null, 'fill', fillColor);
rlm@46 297 }
rlm@46 298 else if (shape == 'image') {
rlm@46 299 var svg = this.container.ownerDocument.createElementNS(svgNamespace, 'image');
rlm@46 300 svg.setAttributeNS(xlinkNS,'href', imageHref);
rlm@46 301 svg.setAttributeNS(null, 'x', left + 'px');
rlm@46 302 svg.setAttributeNS(null, 'y', top + 'px');
rlm@46 303 svg.setAttributeNS(null, 'width', width + 'px');
rlm@46 304 svg.setAttributeNS(null, 'height', height + 'px');
rlm@46 305 svg.setAttributeNS(null, 'opacity', parseFloat(fillOpac));
rlm@46 306 svg.setAttributeNS(null, 'preserveAspectRatio','none');//xMinYMin slice
rlm@46 307 }
rlm@46 308
rlm@46 309 if(shape == 'zoom')
rlm@46 310 {
rlm@46 311
rlm@46 312 }else
rlm@46 313 {
rlm@46 314 if(transform!='')
rlm@46 315 {
rlm@46 316 svg.setAttributeNS(null, 'transform', transform);
rlm@46 317 }
rlm@46 318 if(shape != 'image' || shape != 'group' || shape != 'stop' )
rlm@46 319
rlm@46 320 {
rlm@46 321 if (lineColor.length == 0){ lineColor = 'none';}
rlm@46 322 if (fillColor.length == 0){ fillColor = 'none';}
rlm@46 323 svg.setAttributeNS(null, 'fill', fillColor);
rlm@46 324 svg.setAttributeNS(null, 'stroke', lineColor);
rlm@46 325 svg.setAttributeNS(null, 'stroke-width', parseFloat(lineWidth));
rlm@46 326 svg.setAttributeNS(null, 'fill-opacity', parseFloat(fillOpac));
rlm@46 327 svg.setAttributeNS(null, 'stroke-opacity',parseFloat(lineOpac));
rlm@46 328 svg.setAttributeNS(null, 'stroke-linejoin','round')
rlm@46 329
rlm@46 330 }
rlm@46 331
rlm@46 332
rlm@46 333 if(parent==''){
rlm@46 334 this.svgRoot.appendChild(svg);
rlm@46 335 }else{
rlm@46 336 if(document.getElementById(parent)){
rlm@46 337 var parentShape = document.getElementById(parent);
rlm@46 338 parentShape.appendChild(svg);
rlm@46 339 }
rlm@46 340 }
rlm@46 341
rlm@46 342 return svg;
rlm@46 343
rlm@46 344 }
rlm@46 345
rlm@46 346 };
rlm@46 347
rlm@46 348 SVGRenderer.prototype.zoomFrame = function(zoom){
rlm@46 349 this.svgRoot.setAttributeNS(null,'viewBox', zoom);
rlm@46 350
rlm@46 351
rlm@46 352 }
rlm@46 353 SVGRenderer.prototype.zoom = function(clicx,clicy){
rlm@46 354 /*
rlm@46 355 function(direction, amount) {
rlm@46 356 var viewBox = this.rootNode.getAttribute('viewBox');
rlm@46 357 var viewVals = viewBox.split(' ');
rlm@46 358 if (amount == null) {
rlm@46 359 amount = SVGElement.panFactor;
rlm@46 360 }
rlm@46 361 switch (direction) {
rlm@46 362 case 'left':
rlm@46 363 amount = 0 - amount;
rlm@46 364 // intentionally fall through
rlm@46 365 case 'right':
rlm@46 366 var currentPosition = parseFloat(viewVals[0]);
rlm@46 367 currentPosition += amount;
rlm@46 368 viewVals[0] = currentPosition;
rlm@46 369 break;
rlm@46 370 case 'up':
rlm@46 371 amount = 0 - amount;
rlm@46 372 // intentionally fall through
rlm@46 373 case 'down':
rlm@46 374 var currentPosition = parseFloat(viewVals[1]);
rlm@46 375 currentPosition += amount;
rlm@46 376 viewVals[1] = currentPosition;
rlm@46 377 break;
rlm@46 378 case 'origin':
rlm@46 379 // reset everything to initial values
rlm@46 380 viewVals[0] = 0;
rlm@46 381 viewVals[1] = 0;
rlm@46 382 this.rootNode.currentScale = 1;
rlm@46 383 this.rootNode.currentTranslate.x = 0;
rlm@46 384 this.rootNode.currentTranslate.y = 0;
rlm@46 385 break;
rlm@46 386 }
rlm@46 387 this.rootNode.setAttribute('viewBox', viewVals.join(' '));
rlm@46 388 */
rlm@46 389
rlm@46 390
rlm@46 391
rlm@46 392 //canvasWidth
rlm@46 393 //canvasheight
rlm@46 394 if(zoommode=='frame')
rlm@46 395 {
rlm@46 396 var viewBox = this.svgRoot.getAttributeNS(null,'viewBox');
rlm@46 397
rlm@46 398 //alert(viewBox);
rlm@46 399
rlm@46 400 var viewBox = zoominit;
rlm@46 401 var viewVals = viewBox.split(' ');
rlm@46 402
rlm@46 403 zoomx = parseFloat(viewVals[0]);
rlm@46 404 zoomy = parseFloat(viewVals[1]);
rlm@46 405 zoomw = parseFloat(viewVals[2]);
rlm@46 406 zoomh = parseFloat(viewVals[3]);
rlm@46 407 proporDiagonal=1;
rlm@46 408 }
rlm@46 409 else
rlm@46 410 {
rlm@46 411
rlm@46 412 var viewBox = this.svgRoot.getAttributeNS(null,'viewBox');
rlm@46 413
rlm@46 414 var viewVals = viewBox.split(' ');
rlm@46 415 var prevX = parseFloat(viewVals[0]);
rlm@46 416 var prevY = parseFloat(viewVals[1]);
rlm@46 417 var prevW = parseFloat(viewVals[2]);
rlm@46 418 var prevH = parseFloat(viewVals[3]);
rlm@46 419 var prevWidth=prevW-prevX;
rlm@46 420 var prevHeight=prevH-prevY;
rlm@46 421
rlm@46 422 }
rlm@46 423
rlm@46 424 if(zoommode=='more')
rlm@46 425 {
rlm@46 426 fieldViewx=prevW*0.95;
rlm@46 427 fieldViewy=prevH*0.95;
rlm@46 428 diagonalFrame=dist2p(0,0,fieldViewx,fieldViewy);
rlm@46 429 //diagonalAngle=getAngle(fieldViewx,fieldViewy);
rlm@46 430 zoomx=(diagonalMidx+(diagonalFrame/2)*Math.cos(diagonalAngle+Math.PI));//-(fieldViewx/8);//-(canvasW/2)docx-fieldViewx;
rlm@46 431 zoomy=(diagonalMidy+(diagonalFrame/2)*Math.sin(diagonalAngle+Math.PI));//-(fieldViewy/8);//-(canvasH/2);//docy-fieldViewy;
rlm@46 432 zoomw=prevW*0.95;
rlm@46 433 zoomh=prevH*0.95;
rlm@46 434
rlm@46 435
rlm@46 436 proporDiagonal=diagonalFrame/diagonalinit;
rlm@46 437 //alert(proporDiagonal);
rlm@46 438 }
rlm@46 439 if(zoommode=='minus')
rlm@46 440 {
rlm@46 441 fieldViewx=prevW*1.05;
rlm@46 442 fieldViewy=prevH*1.05;
rlm@46 443 diagonalFrame=dist2p(0,0,fieldViewx,fieldViewy);
rlm@46 444 //diagonalAngle=getAngle(fieldViewx,fieldViewy);
rlm@46 445 zoomx=(diagonalMidx+(diagonalFrame/2)*Math.cos(diagonalAngle+Math.PI));//-(fieldViewx/8);//-(canvasW/2)docx-fieldViewx;
rlm@46 446 zoomy=(diagonalMidy+(diagonalFrame/2)*Math.sin(diagonalAngle+Math.PI));//-(fieldViewy/8);//-(canvasH/2);//docy-fieldViewy;
rlm@46 447 zoomw=prevW*1.05;
rlm@46 448 zoomh=prevH*1.05;
rlm@46 449 proporDiagonal=diagonalFrame/diagonalinit;
rlm@46 450
rlm@46 451 }
rlm@46 452 if(zoommode=='window')
rlm@46 453 {
rlm@46 454
rlm@46 455 zoomx=c.mouseDownX;
rlm@46 456 zoomy=c.mouseDownY;
rlm@46 457 var dF=dist2p(c.mouseDownX,c.mouseDownY,clicx,clicy);
rlm@46 458 //var mid=pmd2pb(c.clicX,c.clicX,clicx,clicy,0.5)
rlm@46 459 zoomw=dF*proporDoc;//(mid[1]+(dF/2)*Math.cos(diagonalAngle+Math.PI));
rlm@46 460 zoomh=dF;//(mid[2]+(dF/2)*Math.sin(diagonalAngle+Math.PI));
rlm@46 461
rlm@46 462
rlm@46 463 }
rlm@46 464 var direction=0;
rlm@46 465 if(zoommode=='hand')
rlm@46 466 {
rlm@46 467 direction=ang2v(clicx,clicy,centerZoomx,centerZoomy);
rlm@46 468 var distance=dist2p(clicx,clicy,centerZoomx,centerZoomy);
rlm@46 469 var left = prevX+distance*Math.cos(direction);
rlm@46 470 var top = prevY+distance*Math.sin(direction);
rlm@46 471 makeWorkSite(prevH,left,top);
rlm@46 472 }
rlm@46 473 direction=direction*180/Math.PI;
rlm@46 474 //this.svgRoot.currentScale = zoomscale+0.1;
rlm@46 475 //this.svgRoot.currentTranslate.x = 0;
rlm@46 476 //this.svgRoot.currentTranslate.y = 0;
rlm@46 477 //var resultPosx=clicx-((prevscalex-posx)/2);//-Math.abs(posx+clicx)
rlm@46 478 //var resultPosy=clicy-((prevscalex-posy)/2);//-Math.abs(posy+clicy)
rlm@46 479 //var resultPosx=-Math.abs(posx+clicx);
rlm@46 480 //var resultPosy=-Math.abs(posy+clicy);
rlm@46 481
rlm@46 482 this.svgRoot.setAttributeNS(null,'viewBox', (zoomx)+' '+(zoomy)+' '+zoomw+' '+zoomh+'');
rlm@46 483 var viewBox = this.svgRoot.getAttributeNS(null,'viewBox');
rlm@46 484 //$('status').innerHTML=' '+viewBox;
rlm@46 485 //alert(direction+'__'+prevZoomCenterx+' '+prevZoomCentery+' '+centerZoomx+' '+centerZoomy);
rlm@46 486 }
rlm@46 487
rlm@46 488 //this.mode, this.fillColor, this.lineColor, this.fillOpac, this.lineOpac, this.lineWidth, this.mouseDownX, this.mouseDownY, 1, 1,'',''
rlm@46 489 SVGRenderer.prototype.datacreate = function(fillColor, lineColor, fillOpac, lineOpac, lineWidth, left, top, width, height, textMessaje, textSize, textFamily, imageHref, transform) {
rlm@46 490 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 491 var svg;
rlm@46 492 svg = this.container.ownerDocument.createElementNS(svgNamespace, 'path');
rlm@46 493 svg.setAttributeNS(null, 'd', data);
rlm@46 494 svg.setAttributeNS(null,'transform', "translate(0,0)");
rlm@46 495 svg.style.position = 'absolute';
rlm@46 496 if (fillColor.length == 0){fillColor = 'none';}
rlm@46 497 svg.setAttributeNS(null, 'fill', fillColor);
rlm@46 498 if (lineColor.length == 0){lineColor = 'none';}
rlm@46 499 svg.setAttributeNS(null, 'stroke', lineColor);
rlm@46 500 svg.setAttributeNS(null, 'stroke-width', lineWidth);
rlm@46 501 this.svgRoot.appendChild(svg);
rlm@46 502 return svg;
rlm@46 503 };
rlm@46 504
rlm@46 505 SVGRenderer.prototype.index = function(shape,order) {
rlm@46 506
rlm@46 507 if(order==-1)
rlm@46 508 {
rlm@46 509 this.svgRoot.appendChild( shape );
rlm@46 510 }
rlm@46 511 if(order==0){
rlm@46 512
rlm@46 513 this.svgRoot.insertBefore( shape, shape.parentNode.firstChild );
rlm@46 514 }
rlm@46 515
rlm@46 516 if(order==1 || order==2)
rlm@46 517 {
rlm@46 518 var id=shape.getAttributeNS(null, 'id');
rlm@46 519 //alert(id);
rlm@46 520
rlm@46 521
rlm@46 522 var numNodes=this.svgRoot.childNodes.length;
rlm@46 523 //alert(numNodes);
rlm@46 524
rlm@46 525 var num=0;
rlm@46 526 for(var i = 1; i < numNodes; i++)
rlm@46 527 {
rlm@46 528
rlm@46 529 var etiq=this.svgRoot.childNodes[i].getAttributeNS(null, 'id');
rlm@46 530 if (etiq==id)
rlm@46 531 {
rlm@46 532 num=i;
rlm@46 533
rlm@46 534 }
rlm@46 535 }
rlm@46 536 //alert(num);
rlm@46 537 if(order==1)
rlm@46 538 {
rlm@46 539 if((num-1)>=-1)
rlm@46 540 {
rlm@46 541 this.svgRoot.insertBefore( shape, this.svgRoot.childNodes[num-1]);
rlm@46 542 }
rlm@46 543 }
rlm@46 544 if(order==2){
rlm@46 545 if((num+1)<numNodes)
rlm@46 546 {
rlm@46 547 this.svgRoot.insertBefore( shape, this.svgRoot.childNodes[num+2]);
rlm@46 548 }
rlm@46 549 }
rlm@46 550
rlm@46 551 }
rlm@46 552
rlm@46 553
rlm@46 554 /*var contshapes = shape.parentNode.childNodes.length;
rlm@46 555 var elem1 = shape;//this.svgRoot.childNodes[1];
rlm@46 556 var elem2 = shape.parentNode.childNodes[parseInt(contshapes-9)];
rlm@46 557 var tmp = elem1.cloneNode( true );
rlm@46 558 shape.parentNode.replaceChild( tmp, elem2 );
rlm@46 559 shape.parentNode.replaceChild( elem2, elem1 );
rlm@46 560 */
rlm@46 561 //alert(elem2+' '+ elem1 )
rlm@46 562 //return elem2;
rlm@46 563
rlm@46 564 }
rlm@46 565 SVGRenderer.prototype.remove = function(shape) {
rlm@46 566 //shape.parentNode.removeChild(shape);
rlm@46 567 this.svgRoot.removeChild(shape);
rlm@46 568 }
rlm@46 569
rlm@46 570
rlm@46 571 SVGRenderer.prototype.copy = function(shape)
rlm@46 572 {
rlm@46 573 var svg;
rlm@46 574 svg =shape.cloneNode(false);
rlm@46 575 if(shape.tagName=="text"){
rlm@46 576 var text=shape.textContent ;
rlm@46 577 svg.textContent=text;
rlm@46 578 }
rlm@46 579 //svg.setAttributeNS(null, 'fill', "#aa00aa");
rlm@46 580 return svg;
rlm@46 581 };
rlm@46 582
rlm@46 583
rlm@46 584 SVGRenderer.prototype.paste = function(clipboard,left,top)
rlm@46 585 {
rlm@46 586 //var svg;
rlm@46 587 //svg =shape;
rlm@46 588 //clipboard.setAttributeNS(null, 'fill', "#0000aa");
rlm@46 589 //clipboard.setAttributeNS(null,'transform', "translate("+left+","+top+")");
rlm@46 590 this.svgRoot.appendChild(clipboard);
rlm@46 591 return clipboard;
rlm@46 592 };
rlm@46 593
rlm@46 594
rlm@46 595 SVGRenderer.prototype.duplicate = function(shape)
rlm@46 596 {
rlm@46 597 var svg;
rlm@46 598 svg =shape.cloneNode(false);
rlm@46 599 //svg.setAttributeNS(null, 'fill', "#aa00aa");
rlm@46 600 this.svgRoot.appendChild(svg);
rlm@46 601 return svg;
rlm@46 602 };
rlm@46 603
rlm@46 604 SVGRenderer.prototype.undo = function()
rlm@46 605 {
rlm@46 606 this.svgRoot.removeChild( this.svgRoot.lastChild );
rlm@46 607 };
rlm@46 608
rlm@46 609 /*
rlm@46 610 function zSwap(parent, elem1, elem2)
rlm@46 611 {
rlm@46 612 var tmp = elem1.cloneNode( true );
rlm@46 613 parent.replaceChild( tmp, elem2 );
rlm@46 614 parent.replaceChild( elem2, elem1 );
rlm@46 615 }
rlm@46 616
rlm@46 617 SVGRenderer.prototype.moveToTop( svgNode )
rlm@46 618 {
rlm@46 619 this.svgRoot.appendChild( svgNode );
rlm@46 620 }
rlm@46 621
rlm@46 622
rlm@46 623 SVGRenderer.prototype.moveToBottom( svgNode )
rlm@46 624 {
rlm@46 625 this.svgRoot.insertBefore( svgNode, svgNode.parentNode.firstChild );
rlm@46 626 }
rlm@46 627
rlm@46 628 */
rlm@46 629
rlm@46 630
rlm@46 631
rlm@46 632
rlm@46 633
rlm@46 634 var xshe=0; //bad
rlm@46 635 var yshe=0;
rlm@46 636 var isArc=false;
rlm@46 637 var contArc=0;
rlm@46 638 SVGRenderer.prototype.move = function(shape, left, top,fromX,fromY) {
rlm@46 639 //typeTransform='Translate';
rlm@46 640
rlm@46 641 var box = shape.getBBox();
rlm@46 642 var angle=0;
rlm@46 643 var dist=0;
rlm@46 644 var rotated=false;
rlm@46 645
rlm@46 646 if (shape.hasAttributeNS(null,'transform')) {
rlm@46 647 var tran=shape.getAttributeNS(null, 'transform');
rlm@46 648 var rot='';
rlm@46 649 var scl='';
rlm@46 650 var angle=0;
rlm@46 651 if(tran.indexOf('rotate')!=-1)
rlm@46 652 {
rlm@46 653 if(tran.indexOf('scale')!=-1)
rlm@46 654 {
rlm@46 655 var chain2=tran.split('),');
rlm@46 656 rot= GetString(chain2[0], 'rotate(', ',');
rlm@46 657 angle=parseFloat(rot);
rlm@46 658 scl= GetString(tran, 'scale(', ')');
rlm@46 659 }else{
rlm@46 660 var chain2=tran.split(',');
rlm@46 661 var rot0=chain2[0].split('rotate(');
rlm@46 662 rot='good';
rlm@46 663 angle=parseFloat(rot0[1]);
rlm@46 664 scl='';
rlm@46 665
rlm@46 666 }
rlm@46 667 }else{
rlm@46 668 if(tran.indexOf('scale')!=-1)
rlm@46 669 {
rlm@46 670 scl= GetString(tran, 'scale(', ')');
rlm@46 671 angle=0;
rlm@46 672 }else{
rlm@46 673 //
rlm@46 674 }
rlm@46 675 }
rlm@46 676
rlm@46 677 //var h=shape.getAttributeNS(null, SVG_TRANSFORM_ROTATE );
rlm@46 678
rlm@46 679 var centerx=box.x+(box.width/2);
rlm@46 680 var centery=box.y+(box.height/2);
rlm@46 681 var cadRot='';
rlm@46 682 var cadScale='';
rlm@46 683 var union='';
rlm@46 684 if(angle!=0)
rlm@46 685 {
rlm@46 686 cadRot='rotate('+(angle)+', '+centerx+', '+centery+')';
rlm@46 687 }
rlm@46 688 if(scl.length>2)
rlm@46 689 {
rlm@46 690 if(rot.length>2){ union=',';}
rlm@46 691 cadScale='scale('+scl+')';
rlm@46 692 if(scl.indexOf('-')!=-1)
rlm@46 693 {
rlm@46 694 var dist= dist2p(left,top,box.x,box.y);
rlm@46 695
rlm@46 696 left=left;
rlm@46 697 }
rlm@46 698 if(scl.indexOf(',-')!=-1 || scl.indexOf(', -')!=-1 )
rlm@46 699 {
rlm@46 700 //top=eval('-'+top);
rlm@46 701 var dist= dist2p(left,top,box.x,box.y);
rlm@46 702 top=top;
rlm@46 703 }
rlm@46 704
rlm@46 705 }
rlm@46 706 //shape.setAttributeNS(null,'transform', 'rotate('+(angle)+', '+centerx+', '+centery+')');
rlm@46 707 shape.setAttributeNS(null,'transform', cadRot+union+cadScale);
rlm@46 708
rlm@46 709 //var angleRad=angle*Math.PI/180;
rlm@46 710
rlm@46 711
rlm@46 712
rlm@46 713 //dist=dist2p(x,y,left, top) ;
rlm@46 714 rotated=true;
rlm@46 715
rlm@46 716 }
rlm@46 717
rlm@46 718 contmove++;
rlm@46 719
rlm@46 720 if (shape.tagName == 'rect'){
rlm@46 721 /* var dudy= shape.parentNode;
rlm@46 722 if(dudy.tagName=='g'){
rlm@46 723 document.forms[0].code.value= 'this g ============ ';
rlm@46 724 shape.setAttributeNS(null, 'x', left);
rlm@46 725 shape.setAttributeNS(null, 'y', top);
rlm@46 726
rlm@46 727 dudy.setAttributeNS(null, 'x', left);
rlm@46 728 dudy.setAttributeNS(null, 'y', top);
rlm@46 729 dudy.childNodes[0].setAttributeNS(null, 'x', left);
rlm@46 730 dudy.childNodes[0].setAttributeNS(null, 'y', top);
rlm@46 731
rlm@46 732 }else{
rlm@46 733 //document.forms[0].code.value= box.x+' '+box.y+' formX Y'+ fromX+'_'+fromY+' left '+left+'_'+top+'==============';
rlm@46 734 //document.forms[0].code.value+= tran+' rot '+ angle+'_'+x+'_'+y+' dist '+dist;
rlm@46 735 if(rotated){
rlm@46 736 //shape.setAttributeNS(null, 'x', box.x*Math.cos(angleRad)) ;
rlm@46 737 //shape.setAttributeNS(null, 'y', box.y*Math.sin(angleRad)) ;
rlm@46 738 shape.setAttributeNS(null, 'x', left);
rlm@46 739 shape.setAttributeNS(null, 'y', top);
rlm@46 740
rlm@46 741
rlm@46 742 }else{
rlm@46 743 */
rlm@46 744 shape.setAttributeNS(null, 'x', left);
rlm@46 745 shape.setAttributeNS(null, 'y', top);
rlm@46 746 //}
rlm@46 747 //$('option_rect_trx').value= left;
rlm@46 748 //$('option_rect_try').value= top;
rlm@46 749 // var h=shape.getAttributeNS(null, 'height');
rlm@46 750 //var w=shape.getAttributeNS(null, 'width');
rlm@46 751 //document.forms[0].code.value= h+' '+w;
rlm@46 752 //}
rlm@46 753 }
rlm@46 754 if (shape.tagName == 'g')
rlm@46 755 {
rlm@46 756 //this.editor.log(shape.tagName+' ==============');
rlm@46 757
rlm@46 758 shape.setAttributeNS(null, 'x', left);
rlm@46 759 shape.setAttributeNS(null, 'y', top);
rlm@46 760 shape.childNodes[0].setAttributeNS(null, 'x', left + 'px');
rlm@46 761 shape.childNodes[0].setAttributeNS(null, 'y', top + 'px');
rlm@46 762 shape.childNodes[1].setAttributeNS(null, 'x', left + 'px');
rlm@46 763 shape.childNodes[1].setAttributeNS(null, 'y', top + 'px');
rlm@46 764
rlm@46 765 }
rlm@46 766 if (shape.tagName == 'image'){
rlm@46 767 shape.setAttributeNS(null, 'x',left + 'px');
rlm@46 768 shape.setAttributeNS(null, 'y', top + 'px');
rlm@46 769 //$('option_img_trx').value= left;
rlm@46 770 //$('option_img_try').value= top;
rlm@46 771 var h=shape.getAttributeNS(null, 'height');
rlm@46 772 var w=shape.getAttributeNS(null, 'width');
rlm@46 773 // this.editor.log( h+' '+w);
rlm@46 774 }
rlm@46 775 if (shape.tagName == 'text'){
rlm@46 776 var size=parseFloat(shape.getAttributeNS(null, 'font-size'));
rlm@46 777 //$('code').value=size;
rlm@46 778 shape.setAttributeNS(null, 'x', left + 'px');
rlm@46 779 shape.setAttributeNS(null, 'y', parseFloat(top+size) + 'px');
rlm@46 780 //$('option_text_trx').value= left;
rlm@46 781 //$('option_text_try').value= top;
rlm@46 782
rlm@46 783 }
rlm@46 784 if (shape.tagName == 'line'){
rlm@46 785 var deltaX = shape.getBBox().width;
rlm@46 786 var deltaY = shape.getBBox().height;
rlm@46 787 shape.setAttributeNS(null, 'x1', left + 'px');
rlm@46 788 shape.setAttributeNS(null, 'y1', top + 'px');
rlm@46 789
rlm@46 790 shape.setAttributeNS(null, 'x2', left + deltaX + 'px');
rlm@46 791 shape.setAttributeNS(null, 'y2', top + deltaY + 'px');
rlm@46 792 //$('option_line_trx').value= left;
rlm@46 793 //$('option_line_try').value= top;
rlm@46 794
rlm@46 795 }
rlm@46 796 if (shape.tagName == 'ellipse'){
rlm@46 797 var putx=left + (shape.getBBox().width / 2)
rlm@46 798 var puty= top + (shape.getBBox().height / 2)
rlm@46 799 shape.setAttributeNS(null, 'cx', putx + 'px');
rlm@46 800 shape.setAttributeNS(null, 'cy', puty + 'px');
rlm@46 801 //$('option_ellipse_trx').value= putx;
rlm@46 802 //$('option_ellipse_try').value= puty;
rlm@46 803
rlm@46 804 }
rlm@46 805 if (shape.tagName == 'path' || shape.tagName == 'polyline' ) {
rlm@46 806
rlm@46 807 if(contmove==1){
rlm@46 808 xshe=left;
rlm@46 809 yshe=top;
rlm@46 810 }
rlm@46 811 var path=shape.getAttributeNS(null, 'd');
rlm@46 812 path=path.replace(/, /g, ',');
rlm@46 813 path=path.replace(/ ,/g, ',');
rlm@46 814 var ps =path.split(" ")
rlm@46 815 var pcc = "";
rlm@46 816 var point =ps[0].split(",");
rlm@46 817
rlm@46 818
rlm@46 819 var num0= parseFloat(point[0].substring(1));
rlm@46 820 var num1= parseFloat(point[1]);
rlm@46 821
rlm@46 822 var ang= ang2v(box.x,box.y,left,top) ;
rlm@46 823 var angle = Math.round((ang/Math.PI* 2)* 360);
rlm@46 824 var angx = Math.cos(ang);
rlm@46 825 var angy = Math.sin(ang);
rlm@46 826 var dist= dist2p(left,top,box.x,box.y);
rlm@46 827 var xinc=dist*angx;
rlm@46 828 var yinc=dist*angy;
rlm@46 829 var re = /^[-]?\d*\.?\d*$/;
rlm@46 830 for(var i = 0; i < ps.length; i++)
rlm@46 831 {
rlm@46 832 if(ps[i].indexOf(',')>0){
rlm@46 833
rlm@46 834 var point =ps[i].split(",");
rlm@46 835 var char1=point[0].substring(0,1);
rlm@46 836 if(char1=='A' || char1=='a'){isArc=true; contArc=0;}
rlm@46 837 if(isArc==true){contArc++}
rlm@46 838 if(contArc==4){contArc=0; isArc=false}
rlm@46 839
rlm@46 840 //if (isNaN(valnum))
rlm@46 841 if (!char1.match(re))
rlm@46 842 {
rlm@46 843 var num0= parseFloat(point[0].substring(1));
rlm@46 844 var text=char1;
rlm@46 845 }else{
rlm@46 846 if(isArc==true && contArc==2 )
rlm@46 847 {
rlm@46 848 var num0= point[0];
rlm@46 849 }else{
rlm@46 850 var num0= parseFloat(point[0]);
rlm@46 851 }
rlm@46 852 var text='';
rlm@46 853
rlm@46 854 }
rlm@46 855
rlm@46 856
rlm@46 857 if(isArc==true && contArc==2)
rlm@46 858 {
rlm@46 859 point[1]= point[1].toString() ;
rlm@46 860 }
rlm@46 861 else
rlm@46 862 {
rlm@46 863
rlm@46 864 num0+=xinc;
rlm@46 865 point[1]= parseFloat(point[1]);
rlm@46 866 point[1]+=yinc;
rlm@46 867
rlm@46 868 }
rlm@46 869 var cx=num0;
rlm@46 870
rlm@46 871 var cy=point[1];
rlm@46 872 pcc+=text+cx+','+cy+' ';
rlm@46 873 }else{
rlm@46 874 pcc+=ps[i]+' ';
rlm@46 875 }
rlm@46 876 }
rlm@46 877
rlm@46 878 shape.setAttributeNS(null,'d', pcc);
rlm@46 879
rlm@46 880 }
rlm@46 881
rlm@46 882
rlm@46 883 //$('status').innerHTML=typeTransform+': '+left+' '+top;
rlm@46 884 //$('option_select_trx').value= left;
rlm@46 885 //$('option_select_try').value= top;
rlm@46 886
rlm@46 887
rlm@46 888
rlm@46 889 };
rlm@46 890
rlm@46 891
rlm@46 892
rlm@46 893 SVGRenderer.prototype.track = function(shape) {
rlm@46 894 // TODO
rlm@46 895 };
rlm@46 896
rlm@46 897
rlm@46 898 SVGRenderer.prototype.clic = function(shape) {
rlm@46 899 var end='';
rlm@46 900 if(data_path_close==true){end='z';}
rlm@46 901 var maxcont=setPoints.length;
rlm@46 902 var thispath='M'+setPoints[0]+' ';
rlm@46 903 $('someinfo').value=maxcont;
rlm@46 904
rlm@46 905 for(var conta=1;conta< maxcont;conta++){
rlm@46 906 thispath+='L'+setPoints[conta]+' ';
rlm@46 907 }
rlm@46 908 //var pointshape=shape.getAttributeNS(null,"d");
rlm@46 909 //shape.setAttributeNS(null,'d',thispath+end);
rlm@46 910 var path=thispath+end;
rlm@46 911
rlm@46 912 shape.setAttributeNS(null,'d',path);
rlm@46 913 $('control_codebase').value=path;
rlm@46 914
rlm@46 915 }
rlm@46 916
rlm@46 917
rlm@46 918 SVGRenderer.prototype.resize = function(shape, fromX, fromY, toX, toY) {
rlm@46 919 var deltaX = toX - fromX;
rlm@46 920 var deltaY = toY - fromY;
rlm@46 921
rlm@46 922 /* if (lineColor.length == 0){lineColor = 'none';}
rlm@46 923 if (fillColor.length == 0){fillColor = 'none';}
rlm@46 924 shape.style.fill = fillColor;
rlm@46 925 shape.style.stroke = lineColor;
rlm@46 926 shape.style.strokeWidth = lineWidth;
rlm@46 927 shape.style.fillOpacity = fillOpac;
rlm@46 928 shape.style.strokOpacity = lineOpac;
rlm@46 929 */
rlm@46 930 if (shape.tagName == 'rect' )
rlm@46 931 {
rlm@46 932
rlm@46 933
rlm@46 934 if (deltaX < 0) {
rlm@46 935 shape.setAttributeNS(null, 'x', toX + 'px');
rlm@46 936 shape.setAttributeNS(null, 'width', -deltaX + 'px');
rlm@46 937 }
rlm@46 938 else
rlm@46 939 {
rlm@46 940 shape.setAttributeNS(null, 'width', deltaX + 'px');
rlm@46 941 }
rlm@46 942
rlm@46 943 if (deltaY < 0)
rlm@46 944 {
rlm@46 945 shape.setAttributeNS(null, 'y', toY + 'px');
rlm@46 946 shape.setAttributeNS(null, 'height', -deltaY + 'px');
rlm@46 947 }
rlm@46 948 else
rlm@46 949 {
rlm@46 950 shape.setAttributeNS(null, 'height', deltaY + 'px');
rlm@46 951 }
rlm@46 952 /*shape.style.fill = fillColor;
rlm@46 953 shape.style.stroke = lineColor;
rlm@46 954 shape.style.strokeWidth = lineWidth;
rlm@46 955 shape.style.fillOpacity = fillOpac;
rlm@46 956 shape.style.strokOpacity = lineOpac;
rlm@46 957 */
rlm@46 958
rlm@46 959 }
rlm@46 960
rlm@46 961 /* if ( shape.tagName == 'simage' )
rlm@46 962 {
rlm@46 963 var img=shape.firstChild;//nodeName;//nodparseFloatue;//nodes.item(0);
rlm@46 964 //alert(img);
rlm@46 965 if (deltaX < 0) {
rlm@46 966 shape.setAttributeNS(null, 'x', parseFloat(toX) + 'px');
rlm@46 967 shape.setAttributeNS(null, 'width', parseFloat(-deltaX) + 'px');
rlm@46 968
rlm@46 969 }
rlm@46 970 else
rlm@46 971 {
rlm@46 972 shape.setAttributeNS(null, 'width', parseFloat(deltaX) + 'px');
rlm@46 973 }
rlm@46 974
rlm@46 975 if (deltaY < 0)
rlm@46 976 {
rlm@46 977 shape.setAttributeNS(null, 'y', parseFloat(toY) + 'px');
rlm@46 978 shape.setAttributeNS(null, 'height', parseFloat(-deltaY) + 'px');
rlm@46 979 }
rlm@46 980 else
rlm@46 981 {
rlm@46 982 shape.setAttributeNS(null, 'height', parseFloat(deltaY) + 'px');
rlm@46 983 }
rlm@46 984 var h=shape.getAttributeNS(null, 'height');
rlm@46 985 var w=shape.getAttributeNS(null, 'width');
rlm@46 986 document.forms[0].code.value= h+' '+w;
rlm@46 987
rlm@46 988
rlm@46 989
rlm@46 990 }*/
rlm@46 991 if (shape.tagName == 'g' || shape.tagName == 'image')
rlm@46 992 {
rlm@46 993
rlm@46 994
rlm@46 995 if (deltaX < 0)
rlm@46 996 {
rlm@46 997 shape.setAttributeNS(null, 'x', parseFloat(toX) + 'px' );
rlm@46 998 shape.setAttributeNS(null, 'width', parseFloat(-deltaX) + 'px');
rlm@46 999
rlm@46 1000
rlm@46 1001 }
rlm@46 1002 else
rlm@46 1003 {
rlm@46 1004 shape.setAttributeNS(null, 'width', parseFloat(deltaX) + 'px');
rlm@46 1005 }
rlm@46 1006
rlm@46 1007 if (deltaY < 0)
rlm@46 1008 {
rlm@46 1009 shape.setAttributeNS(null, 'y', parseFloat(toY) + 'px');
rlm@46 1010 shape.setAttributeNS(null, 'height', parseFloat(-deltaY) + 'px' );
rlm@46 1011 }
rlm@46 1012 else
rlm@46 1013 {
rlm@46 1014 shape.setAttributeNS(null, 'height', parseFloat(deltaY) + 'px');
rlm@46 1015
rlm@46 1016 }
rlm@46 1017
rlm@46 1018 }
rlm@46 1019 if (shape.tagName == 'ellipse') {
rlm@46 1020 if (deltaX < 0) {
rlm@46 1021 shape.setAttributeNS(null, 'cx', (fromX + deltaX / 2) + 'px');
rlm@46 1022 shape.setAttributeNS(null, 'rx', (-deltaX / 2) + 'px');
rlm@46 1023 }
rlm@46 1024 else {
rlm@46 1025 shape.setAttributeNS(null, 'cx', (fromX + deltaX / 2) + 'px');
rlm@46 1026 shape.setAttributeNS(null, 'rx', (deltaX / 2) + 'px');
rlm@46 1027 }
rlm@46 1028
rlm@46 1029 if (deltaY < 0) {
rlm@46 1030 shape.setAttributeNS(null, 'cy', (fromY + deltaY / 2) + 'px');
rlm@46 1031 shape.setAttributeNS(null, 'ry', (-deltaY / 2) + 'px');
rlm@46 1032 }
rlm@46 1033 else {
rlm@46 1034 shape.setAttributeNS(null, 'cy', (fromY + deltaY / 2) + 'px');
rlm@46 1035 shape.setAttributeNS(null, 'ry', (deltaY / 2) + 'px');
rlm@46 1036 }
rlm@46 1037 }
rlm@46 1038 if (shape.tagName == 'line') {
rlm@46 1039 shape.setAttributeNS(null, 'x2', toX);
rlm@46 1040 shape.setAttributeNS(null, 'y2', toY);
rlm@46 1041 }
rlm@46 1042 if (shape.tagName == 'polyline') {
rlm@46 1043
rlm@46 1044 xpArray.push(toX);
rlm@46 1045 ypArray.push(toY);
rlm@46 1046 var thispath=''+xpArray[1]+','+ypArray[1];
rlm@46 1047 var thispath1='';
rlm@46 1048 var thispath2='';
rlm@46 1049 var maxcont=xpArray.length;
rlm@46 1050
rlm@46 1051 for(var conta=2;conta< maxcont;conta++){
rlm@46 1052 thispath1+=' '+xpArray[conta]+' '+ypArray[conta];
rlm@46 1053 thispath2+=' '+xpArray[conta]+', '+ypArray[conta];
rlm@46 1054
rlm@46 1055 }
rlm@46 1056
rlm@46 1057
rlm@46 1058 shape.setAttributeNS(null,'points',thispath+thispath1);
rlm@46 1059
rlm@46 1060
rlm@46 1061 }
rlm@46 1062
rlm@46 1063 if (shape.tagName == 'path') {
rlm@46 1064
rlm@46 1065 if (selectmode == 'controlpath')
rlm@46 1066 {
rlm@46 1067 var end='';
rlm@46 1068 if(data_path_close==true){end='z';}
rlm@46 1069
rlm@46 1070 var thispath='M'+setPoints[0]+' ';
rlm@46 1071 var maxcont=setPoints.length;
rlm@46 1072
rlm@46 1073 for(var conta=1;conta< maxcont;conta++){
rlm@46 1074 thispath+='L'+setPoints[conta]+' ';
rlm@46 1075
rlm@46 1076
rlm@46 1077 }
rlm@46 1078 var path=thispath+'L'+toX+','+toY+end;
rlm@46 1079 //var pointshape=shape.getAttributeNS(null,"d");
rlm@46 1080 shape.setAttributeNS(null,'d',path);
rlm@46 1081 document.forms[0].control_codebase.value=path;
rlm@46 1082 }
rlm@46 1083 else
rlm@46 1084 {
rlm@46 1085
rlm@46 1086 xpArray.push(toX);
rlm@46 1087 ypArray.push(toY);
rlm@46 1088
rlm@46 1089 var thispath=''+xpArray[1]+','+ypArray[1];
rlm@46 1090 var thispath1='';
rlm@46 1091 var thispath2='';
rlm@46 1092 var maxcont=xpArray.length;
rlm@46 1093
rlm@46 1094 for(var conta=2;conta< maxcont;conta++){
rlm@46 1095 //thispath1+=' '+xpArray[conta]+' '+ypArray[conta];
rlm@46 1096 thispath2+=' '+xpArray[conta]+','+ypArray[conta];
rlm@46 1097 //if((conta+2)%3==0){thispath2+=' C';}
rlm@46 1098 }
rlm@46 1099 var end='';
rlm@46 1100 if(data_path_close==true){end='z';}
rlm@46 1101 shape.setAttributeNS(null,'d','M '+thispath+ ' L'+thispath2+end);
rlm@46 1102
rlm@46 1103
rlm@46 1104
rlm@46 1105 /*
rlm@46 1106
rlm@46 1107 var pointshape=shape.getAttributeNS(null,"points");
rlm@46 1108 var thispoint=' '+toX+' '+toY;
rlm@46 1109 $('status').innerHTML =pointshape;
rlm@46 1110 shape.setAttributeNS(null,'points',pointshape+thispoint)
rlm@46 1111 shape.setAttributeNS(null, 'stroke-width', "25");
rlm@46 1112 shape.setAttributeNS(null, 'fill', "#FFFF00");
rlm@46 1113
rlm@46 1114 //shape.points.push(toX);
rlm@46 1115 //shape.points.push(toY);
rlm@46 1116 //shape.setAttribute("points",pointshape+);
rlm@46 1117 // var maxcont=xpArray.length-1;
rlm@46 1118 var thispath=''+xpArray[1]+','+ypArray[1];
rlm@46 1119 var maxcont=xpArray.length;
rlm@46 1120 //alert(maxcont);
rlm@46 1121 for(var conta=2;conta< maxcont;conta++){
rlm@46 1122 thispath+=','+xpArray[conta]+','+ypArray[conta];
rlm@46 1123 }
rlm@46 1124 //alert(shape.points[1]);
rlm@46 1125 //shape.setAttribute("points",thispath);
rlm@46 1126 //points.Value = thispath;
rlm@46 1127 var thispath=''+xpArray[1]+','+ypArray[1];
rlm@46 1128 var maxcont=xpArray.length;
rlm@46 1129 //alert(maxcont);
rlm@46 1130 for(var conta=1;conta< maxcont;conta++){
rlm@46 1131 thispath+=','+xpArray[conta]+','+ypArray[conta];
rlm@46 1132 }
rlm@46 1133
rlm@46 1134 shape.points.Value = thispath;
rlm@46 1135 */
rlm@46 1136
rlm@46 1137
rlm@46 1138
rlm@46 1139
rlm@46 1140 /*
rlm@46 1141
rlm@46 1142
rlm@46 1143 //this.renderer.move(this.selected, this.selectedBounds.x + deltaX, this.selectedBounds.y + deltaY);
rlm@46 1144 // shape.setAttributeNS(null,'transform', "translate("+(toX)+","+(toy)+")");
rlm@46 1145
rlm@46 1146
rlm@46 1147
rlm@46 1148 var thispath=''+xpArray[0]+','+ypArray[0];
rlm@46 1149 var maxcont=xpArray.length;
rlm@46 1150 //shape.setAttributeNS(null,'transform', "translate("+toX+","+toY+")");
rlm@46 1151 for(var conta=1;conta< maxcont;conta++){
rlm@46 1152 thispath+=','+xpArray[conta]+','+ypArray[conta];
rlm@46 1153 }
rlm@46 1154
rlm@46 1155 shape.setAttributeNS(null, 'x', toX);
rlm@46 1156 shape.setAttributeNS(null, 'y', toY);
rlm@46 1157 shape.setAttributeNS(null, 'points', thispath);
rlm@46 1158 */
rlm@46 1159 }
rlm@46 1160 }
rlm@46 1161 if (shape == 'text') {}
rlm@46 1162
rlm@46 1163 };
rlm@46 1164 SVGRenderer.prototype.tocurve = function()
rlm@46 1165 {
rlm@46 1166 var points=$('control_codebase').value.split('L');
rlm@46 1167 var chain='';
rlm@46 1168 chain+=points[0]+'C';
rlm@46 1169 var numpoints=points.length-1;
rlm@46 1170 for(var a=1;a<numpoints;a++)
rlm@46 1171 {
rlm@46 1172 if(a%3==0)
rlm@46 1173 {
rlm@46 1174 chain+=points[a]+'C';
rlm@46 1175 }
rlm@46 1176 else
rlm@46 1177 {
rlm@46 1178 chain+=points[a];
rlm@46 1179 }
rlm@46 1180 }
rlm@46 1181 if(numpoints%3==0){
rlm@46 1182 chain+=points[numpoints]+'';
rlm@46 1183 }
rlm@46 1184 if(numpoints%3==2){
rlm@46 1185 chain+=points[numpoints-1]+'';
rlm@46 1186 chain+=points[numpoints]+'';
rlm@46 1187 }
rlm@46 1188 if(numpoints%3==1){
rlm@46 1189 chain+=points[numpoints-1]+'';
rlm@46 1190 chain+=points[numpoints-1]+'';
rlm@46 1191 chain+=points[numpoints]+'';
rlm@46 1192 }
rlm@46 1193 if(numpoints%3==3){
rlm@46 1194 chain+=points[numpoints-1]+'';
rlm@46 1195 chain+=points[numpoints-1]+'';
rlm@46 1196 chain+=points[numpoints-1]+'';
rlm@46 1197 chain+=points[numpoints]+'';
rlm@46 1198 }
rlm@46 1199
rlm@46 1200 $('someinfo').value=numpoints+ ' '+ numpoints%3;
rlm@46 1201 $('control_codebase').value=chain;
rlm@46 1202 setShape();
rlm@46 1203 };
rlm@46 1204 SVGRenderer.prototype.info = function(shape)
rlm@46 1205 {
rlm@46 1206 var shInfo = {};
rlm@46 1207 if(shape.id != "tracker"){
rlm@46 1208 //shInfo.id = shape.id.substr(6);
rlm@46 1209 shInfo.id =shape.getAttribute('id');
rlm@46 1210 shInfo.type = shape.tagName;
rlm@46 1211 if (shape.hasAttributeNS(null,'transform')) {
rlm@46 1212 shInfo.transform = shape.getAttribute('transform');
rlm@46 1213 }else{
rlm@46 1214 shInfo.transform ='';
rlm@46 1215 }
rlm@46 1216
rlm@46 1217 if(shape.tagName == "text"){
rlm@46 1218
rlm@46 1219 shInfo.textFamily = shape.getAttribute('font-family')
rlm@46 1220 shInfo.textSize = parseInt(shape.getAttribute('font-size'))
rlm@46 1221 shInfo.top = parseFloat(shape.getAttribute('y'))
rlm@46 1222 shInfo.left = parseFloat(shape.getAttribute('x'))
rlm@46 1223 shInfo.text = shape.textContent
rlm@46 1224 shInfo.lineWidth = parseFloat(shape.getAttribute('stroke-width'))
rlm@46 1225
rlm@46 1226 //shInfo.text = shape.nodparseFloatue;
rlm@46 1227 }
rlm@46 1228
rlm@46 1229
rlm@46 1230 if(shape.tagName !='image' || shape.tagName !='g' || shape.tagName !='stop')
rlm@46 1231 {
rlm@46 1232 shInfo.fillColor = shape.getAttribute('fill')
rlm@46 1233 shInfo.lineColor = shape.getAttribute('stroke')
rlm@46 1234 shInfo.fillOpac = parseFloat(shape.getAttribute('fill-opacity'))
rlm@46 1235 shInfo.lineOpac = parseFloat(shape.getAttribute('stroke-opacity'))
rlm@46 1236 shInfo.lineWidth = parseFloat(shape.getAttribute('stroke-width'))
rlm@46 1237
rlm@46 1238 var mystyle= shape.getAttribute('style');
rlm@46 1239
rlm@46 1240 if(mystyle!= null && mystyle.indexOf('<![CDATA[')>=0)
rlm@46 1241 {
rlm@46 1242
rlm@46 1243 }
rlm@46 1244 else
rlm@46 1245 {
rlm@46 1246 // shInfo.style=shape.getAttribute('style');
rlm@46 1247
rlm@46 1248 if(mystyle!= null){
rlm@46 1249 //var estilo=shape.getAttribute('style');
rlm@46 1250 var data;
rlm@46 1251
rlm@46 1252 var estilo=generateJSON(mystyle);
rlm@46 1253 eval("data="+estilo);
rlm@46 1254 //var data=eval('"'+estilo+'"');
rlm@46 1255 //var data=estilo.evalJSON();
rlm@46 1256
rlm@46 1257 (data["font-size"])?shInfo.textSize=data["font-size"]:shInfo.textSize;
rlm@46 1258 (data["font-family"])?shInfo.textFamily=data["font-family"]:shInfo.textFamily;
rlm@46 1259
rlm@46 1260 (data.fill)?shInfo.fillColor=data.fill:shInfo.fillColor;
rlm@46 1261 (data.stroke)?shInfo.lineColor=data.stroke:shInfo.lineColor;
rlm@46 1262 (data.transform)?shInfo.transform=data.transform:shInfo.transform;
rlm@46 1263 (data["fill-opacity"])?shInfo.fillOpac=data["fill-opacity"]:shInfo.fillOpac;
rlm@46 1264 //shInfo.fillColor=data.fill;
rlm@46 1265 //document.getElementById("someinfo").value +=data.fill+' ';//estilo ;//data['fill']+' ';//
rlm@46 1266 }
rlm@46 1267 }
rlm@46 1268 }
rlm@46 1269
rlm@46 1270
rlm@46 1271 if (shape.tagName == 'rect')
rlm@46 1272 {
rlm@46 1273 if(shape.getAttribute('rx') || shape.getAttribute('ry')){
rlm@46 1274 shInfo.type = "roundrect";
rlm@46 1275 shInfo.rx = parseFloat(shape.getAttribute('rx'))
rlm@46 1276 shInfo.ry = parseFloat(shape.getAttribute('rx'))
rlm@46 1277 }
rlm@46 1278 shInfo.left = parseFloat(shape.getAttribute( 'x'));
rlm@46 1279 shInfo.top = parseFloat(shape.getAttribute( 'y'));
rlm@46 1280 shInfo.width = parseFloat(shape.getAttribute('width'));
rlm@46 1281 shInfo.height = parseFloat(shape.getAttribute('height'));
rlm@46 1282 }
rlm@46 1283 else if (shape.tagName == 'ellipse' || shape.tagName == 'circle')
rlm@46 1284 {
rlm@46 1285 if(shape.tagName == 'circle'){
rlm@46 1286 shInfo.width = parseFloat(shape.getAttribute('r'))*2;
rlm@46 1287 shInfo.height = parseFloat(shape.getAttribute('r'))*2;
rlm@46 1288 }else{
rlm@46 1289 shInfo.width = parseFloat(shape.getAttribute('rx'))*2;
rlm@46 1290 shInfo.height = parseFloat(shape.getAttribute('ry'))*2;
rlm@46 1291 }
rlm@46 1292
rlm@46 1293 shInfo.left = parseFloat(shape.getAttribute('cx')) - (shInfo.width/2);
rlm@46 1294 shInfo.top = parseFloat(shape.getAttribute('cy')) - (shInfo.height/2) ;
rlm@46 1295 }
rlm@46 1296 else if(shape.tagName == 'linearGradient') {
rlm@46 1297 shInfo.left = (shape.getAttribute( 'x1'));
rlm@46 1298 shInfo.top = parseFloat(shape.getAttribute( 'y1'));
rlm@46 1299 shInfo.width = parseFloat(shape.getAttribute('x2'));
rlm@46 1300 shInfo.height = parseFloat(shape.getAttribute('y2'));
rlm@46 1301
rlm@46 1302 }
rlm@46 1303 else if(shape.tagName == 'stop') {
rlm@46 1304 shInfo.fillColor = shape.getAttribute('stop-color');
rlm@46 1305 shInfo.fillOpac = shape.getAttribute('stop-opacity');
rlm@46 1306 shInfo.lineOpac = shape.getAttribute('offset');
rlm@46 1307 var mystyle= shape.getAttribute('style');
rlm@46 1308 if(mystyle!= null && mystyle.indexOf('<![CDATA[')>=0)
rlm@46 1309 {
rlm@46 1310
rlm@46 1311 }
rlm@46 1312 else
rlm@46 1313 {
rlm@46 1314 if(mystyle!= null){
rlm@46 1315 var data;
rlm@46 1316 var estilo=generateJSON(mystyle);
rlm@46 1317 eval("data="+estilo);
rlm@46 1318 (data["stop-color"])?shInfo.fillColor=data["stop-color"]:shInfo.fillColor;
rlm@46 1319 (data["stop-opacity"])?shInfo.fillOpac=data["stop-opacity"]:shInfo.fillOpac;
rlm@46 1320 document.getElementById("someinfo").value +=data["stop-color"]+' ';
rlm@46 1321 }
rlm@46 1322
rlm@46 1323 }
rlm@46 1324 }
rlm@46 1325 else if (shape.tagName == 'line')
rlm@46 1326 {
rlm@46 1327 shInfo.left = parseFloat(shape.getAttribute('x1'));
rlm@46 1328 shInfo.top = parseFloat(shape.getAttribute('y1'));
rlm@46 1329 shInfo.width = parseFloat(shape.getAttribute('x2')) -shInfo.left;
rlm@46 1330 shInfo.height = parseFloat(shape.getAttribute('y2')) -shInfo.top;
rlm@46 1331 }
rlm@46 1332 else if (shape.tagName == 'polyline')
rlm@46 1333 {
rlm@46 1334 shInfo.points = shape.getAttribute('points');
rlm@46 1335 }
rlm@46 1336 else if (shape.tagName == 'g')
rlm@46 1337 {
rlm@46 1338 shInfo.type = "group";
rlm@46 1339 shInfo.left = parseFloat(shape.getAttribute( 'x'));
rlm@46 1340 shInfo.top = parseFloat(shape.getAttribute( 'y'));
rlm@46 1341 shInfo.width = parseFloat(shape.getAttribute('width'));
rlm@46 1342 shInfo.height = parseFloat(shape.getAttribute('height'));
rlm@46 1343 shInfo.fillColor = shape.getAttribute('fill')
rlm@46 1344
rlm@46 1345 }
rlm@46 1346 else if (shape.tagName == 'path')
rlm@46 1347 {
rlm@46 1348 shInfo.points = shape.getAttribute('d');
rlm@46 1349 //shInfo.transform = shape.getAttribute('transform');
rlm@46 1350
rlm@46 1351 //alert(shInfo.transform);
rlm@46 1352 //document.forms[0].codebase.value=shape.getAttribute('d');
rlm@46 1353
rlm@46 1354 }
rlm@46 1355 else
rlm@46 1356
rlm@46 1357
rlm@46 1358 if (shape.tagName == 'image')
rlm@46 1359 {
rlm@46 1360
rlm@46 1361 shInfo.left = parseFloat(shape.getAttribute( 'x'));
rlm@46 1362 shInfo.top = parseFloat(shape.getAttribute( 'y'));
rlm@46 1363 shInfo.width = parseFloat(shape.getAttribute('width'));
rlm@46 1364 shInfo.height = parseFloat(shape.getAttribute('height'));
rlm@46 1365 shInfo.fillOpac = parseFloat(shape.getAttribute('opacity'));
rlm@46 1366 shInfo.href = shape.getAttribute('href');
rlm@46 1367
rlm@46 1368 }
rlm@46 1369 if(shape.parentNode.tagName != 'svg'){
rlm@46 1370 //shInfo.width = parseFloat(shape.getAttribute('width'));
rlm@46 1371 //shInfo.height = parseFloat(shape.getAttribute('height'));
rlm@46 1372 //shInfo.viewBox = parseFloat(shape.getAttribute('viewBox'));
rlm@46 1373 shInfo.parent=shape.parentNode.getAttribute('id');
rlm@46 1374
rlm@46 1375 }
rlm@46 1376 return shInfo;
rlm@46 1377 }else{
rlm@46 1378 //do nothing if its the tracker
rlm@46 1379 }
rlm@46 1380
rlm@46 1381
rlm@46 1382
rlm@46 1383 };
rlm@46 1384 SVGRenderer.prototype.info01 = function(shape)
rlm@46 1385 {
rlm@46 1386
rlm@46 1387 var shInfo = {};
rlm@46 1388 if(shape.id != "tracker"){
rlm@46 1389 shInfo.id = shape.id.substr(6);
rlm@46 1390 shInfo.type = shape.tagName;
rlm@46 1391 if (shape.hasAttributeNS(null,'transform')) {
rlm@46 1392 shInfo.transform = shape.getAttribute('transform');
rlm@46 1393 }else{
rlm@46 1394 shInfo.transform ='';
rlm@46 1395 }
rlm@46 1396
rlm@46 1397
rlm@46 1398 if(shape.tagName !='image')
rlm@46 1399 {
rlm@46 1400 shInfo.fillColor = shape.getAttribute('fill')
rlm@46 1401 shInfo.lineColor = shape.getAttribute('stroke')
rlm@46 1402 shInfo.fillOpac = parseFloat(shape.getAttribute('fill-opacity'))
rlm@46 1403 shInfo.lineOpac = parseFloat(shape.getAttribute('stroke-opacity'))
rlm@46 1404 shInfo.lineWidth = parseFloat(shape.getAttribute('stroke-width'))
rlm@46 1405 }
rlm@46 1406
rlm@46 1407
rlm@46 1408 if (shape.tagName == 'rect')
rlm@46 1409 {
rlm@46 1410 if(shape.getAttribute('rx') || shape.getAttribute('ry')){
rlm@46 1411 shInfo.type = "roundrect";
rlm@46 1412 shInfo.rx = parseFloat(shape.getAttribute('rx'))
rlm@46 1413 shInfo.ry = parseFloat(shape.getAttribute('rx'))
rlm@46 1414 }
rlm@46 1415 shInfo.left = parseFloat(shape.getAttribute( 'x'));
rlm@46 1416 shInfo.top = parseFloat(shape.getAttribute( 'y'));
rlm@46 1417 shInfo.width = parseFloat(shape.getAttribute('width'));
rlm@46 1418 shInfo.height = parseFloat(shape.getAttribute('height'));
rlm@46 1419 }
rlm@46 1420 else if (shape.tagName == 'ellipse')
rlm@46 1421 {
rlm@46 1422 shInfo.width = parseFloat(shape.getAttribute('rx'))*2;
rlm@46 1423 shInfo.height = parseFloat(shape.getAttribute('ry'))*2;
rlm@46 1424 shInfo.left = parseFloat(shape.getAttribute('cx')) - (shInfo.width/2);
rlm@46 1425 shInfo.top = parseFloat(shape.getAttribute('cy')) - (shInfo.height/2) ;
rlm@46 1426
rlm@46 1427 }
rlm@46 1428 else if (shape.tagName == 'line')
rlm@46 1429 {
rlm@46 1430 shInfo.left = parseFloat(shape.getAttribute('x1'));
rlm@46 1431 shInfo.top = parseFloat(shape.getAttribute('y1'));
rlm@46 1432 shInfo.width = parseFloat(shape.getAttribute('x2')) -shInfo.left;
rlm@46 1433 shInfo.height = parseFloat(shape.getAttribute('y2')) -shInfo.top;
rlm@46 1434 }
rlm@46 1435 else if (shape.tagName == 'polyline')
rlm@46 1436 {
rlm@46 1437 shInfo.points = shape.getAttribute('points');
rlm@46 1438 }
rlm@46 1439 else
rlm@46 1440
rlm@46 1441 if (shape.tagName == 'path')
rlm@46 1442 {
rlm@46 1443 shInfo.d = shape.getAttribute('d');
rlm@46 1444 //shInfo.transform = shape.getAttribute('transform');
rlm@46 1445
rlm@46 1446 //alert(shInfo.transform);
rlm@46 1447 //document.forms[0].codebase.value=shape.getAttribute('d');
rlm@46 1448
rlm@46 1449 }
rlm@46 1450 else
rlm@46 1451
rlm@46 1452 if(shape.tagName == "text"){
rlm@46 1453
rlm@46 1454 shInfo.textFamily = shape.getAttribute('font-family')
rlm@46 1455 shInfo.textSize = parseInt(shape.getAttribute('font-size'))
rlm@46 1456 shInfo.top = parseFloat(shape.getAttribute('y'))
rlm@46 1457 shInfo.left = parseFloat(shape.getAttribute('x'))
rlm@46 1458 shInfo.text = shape.textContent
rlm@46 1459 shInfo.lineWidth = parseFloat(shape.getAttribute('stroke-width'))
rlm@46 1460
rlm@46 1461 //shInfo.text = shape.nodparseFloatue;
rlm@46 1462 }
rlm@46 1463 else
rlm@46 1464
rlm@46 1465 if (shape.tagName == 'image')
rlm@46 1466 {
rlm@46 1467
rlm@46 1468 shInfo.left = parseFloat(shape.getAttribute( 'x'));
rlm@46 1469 shInfo.top = parseFloat(shape.getAttribute( 'y'));
rlm@46 1470 shInfo.width = parseFloat(shape.getAttribute('width'));
rlm@46 1471 shInfo.height = parseFloat(shape.getAttribute('height'));
rlm@46 1472 shInfo.fillOpac = parseFloat(shape.getAttribute('opacity'));
rlm@46 1473 shInfo.href = shape.getAttribute('href');
rlm@46 1474
rlm@46 1475 }
rlm@46 1476
rlm@46 1477 return shInfo;
rlm@46 1478 }else{
rlm@46 1479 //do nothing if its the tracker
rlm@46 1480 }
rlm@46 1481
rlm@46 1482
rlm@46 1483 }
rlm@46 1484
rlm@46 1485
rlm@46 1486
rlm@46 1487
rlm@46 1488
rlm@46 1489 SVGRenderer.prototype.transformShape = function(shape,data,transform)
rlm@46 1490 {
rlm@46 1491 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 1492 var xlinkNS="http://www.w3.org/1999/xlink";
rlm@46 1493 //
rlm@46 1494
rlm@46 1495 if(shape.tagName == 'rect')
rlm@46 1496 {
rlm@46 1497 var box = shape.getBBox();
rlm@46 1498 var sdata=data.split(';');
rlm@46 1499
rlm@46 1500 //alert(data[0]);
rlm@46 1501 shape.setAttributeNS(null,'x',parseFloat(sdata[0]));
rlm@46 1502 shape.setAttributeNS(null,'y',parseFloat(sdata[1]));
rlm@46 1503 shape.setAttributeNS(null, 'width', parseFloat(sdata[2]));
rlm@46 1504 shape.setAttributeNS(null, 'height', parseFloat(sdata[3]));
rlm@46 1505 var centerx=parseFloat(sdata[0])+parseFloat(box.width/2);
rlm@46 1506 var centery=parseFloat(sdata[1])+parseFloat(box.height/2);
rlm@46 1507 shape.setAttributeNS(null, 'transform','rotate('+parseFloat(sdata[4])+','+centerx+','+centery+')');
rlm@46 1508
rlm@46 1509 //shape.nodparseFloatue=data;
rlm@46 1510 }
rlm@46 1511 else
rlm@46 1512 if(shape.tagName == 'text')
rlm@46 1513 {
rlm@46 1514 if(data.indexOf('<;>',0)==-1 )
rlm@46 1515 {
rlm@46 1516 shape.textContent = data;
rlm@46 1517 }
rlm@46 1518 else
rlm@46 1519 {
rlm@46 1520 var sdata=data.split('<;>'); //?????????
rlm@46 1521 shape.textContent = sdata[0];
rlm@46 1522 shape.setAttributeNS(null,'font-size',parseFloat(sdata[1]));
rlm@46 1523 shape.setAttributeNS(null,'font-family',sdata[2]);
rlm@46 1524 }
rlm@46 1525 //shape.nodparseFloatue=data;
rlm@46 1526 }
rlm@46 1527 else
rlm@46 1528 if (shape.tagName == 'polyline')
rlm@46 1529 {
rlm@46 1530 shape.setAttributeNS(null,'points',data);
rlm@46 1531 }
rlm@46 1532 else
rlm@46 1533 if (shape.tagName == 'image')
rlm@46 1534 {
rlm@46 1535 //alert(data);
rlm@46 1536 if(data.indexOf(';',0)==-1 )
rlm@46 1537 {
rlm@46 1538 shape.setAttributeNS(xlinkNS,'href',data);
rlm@46 1539 }
rlm@46 1540 else
rlm@46 1541 {
rlm@46 1542 var box = shape.getBBox();
rlm@46 1543 var sdata=data.split(';');
rlm@46 1544 shape.setAttributeNS(null,'x',parseFloat(sdata[0]));
rlm@46 1545 shape.setAttributeNS(null,'y',parseFloat(sdata[1]));
rlm@46 1546 shape.setAttributeNS(null, 'width', parseFloat(sdata[2]));
rlm@46 1547 shape.setAttributeNS(null, 'height',parseFloat(sdata[3]));
rlm@46 1548 var centerx=parseFloat(sdata[0])+parseFloat(box.width/2);
rlm@46 1549 var centery=parseFloat(sdata[1])+parseFloat(box.height/2);
rlm@46 1550 shape.setAttributeNS(null, 'transform',' rotate('+parseFloat(sdata[4])+','+centerx+','+centery+')');
rlm@46 1551
rlm@46 1552
rlm@46 1553 }
rlm@46 1554
rlm@46 1555 }
rlm@46 1556 else
rlm@46 1557 if (shape.tagName == 'path')
rlm@46 1558 {
rlm@46 1559 if(data.indexOf(';',0)==-1 )
rlm@46 1560 {
rlm@46 1561 shape.setAttributeNS(null, 'd', data);
rlm@46 1562 shape.setAttributeNS(null, 'transform', transform);
rlm@46 1563 }
rlm@46 1564 else
rlm@46 1565 {
rlm@46 1566 var box = shape.getBBox();
rlm@46 1567 var sdata=data.split(';');
rlm@46 1568 var centerx=parseFloat(sdata[0])+parseFloat(box.width/2);
rlm@46 1569 var centery=parseFloat(sdata[1])+parseFloat(box.height/2);
rlm@46 1570 shape.setAttributeNS(null, 'transform','scale('+parseFloat(sdata[2])+','+parseFloat(sdata[3])+')'+' rotate('+parseFloat(sdata[4])+','+centerx+','+centery+')'+' translate('+parseFloat(sdata[0])+','+parseFloat(sdata[1])+')');
rlm@46 1571
rlm@46 1572
rlm@46 1573 }
rlm@46 1574 }
rlm@46 1575
rlm@46 1576
rlm@46 1577 }
rlm@46 1578 SVGRenderer.prototype.editShape = function(shape,data)
rlm@46 1579 {
rlm@46 1580 if(shape.tagName == 'text'){
rlm@46 1581 shape.textContent = data
rlm@46 1582 }else
rlm@46 1583 if (shape.tagName == 'polyline')
rlm@46 1584 {
rlm@46 1585 shape.setAttributeNS(null,'points',data);
rlm@46 1586 }
rlm@46 1587 else
rlm@46 1588
rlm@46 1589 if (shape.tagName == 'path')
rlm@46 1590 {
rlm@46 1591 shape.setAttributeNS(null, 'd', data);
rlm@46 1592
rlm@46 1593 }
rlm@46 1594
rlm@46 1595 }
rlm@46 1596 SVGRenderer.prototype.editCommand = function(shape, cmd, value)
rlm@46 1597 {
rlm@46 1598 if (shape != null) {
rlm@46 1599 if (cmd == 'fillcolor') {
rlm@46 1600 if (value != '')
rlm@46 1601 shape.setAttributeNS(null, 'fill', value);
rlm@46 1602 else
rlm@46 1603 shape.setAttributeNS(null, 'fill', 'none');
rlm@46 1604 }
rlm@46 1605 else if (cmd == 'linecolor') {
rlm@46 1606 if (value != '')
rlm@46 1607 shape.setAttributeNS(null, 'stroke', value);
rlm@46 1608 else
rlm@46 1609 shape.setAttributeNS(null, 'stroke', 'none');
rlm@46 1610 }
rlm@46 1611 else if (cmd == 'linewidth') {
rlm@46 1612 shape.setAttributeNS(null, 'stroke-width', parseInt(value) + 'px');
rlm@46 1613 }
rlm@46 1614 else if (cmd == 'fillopacity') {
rlm@46 1615 if(shape.tagName=='image')
rlm@46 1616 {
rlm@46 1617 shape.setAttributeNS(null, 'opacity', parseFloat(value));
rlm@46 1618 }
rlm@46 1619 else
rlm@46 1620 {
rlm@46 1621 shape.setAttributeNS(null, 'fill-opacity', parseFloat(value));
rlm@46 1622 }
rlm@46 1623
rlm@46 1624 }
rlm@46 1625 else if (cmd == 'lineopacity') {
rlm@46 1626
rlm@46 1627 shape.setAttributeNS(null, 'stroke-opacity', parseFloat(value));
rlm@46 1628
rlm@46 1629 }
rlm@46 1630
rlm@46 1631 }
rlm@46 1632 }
rlm@46 1633
rlm@46 1634
rlm@46 1635 SVGRenderer.prototype.queryCommand = function(shape, cmd)
rlm@46 1636 {
rlm@46 1637 var result = '';
rlm@46 1638
rlm@46 1639 if (shape != null) {
rlm@46 1640 if (cmd == 'fillcolor') {
rlm@46 1641 result = shape.getAttributeNS(null, 'fill');
rlm@46 1642 if (result == 'none')
rlm@46 1643 result = '';
rlm@46 1644 }
rlm@46 1645 else if (cmd == 'linecolor') {
rlm@46 1646 result = shape.getAttributeNS(null, 'stroke');
rlm@46 1647 if (result == 'none')
rlm@46 1648 result = '';
rlm@46 1649 }
rlm@46 1650 else if (cmd == 'linewidth') {
rlm@46 1651 result = shape.getAttributeNS(null, 'stroke');
rlm@46 1652 if (result == 'none')
rlm@46 1653 result = '';
rlm@46 1654 else
rlm@46 1655 result = shape.getAttributeNS(null, 'stroke-width');
rlm@46 1656 }
rlm@46 1657 else if (cmd == 'fillopacity') {
rlm@46 1658 if(shape.tagName=='image')
rlm@46 1659 {
rlm@46 1660 shape.setAttributeNS(null, 'opacity', parseFloat(value));
rlm@46 1661 }
rlm@46 1662 else
rlm@46 1663 {
rlm@46 1664 shape.setAttributeNS(null, 'fill-opacity', parseFloat(value));
rlm@46 1665 }
rlm@46 1666
rlm@46 1667 }
rlm@46 1668 else if (cmd == 'lineopacity') {
rlm@46 1669
rlm@46 1670 shape.setAttributeNS(null, 'stroke-opacity', parseFloat(value));
rlm@46 1671
rlm@46 1672 }
rlm@46 1673
rlm@46 1674 }
rlm@46 1675
rlm@46 1676 return result;
rlm@46 1677 }
rlm@46 1678
rlm@46 1679 SVGRenderer.prototype.getProperties = function(shape)
rlm@46 1680 {
rlm@46 1681 var result = '';
rlm@46 1682
rlm@46 1683 if (shape != null)
rlm@46 1684 {
rlm@46 1685 result = shape.getAttributeNS(null, 'fill');
rlm@46 1686 if (result == 'none')
rlm@46 1687 {
rlm@46 1688 mefillColor.visible = 'hidden';
rlm@46 1689 mefillColor.hex = '#000000';
rlm@46 1690 filldraw=true;
rlm@46 1691 setbe(1,'img_okfill');
rlm@46 1692 }
rlm@46 1693 else
rlm@46 1694 {
rlm@46 1695 //alert(mefillColor.hex+' '+result);
rlm@46 1696 mefillColor.visible = 'visible';
rlm@46 1697 mefillColor.hex = result;
rlm@46 1698 var rgb=hex2rgb(result)
rlm@46 1699 mefillColor.r=rgb[0];
rlm@46 1700 mefillColor.g=rgb[1];
rlm@46 1701 mefillColor.b=rgb[2];
rlm@46 1702 filldraw=false;
rlm@46 1703 setbe(1,'img_okfill');
rlm@46 1704
rlm@46 1705 }
rlm@46 1706
rlm@46 1707 result = shape.getAttributeNS(null, 'stroke');
rlm@46 1708 if (result == 'none')
rlm@46 1709 {
rlm@46 1710 mestrokeColor.visible = 'hidden';
rlm@46 1711 mestrokeColor.hex = '#000000';
rlm@46 1712 mestrokeColor.width = 0;
rlm@46 1713 strokedraw=true;
rlm@46 1714 setbe(2,'img_okstroke');
rlm@46 1715
rlm@46 1716 }
rlm@46 1717 else
rlm@46 1718 {
rlm@46 1719 mestrokeColor.visible = 'visible';
rlm@46 1720 mestrokeColor.hex = result;
rlm@46 1721 var rgb=hex2rgb(result)
rlm@46 1722 mestrokeColor.r=rgb[0];
rlm@46 1723 mestrokeColor.g=rgb[1];
rlm@46 1724 mestrokeColor.b=rgb[2];
rlm@46 1725 strokedraw=false;
rlm@46 1726 setbe(2,'img_okstroke');
rlm@46 1727
rlm@46 1728 }
rlm@46 1729
rlm@46 1730 result = shape.getAttributeNS(null, 'stroke-width');
rlm@46 1731 mestrokeColor.width = result;
rlm@46 1732
rlm@46 1733 result = shape.getAttributeNS(null, 'fill-opacity');
rlm@46 1734 mefillColor.opacity = result;
rlm@46 1735
rlm@46 1736 result = shape.getAttributeNS(null, 'stroke-opacity');
rlm@46 1737 mestrokeColor.opacity = result;
rlm@46 1738
rlm@46 1739 setProperties();
rlm@46 1740 }
rlm@46 1741 }
rlm@46 1742
rlm@46 1743
rlm@46 1744 SVGRenderer.prototype.showMultiSelect = function(iniX,iniY) {
rlm@46 1745 var tracker = document.getElementById('trackerMultiSelect');
rlm@46 1746 if (tracker) {
rlm@46 1747 this.remove(tracker);
rlm@46 1748 }
rlm@46 1749
rlm@46 1750 var coord=this.editor.inputxy;
rlm@46 1751 toX=parseFloat(coord[0]);
rlm@46 1752 toY=parseFloat(coord[1]);
rlm@46 1753
rlm@46 1754 tracker = document.createElementNS(svgNamespace, 'rect');
rlm@46 1755
rlm@46 1756 tracker.setAttributeNS(null, 'x', iniX);
rlm@46 1757 tracker.setAttributeNS(null, 'y', iniY);
rlm@46 1758 tracker.setAttributeNS(null, 'width', toX);
rlm@46 1759 tracker.setAttributeNS(null, 'height', toY);
rlm@46 1760 tracker.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 1761 tracker.setAttributeNS(null, 'stroke', 'green');
rlm@46 1762 tracker.setAttributeNS(null, 'stroke-width', '1');
rlm@46 1763
rlm@46 1764 this.svgRoot.appendChild(tracker);
rlm@46 1765 }
rlm@46 1766
rlm@46 1767
rlm@46 1768 function mouseCoord()
rlm@46 1769 {
rlm@46 1770 var coord=this.editor.inputxy;
rlm@46 1771 coord[0]=parseFloat(coord[0]);
rlm@46 1772 coord[1]=parseFloat(coord[1]);
rlm@46 1773 return coord
rlm@46 1774 }
rlm@46 1775 /*
rlm@46 1776 function nodeHit(node)
rlm@46 1777 {
rlm@46 1778 node.addEventListener("mousemove", function(event) {nodeMove(node)}, false);
rlm@46 1779
rlm@46 1780 }
rlm@46 1781
rlm@46 1782 function nodeUp(node)
rlm@46 1783 {
rlm@46 1784 //node.stopObserving("mousemove");
rlm@46 1785 }
rlm@46 1786
rlm@46 1787 function nodeMove(node)
rlm@46 1788 {
rlm@46 1789 var mypath=$('control_codebase').value;
rlm@46 1790 var x= $('option_path_x').value;
rlm@46 1791 var y= $('option_path_y').value;
rlm@46 1792 var precoord=x+','+y;
rlm@46 1793 var coord=mouseCoord();
rlm@46 1794 node.setAttributeNS(null, 'x', coord[0]-2);
rlm@46 1795 node.setAttributeNS(null, 'y', coord[1]-2);
rlm@46 1796
rlm@46 1797 $('option_path_x').value=parseFloat(node.getAttributeNS(null,'x'))+2;
rlm@46 1798 $('option_path_y').value=parseFloat(node.getAttributeNS(null,'y'))+2;
rlm@46 1799
rlm@46 1800 var cadx= $('option_path_x').value;
rlm@46 1801 var cady= $('option_path_y').value;
rlm@46 1802 var coord=cadx+','+cady;
rlm@46 1803 var cad1=new RegExp(precoord,"g");
rlm@46 1804
rlm@46 1805
rlm@46 1806 var result=mypath.replace(cad1, coord);
rlm@46 1807
rlm@46 1808
rlm@46 1809 $('control_codebase').value=result;
rlm@46 1810
rlm@46 1811 $('someinfo').value=precoord;
rlm@46 1812 setShape();
rlm@46 1813
rlm@46 1814
rlm@46 1815
rlm@46 1816 }
rlm@46 1817 */
rlm@46 1818 var memoNode=null;
rlm@46 1819 var memoPrevControl=new Array();
rlm@46 1820 var memoNextControl=new Array();
rlm@46 1821 SVGRenderer.prototype.nodeMove = function(newx,newy) {
rlm@46 1822 var mypath=$('control_codebase').value;
rlm@46 1823 var x= $('option_path_x').value;
rlm@46 1824 var y= $('option_path_y').value;
rlm@46 1825 var precoord=x+','+y;
rlm@46 1826
rlm@46 1827 $('option_path_x').value=newx;
rlm@46 1828 $('option_path_y').value=newy;
rlm@46 1829
rlm@46 1830 var cadx= newx;
rlm@46 1831 var cady= newy;
rlm@46 1832
rlm@46 1833 var coord=cadx+','+cady;
rlm@46 1834 var cad1=new RegExp(precoord,"g");
rlm@46 1835
rlm@46 1836
rlm@46 1837 var result=mypath.replace(cad1, coord);
rlm@46 1838
rlm@46 1839
rlm@46 1840 $('control_codebase').value=result;
rlm@46 1841
rlm@46 1842 $('someinfo').value=precoord;
rlm@46 1843 setShape();
rlm@46 1844
rlm@46 1845 }
rlm@46 1846
rlm@46 1847 function drawNodeControl(svg,numId){
rlm@46 1848
rlm@46 1849 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 1850 var color1='#0066ff';
rlm@46 1851 // if(parseInt(memoNode.id)==a){
rlm@46 1852
rlm@46 1853 var pointprev=memoPrevControl[numId].split(',');
rlm@46 1854
rlm@46 1855 var controlNode1 = document.createElementNS(svgNamespace, 'rect');
rlm@46 1856 controlNode1.setAttributeNS(null, 'x', pointprev[0]-2);
rlm@46 1857 controlNode1.setAttributeNS(null, 'y', pointprev[1]-2);
rlm@46 1858
rlm@46 1859 controlNode1.setAttributeNS(null, 'width', 4);
rlm@46 1860 controlNode1.setAttributeNS(null, 'height', 4);
rlm@46 1861 controlNode1.setAttributeNS(null, 'fill', color1);
rlm@46 1862 controlNode1.setAttributeNS(null, 'stroke', '#000000');
rlm@46 1863 controlNode1.setAttributeNS(null, 'stroke-width', '0');
rlm@46 1864 controlNode1.setAttributeNS(null, 'id', 'controlNode1');
rlm@46 1865 controlNode1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 1866 svg.appendChild(controlNode1);
rlm@46 1867
rlm@46 1868 var pointnext=memoNextControl[numId].split(',');
rlm@46 1869
rlm@46 1870
rlm@46 1871 var controlNode2 = document.createElementNS(svgNamespace, 'rect');
rlm@46 1872 controlNode2.setAttributeNS(null, 'x', pointnext[0]-2);
rlm@46 1873 controlNode2.setAttributeNS(null, 'y', pointnext[1]-2);
rlm@46 1874
rlm@46 1875 controlNode2.setAttributeNS(null, 'width', 4);
rlm@46 1876 controlNode2.setAttributeNS(null, 'height', 4);
rlm@46 1877 controlNode2.setAttributeNS(null, 'fill', color1);
rlm@46 1878 controlNode2.setAttributeNS(null, 'stroke', '#000000');
rlm@46 1879 controlNode2.setAttributeNS(null, 'stroke-width', '0');
rlm@46 1880 controlNode2.setAttributeNS(null, 'id', 'controlNode1');
rlm@46 1881 controlNode2.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 1882 svg.appendChild(controlNode2);
rlm@46 1883
rlm@46 1884 //}
rlm@46 1885
rlm@46 1886
rlm@46 1887 }
rlm@46 1888
rlm@46 1889 SVGRenderer.prototype.showNodesCurve = function(path,controlNodeNum){
rlm@46 1890 memoNextControl=new Array();
rlm@46 1891 memoPrevControl=new Array();
rlm@46 1892 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 1893 // tracker = document.createElementNS(svgNamespace, 'g');
rlm@46 1894 var svg = this.container.ownerDocument.createElementNS(svgNamespace, 'g');
rlm@46 1895 svg.setAttributeNS(null, 'id', 'editNodesPath');
rlm@46 1896
rlm@46 1897 /* var group = document.getElementById('editNodesPath');
rlm@46 1898 if (group)
rlm@46 1899 {
rlm@46 1900 this.remove(group);
rlm@46 1901 }
rlm@46 1902 */
rlm@46 1903
rlm@46 1904 var points=path.split(' ');
rlm@46 1905 var chain='';
rlm@46 1906 var segment=' ';
rlm@46 1907 prevControl=' ';
rlm@46 1908 nextControl=' ';
rlm@46 1909 nodePoint=' ';
rlm@46 1910 var init=points[0].split('M');
rlm@46 1911 var allcoords=init[1].split(' ');
rlm@46 1912 var point=allcoords[0].split(',');
rlm@46 1913 var rect1 = document.createElementNS(svgNamespace, 'rect');
rlm@46 1914 rect1.setAttributeNS(null, 'x', point[0]-2);
rlm@46 1915 rect1.setAttributeNS(null, 'y', point[1]-2);
rlm@46 1916
rlm@46 1917 rect1.setAttributeNS(null, 'width', 4);
rlm@46 1918 rect1.setAttributeNS(null, 'height', 4);
rlm@46 1919 rect1.setAttributeNS(null, 'fill', '#ff7700');
rlm@46 1920 rect1.setAttributeNS(null, 'stroke', '#000000');
rlm@46 1921 rect1.setAttributeNS(null, 'stroke-width', '0');
rlm@46 1922 rect1.setAttributeNS(null, 'id', '0');
rlm@46 1923 //rect1.addEventListener("mouseover", function(event) {this.setAttributeNS(null, 'stroke-width', 1 ); }, false);
rlm@46 1924 rect1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 1925
rlm@46 1926 //rect1.addEventListener("mouseout", function(event) {this.setAttributeNS(null, 'stroke-width', 0 );}, false);
rlm@46 1927
rlm@46 1928 svg.appendChild(rect1);
rlm@46 1929
rlm@46 1930 if(controlNodeNum==0){ var color='#ffff00';}
rlm@46 1931 if(controlNodeNum==1){var color='#00ffff';}
rlm@46 1932 if(controlNodeNum==2){var color='#00cc00';}
rlm@46 1933 var color1='#ffff00';
rlm@46 1934
rlm@46 1935 var numpoints=points.length-1;
rlm@46 1936 var recalls='';
rlm@46 1937 var re = /^[-]?\d*\.?\d*$/;
rlm@46 1938 for(var a=1;a<=numpoints;a++)
rlm@46 1939 {
rlm@46 1940
rlm@46 1941 var ini=points[a].substring(0,1);
rlm@46 1942 if (!ini.match(re))
rlm@46 1943 {
rlm@46 1944 var end=points[a].substring(1);
rlm@46 1945 color='#0000ff';
rlm@46 1946 if(ini=='L' || ini=='M')
rlm@46 1947 {
rlm@46 1948 color='#ffff00';
rlm@46 1949 }
rlm@46 1950
rlm@46 1951 if(ini=='C')
rlm@46 1952 {
rlm@46 1953 recall=a+2;
rlm@46 1954 //color='#ffff00';
rlm@46 1955 }
rlm@46 1956
rlm@46 1957 }else
rlm@46 1958 {
rlm@46 1959 var end=points[a];
rlm@46 1960 var ini='';
rlm@46 1961 color='#ff00ff';
rlm@46 1962 if(a==recall)
rlm@46 1963 {
rlm@46 1964 color='#ffff00';
rlm@46 1965 }
rlm@46 1966 }
rlm@46 1967
rlm@46 1968
rlm@46 1969 //segment=points[a].split(',');
rlm@46 1970 /*prevControl=segment[0]+' ';
rlm@46 1971 nextControl=segment[1]+' ';
rlm@46 1972 nodePoint=segment[2]+' ';
rlm@46 1973 memoPrevControl[a]=prevControl;
rlm@46 1974 memoNextControl[a]=nextControl;
rlm@46 1975 if(controlNodeNum==0){chain+=prevControl; var point=prevControl.split(',');}
rlm@46 1976 if(controlNodeNum==1){chain+=nextControl; var point=nextControl.split(',');}
rlm@46 1977 if(controlNodeNum==2){chain+=nodePoint; var point=nodePoint.split(',');}
rlm@46 1978 if(controlNodeNum==3){chain+=nodePoint; var point=nodePoint.split(',');}
rlm@46 1979
rlm@46 1980 */
rlm@46 1981 //if (isNaN(valnum))
rlm@46 1982
rlm@46 1983 //if(ini=='C'){color='#ff00ff';}
rlm@46 1984
rlm@46 1985 var point=end.split(',');
rlm@46 1986 if(memoNode!=null){
rlm@46 1987 }
rlm@46 1988 var rect1 = document.createElementNS(svgNamespace, 'rect');
rlm@46 1989 rect1.setAttributeNS(null, 'x', point[0]-2);
rlm@46 1990 rect1.setAttributeNS(null, 'y', point[1]-2);
rlm@46 1991
rlm@46 1992 rect1.setAttributeNS(null, 'width', 4);
rlm@46 1993 rect1.setAttributeNS(null, 'height', 4);
rlm@46 1994 rect1.setAttributeNS(null, 'fill', color);
rlm@46 1995 rect1.setAttributeNS(null, 'stroke', '#000000');
rlm@46 1996 rect1.setAttributeNS(null, 'stroke-width', '0');
rlm@46 1997 rect1.setAttributeNS(null, 'id', ''+a);
rlm@46 1998 rect1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );}drawNodeControl(svg,this.getAttributeNS(null,'id')); memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 1999
rlm@46 2000 //rect1.addEventListener("mouseover", function(event) {this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2001 // rect1.addEventListener("mousedown", function(event) {nodeHit(this);if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; document.forms[0].option_path_x.focus(); }, false);
rlm@46 2002 //rect1.addEventListener("mousedown", function(event) { if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} nodeHit(this); memoNode=this;this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2003 //rect1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} addControlPoints(segment[0],segment[1],svg); memoNode=this; this.setAttributeNS(null, 'fillColor', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2004 //rect1.addEventListener("mouseup", function(event) {nodeUp(this); }, false);
rlm@46 2005 //rect1.addEventListener("mouseover", function(event) {this.setAttributeNS(null, 'fillColor', '#ffcc00' ); }, false);
rlm@46 2006 //rect1.addEventListener("mouseout", function(event) {this.setAttributeNS(null, 'fillColor', '#00cc00' ); }, false);
rlm@46 2007
rlm@46 2008
rlm@46 2009 //rect1.addEventListener("mouseout", function(event) {this.setAttributeNS(null, 'stroke-width', 0 ); }, false);
rlm@46 2010
rlm@46 2011 svg.appendChild(rect1);
rlm@46 2012
rlm@46 2013 }
rlm@46 2014 var info='';
rlm@46 2015
rlm@46 2016 if(controlNodeNum==0){info='prev Control'}
rlm@46 2017 if(controlNodeNum==1){info='next Control'}
rlm@46 2018 if(controlNodeNum==2){info='points node'}
rlm@46 2019 // $('someinfo').value=numpoints+ ' '+info+':'+ chain;
rlm@46 2020 $('someinfo').value='Crtl+Arrow to move';
rlm@46 2021 //return chain;
rlm@46 2022
rlm@46 2023
rlm@46 2024 //this.svgRoot.appendChild(svg);
rlm@46 2025
rlm@46 2026 return svg;
rlm@46 2027
rlm@46 2028 };
rlm@46 2029
rlm@46 2030 SVGRenderer.prototype.showNodesCurve1 = function(path,controlNodeNum){
rlm@46 2031 memoNextControl=new Array();
rlm@46 2032 memoPrevControl=new Array();
rlm@46 2033 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 2034 // tracker = document.createElementNS(svgNamespace, 'g');
rlm@46 2035 var svg = this.container.ownerDocument.createElementNS(svgNamespace, 'g');
rlm@46 2036 svg.setAttributeNS(null, 'id', 'editNodesPath');
rlm@46 2037
rlm@46 2038 /* var group = document.getElementById('editNodesPath');
rlm@46 2039 if (group)
rlm@46 2040 {
rlm@46 2041 this.remove(group);
rlm@46 2042 }
rlm@46 2043 */
rlm@46 2044
rlm@46 2045 var points=path.split('C');
rlm@46 2046 var chain='';
rlm@46 2047 var segment=' ';
rlm@46 2048 prevControl=' ';
rlm@46 2049 nextControl=' ';
rlm@46 2050 nodePoint=' ';
rlm@46 2051 var init=points[0].split('M');
rlm@46 2052 var allcoords=init[1].split(' ');
rlm@46 2053 var point=allcoords[0].split(',');
rlm@46 2054 var rect1 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2055 rect1.setAttributeNS(null, 'x', point[0]-2);
rlm@46 2056 rect1.setAttributeNS(null, 'y', point[1]-2);
rlm@46 2057
rlm@46 2058 rect1.setAttributeNS(null, 'width', 4);
rlm@46 2059 rect1.setAttributeNS(null, 'height', 4);
rlm@46 2060 rect1.setAttributeNS(null, 'fill', '#ff7700');
rlm@46 2061 rect1.setAttributeNS(null, 'stroke', '#000000');
rlm@46 2062 rect1.setAttributeNS(null, 'stroke-width', '0');
rlm@46 2063 rect1.setAttributeNS(null, 'id', '0');
rlm@46 2064 //rect1.addEventListener("mouseover", function(event) {this.setAttributeNS(null, 'stroke-width', 1 ); }, false);
rlm@46 2065 rect1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2066
rlm@46 2067 //rect1.addEventListener("mouseout", function(event) {this.setAttributeNS(null, 'stroke-width', 0 );}, false);
rlm@46 2068
rlm@46 2069 svg.appendChild(rect1);
rlm@46 2070
rlm@46 2071 if(controlNodeNum==0){ var color='#ffff00';}
rlm@46 2072 if(controlNodeNum==1){var color='#00ffff';}
rlm@46 2073 if(controlNodeNum==2){var color='#00cc00';}
rlm@46 2074 var color1='#ffff00';
rlm@46 2075
rlm@46 2076 var numpoints=points.length-1;
rlm@46 2077 for(var a=1;a<=numpoints;a++)
rlm@46 2078 {
rlm@46 2079
rlm@46 2080
rlm@46 2081
rlm@46 2082 segment=points[a].split(' ');
rlm@46 2083 prevControl=segment[0]+' ';
rlm@46 2084 nextControl=segment[1]+' ';
rlm@46 2085 nodePoint=segment[2]+' ';
rlm@46 2086 memoPrevControl[a]=prevControl;
rlm@46 2087 memoNextControl[a]=nextControl;
rlm@46 2088 if(controlNodeNum==0){chain+=prevControl; var point=prevControl.split(',');}
rlm@46 2089 if(controlNodeNum==1){chain+=nextControl; var point=nextControl.split(',');}
rlm@46 2090 if(controlNodeNum==2){chain+=nodePoint; var point=nodePoint.split(',');}
rlm@46 2091 if(controlNodeNum==3){chain+=nodePoint; var point=nodePoint.split(',');}
rlm@46 2092
rlm@46 2093 if(memoNode!=null){
rlm@46 2094 }
rlm@46 2095 var rect1 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2096 rect1.setAttributeNS(null, 'x', point[0]-2);
rlm@46 2097 rect1.setAttributeNS(null, 'y', point[1]-2);
rlm@46 2098
rlm@46 2099 rect1.setAttributeNS(null, 'width', 4);
rlm@46 2100 rect1.setAttributeNS(null, 'height', 4);
rlm@46 2101 rect1.setAttributeNS(null, 'fill', color);
rlm@46 2102 rect1.setAttributeNS(null, 'stroke', '#000000');
rlm@46 2103 rect1.setAttributeNS(null, 'stroke-width', '0');
rlm@46 2104 rect1.setAttributeNS(null, 'id', ''+a);
rlm@46 2105 rect1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );}drawNodeControl(svg,this.getAttributeNS(null,'id')); memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2106
rlm@46 2107 //rect1.addEventListener("mouseover", function(event) {this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2108 // rect1.addEventListener("mousedown", function(event) {nodeHit(this);if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} memoNode=this; this.setAttributeNS(null, 'fill-color', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; document.forms[0].option_path_x.focus(); }, false);
rlm@46 2109 //rect1.addEventListener("mousedown", function(event) { if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} nodeHit(this); memoNode=this;this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2110 //rect1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttributeNS(null, 'stroke-width', 0 );} addControlPoints(segment[0],segment[1],svg); memoNode=this; this.setAttributeNS(null, 'fillColor', '#ffff00' );this.setAttributeNS(null, 'stroke-width', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttributeNS(null,'x'))+2; $('option_path_y').value=parseFloat(this.getAttributeNS(null,'y'))+2; }, false);
rlm@46 2111 //rect1.addEventListener("mouseup", function(event) {nodeUp(this); }, false);
rlm@46 2112 //rect1.addEventListener("mouseover", function(event) {this.setAttributeNS(null, 'fillColor', '#ffcc00' ); }, false);
rlm@46 2113 //rect1.addEventListener("mouseout", function(event) {this.setAttributeNS(null, 'fillColor', '#00cc00' ); }, false);
rlm@46 2114
rlm@46 2115
rlm@46 2116 //rect1.addEventListener("mouseout", function(event) {this.setAttributeNS(null, 'stroke-width', 0 ); }, false);
rlm@46 2117
rlm@46 2118 svg.appendChild(rect1);
rlm@46 2119
rlm@46 2120 }
rlm@46 2121 var info='';
rlm@46 2122
rlm@46 2123 if(controlNodeNum==0){info='prev Control'}
rlm@46 2124 if(controlNodeNum==1){info='next Control'}
rlm@46 2125 if(controlNodeNum==2){info='points node'}
rlm@46 2126 // $('someinfo').value=numpoints+ ' '+info+':'+ chain;
rlm@46 2127 $('someinfo').value='Crtl+Arrow to move';
rlm@46 2128 //return chain;
rlm@46 2129
rlm@46 2130
rlm@46 2131 //this.svgRoot.appendChild(svg);
rlm@46 2132
rlm@46 2133 return svg;
rlm@46 2134
rlm@46 2135 };
rlm@46 2136 SVGRenderer.prototype.showTracker = function(shape,pathsEdit) {
rlm@46 2137
rlm@46 2138 var box = shape.getBBox();
rlm@46 2139 var matrix = shape.getScreenCTM();
rlm@46 2140 var trshape= shape.getAttributeNS(null, 'transform');
rlm@46 2141 var shap=1;
rlm@46 2142 var T = shape.getCTM();
rlm@46 2143 //a,b,c,d,e,f
rlm@46 2144
rlm@46 2145
rlm@46 2146
rlm@46 2147
rlm@46 2148 //var thisTransform = { sx: s[0], r: shape.vRotate, t: shape.vTranslate };
rlm@46 2149 //if (currentTransform != null) alert(currentTransform.t);
rlm@46 2150
rlm@46 2151 if (shape.tagName == 'rect') {
rlm@46 2152
rlm@46 2153 $('option_rect_rot').value= T.b* (Math.PI * 2 / 360);
rlm@46 2154 $('option_rect_trx').value= box.x;
rlm@46 2155 $('option_rect_try').value= box.y;
rlm@46 2156 $('option_rect_sclx').value= box.width;
rlm@46 2157 $('option_rect_scly').value= box.height;
rlm@46 2158
rlm@46 2159 }
rlm@46 2160
rlm@46 2161 if (shape.tagName == 'image'){
rlm@46 2162 $('option_img_trx').value= box.x;
rlm@46 2163 $('option_img_try').value= box.y;
rlm@46 2164 $('option_img_sclx').value= box.width;
rlm@46 2165 $('option_img_scly').value= box.height;
rlm@46 2166 $('option_img_rot').value= T.b* (Math.PI * 2 / 360);
rlm@46 2167 }
rlm@46 2168 if (shape.tagName == 'text'){
rlm@46 2169 /* f$('option_text_trx').value= box.x;
rlm@46 2170 $('option_text_try').value= box.y;
rlm@46 2171 $('option_text_sclx').value= box.width;
rlm@46 2172 $('option_text_scly').value= box.height;
rlm@46 2173 $('option_text_rot').value= T.b* (Math.PI * 2 / 360);
rlm@46 2174 */
rlm@46 2175 }
rlm@46 2176 if (shape.tagName == 'line'){
rlm@46 2177 /*
rlm@46 2178 $('option_line_trx').value= box.x;
rlm@46 2179 $('option_line_try').value= box.y;
rlm@46 2180 */
rlm@46 2181 }
rlm@46 2182 if (shape.tagName == 'ellipse'){
rlm@46 2183 /*$('option_ellipse_trx').value= putx;
rlm@46 2184 $('option_ellipse_try').value= puty;
rlm@46 2185 $('option_ellipse_sclx').value= box.width;
rlm@46 2186 $('option_ellipse_scly').value= box.height;
rlm@46 2187 $('option_ellipse_rot').value= T.b* (Math.PI * 2 / 360);
rlm@46 2188 */
rlm@46 2189 }
rlm@46 2190
rlm@46 2191
rlm@46 2192
rlm@46 2193 /* if (shape.getAttributeNS(null, 'transform') ) {
rlm@46 2194
rlm@46 2195
rlm@46 2196 shap=2; }else{
rlm@46 2197 }*/
rlm@46 2198 var tracker = document.getElementById('tracker');
rlm@46 2199 if (tracker) {
rlm@46 2200 this.remove(tracker);
rlm@46 2201 }
rlm@46 2202
rlm@46 2203 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 2204
rlm@46 2205 tracker = document.createElementNS(svgNamespace, 'g');
rlm@46 2206 tracker.setAttributeNS(null, 'id', 'tracker');
rlm@46 2207
rlm@46 2208 var controlPoints=null;
rlm@46 2209 if (shape.tagName == 'path') { shap=2;
rlm@46 2210
rlm@46 2211 /* $('option_path_trx').value= box.x;
rlm@46 2212 $('option_path_try').value= box.y;
rlm@46 2213 $('option_path_sclx').value= T.a;
rlm@46 2214 $('option_path_scly').value= T.d;
rlm@46 2215 $('option_path_rot').value= T.b* (Math.PI * 2 / 360);
rlm@46 2216 */
rlm@46 2217 var path=shape.getAttributeNS(null, 'd');
rlm@46 2218 $('control_codebase').value=path;
rlm@46 2219
rlm@46 2220 //controlPoints=this.showNodesCurve(path,0);
rlm@46 2221 //controlPoints=this.showNodesCurve(path,1);
rlm@46 2222 controlPoints=this.showNodesCurve(path,2);
rlm@46 2223
rlm@46 2224
rlm@46 2225 /* controlPoints=this.showNodesCurve(path,1);
rlm@46 2226
rlm@46 2227 tracker.appendChild(controlPoints);
rlm@46 2228
rlm@46 2229 controlPoints=this.showNodesCurve(path,0);
rlm@46 2230
rlm@46 2231 tracker.appendChild(controlPoints);
rlm@46 2232 */
rlm@46 2233 }
rlm@46 2234
rlm@46 2235 var svg = this.container.ownerDocument.createElementNS(svgNamespace, 'g');
rlm@46 2236 svg.setAttributeNS(null, 'id', 'transformSquares');
rlm@46 2237
rlm@46 2238
rlm@46 2239 //var rect = document.createElementNS(svgNamespace, 'rect');
rlm@46 2240 var border = document.createElementNS(svgNamespace, 'path');
rlm@46 2241
rlm@46 2242 var trshape='translate (0,0) rotate(0) translate(0,0) ';
rlm@46 2243 var trshape_split=trshape.split(') ');
rlm@46 2244
rlm@46 2245 // get_between (trshape, s1, s2) ;
rlm@46 2246 if(shape.getAttributeNS(null, 'transform')){
rlm@46 2247 var trshape=shape.getAttributeNS(null, 'transform') ;
rlm@46 2248 //var spl=trshape.replace(', ',' ');
rlm@46 2249 //var spl1=spl.replace(')',' ');
rlm@46 2250 var trshape_split=trshape.split(') ');
rlm@46 2251
rlm@46 2252
rlm@46 2253 }
rlm@46 2254
rlm@46 2255 var corners = [];
rlm@46 2256 var point = createPoint(box.x, box.y, box.width, box.height);
rlm@46 2257 //point = {x:box.x, y:box.y, width: box.width, height:box.height};
rlm@46 2258 //point = createPoint(box.x, box.y, box.width, box.height);
rlm@46 2259 //1
rlm@46 2260 corners.push( createPoint(box.x + box.width, box.y, box.width, box.height) );
rlm@46 2261 point.x = box.x + box.width;
rlm@46 2262 point.y = box.y;
rlm@46 2263 //2
rlm@46 2264 corners.push( createPoint(box.x + box.width, box.y + box.height, box.width, box.height) );
rlm@46 2265 point.x = box.x + box.width;
rlm@46 2266 point.y = box.y + box.height;
rlm@46 2267 //3
rlm@46 2268 //corners.push( point.matrixTransform(matrix) );
rlm@46 2269 corners.push( createPoint(box.x , box.y + box.height, box.width, box.height) );
rlm@46 2270 point.x = box.x;
rlm@46 2271 point.y = box.y + box.height;
rlm@46 2272 //4
rlm@46 2273 corners.push( createPoint(box.x + box.width, box.y, box.width, box.height) );
rlm@46 2274
rlm@46 2275 var max = createPoint(corners[0].x, corners[0].y);
rlm@46 2276 var min = createPoint(corners[0].x, corners[0].y);
rlm@46 2277
rlm@46 2278 // identify the new corner coordinates of the
rlm@46 2279 // fully transformed bounding box
rlm@46 2280 for (var i = 1; i < corners.length; i++) {
rlm@46 2281 var x = corners[i].x;
rlm@46 2282 var y = corners[i].y;
rlm@46 2283 if (x < min.x) {
rlm@46 2284 min.x = x;
rlm@46 2285 }
rlm@46 2286 else if (x > max.x) {
rlm@46 2287 max.x = x;
rlm@46 2288 }
rlm@46 2289 if (y < min.y) {
rlm@46 2290 min.y = y;
rlm@46 2291 }
rlm@46 2292 else if (y > max.y) {
rlm@46 2293 max.y = y;
rlm@46 2294 }
rlm@46 2295 }
rlm@46 2296
rlm@46 2297 // return the bounding box as an SVGRect object
rlm@46 2298 //rect = document.createElementNS(svgNamespace, 'rect');
rlm@46 2299 //rect.setAttributeNS(null, 'x', min.x-10);
rlm@46 2300 //rect.setAttributeNS(null, 'y', min.y-10);
rlm@46 2301
rlm@46 2302 //rect.setAttributeNS(null, 'width', max.x - min.x+20);
rlm@46 2303 //rect.setAttributeNS(null, 'height', max.y - min.y+20);
rlm@46 2304
rlm@46 2305 border.setAttributeNS(null, 'd', "M"+(min.x-10)+","+ (min.y-10)+' h'+(box.width+20)+','+(0)+' v'+(0)+','+(box.height+20)+' h'+(-box.width-20)+','+(0)+' z M'+(box.x+box.width+10)+","+ (box.y+(box.height/2)+' h'+(25)+',0 '));
rlm@46 2306
rlm@46 2307
rlm@46 2308 border.setAttributeNS(null, 'fill', 'none');
rlm@46 2309 border.setAttributeNS(null, 'stroke', '#cccccc');
rlm@46 2310 border.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2311
rlm@46 2312 // createRect(min.x, min.y, max.x - min.x, max.y - min.y);
rlm@46 2313
rlm@46 2314 var circle1 = document.createElementNS(svgNamespace, 'ellipse');
rlm@46 2315 circle1.setAttributeNS(null, 'cx', (box.x + box.width+40) + 'px');
rlm@46 2316 circle1.setAttributeNS(null, 'cy', (box.y + box.height / 2) + 'px');
rlm@46 2317 circle1.setAttributeNS(null, 'rx', (5) + 'px');
rlm@46 2318 circle1.setAttributeNS(null, 'ry', (5) + 'px');
rlm@46 2319 circle1.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2320 circle1.setAttributeNS(null, 'stroke', 'green');
rlm@46 2321 circle1.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2322
rlm@46 2323 var circleCenter = document.createElementNS(svgNamespace, 'ellipse');
rlm@46 2324 circleCenter.setAttributeNS(null, 'cx', (box.x + (box.width/2)) + 'px');
rlm@46 2325 circleCenter.setAttributeNS(null, 'cy', (box.y + (box.height /2)) + 'px');
rlm@46 2326 circleCenter.setAttributeNS(null, 'rx', (10) + 'px');
rlm@46 2327 circleCenter.setAttributeNS(null, 'ry', (10) + 'px');
rlm@46 2328 circleCenter.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2329 circleCenter.setAttributeNS(null, 'stroke', 'green');
rlm@46 2330 circleCenter.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2331
rlm@46 2332 var rect1 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2333 rect1.setAttributeNS(null, 'width', 10);
rlm@46 2334 rect1.setAttributeNS(null, 'height', 10);
rlm@46 2335 rect1.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2336 rect1.setAttributeNS(null, 'stroke', 'green');
rlm@46 2337 rect1.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2338
rlm@46 2339 var rect2 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2340 rect2.setAttributeNS(null, 'width', 10);
rlm@46 2341 rect2.setAttributeNS(null, 'height', 10);
rlm@46 2342 rect2.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2343 rect2.setAttributeNS(null, 'stroke', 'green');
rlm@46 2344 rect2.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2345
rlm@46 2346 var rect3 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2347 rect3.setAttributeNS(null, 'width', 10);
rlm@46 2348 rect3.setAttributeNS(null, 'height', 10);
rlm@46 2349 rect3.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2350 rect3.setAttributeNS(null, 'stroke', 'green');
rlm@46 2351 rect3.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2352
rlm@46 2353 var rect4 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2354 rect4.setAttributeNS(null, 'width', 10);
rlm@46 2355 rect4.setAttributeNS(null, 'height', 10);
rlm@46 2356 rect4.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2357 rect4.setAttributeNS(null, 'stroke', 'green');
rlm@46 2358 rect4.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2359
rlm@46 2360 var rectmid12 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2361 rectmid12.setAttributeNS(null, 'width', 10);
rlm@46 2362 rectmid12.setAttributeNS(null, 'height', 10);
rlm@46 2363 rectmid12.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2364 rectmid12.setAttributeNS(null, 'stroke', 'green');
rlm@46 2365 rectmid12.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2366
rlm@46 2367 var rectmid23 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2368 rectmid23.setAttributeNS(null, 'width', 10);
rlm@46 2369 rectmid23.setAttributeNS(null, 'height', 10);
rlm@46 2370 rectmid23.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2371 rectmid23.setAttributeNS(null, 'stroke', 'green');
rlm@46 2372 rectmid23.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2373
rlm@46 2374 var rectmid34 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2375 rectmid34.setAttributeNS(null, 'width', 10);
rlm@46 2376 rectmid34.setAttributeNS(null, 'height', 10);
rlm@46 2377 rectmid34.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2378 rectmid34.setAttributeNS(null, 'stroke', 'green');
rlm@46 2379 rectmid34.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2380
rlm@46 2381 var rectmid41 = document.createElementNS(svgNamespace, 'rect');
rlm@46 2382 rectmid41.setAttributeNS(null, 'width', 10);
rlm@46 2383 rectmid41.setAttributeNS(null, 'height', 10);
rlm@46 2384 rectmid41.setAttributeNS(null, 'fill', '#ffffff');
rlm@46 2385 rectmid41.setAttributeNS(null, 'stroke', 'green');
rlm@46 2386 rectmid41.setAttributeNS(null, 'stroke-width', '1');
rlm@46 2387 // rect.setAttributeNS(null, 'x', box.x - 10);
rlm@46 2388 // rect.setAttributeNS(null, 'y', box.y - 10);
rlm@46 2389
rlm@46 2390 rect1.setAttributeNS(null, 'x', box.x - 10-5);
rlm@46 2391 rect1.setAttributeNS(null, 'y', box.y - 10-5);
rlm@46 2392
rlm@46 2393
rlm@46 2394 rect2.setAttributeNS(null, 'x', box.x + box.width +5 );
rlm@46 2395 rect2.setAttributeNS(null, 'y', box.y -10 -5);
rlm@46 2396
rlm@46 2397 rect3.setAttributeNS(null, 'x', box.x + box.width+5 );
rlm@46 2398 rect3.setAttributeNS(null, 'y', box.y + box.height+5);
rlm@46 2399
rlm@46 2400 rect4.setAttributeNS(null, 'x', box.x -10-5 );
rlm@46 2401 rect4.setAttributeNS(null, 'y', box.y + box.height+5);
rlm@46 2402
rlm@46 2403
rlm@46 2404
rlm@46 2405 rectmid12.setAttributeNS(null, 'x', box.x + (box.width/2) -5);
rlm@46 2406 rectmid12.setAttributeNS(null, 'y', box.y - 10-5);
rlm@46 2407
rlm@46 2408 rectmid23.setAttributeNS(null, 'x', box.x + box.width +5 );
rlm@46 2409 rectmid23.setAttributeNS(null, 'y', box.y + (box.height/2)-5);
rlm@46 2410
rlm@46 2411 rectmid34.setAttributeNS(null, 'x', box.x + (box.width/2)-5 );
rlm@46 2412 rectmid34.setAttributeNS(null, 'y', box.y + box.height+5);
rlm@46 2413
rlm@46 2414 rectmid41.setAttributeNS(null, 'x', box.x -10-5 );
rlm@46 2415 rectmid41.setAttributeNS(null, 'y', box.y + (box.height/2)-5);
rlm@46 2416
rlm@46 2417 svg.appendChild(border);
rlm@46 2418 //tracker.appendChild(getScreenBBox (shape));
rlm@46 2419 //currentTranslate
rlm@46 2420 //currentScale
rlm@46 2421 // shape.setAttributeNS(null,'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 2422
rlm@46 2423 //var trshape=shape.getAttributeNS(null, 'transform') ;
rlm@46 2424 //----tracker.setAttributeNS(null,'transform', "translate("+(box.x+(box.width/2))+","+(box.y+(box.height/2))+") "+trshape_split[1]+") translate("+(-box.x-(box.width/2))+","+(-box.y-(box.height/2))+") ");
rlm@46 2425
rlm@46 2426
rlm@46 2427
rlm@46 2428 //}
rlm@46 2429 // tracker.appendChild(getScreenBBox (shape));
rlm@46 2430 var colorin="#ff0000";
rlm@46 2431 var colorout="#ffffff"
rlm@46 2432
rlm@46 2433 circle1.addEventListener("mouseover", function(event) {circle1.setAttributeNS(null, 'cursor', 's-resize'); circle1.setAttributeNS(null, 'fill', colorin ); typeTransform='Rotate'; scaleType='nw'; }, false);
rlm@46 2434 circle1.addEventListener("mouseout", function(event) {circle1.setAttributeNS(null, 'cursor', 'default'); circle1.setAttributeNS(null, 'fill', colorout ); typeTransform='Rotate'; }, false); //typeTransform='rotate'
rlm@46 2435 circleCenter.addEventListener("mouseover", function(event) {circleCenter.setAttributeNS(null, 'cursor', 'move'); circleCenter.setAttributeNS(null, 'fill', colorin ); typeTransform='spìnCenter'; scaleType='nw'; }, false);
rlm@46 2436 circleCenter.addEventListener("mouseout", function(event) {circleCenter.setAttributeNS(null, 'cursor', 'default'); circleCenter.setAttributeNS(null, 'fill', colorout ); typeTransform=''; }, false); //typeTransform='rotate'
rlm@46 2437
rlm@46 2438
rlm@46 2439 //rect1.addEventListener("mouseover", cursore1in, false);
rlm@46 2440 rect1.addEventListener("mouseover", function(event) {rect1.setAttributeNS(null, 'cursor', 'nw-resize'); rect1.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='nw';}, false);
rlm@46 2441 rect1.addEventListener("mouseout", function(event) {rect1.setAttributeNS(null, 'cursor', 'default'); rect1.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false); //typeTransform='rotate'
rlm@46 2442 //rect1.addEventListener("click", function(event) { rect1.setAttributeNS(null, 'fill', '#00ff00' ); typeTransform='Scale'; }, false);
rlm@46 2443
rlm@46 2444 rect2.addEventListener("mouseover", function(event) {rect2.setAttributeNS(null, 'cursor', 'ne-resize'); rect2.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='ne';}, false);
rlm@46 2445 rect2.addEventListener("mouseout", function(event) {rect2.setAttributeNS(null, 'cursor', 'default'); rect2.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false);
rlm@46 2446
rlm@46 2447 rect3.addEventListener("mouseover", function(event) {rect3.setAttributeNS(null, 'cursor', 'se-resize'); rect3.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='se';}, false);
rlm@46 2448 rect3.addEventListener("mouseout", function(event) {rect3.setAttributeNS(null, 'cursor', 'default'); rect3.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false);
rlm@46 2449
rlm@46 2450 rect4.addEventListener("mouseover", function(event) {rect4.setAttributeNS(null, 'cursor', 'sw-resize'); rect4.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='sw';}, false);
rlm@46 2451 rect4.addEventListener("mouseout", function(event) {rect4.setAttributeNS(null, 'cursor', 'default'); rect4.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false);
rlm@46 2452
rlm@46 2453 rectmid12.addEventListener("mouseover", function(event) {rectmid12.setAttributeNS(null, 'cursor', 'n-resize'); rectmid12.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='n';}, false);
rlm@46 2454 rectmid12.addEventListener("mouseout", function(event) {rectmid12.setAttributeNS(null, 'cursor', 'default'); rectmid12.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false);
rlm@46 2455
rlm@46 2456 rectmid23.addEventListener("mouseover", function(event) {rectmid23.setAttributeNS(null, 'cursor', 'e-resize'); rectmid23.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='e';}, false);
rlm@46 2457 rectmid23.addEventListener("mouseout", function(event) {rectmid23.setAttributeNS(null, 'cursor', 'default'); rectmid23.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false);
rlm@46 2458
rlm@46 2459 rectmid34.addEventListener("mouseover", function(event) {rectmid34.setAttributeNS(null, 'cursor', 's-resize'); rectmid34.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='s';}, false);
rlm@46 2460 rectmid34.addEventListener("mouseout", function(event) {rectmid34.setAttributeNS(null, 'cursor', 'default'); rectmid34.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false);
rlm@46 2461
rlm@46 2462 rectmid41.addEventListener("mouseover", function(event) {rectmid41.setAttributeNS(null, 'cursor', 'w-resize'); rectmid41.setAttributeNS(null, 'fill', colorin ); typeTransform='Scale'; scaleType='w'; }, false);
rlm@46 2463 rectmid41.addEventListener("mouseout", function(event) {rectmid41.setAttributeNS(null, 'cursor', 'default'); rectmid41.setAttributeNS(null, 'fill', colorout ); typeTransform='Scale'; }, false);
rlm@46 2464
rlm@46 2465 //////////
rlm@46 2466 svg.setAttributeNS(null, 'transform',trshape);
rlm@46 2467
rlm@46 2468 svg.appendChild(circle1);
rlm@46 2469 //tracker.appendChild(circleCenter);
rlm@46 2470 if (shape.tagName == 'text'){
rlm@46 2471 svg.appendChild(rect1);
rlm@46 2472 svg.appendChild(rect2);
rlm@46 2473 svg.appendChild(rect3);
rlm@46 2474 svg.appendChild(rect4);
rlm@46 2475 }else{
rlm@46 2476 svg.appendChild(rect1);
rlm@46 2477 svg.appendChild(rect2);
rlm@46 2478 svg.appendChild(rect3);
rlm@46 2479 svg.appendChild(rect4);
rlm@46 2480 svg.appendChild(rectmid12);
rlm@46 2481 svg.appendChild(rectmid23);
rlm@46 2482 svg.appendChild(rectmid34);
rlm@46 2483 svg.appendChild(rectmid41);
rlm@46 2484
rlm@46 2485 }
rlm@46 2486 if(pathsEdit)
rlm@46 2487 {
rlm@46 2488 controlPoints.setAttributeNS(null, 'transform',trshape);
rlm@46 2489 tracker.appendChild(controlPoints);
rlm@46 2490 }else{
rlm@46 2491 tracker.appendChild(svg);
rlm@46 2492 }
rlm@46 2493 this.svgRoot.appendChild(tracker);
rlm@46 2494
rlm@46 2495 }
rlm@46 2496
rlm@46 2497
rlm@46 2498 SVGRenderer.prototype.getMarkup = function() {
rlm@46 2499
rlm@46 2500 return this.container.innerHTML;
rlm@46 2501 }
rlm@46 2502
rlm@46 2503
rlm@46 2504 /////////////////////////////////
rlm@46 2505 var rotatexxx=0;
rlm@46 2506
rlm@46 2507 var scaleType='';
rlm@46 2508 var xrot=0;
rlm@46 2509 var yrot=0;
rlm@46 2510
rlm@46 2511 var point = {x:0, y:0, width: 0, height:0};
rlm@46 2512
rlm@46 2513 function createPoint (x, y, width, height) {
rlm@46 2514 //var point = {x:34, y:22, width: 22, height:23};
rlm@46 2515 //point.x = x;
rlm@46 2516 //point.y = y;
rlm@46 2517 point = {x:x, y:y, width: width, height:height};
rlm@46 2518 return point;
rlm@46 2519 }
rlm@46 2520
rlm@46 2521 ///////////////////////////////
rlm@46 2522
rlm@46 2523 SVGRenderer.prototype.restruct= function(shape)
rlm@46 2524 {
rlm@46 2525 //alert('end');
rlm@46 2526 //forceRedraw();
rlm@46 2527 //clearWorkspace();
rlm@46 2528 //document.getElementById('richdraw').style.cursor='default';
rlm@46 2529 };
rlm@46 2530
rlm@46 2531
rlm@46 2532
rlm@46 2533 SVGRenderer.prototype.transform = function() {
rlm@46 2534 //document.forms[0].code.value='Im tranforming';
rlm@46 2535 };
rlm@46 2536
rlm@46 2537 SVGRenderer.prototype.scaleShape = function(shape,previus, toX, toY) {
rlm@46 2538
rlm@46 2539 var box = shape.getBBox();
rlm@46 2540 var prevbox=previus.getBBox();
rlm@46 2541 var centerx= box.x+(box.width/2);
rlm@46 2542 var centery= box.y+(box.height/2);
rlm@46 2543 var coord=this.editor.inputxy;
rlm@46 2544 toX=parseFloat(coord[0]);
rlm@46 2545 toY=parseFloat(coord[1]);
rlm@46 2546 var d2p_center=dist2p(centerx,centery,toX,toY);
rlm@46 2547
rlm@46 2548 var d2p=dist2p(box.x,box.y,toX,toY);
rlm@46 2549
rlm@46 2550 var shareScale=box.width/d2p;
rlm@46 2551
rlm@46 2552 var trans_ShareScale='';
rlm@46 2553 var tx, ty, tw, yh;
rlm@46 2554
rlm@46 2555 if(scaleType.length==1){
rlm@46 2556 if(scaleType== 'w')
rlm@46 2557 {
rlm@46 2558 trans_ShareScale=shareScale+",1";
rlm@46 2559 tx=toX;
rlm@46 2560 ty=prevbox.y;
rlm@46 2561 var dist=prevbox.x-toX;
rlm@46 2562 var w=dist+prevbox.width;
rlm@46 2563 if(w<1){w=1;}
rlm@46 2564 tw=w;
rlm@46 2565 th=prevbox.height;
rlm@46 2566 //document.forms[0].code.value=box.x+' '+toX+' '+dist+'';
rlm@46 2567 }
rlm@46 2568 if(scaleType== 'e')
rlm@46 2569 {
rlm@46 2570 trans_ShareScale=shareScale+",1";
rlm@46 2571 tx=prevbox.x;
rlm@46 2572 ty=prevbox.y;
rlm@46 2573 var dist=toX-(prevbox.x+prevbox.width); //dist2p(toX,b,c,d);
rlm@46 2574 var w=dist+prevbox.width;
rlm@46 2575 if(w<1){w=1;}
rlm@46 2576 tw=w;
rlm@46 2577 th=prevbox.height;
rlm@46 2578
rlm@46 2579 }
rlm@46 2580 if(scaleType== 'n')
rlm@46 2581 {
rlm@46 2582 trans_ShareScale="1,"+shareScale;
rlm@46 2583
rlm@46 2584 tx=prevbox.x;
rlm@46 2585 ty=toY;
rlm@46 2586 var dist=prevbox.y-toY;
rlm@46 2587 var h=dist+prevbox.height;
rlm@46 2588 if(h<1){h=1;}
rlm@46 2589 tw=prevbox.width;
rlm@46 2590 th=h;
rlm@46 2591
rlm@46 2592 }
rlm@46 2593 if( scaleType== 's')
rlm@46 2594 {
rlm@46 2595 trans_ShareScale="1,"+shareScale;
rlm@46 2596
rlm@46 2597 tx=prevbox.x;
rlm@46 2598 ty=prevbox.y;
rlm@46 2599 var dist=toY-(prevbox.y+prevbox.height); //dist2p(toX,b,c,d);
rlm@46 2600 var h=dist+prevbox.height;
rlm@46 2601 if(h<1){h=1;}
rlm@46 2602 tw=prevbox.width;
rlm@46 2603 th=h;
rlm@46 2604
rlm@46 2605 }
rlm@46 2606 }
rlm@46 2607 if(scaleType.length==2){
rlm@46 2608 if(scaleType== 'nw'){
rlm@46 2609 trans_ShareScale=shareScale+","+shareScale;
rlm@46 2610
rlm@46 2611 //var angle_diagonal=getAngle(prevbox.width,prevbox.height);
rlm@46 2612 var angle_diagonal=ang2v(prevbox.x,prevbox.y,prevbox.x+prevbox.width,prevbox.y+prevbox.height)
rlm@46 2613
rlm@46 2614 var ax= prevbox.x;
rlm@46 2615 var ay= prevbox.y;
rlm@46 2616 var bx= prevbox.x+prevbox.width;
rlm@46 2617 var by= prevbox.y+prevbox.height;
rlm@46 2618
rlm@46 2619 var cx= toX;
rlm@46 2620 var cy= toY;
rlm@46 2621 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2));
rlm@46 2622 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2));
rlm@46 2623
rlm@46 2624 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2625 this.editor.log(angle_diagonal* 180 / Math.PI);
rlm@46 2626
rlm@46 2627 var tx= section_a[1];
rlm@46 2628 var ty= section_a[2];
rlm@46 2629
rlm@46 2630 var ax= section_a[1];
rlm@46 2631 var ay= section_a[2];
rlm@46 2632 var bx= 0;
rlm@46 2633 var by= section_a[2] ;
rlm@46 2634
rlm@46 2635 var cx=prevbox.x+prevbox.width;
rlm@46 2636 var cy= prevbox.y;
rlm@46 2637
rlm@46 2638 var dx= prevbox.x+prevbox.width;
rlm@46 2639 var dy= 0;
rlm@46 2640
rlm@46 2641
rlm@46 2642 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2643
rlm@46 2644 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]);
rlm@46 2645
rlm@46 2646
rlm@46 2647
rlm@46 2648 var ax= section_a[1];
rlm@46 2649 var ay= section_a[2];
rlm@46 2650 var bx= section_a[1]
rlm@46 2651 var by= 0;
rlm@46 2652
rlm@46 2653 var cx= prevbox.x;
rlm@46 2654 var cy= prevbox.y+prevbox.height;
rlm@46 2655
rlm@46 2656 var dx= 0;
rlm@46 2657 var dy= prevbox.y+prevbox.height;
rlm@46 2658
rlm@46 2659
rlm@46 2660 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2661 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]);
rlm@46 2662
rlm@46 2663
rlm@46 2664
rlm@46 2665
rlm@46 2666 if(distx<1){distx=1;}
rlm@46 2667
rlm@46 2668
rlm@46 2669 if(disty<1){disty=1;}
rlm@46 2670 //document.forms[0].code.value=distx+' '+disty;
rlm@46 2671 tw=distx;
rlm@46 2672 th=disty;
rlm@46 2673
rlm@46 2674
rlm@46 2675 }
rlm@46 2676
rlm@46 2677 //////////////////// SE
rlm@46 2678
rlm@46 2679 if( scaleType== 'se'){
rlm@46 2680 trans_ShareScale=shareScale+","+shareScale;
rlm@46 2681
rlm@46 2682
rlm@46 2683 //var angle_diagonal=getAngle(prevbox.width,prevbox.height);
rlm@46 2684 var angle_diagonal=ang2v(prevbox.x,prevbox.y,prevbox.x+prevbox.width,prevbox.y+prevbox.height)
rlm@46 2685
rlm@46 2686
rlm@46 2687
rlm@46 2688 var ax= prevbox.x;
rlm@46 2689 var ay= prevbox.y;
rlm@46 2690 var bx= prevbox.x+prevbox.width;
rlm@46 2691 var by= prevbox.y+prevbox.height;
rlm@46 2692
rlm@46 2693 var cx= toX;
rlm@46 2694 var cy= toY;
rlm@46 2695 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2));
rlm@46 2696 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2));
rlm@46 2697
rlm@46 2698 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2699
rlm@46 2700
rlm@46 2701 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 2702 var tracker = document.getElementById('tracker');
rlm@46 2703
rlm@46 2704 //////////
rlm@46 2705 var tx= prevbox.x;
rlm@46 2706 var ty= prevbox.y;
rlm@46 2707
rlm@46 2708 var ax= section_a[1];
rlm@46 2709 var ay= section_a[2];
rlm@46 2710 var bx= 0;
rlm@46 2711 var by= section_a[2] ;
rlm@46 2712
rlm@46 2713 var cx=prevbox.x;
rlm@46 2714 var cy= prevbox.y;
rlm@46 2715
rlm@46 2716 var dx= prevbox.x;
rlm@46 2717 var dy= 0;
rlm@46 2718
rlm@46 2719
rlm@46 2720 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2721
rlm@46 2722 /////////////////
rlm@46 2723
rlm@46 2724
rlm@46 2725 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]);
rlm@46 2726
rlm@46 2727
rlm@46 2728 var ax= section_a[1];
rlm@46 2729 var ay= section_a[2];
rlm@46 2730 var bx= section_a[1]
rlm@46 2731 var by= 0;
rlm@46 2732
rlm@46 2733 var cx= prevbox.x;
rlm@46 2734 var cy= prevbox.y;
rlm@46 2735
rlm@46 2736 var dx=0;
rlm@46 2737 var dy= prevbox.y;
rlm@46 2738
rlm@46 2739
rlm@46 2740 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2741
rlm@46 2742 ///////////////
rlm@46 2743
rlm@46 2744 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]);
rlm@46 2745
rlm@46 2746
rlm@46 2747
rlm@46 2748 if(distx<1){distx=1;}
rlm@46 2749
rlm@46 2750
rlm@46 2751 if(disty<1){disty=1;}
rlm@46 2752
rlm@46 2753 tw=distx;
rlm@46 2754 th=disty;
rlm@46 2755
rlm@46 2756
rlm@46 2757 }
rlm@46 2758
rlm@46 2759 if(scaleType== 'ne'){
rlm@46 2760
rlm@46 2761 trans_ShareScale=shareScale+","+shareScale;
rlm@46 2762
rlm@46 2763 var angle_diagonal=ang2v(prevbox.x,prevbox.y+prevbox.height,prevbox.x+prevbox.width,prevbox.y)
rlm@46 2764 //var angle_diagonal=getAngle(prevbox.width,prevbox.height);
rlm@46 2765
rlm@46 2766
rlm@46 2767
rlm@46 2768
rlm@46 2769 var ax= prevbox.x;
rlm@46 2770 var ay= prevbox.y+prevbox.height;
rlm@46 2771 var bx= prevbox.x+prevbox.width;
rlm@46 2772 var by= prevbox.y;
rlm@46 2773
rlm@46 2774 var cx= toX;
rlm@46 2775 var cy= toY;
rlm@46 2776 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2));
rlm@46 2777 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2));
rlm@46 2778
rlm@46 2779
rlm@46 2780 this.editor.log(angle_diagonal);
rlm@46 2781
rlm@46 2782
rlm@46 2783 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2784
rlm@46 2785
rlm@46 2786 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 2787 var tracker = document.getElementById('tracker');
rlm@46 2788
rlm@46 2789 //////////
rlm@46 2790 var tx= prevbox.x;
rlm@46 2791 var ty= section_a[2];
rlm@46 2792
rlm@46 2793 var ax= section_a[1];
rlm@46 2794 var ay= section_a[2];
rlm@46 2795 var bx= 0;
rlm@46 2796 var by= section_a[2] ;
rlm@46 2797
rlm@46 2798 var cx=prevbox.x;
rlm@46 2799 var cy= prevbox.y;
rlm@46 2800
rlm@46 2801 var dx= prevbox.x;
rlm@46 2802 var dy= 0;
rlm@46 2803
rlm@46 2804
rlm@46 2805 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2806
rlm@46 2807 /////////////////
rlm@46 2808
rlm@46 2809
rlm@46 2810 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]);
rlm@46 2811
rlm@46 2812
rlm@46 2813 var ax= section_a[1];
rlm@46 2814 var ay= section_a[2];
rlm@46 2815 var bx= section_a[1];
rlm@46 2816 var by= 0;
rlm@46 2817
rlm@46 2818 var cx= prevbox.x;
rlm@46 2819 var cy= prevbox.y+prevbox.height;
rlm@46 2820
rlm@46 2821 var dx=0;
rlm@46 2822 var dy= prevbox.y+prevbox.height;
rlm@46 2823
rlm@46 2824
rlm@46 2825 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2826
rlm@46 2827 ///////////////
rlm@46 2828
rlm@46 2829 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]);
rlm@46 2830
rlm@46 2831
rlm@46 2832
rlm@46 2833 if(distx<1){distx=1;}
rlm@46 2834
rlm@46 2835
rlm@46 2836 if(disty<1){disty=1;}
rlm@46 2837 //document.forms[0].code.value=distx+' '+disty;
rlm@46 2838 tw=distx;
rlm@46 2839 th=disty;
rlm@46 2840
rlm@46 2841
rlm@46 2842
rlm@46 2843
rlm@46 2844
rlm@46 2845 }
rlm@46 2846 if(scaleType== 'sw'){
rlm@46 2847 trans_ShareScale=shareScale+","+shareScale;
rlm@46 2848
rlm@46 2849
rlm@46 2850
rlm@46 2851
rlm@46 2852 var angle_diagonal=ang2v(prevbox.x,prevbox.y+prevbox.height,prevbox.x+prevbox.width,prevbox.y)
rlm@46 2853 //var angle_diagonal=getAngle(prevbox.width,prevbox.height);
rlm@46 2854
rlm@46 2855
rlm@46 2856
rlm@46 2857
rlm@46 2858 var ax= prevbox.x;
rlm@46 2859 var ay= prevbox.y+prevbox.height;
rlm@46 2860 var bx= prevbox.x+prevbox.width;
rlm@46 2861 var by= prevbox.y;
rlm@46 2862
rlm@46 2863 var cx= toX;
rlm@46 2864 var cy= toY;
rlm@46 2865 var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2));
rlm@46 2866 var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2));
rlm@46 2867
rlm@46 2868
rlm@46 2869 this.editor.log(angle_diagonal);
rlm@46 2870
rlm@46 2871
rlm@46 2872 var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2873
rlm@46 2874
rlm@46 2875 var svgNamespace = 'http://www.w3.org/2000/svg';
rlm@46 2876 var tracker = document.getElementById('tracker');
rlm@46 2877
rlm@46 2878 //////////
rlm@46 2879 var tx= section_a[1];
rlm@46 2880 var ty= prevbox.y;
rlm@46 2881
rlm@46 2882 var ax= section_a[1];
rlm@46 2883 var ay= section_a[2];
rlm@46 2884 var bx= 0;
rlm@46 2885 var by= section_a[2] ;
rlm@46 2886
rlm@46 2887 var cx=prevbox.x+prevbox.width;
rlm@46 2888 var cy= prevbox.y+prevbox.height;
rlm@46 2889
rlm@46 2890 var dx= prevbox.x+prevbox.width;
rlm@46 2891 var dy= 0;
rlm@46 2892
rlm@46 2893
rlm@46 2894 var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2895 var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]);
rlm@46 2896
rlm@46 2897 /////////////////
rlm@46 2898 var ax= section_a[1];
rlm@46 2899 var ay= section_a[2];
rlm@46 2900 var bx= section_a[1];
rlm@46 2901 var by= 0;
rlm@46 2902
rlm@46 2903 var cx= prevbox.x;
rlm@46 2904 var cy= prevbox.y;
rlm@46 2905
rlm@46 2906 var dx=0;
rlm@46 2907 var dy= prevbox.y;
rlm@46 2908
rlm@46 2909
rlm@46 2910 var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy);
rlm@46 2911 var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]);
rlm@46 2912 ///////////////
rlm@46 2913
rlm@46 2914
rlm@46 2915
rlm@46 2916 if(distx<1){distx=1;}
rlm@46 2917
rlm@46 2918
rlm@46 2919 if(disty<1){disty=1;}
rlm@46 2920 //document.forms[0].code.value=distx+' '+disty;
rlm@46 2921 tw=distx;
rlm@46 2922 th=disty;
rlm@46 2923
rlm@46 2924 }
rlm@46 2925
rlm@46 2926 }
rlm@46 2927
rlm@46 2928
rlm@46 2929
rlm@46 2930 if(shape.tagName == 'rect')
rlm@46 2931 {
rlm@46 2932 //alert(data[0]);
rlm@46 2933 shape.setAttributeNS(null,'x',tx);
rlm@46 2934 shape.setAttributeNS(null,'y',ty);
rlm@46 2935 shape.setAttributeNS(null, 'width', tw);
rlm@46 2936 shape.setAttributeNS(null, 'height', th);
rlm@46 2937
rlm@46 2938 //shape.nodparseFloatue=data;
rlm@46 2939 }
rlm@46 2940 else
rlm@46 2941 if(shape.tagName == 'text')
rlm@46 2942 {
rlm@46 2943
rlm@46 2944 var tsize=shape.getAttributeNS(null, 'font-size') ;
rlm@46 2945 tsize=eval(tsize);
rlm@46 2946 //shape.setAttributeNS(null, 'x', tx + 'px');
rlm@46 2947 //shape.setAttributeNS(null, 'y', ty + 'px');
rlm@46 2948 //var mysize=box.height+1 ;
rlm@46 2949 var mysize=parseInt(Math.round(th));
rlm@46 2950
rlm@46 2951 if(scaleType== 'ne'){ shape.setAttributeNS(null, 'font-size',tsize+1);}
rlm@46 2952 //shape.setAttributeNS(null, 'font-size', mysize);
rlm@46 2953
rlm@46 2954
rlm@46 2955 /*
rlm@46 2956 shape.setAttributeNS(null,'x',tx);
rlm@46 2957 shape.setAttributeNS(null,'y',ty);
rlm@46 2958 shape.setAttributeNS(null, 'width', tw);
rlm@46 2959 shape.setAttributeNS(null, 'height', th);
rlm@46 2960
rlm@46 2961 //previus.setAttributeNS(null,'transform', "scale("+trans_ShareScale+")");
rlm@46 2962 shape.setAttributeNS(null, 'x', tx + 'px');
rlm@46 2963 shape.setAttributeNS(null, 'y', ty + 'px');
rlm@46 2964
rlm@46 2965 shape.setAttributeNS(null, 'textLength', parseInt(Math.round(tw)));
rlm@46 2966
rlm@46 2967 */
rlm@46 2968 }
rlm@46 2969 else
rlm@46 2970 if(shape.tagName == 'ellipse')
rlm@46 2971 {
rlm@46 2972 //shape.getAttributeNS(null, 'transform)
rlm@46 2973 shape.setAttributeNS(null, 'cx', (tx + (box.width / 2)) + 'px');
rlm@46 2974 shape.setAttributeNS(null, 'cy', (ty + (box.height / 2)) + 'px');
rlm@46 2975 shape.setAttributeNS(null, 'rx', (tw / 2) + 'px');
rlm@46 2976 shape.setAttributeNS(null, 'ry', (th / 2) + 'px');
rlm@46 2977
rlm@46 2978
rlm@46 2979 }
rlm@46 2980 else
rlm@46 2981 if(shape.tagName == 'line')
rlm@46 2982 {
rlm@46 2983 shape.setAttributeNS(null, 'x1', tx + 'px');
rlm@46 2984 shape.setAttributeNS(null, 'y1', ty + 'px');
rlm@46 2985 shape.setAttributeNS(null, 'x2', tx + tw + 'px');
rlm@46 2986 shape.setAttributeNS(null, 'y2', ty + th + 'px');
rlm@46 2987
rlm@46 2988 }
rlm@46 2989 else
rlm@46 2990 if (shape.tagName == 'polyline')
rlm@46 2991 {
rlm@46 2992
rlm@46 2993 }
rlm@46 2994 else
rlm@46 2995 if (shape.tagName == 'image')
rlm@46 2996 {
rlm@46 2997 shape.setAttributeNS(null,'x',tx);
rlm@46 2998 shape.setAttributeNS(null,'y',ty);
rlm@46 2999 shape.setAttributeNS(null, 'width', tw);
rlm@46 3000 shape.setAttributeNS(null, 'height', th);
rlm@46 3001
rlm@46 3002 }
rlm@46 3003 else
rlm@46 3004 if (shape.tagName == 'path')
rlm@46 3005 {
rlm@46 3006 // var xscale= box.width/tw;
rlm@46 3007 // var yscale= box.height/th;
rlm@46 3008 var xscale= tw/box.width;
rlm@46 3009 var yscale= th/box.height;
rlm@46 3010 var xinc=xscale;//dist*angx;
rlm@46 3011 var yinc=yscale/ty;//dist*angy;
rlm@46 3012
rlm@46 3013 if(scaleType== 'n')
rlm@46 3014 {
rlm@46 3015 tx=box.x+(box.width/2);
rlm@46 3016 ty=box.y+box.height;
rlm@46 3017 var xinc=1;
rlm@46 3018 var yinc=box.y/toY;//dist*angy;
rlm@46 3019
rlm@46 3020 }
rlm@46 3021 if(scaleType== 's')
rlm@46 3022 {
rlm@46 3023 tx=box.x+(box.width/2);
rlm@46 3024 ty=box.y;
rlm@46 3025 var xinc=1;
rlm@46 3026 var yinc=toY/(box.y+box.height);//dist*angy;
rlm@46 3027 }
rlm@46 3028 if(scaleType== 'e')
rlm@46 3029 {
rlm@46 3030 tx=box.x;
rlm@46 3031 ty=box.y+(box.height/2);
rlm@46 3032 var xinc=toX/(box.x+box.width);
rlm@46 3033 var yinc=1;
rlm@46 3034
rlm@46 3035 }
rlm@46 3036 if(scaleType== 'w')
rlm@46 3037 {
rlm@46 3038 tx=box.x+box.width;
rlm@46 3039 ty=box.y+(box.height/2);
rlm@46 3040 var xinc=box.x/toX;
rlm@46 3041 var yinc=1;
rlm@46 3042
rlm@46 3043 }
rlm@46 3044 if(scaleType== 'ne')
rlm@46 3045 {
rlm@46 3046 tx=box.x;
rlm@46 3047 ty=box.y+box.height;
rlm@46 3048 var xinc=toX/(box.x+box.width);
rlm@46 3049 var yinc=xinc;
rlm@46 3050 }
rlm@46 3051 if(scaleType== 'nw')
rlm@46 3052 {
rlm@46 3053 tx=box.x+box.width;
rlm@46 3054 ty=box.y+box.height;
rlm@46 3055 var xinc=box.x/toX;
rlm@46 3056 var yinc=xinc;
rlm@46 3057 }
rlm@46 3058 if(scaleType== 'se')
rlm@46 3059 {
rlm@46 3060 tx=box.x;
rlm@46 3061 ty=box.y;
rlm@46 3062 var xinc=toX/(box.x+box.width);
rlm@46 3063 var yinc=xinc;
rlm@46 3064 }
rlm@46 3065 if(scaleType== 'sw')
rlm@46 3066 {
rlm@46 3067 tx=(box.x+box.width);
rlm@46 3068 ty=box.y;
rlm@46 3069 var xinc=box.x/toX;
rlm@46 3070 var yinc=xinc;
rlm@46 3071 }
rlm@46 3072 if(xinc==0){ xinc= 0.0000001;}
rlm@46 3073 if(yinc==0){ yinc= 0.0000001; }
rlm@46 3074 var prevpath=previus.getAttributeNS(null, 'd');
rlm@46 3075 var path=shape.getAttributeNS(null, 'd');
rlm@46 3076 ////////////
rlm@46 3077
rlm@46 3078
rlm@46 3079 //xshe=left;
rlm@46 3080 //yshe=top;
rlm@46 3081
rlm@46 3082 path=path.replace(/, /g, ',');
rlm@46 3083 path=path.replace(/ ,/g, ',');
rlm@46 3084 var ps =path.split(" ")
rlm@46 3085 var pcc = "";
rlm@46 3086 var point =ps[0].split(",");
rlm@46 3087
rlm@46 3088
rlm@46 3089 var num0= parseFloat(point[0].substring(1));
rlm@46 3090 var num1= parseFloat(point[1]);
rlm@46 3091
rlm@46 3092
rlm@46 3093 var ang= ang2v(box.x,box.y,tx,ty) ;
rlm@46 3094 var angle = Math.round((ang/Math.PI* 2)* 360);
rlm@46 3095 var angx = Math.cos(ang);
rlm@46 3096 var angy = Math.sin(ang);
rlm@46 3097 var dist= dist2p(tx,ty,box.x,box.y);
rlm@46 3098 //var xinc=xscale;//dist*angx;
rlm@46 3099 //var yinc=yscale;//dist*angy;
rlm@46 3100 var re = /^[-]?\d*\.?\d*$/;
rlm@46 3101 var axis = $V([tx,ty]);
rlm@46 3102 for(var i = 0; i < ps.length; i++)
rlm@46 3103 {
rlm@46 3104 if(ps[i].indexOf(',')>0){
rlm@46 3105
rlm@46 3106 var point =ps[i].split(",");
rlm@46 3107 var char1=point[0].substring(0,1);
rlm@46 3108 if(char1=='A' || char1=='a'){isArc=true; contArc=0;}
rlm@46 3109 if(isArc==true){contArc++}
rlm@46 3110 if(contArc==4){contArc=0; isArc=false}
rlm@46 3111
rlm@46 3112 //if (isNaN(valnum))
rlm@46 3113 if (!char1.match(re))
rlm@46 3114 {
rlm@46 3115 var num0= parseFloat(point[0].substring(1));
rlm@46 3116 var text=char1;
rlm@46 3117 }else{
rlm@46 3118 if(isArc==true && contArc==2 )
rlm@46 3119 {
rlm@46 3120 var num0= point[0];
rlm@46 3121 }else{
rlm@46 3122 var num0= parseFloat(point[0]);
rlm@46 3123 }
rlm@46 3124 var text='';
rlm@46 3125
rlm@46 3126 }
rlm@46 3127
rlm@46 3128
rlm@46 3129 if(isArc==true && contArc==2)
rlm@46 3130 {
rlm@46 3131 point[1]= point[1].toString() ;
rlm@46 3132 }
rlm@46 3133 else
rlm@46 3134 {
rlm@46 3135
rlm@46 3136 //num0*=xinc;
rlm@46 3137 point[1]= parseFloat(point[1]);
rlm@46 3138 //point[1]*=yinc;
rlm@46 3139 var pointIni=$V([num0,point[1],1]);
rlm@46 3140 var matrT = $M([[1,0,-tx],[0,1,-ty],[0,0,1]]);
rlm@46 3141 var matrS = $M([[xinc,0,0],[0,yinc,0],[0,0,1]]);
rlm@46 3142 var matrR = $M([[1,0,tx],[0,1,ty],[0,0,1]]);
rlm@46 3143 var matr1= matrT.x(pointIni);
rlm@46 3144 var matr2= matrS.x(matr1);
rlm@46 3145 //var pointR=pointIni.Random(1)
rlm@46 3146 //var pointR=pointIni.rotate(Math.PI/180,axis);
rlm@46 3147 //var pointRc=pointIni.cross(axis);
rlm@46 3148 //var pointR=matr2;
rlm@46 3149 var pointR=matrR.x(matr2);
rlm@46 3150 num0=pointR.elements[0];
rlm@46 3151 point[1]=pointR.elements[1];
rlm@46 3152 $('code').value=pointIni.elements[0]+','+pointR.elements[1]+' ';
rlm@46 3153 }
rlm@46 3154 var cx=num0;
rlm@46 3155 var cy=point[1];
rlm@46 3156 pcc+=text+cx+','+cy+' ';
rlm@46 3157 //pcc+=text+cx+','+cy+' ';
rlm@46 3158
rlm@46 3159 }else{
rlm@46 3160 pcc+=ps[i]+' ';
rlm@46 3161 }
rlm@46 3162 }
rlm@46 3163
rlm@46 3164 shape.setAttributeNS(null,'d', pcc);
rlm@46 3165
rlm@46 3166
rlm@46 3167
rlm@46 3168 //////////////
rlm@46 3169 /*
rlm@46 3170 path=path.replace(/, /g, ',');
rlm@46 3171 path=path.replace(/ ,/g, ',');
rlm@46 3172 var ps =path.split(" ")
rlm@46 3173 var pcc = "";
rlm@46 3174
rlm@46 3175 var xinc=tx-prevbox.x;
rlm@46 3176 var yinc=ty-prevbox.y;
rlm@46 3177
rlm@46 3178 var re = /^[-]?\d*\.?\d*$/;
rlm@46 3179 for(var i = 0; i < ps.length; i++)
rlm@46 3180 {
rlm@46 3181 if(ps[i].indexOf(',')>0){
rlm@46 3182
rlm@46 3183 var point =ps[i].split(",");
rlm@46 3184 var char1=point[0].substring(0,1);
rlm@46 3185 point[1]= parseFloat(point[1]);
rlm@46 3186
rlm@46 3187 // var valnum =char1.charAt(0);
rlm@46 3188 //if (isNaN(valnum))
rlm@46 3189 if (!char1.match(re))
rlm@46 3190
rlm@46 3191 {
rlm@46 3192 var num0= parseFloat(point[0].substring(1));
rlm@46 3193 var text=char1;
rlm@46 3194 }else{
rlm@46 3195 var num0= parseFloat(point[0]);
rlm@46 3196 var text='';
rlm@46 3197
rlm@46 3198 }
rlm@46 3199 //num0+=dist*angx;
rlm@46 3200 //point[1]+=dist*angy;
rlm@46 3201 num0*=xscale;
rlm@46 3202 point[1]*=yscale;
rlm@46 3203
rlm@46 3204 // num0+=xinc;
rlm@46 3205 // point[1]+=yinc;
rlm@46 3206
rlm@46 3207
rlm@46 3208
rlm@46 3209 var cx=num0;
rlm@46 3210 var cy=point[1];
rlm@46 3211 pcc+=text+cx+','+cy+' ';
rlm@46 3212 }else{
rlm@46 3213 pcc+=ps[i]+' ';
rlm@46 3214 }
rlm@46 3215 }
rlm@46 3216
rlm@46 3217
rlm@46 3218
rlm@46 3219
rlm@46 3220
rlm@46 3221 // $('code').value=dist+' '+ ang+' '+'__'+x+'= '+left+'/ '+y+'= ' +top+'';
rlm@46 3222
rlm@46 3223 //shape.setAttributeNS(null,'transform', "rotate("+left+")");
rlm@46 3224
rlm@46 3225 // shape.setAttributeNS(null,'transform', "translate("+trax+","+tray+") rotate("+0+") scale(1,1)");
rlm@46 3226 shape.setAttributeNS(null,'d', pcc);
rlm@46 3227
rlm@46 3228
rlm@46 3229
rlm@46 3230
rlm@46 3231
rlm@46 3232
rlm@46 3233
rlm@46 3234 //document.forms[0].code.value='';
rlm@46 3235 //shape.setAttributeNS(null,'transform', "scale("+trans_ShareScale+")");
rlm@46 3236 */
rlm@46 3237
rlm@46 3238 }
rlm@46 3239
rlm@46 3240
rlm@46 3241
rlm@46 3242
rlm@46 3243
rlm@46 3244
rlm@46 3245
rlm@46 3246
rlm@46 3247
rlm@46 3248
rlm@46 3249
rlm@46 3250
rlm@46 3251
rlm@46 3252 //$('status').innerHTML=typeTransform+': '+shareScale;
rlm@46 3253
rlm@46 3254
rlm@46 3255 };
rlm@46 3256
rlm@46 3257
rlm@46 3258 SVGRenderer.prototype.rotateShape = function(shape, previus, toX, toY) {
rlm@46 3259
rlm@46 3260 //document.getElementById('richdraw').style.cursor='e-resize';
rlm@46 3261 var box = shape.getBBox();
rlm@46 3262 var prevbox=previus.getBBox();
rlm@46 3263 var centerx= box.x+(box.width/2);
rlm@46 3264 var centery= box.y+(box.height/2);
rlm@46 3265 var coord=this.editor.inputxy;
rlm@46 3266
rlm@46 3267 var actual_angle=ang2v(centerx,centery,coord[0], coord[1]);
rlm@46 3268
rlm@46 3269 if(xrot<toX) { rotatexxx+=1;}else{rotatexxx-=1;}
rlm@46 3270 xrot=toX;
rlm@46 3271 yrot=toY;
rlm@46 3272
rlm@46 3273 var xtr=0;
rlm@46 3274 var ytr=0;
rlm@46 3275
rlm@46 3276 var box= shape.getBBox();
rlm@46 3277 var tr1x= box.x;
rlm@46 3278 var tr1y= box.y;
rlm@46 3279
rlm@46 3280
rlm@46 3281
rlm@46 3282 toX+=xtr;
rlm@46 3283 toY+=xtr;
rlm@46 3284
rlm@46 3285 //var trax=parseFloat(toX-box.x); var tray= parseFloat(toY-box.y);
rlm@46 3286 var trax=parseFloat(box.x/2); var tray= parseFloat(box.y/2);
rlm@46 3287 var angler=Math.atan2(toX,toY);
rlm@46 3288 var angle=angler*180/Math.PI;
rlm@46 3289 var T = shape.getCTM();
rlm@46 3290 var rotini=T.a*(180 / Math.PI);
rlm@46 3291 var angle=rotini*180/Math.PI;
rlm@46 3292 var rot_angle=actual_angle*180/Math.PI;
rlm@46 3293 this.editor.log(centerx+' '+centery+' '+coord[0]+' '+coord[1]+'____ '+rot_angle+' '+actual_angle*180/Math.PI);
rlm@46 3294
rlm@46 3295
rlm@46 3296 // matrix( a, b, c, d, e, f )
rlm@46 3297 // a c e
rlm@46 3298 // b d f
rlm@46 3299 // 0 0 1
rlm@46 3300 //a scale factor of 2, a rotation of 30 deg and a translation of (500,50)
rlm@46 3301 //T 1.732 -1 500 1 1.732 50 0 0 1
rlm@46 3302 //T 1 ad-bc d -c -de+cf -b a be-df 0 0 1
rlm@46 3303
rlm@46 3304 //shape.setAttributeNS(null,'transform', "translate("+(-xshe)+","+(-yshe)+")");
rlm@46 3305
rlm@46 3306 // shape.setAttributeNS(null,"transform", " matrix( a, b, c, d, e, f )");
rlm@46 3307 // shape.setAttributeNS(null,'transform', "translate("+(box.x+(box.width/2))+","+(box.y+(box.height/2))+") rotate("+rotatexxx+") ");
rlm@46 3308 //shape.setAttributeNS(null,'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 3309 //shape.setAttributeNS(null,'transform', "rotate("+rotatexxx+","+(box.x+(box.width/2))+","+(box.y+(box.height/2))+")");
rlm@46 3310 //shape.setAttributeNS(null,'transform', "rotate("+rotatexxx+","+(prevbox.x+(prevbox.width/2))+","+(prevbox.y+(prevbox.height/2))+")");
rlm@46 3311 shape.setAttributeNS(null,'transform', "rotate("+rot_angle+","+(prevbox.x+(prevbox.width/2))+","+(prevbox.y+(prevbox.height/2))+")");
rlm@46 3312
rlm@46 3313
rlm@46 3314 //alert('[ ['+T.a+' '+T.c+' '+T.e+'] ['+T.b+' '+T.d+' '+T.f+'] [0 0 1] ]');
rlm@46 3315 //a,b,c,d,e,f
rlm@46 3316
rlm@46 3317 // shape.setAttributeNS(null,'transform', 'matrix('+T.a+', '+T.b+', '+ T.c+', '+ T.d+', '+ T.e+', '+ T.f+')' );
rlm@46 3318
rlm@46 3319 var x1=T.e;
rlm@46 3320 var y1=T.f;
rlm@46 3321 var sp = Math.sin(rotatexxx*(Math.PI / 180));
rlm@46 3322 var cp = Math.cos(rotatexxx*(Math.PI / 180));
rlm@46 3323 var x2 = 0 + r*rotatexxx*(Math.PI / 180);
rlm@46 3324 var y2 = 0;
rlm@46 3325 var r=0;
rlm@46 3326
rlm@46 3327 var a=cp;
rlm@46 3328 var c=sp;
rlm@46 3329 var e=T.e;
rlm@46 3330 var b=T.b;
rlm@46 3331 var d=(-x1*cp+y1*sp+x2);
rlm@46 3332 var f=(-x1*sp-y1*cp+y2);
rlm@46 3333
rlm@46 3334 var inv=T.inverse;
rlm@46 3335 var inv_mat=T.multiply(inv);
rlm@46 3336 //var matrix = "matrix(" + cp +"," + sp + "," + (-sp) + "," + cp + ","+ (-x1*cp+y1*sp+x2) + ","+ (-x1*sp-y1*cp+y2) + ")";
rlm@46 3337 //var matrix = "matrix(" + a +"," + c + "," + e + "," + b + ","+ d + ","+ f + ")";
rlm@46 3338 var matrix='matrix('+inv_mat.a+' '+inv_mat.b+' '+inv_mat.c+' '+inv_mat.d+' '+inv_mat.e+' '+inv_mat.f+')'
rlm@46 3339
rlm@46 3340 //++ shape.setAttributeNS(null,'transform',matrix);
rlm@46 3341
rlm@46 3342 //shape.setAttributeNS(null,'transform', "rotate("+rotatexxx+")");
rlm@46 3343 // shape.setAttributeNS(null,'transform', "translate("+(box.x)+","+(box.y)+")");
rlm@46 3344
rlm@46 3345 //shape.setAttributeNS(null,'transform', "rotate("+rotatexxx+")");
rlm@46 3346 //shape.setAttributeNS(null, 'x', -box.width/2 + 'px');
rlm@46 3347 //shape.setAttributeNS(null, 'y', -box.height/2 + 'px');
rlm@46 3348 //shape.setAttributeNS(null,"transform", "matrix("+Math.cos(angle)+", "+Math.sin(angle)+", "+Math.sin(-angle)+", "+Math.cos(angle)+", 0, 0 )");
rlm@46 3349 //shape.setAttributeNS(null,'transform', "rotate("+10+")");
rlm@46 3350
rlm@46 3351 //shape.setAttributeNS(null, 'x', box.width/2 + 'px');
rlm@46 3352 //shape.setAttributeNS(null, 'y', box.height/2 + 'px');
rlm@46 3353
rlm@46 3354
rlm@46 3355
rlm@46 3356 //$('status').innerHTML = 'Mode: Draw '+pointshape +'_'+xsh +' '+ ysh+' '+trshape;
rlm@46 3357
rlm@46 3358 //$('status').innerHTML=typeTransform+': '+rotatexxx;
rlm@46 3359
rlm@46 3360 };
rlm@46 3361
rlm@46 3362
rlm@46 3363
rlm@46 3364 // x(u) = x0*(1-u) + x1*u = x0 + (x1-x0)*u
rlm@46 3365 // y(u) = y0*(1-u) + y1*u = y0 + (y1-y0)*u
rlm@46 3366
rlm@46 3367
rlm@46 3368
rlm@46 3369 SVGRenderer.prototype.getshapes = function(){
rlm@46 3370 return this.svgRoot.childNodes;
rlm@46 3371 }
rlm@46 3372
rlm@46 3373 SVGRenderer.prototype.reflect = function(HorV) {
rlm@46 3374 var shape= c.selected;
rlm@46 3375 var box = shape.getBBox();
rlm@46 3376
rlm@46 3377 if(shape.tagName=="path")
rlm@46 3378 {
rlm@46 3379
rlm@46 3380 var tx=box.x+(box.width/2);
rlm@46 3381 var ty=box.y+(box.height/2);
rlm@46 3382
rlm@46 3383 if(HorV=='V'){
rlm@46 3384 var xinc=-1;
rlm@46 3385 var yinc=1;
rlm@46 3386 }
rlm@46 3387 if(HorV=='H'){
rlm@46 3388 var xinc=1;
rlm@46 3389 var yinc=-1;
rlm@46 3390 }
rlm@46 3391
rlm@46 3392
rlm@46 3393 var path=shape.getAttributeNS(null, 'd');
rlm@46 3394 path=path.replace(/, /g, ',');
rlm@46 3395 path=path.replace(/ ,/g, ',');
rlm@46 3396 var ps =path.split(" ")
rlm@46 3397 var pcc = "";
rlm@46 3398 var point =ps[0].split(",");
rlm@46 3399
rlm@46 3400
rlm@46 3401 var num0= parseFloat(point[0].substring(1));
rlm@46 3402 var num1= parseFloat(point[1]);
rlm@46 3403
rlm@46 3404 var re = /^[-]?\d*\.?\d*$/;
rlm@46 3405 var axis = $V([tx,ty]);
rlm@46 3406
rlm@46 3407 for(var i = 0; i < ps.length; i++)
rlm@46 3408 {
rlm@46 3409 if(ps[i].indexOf(',')>0){
rlm@46 3410
rlm@46 3411 var point =ps[i].split(",");
rlm@46 3412 var char1=point[0].substring(0,1);
rlm@46 3413 if(char1=='A' || char1=='a'){isArc=true; contArc=0;}
rlm@46 3414 if(isArc==true){contArc++}
rlm@46 3415 if(contArc==4){contArc=0; isArc=false}
rlm@46 3416
rlm@46 3417 //if (isNaN(valnum))
rlm@46 3418 if (!char1.match(re))
rlm@46 3419 {
rlm@46 3420 var num0= parseFloat(point[0].substring(1));
rlm@46 3421 var text=char1;
rlm@46 3422 }else{
rlm@46 3423 if(isArc==true && contArc==2 )
rlm@46 3424 {
rlm@46 3425 var num0= point[0];
rlm@46 3426 }else{
rlm@46 3427 var num0= parseFloat(point[0]);
rlm@46 3428 }
rlm@46 3429 var text='';
rlm@46 3430
rlm@46 3431 }
rlm@46 3432
rlm@46 3433
rlm@46 3434 if(isArc==true && contArc==2)
rlm@46 3435 {
rlm@46 3436 point[1]= point[1].toString() ;
rlm@46 3437 }
rlm@46 3438 else
rlm@46 3439 {
rlm@46 3440
rlm@46 3441 //num0*=xinc;
rlm@46 3442 point[1]= parseFloat(point[1]);
rlm@46 3443 //point[1]*=yinc;
rlm@46 3444 var pointIni=$V([num0,point[1],1]);
rlm@46 3445 var matrT = $M([[1,0,-tx],[0,1,-ty],[0,0,1]]);
rlm@46 3446 var matrS = $M([[xinc,0,0],[0,yinc,0],[0,0,1]]);
rlm@46 3447 var matrR = $M([[1,0,tx],[0,1,ty],[0,0,1]]);
rlm@46 3448 var matr1= matrT.x(pointIni);
rlm@46 3449 var matr2= matrS.x(matr1);
rlm@46 3450 //var pointR=pointIni.Random(1)
rlm@46 3451 //var pointR=pointIni.rotate(Math.PI/180,axis);
rlm@46 3452 //var pointRc=pointIni.cross(axis);
rlm@46 3453 //var pointR=matr2;
rlm@46 3454 var pointR=matrR.x(matr2);
rlm@46 3455 num0=pointR.elements[0];
rlm@46 3456 point[1]=pointR.elements[1];
rlm@46 3457 $('code').value=pointIni.elements[0]+','+pointR.elements[1]+' ';
rlm@46 3458 }
rlm@46 3459 var cx=num0;
rlm@46 3460 var cy=point[1];
rlm@46 3461 pcc+=text+cx+','+cy+' ';
rlm@46 3462 //pcc+=text+cx+','+cy+' ';
rlm@46 3463
rlm@46 3464 }else{
rlm@46 3465 pcc+=ps[i]+' ';
rlm@46 3466 }
rlm@46 3467 }
rlm@46 3468 var svg =shape.cloneNode(false);
rlm@46 3469 svg.setAttributeNS(null,'d', pcc);
rlm@46 3470 this.svgRoot.appendChild(svg);
rlm@46 3471 return svg;
rlm@46 3472 }
rlm@46 3473 else
rlm@46 3474 {
rlm@46 3475 if(shape.tagName=="text" || shape.tagName=="image" )
rlm@46 3476 {
rlm@46 3477
rlm@46 3478
rlm@46 3479 var tr='';
rlm@46 3480 var turn0='';
rlm@46 3481 var svg =shape.cloneNode(false);
rlm@46 3482 var x= shape.getAttributeNS(null, 'x');
rlm@46 3483 var y= shape.getAttributeNS(null, 'y');
rlm@46 3484 x+=box.width/2;
rlm@46 3485 y+=box.height/2;
rlm@46 3486 if(HorV=='V')
rlm@46 3487 {
rlm@46 3488 svg.setAttributeNS(null,'x',-parseFloat(x));
rlm@46 3489 var scaleSim='-1, 1';
rlm@46 3490 svg.setAttributeNS(null,'transform','scale('+scaleSim+')');
rlm@46 3491 //svg.setAttributeNS(null,'y',parseFloat(x));
rlm@46 3492 svg.setAttributeNS(null,'x',-parseFloat(x));
rlm@46 3493
rlm@46 3494
rlm@46 3495 }
rlm@46 3496 if(HorV=='H')
rlm@46 3497 {
rlm@46 3498 var scaleSim='1, -1';
rlm@46 3499 svg.setAttributeNS(null,'y',-parseFloat(y));
rlm@46 3500 svg.setAttributeNS(null,'transform','scale('+scaleSim+')');
rlm@46 3501 //svg.setAttributeNS(null,'x',parseFloat(x));
rlm@46 3502 svg.setAttributeNS(null,'y',-parseFloat(y));
rlm@46 3503
rlm@46 3504
rlm@46 3505 }
rlm@46 3506
rlm@46 3507 if(shape.hasAttributeNS(null, 'transform'))
rlm@46 3508 {
rlm@46 3509 tr=shape.getAttributeNS(null, 'transform');
rlm@46 3510 turn0=GetString(tr,'rotate(',')');
rlm@46 3511
rlm@46 3512 svg.setAttributeNS(null,'transform','rotate('+turn+'),scale('+scaleSim+')');
rlm@46 3513 svg.setAttributeNS(null,'x',parseFloat(x));
rlm@46 3514 svg.setAttributeNS(null,'y',parseFloat(y));
rlm@46 3515
rlm@46 3516 //svg.setAttributeNS(null,'transform','rotate('+turn+'),scale('+'');
rlm@46 3517 }else{
rlm@46 3518
rlm@46 3519 }
rlm@46 3520
rlm@46 3521
rlm@46 3522
rlm@46 3523 if(shape.tagName=="text"){
rlm@46 3524 var text=shape.textContent ;
rlm@46 3525 svg.textContent=text;
rlm@46 3526 }
rlm@46 3527 //svg.setAttributeNS(null,'writing-mode',mode);
rlm@46 3528 //svg.setAttributeNS(null,'glyph-orientation-horizontal','0deg');
rlm@46 3529 //
rlm@46 3530 //svg.appendChild(text);
rlm@46 3531
rlm@46 3532 this.svgRoot.appendChild(svg);
rlm@46 3533 return svg;
rlm@46 3534 }
rlm@46 3535 else
rlm@46 3536 {
rlm@46 3537 if(shape.hasAttributeNS(null, 'transform'))
rlm@46 3538 {
rlm@46 3539
rlm@46 3540
rlm@46 3541 var tr=shape.getAttributeNS(null, 'transform');
rlm@46 3542 var turn0=GetString(tr, 'rotate(',',');
rlm@46 3543 turn0=parseFloat(turn0);
rlm@46 3544 //alert(turn0);
rlm@46 3545
rlm@46 3546 if(HorV=='V'){
rlm@46 3547 var angle=180;
rlm@46 3548 //var turn=(turn0+angle)-(turn0-90);
rlm@46 3549 var turn=turn0+((angle-turn0)*2);
rlm@46 3550 }
rlm@46 3551 if(HorV=='H'){
rlm@46 3552 var angle=90;
rlm@46 3553 var turn=turn0+((angle-turn0)*2);
rlm@46 3554 }
rlm@46 3555 var centerx= box.x+(box.width/2);
rlm@46 3556 var centery= box.y+(box.height/2);
rlm@46 3557 //this.editor.log(centerx+' '+centery+' '+coord[0]+' '+coord[1]+'____ '+rot_angle+' '+actual_angle*180/Math.PI);
rlm@46 3558 var svg =shape.cloneNode(false);
rlm@46 3559 svg.setAttributeNS(null,'transform', "rotate("+turn+","+centerx+","+centery+")");
rlm@46 3560 this.svgRoot.appendChild(svg);
rlm@46 3561 return svg;
rlm@46 3562 }
rlm@46 3563 else
rlm@46 3564 {
rlm@46 3565 var centerx= box.x+(box.width/2);
rlm@46 3566 var centery= box.y+(box.height/2);
rlm@46 3567 shape.setAttributeNS(null,'transform', "rotate("+180+","+centerx+","+centery+")");
rlm@46 3568
rlm@46 3569 }
rlm@46 3570 }
rlm@46 3571 }
rlm@46 3572 };
rlm@46 3573 //http://dev.opera.com/articles/view/svg-evolution-2-our-first-steps-into-sv/?page=3
rlm@46 3574 //http://www.w3.org/TR/2000/03/WD-SVG-20000303/exchange.html#StylingAttributes
rlm@46 3575 //http://www.xml.com/lpt/a/1390
rlm@46 3576
rlm@46 3577
rlm@46 3578
rlm@46 3579
rlm@46 3580
rlm@46 3581
rlm@46 3582
rlm@46 3583 //http://xml-utils.com/conferencia-svg.html#d0e527
rlm@46 3584 //http://www.xml.com/lpt/a/1321
rlm@46 3585 //http://phrogz.net/objjob/object.asp?id=101
rlm@46 3586 //http://admisource.gouv.fr/plugins/scmcvs/cvsweb.php/Cassini-ihm/js-yosemite/mapApp.js?rev=1.1;cvsroot=cassini
rlm@46 3587 //http://groups.google.com/group/prototype-graphic/msg/0547c0caea8869c6
rlm@46 3588 //http://sylvester.jcoglan.com/