annotate onlypaths/js/svgrenderer.js @ 46:26c2b3ad21c7 laserkard

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