rlm@46: /*---------------------------------------------------------------------------- rlm@46: VMLRENDERER 1.0 rlm@46: VML Renderer For RichDraw rlm@46: ----------------------------------------------------------------------------- rlm@46: Created by Mark Finkle (mark.finkle@gmail.com) rlm@46: Implementation of VML based renderer. rlm@46: ----------------------------------------------------------------------------- rlm@46: Copyright (c) 2006 Mark Finkle rlm@46: rlm@46: This program is free software; you can redistribute it and/or modify it rlm@46: under the terms of the MIT License. rlm@46: rlm@46: Permission is hereby granted, free of charge, to any person obtaining a rlm@46: copy of this software and associated documentation files (the "Software"), rlm@46: to deal in the Software without restriction, including without limitation rlm@46: the rights to use, copy, modify, merge, publish, distribute, sublicense, rlm@46: and/or sell copies of the Software, and to permit persons to whom the rlm@46: Software is furnished to do so, subject to the following conditions: rlm@46: The above copyright notice and this permission notice shall be included in rlm@46: all copies or substantial portions of the Software. rlm@46: rlm@46: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR rlm@46: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, rlm@46: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE rlm@46: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER rlm@46: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING rlm@46: FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER rlm@46: DEALINGS IN THE SOFTWARE. rlm@46: ----------------------------------------------------------------------------- rlm@46: Dependencies: rlm@46: History: rlm@46: 2006-04-05 | Created rlm@46: --------------------------------------------------------------------------*/ rlm@46: rlm@46: rlm@46: rlm@46: function VMLRenderer() { rlm@46: this.base = AbstractRenderer; rlm@46: } rlm@46: rlm@46: rlm@46: VMLRenderer.prototype = new AbstractRenderer; rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.init = function(elem) rlm@46: { rlm@46: this.container = elem; rlm@46: // this.container.style.overflow = 'hidden'; rlm@46: this.container.unselectable = "on"; rlm@46: // Add VML includes and namespace rlm@46: elem.ownerDocument.namespaces.add("v", "urn:schemas-microsoft-com:vml"); rlm@46: var style = elem.ownerDocument.createStyleSheet(); rlm@46: style.addRule('v\\:*', "behavior: url(#default#VML); display:inline-block"); rlm@46: //NOT VML biewBox rlm@46: //http://blogs.msdn.com/ie/archive/2008/03/18/webbrowser-control-rendering-modes-in-ie8.aspx rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.view = function(left,top,width,height,viewBox) { rlm@46: if(mode=='preview') rlm@46: { rlm@46: rlm@46: var tokens = viewBox.split(' '); rlm@46: var prx=100; rlm@46: this.container.style.top =(parseInt(document.getElementById('FRONT').style.height)-height)/2+'px' rlm@46: this.container.style.left =(parseInt(document.getElementById('FRONT').style.width)-width)/2+'px' rlm@46: rlm@46: this.container.style.width = width;//document.getElementById('FRONT').style.width; rlm@46: this.container.style.height =height;//document.getElementById('FRONT').style.height; rlm@46: rlm@46: rlm@46: canvasLeft = left; rlm@46: canvasTop = top; rlm@46: canvasWidth = width; rlm@46: canvasHeight = height; rlm@46: zoominit = viewBox; rlm@46: zoominit1 = viewBox; rlm@46: zoominit2 = viewBox; rlm@46: var tokens = zoominit.split(' '); rlm@46: proporx = width/tokens[2]; rlm@46: propory = height/tokens[3]; rlm@46: /* var x=parseFloat(tokens[0])-prx; rlm@46: var y=parseFloat(tokens[1])-prx; rlm@46: var w=parseFloat(tokens[2])+prx; rlm@46: var h=parseFloat(tokens[3])+prx; rlm@46: workspace= x+''+y+''+w+''+h; rlm@46: //zoominit = workspace; rlm@46: */ rlm@46: //VMLviewBox('',left,top,width,height) rlm@46: } rlm@46: else rlm@46: { rlm@46: rlm@46: // rlm@46: this.container.style.top =0+'px'; rlm@46: rlm@46: var tokens = viewBox.split(' '); rlm@46: proporImage= (parseFloat(tokens[2])-parseFloat(tokens[0]))/(parseFloat(tokens[3])-parseFloat(tokens[1])); rlm@46: var marginx=(parseInt(document.getElementById('FRONT').style.width)-(parseFloat(tokens[2])-parseFloat(tokens[0])))/2; rlm@46: var marginy=(parseInt(document.getElementById('FRONT').style.height)-(parseFloat(tokens[3])-parseFloat(tokens[1])))/2; rlm@46: var x=(parseFloat(tokens[0])-marginx); rlm@46: var y=(parseFloat(tokens[1])-marginy); rlm@46: var w=(parseFloat(tokens[2])+marginx*2); rlm@46: var h=(parseFloat(tokens[3])+marginy*2); rlm@46: //alert(tokens[3]+' '+tokens[1]+' / '+(parseFloat(tokens[3])-parseFloat(tokens[1]))+' '+parseInt(document.getElementById('FRONT').style.height)+' /'+h+' '+height); rlm@46: //if(h>=parseInt(document.getElementById('FRONT').style.height)){h=parseInt(document.getElementById('FRONT').style.height);} rlm@46: //if(h>=parseInt(document.getElementById('FRONT').style.height)){y=0;h=600;}//parseInt(document.getElementById('FRONT').style.height)*2} rlm@46: //zoominit = x+' '+y+' '+w+' '+h; rlm@46: canvasLeft = 0; rlm@46: canvasTop = 0; rlm@46: canvasWidth = w; rlm@46: canvasHeight = h; rlm@46: //proporx = w/tokens[2]; rlm@46: //propory = h/tokens[3]; rlm@46: rlm@46: this.container.style.left =canvasLeft+'px' rlm@46: this.container.style.top =canvasTop+'px' rlm@46: rlm@46: this.container.style.width = canvasWidth;//document.getElementById('FRONT').style.width; rlm@46: this.container.style.height =canvasHeight;//document.getElementById('FRONT').style.height; rlm@46: zoominit1 = canvasLeft+' '+canvasTop+' '+canvasWidth+' '+canvasHeight; rlm@46: zoominit2= x+' '+y+' '+w+' '+h; rlm@46: //VMLviewBox('',x,canvasTop,w,h) rlm@46: //this.rectCanvas(x,y,w,h,zoominit) rlm@46: // this.rectCanvas(x,y,canvasWidth,canvasHeight,zoominit2) rlm@46: // zoominit = viewBox; rlm@46: } rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.zoomFrame = function(zoom){ rlm@46: myOPF.viewBox=zoom; rlm@46: load(myOPF,c); rlm@46: document.getElementById("source").value=myOPF.toJSONString(); rlm@46: } rlm@46: VMLRenderer.prototype.rectDoc = function(viewBox) { rlm@46: var tokens2 = zoominit2.split(' '); rlm@46: var tokens = zoominit.split(' '); rlm@46: var shape = document.getElementById('rectDoc'); rlm@46: if (shape) { rlm@46: this.remove(shape); rlm@46: } rlm@46: var rect=this.container.ownerDocument.createElement('v:rect'); rlm@46: rect.id='rectDoc'; rlm@46: rect.style.position = 'absolute'; rlm@46: rect.style.left =-parseInt(tokens2[0]); rlm@46: rect.style.top = -parseInt(tokens2[1]); rlm@46: rect.style.width = parseInt(tokens[2]); rlm@46: rect.style.height = parseInt(tokens[3]); rlm@46: rect.setAttribute('filled', 'false'); rlm@46: rect.setAttribute('stroked', 'true'); rlm@46: rect.setAttribute('strokeweight', 2); rlm@46: rect.setAttribute('strokecolor',"#ff0000"); rlm@46: this.container.appendChild(rect); rlm@46: //this.container.insertBefore(rect, this.container.firstChild ); rlm@46: //alert(docx+' '+docy+' '+docw+' '+doch+' '+viewBox) rlm@46: } rlm@46: VMLRenderer.prototype.rectCanvas = function(docx,docy,docw,doch,viewBox) { rlm@46: rlm@46: var tokens = zoominit1.split(' '); rlm@46: var shape = document.getElementById('rectCanvas'); rlm@46: if (shape) { rlm@46: this.remove(shape); rlm@46: } rlm@46: rlm@46: var rect=this.container.ownerDocument.createElement('v:rect'); rlm@46: rect.id='rectBackground'; rlm@46: rect.style.position = 'absolute'; rlm@46: rect.style.left = tokens[0] ; rlm@46: rect.style.top =tokens[1]; rlm@46: rect.style.width=tokens[2]; rlm@46: rect.style.height= tokens[3] ; rlm@46: rect.setAttribute('filled', 'true'); rlm@46: rect.setAttribute('fillcolor',"#666666"); rlm@46: rect.setAttribute('stroked', 'false'); rlm@46: rlm@46: this.container.insertBefore(rect, this.container.firstChild ); rlm@46: rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.removeAll = function(){ rlm@46: while (this.container.hasChildNodes()) { rlm@46: this.container.removeChild(this.container.firstChild); rlm@46: } rlm@46: } rlm@46: rlm@46: function VMLviewBox(container,left,top,width,height){ rlm@46: var tokens = zoominit2.split(' '); rlm@46: left *= proporx; rlm@46: left = left - parseFloat(tokens[0]); rlm@46: top *= propory; rlm@46: top = top - parseFloat(tokens[1]); rlm@46: width *= proporx; rlm@46: height *= propory; rlm@46: rlm@46: return {"x":parseFloat(Math.round(left)), "y":parseFloat(Math.round(top)), "w":parseFloat(Math.round(width)), "h":parseFloat(Math.round(height))}; rlm@46: } rlm@46: function VMLviewBox1(container,left,top,width,height){ rlm@46: var tokens = zoominit2.split(' '); rlm@46: left *= proporx; rlm@46: left = left - parseFloat(tokens[0]); rlm@46: top *= propory; rlm@46: top = top - parseFloat(tokens[1]); rlm@46: width *= proporx; rlm@46: height *= propory; rlm@46: rlm@46: return {"x":parseFloat(Math.round(left)), "y":parseFloat(Math.round(top)), "w":parseFloat(Math.round(width)), "h":parseFloat(Math.round(height))}; rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.create = function(shape, fillColor, lineColor, fillOpac, lineOpac, lineWidth, left, top, width, height, textMessaje, textSize, textFamily, imageHref, points, transform, parent) { rlm@46: var tokens = zoominit2.split(' '); rlm@46: var zoom=VMLviewBox(this.container,left,top,width,height); rlm@46: left=zoom.x; rlm@46: top=zoom.y; rlm@46: width=zoom.w; rlm@46: height=zoom.h; rlm@46: rlm@46: var zoom=VMLviewBox(this.container,left,top,textSize,textSize); rlm@46: if(zoom.w<1){zoom.w=1} rlm@46: textSize=zoom.h; rlm@46: rlm@46: var zoom=VMLviewBox(this.container,left,top,lineWidth*2/3,lineWidth); rlm@46: if(zoom.w<1){zoom.w=1} rlm@46: lineWidth=zoom.w; rlm@46: rlm@46: rlm@46: var vml; rlm@46: rlm@46: var shap=1; rlm@46: if (shape == 'rect') { rlm@46: vml = this.container.ownerDocument.createElement('v:rect'); rlm@46: vml.style.position = 'absolute'; rlm@46: vml.style.left = left; rlm@46: vml.style.top = top; rlm@46: vml.style.width = width; rlm@46: vml.style.height = height; rlm@46: } rlm@46: else if (shape == 'roundrect') { rlm@46: vml = this.container.ownerDocument.createElement('v:roundrect'); rlm@46: vml.style.position = 'absolute'; rlm@46: vml.style.left = left; rlm@46: vml.style.top = top; rlm@46: vml.style.width = width; rlm@46: vml.style.height = height; rlm@46: vml.setAttribute('arcsize', '20%'); rlm@46: rlm@46: } rlm@46: else if (shape == 'ellipse') { rlm@46: vml = this.container.ownerDocument.createElement('v:oval'); rlm@46: vml.style.left = left; rlm@46: vml.style.top = top; rlm@46: vml.style.width = width; rlm@46: vml.style.height = height; rlm@46: vml.style.position = 'absolute'; rlm@46: } rlm@46: else if (shape == 'line') { rlm@46: vml = this.container.ownerDocument.createElement('v:line'); rlm@46: vml.style.position = 'absolute'; rlm@46: vml.setAttribute('from', left-80 + 'px,' + top + 'px'); rlm@46: vml.setAttribute('to', (left-80+width) + 'px,' + (top+height) + 'px'); rlm@46: rlm@46: } rlm@46: else if (shape == 'polyline') { rlm@46: vml = this.container.ownerDocument.createElement('v:polyline'); rlm@46: vml.setAttribute("points", points); rlm@46: rlm@46: } rlm@46: else if (shape == 'path') rlm@46: { rlm@46: vml = this.container.ownerDocument.createElement('v:shape'); rlm@46: var tokens = zoominit1.split(' '); rlm@46: var tokens1 = zoominit1.split(' '); rlm@46: var tokens2 = zoominit2.split(' '); rlm@46: tokens[0]=0; rlm@46: tokens[1]=0; rlm@46: var path=points; rlm@46: path=path.replace(/, /g, ','); rlm@46: path=path.replace(/ ,/g, ','); rlm@46: var ps =path.split(" ") rlm@46: var pcc = ""; rlm@46: rlm@46: var re = /^[-]?\d*\.?\d*$/; rlm@46: var contArc=0; rlm@46: var isArc=false; rlm@46: for(var i = 0; i < ps.length; i++) rlm@46: { rlm@46: if(ps[i].indexOf(',')>0){ rlm@46: rlm@46: var point =ps[i].split(","); rlm@46: var char1=point[0].substring(0,1); rlm@46: rlm@46: if (!char1.match(re)) rlm@46: { rlm@46: var num0= parseFloat(point[0].substring(1)); rlm@46: var zoom=VMLviewBox(this.container,num0+(parseInt(tokens2[0])*proporx),0,parseInt(tokens2[2]),parseInt(tokens2[3])); rlm@46: num0=zoom.x; rlm@46: rlm@46: var text=char1; rlm@46: }else{ rlm@46: var num0= parseFloat(point[0]); rlm@46: var zoom=VMLviewBox(this.container,num0+(parseInt(tokens2[0])*proporx),0,parseInt(tokens2[2]),parseInt(tokens2[3])); rlm@46: num0=zoom.x; rlm@46: rlm@46: } rlm@46: point[1]= parseFloat(point[1]); rlm@46: var zoom=VMLviewBox(this.container,0,point[1],parseInt(tokens2[2]),parseInt(tokens2[3])); rlm@46: point[1]=zoom.y; rlm@46: var cx=num0; rlm@46: var cy=point[1]+parseInt(tokens2[1]); rlm@46: pcc+=text+cx+','+cy+' '; rlm@46: } rlm@46: else rlm@46: { rlm@46: pcc+=ps[i]+' '; rlm@46: } rlm@46: rlm@46: } rlm@46: //////////////////// rlm@46: var thispath=pcc; rlm@46: thispath=thispath.replace(/M/g,'m'); rlm@46: thispath=thispath.replace(/C/g,'c'); rlm@46: thispath=thispath.replace(/L/g,'l'); rlm@46: thispath=thispath.replace(/z/g,'x'); rlm@46: rlm@46: //document.getElementById('source').value=points+'\r\n'+thispath +'\r\n'+'________'+'\r\n' rlm@46: var zoom=VMLviewBox(this.container,tokens[0],tokens[1],tokens[2],tokens[3]); rlm@46: rlm@46: vml.style.position="absolute"; rlm@46: vml.style.width= zoom.w+"px"; rlm@46: vml.style.height=zoom.h+"px"; rlm@46: vml.style.left=zoom.x+"px"; rlm@46: vml.style.top=zoom.y+"px"; rlm@46: vml.setAttribute('coordsize', zoom.w+','+zoom.h); rlm@46: rlm@46: var path01 = this.container.ownerDocument.createElement('v:path'); rlm@46: path01.setAttribute("v", thispath+' e'); rlm@46: rlm@46: rlm@46: rlm@46: vml.appendChild(path01) rlm@46: rlm@46: } rlm@46: rlm@46: else if (shape == 'controlpath') rlm@46: { rlm@46: rlm@46: vml = this.container.ownerDocument.createElement('v:shape'); rlm@46: vml.style.position="absolute"; rlm@46: vml.style.width= 700+"px"; rlm@46: vml.style.height=500+"px"; rlm@46: vml.style.left=left+"px"; rlm@46: vml.style.top=top+"px"; rlm@46: vml.setAttribute('coordsize', '700,500'); rlm@46: rlm@46: var path01 = this.container.ownerDocument.createElement('v:path'); rlm@46: path01.setAttribute('v', 'm '+left+','+top+' c'+(left+1)+','+(top+1)+' e '); rlm@46: rlm@46: vml.appendChild(path01) rlm@46: } rlm@46: else if (shape == 'image') { rlm@46: var data =imageHref;//document.forms[0].option_text_message.value; rlm@46: vml = this.container.ownerDocument.createElement('v:image'); rlm@46: vml.setAttribute('src',imageHref); rlm@46: vml.style.position="absolute"; rlm@46: vml.style.width=width+"px"; rlm@46: vml.style.height=height+"px"; rlm@46: vml.style.left=left+"px"; rlm@46: vml.style.top=top+"px"; rlm@46: vml.style.margin=0+"px"; rlm@46: vml.style.padding=0+"px"; rlm@46: if (fillColor != '' || fillColor != 'none') { rlm@46: vml.setAttribute('filled', 'false'); rlm@46: vml.setAttribute('fillcolor', fillColor); rlm@46: } rlm@46: else { rlm@46: vml.setAttribute('filled', 'false'); rlm@46: } rlm@46: vml.setAttribute('strokeweight','0px');// parseFloat(lineWidth)+'px'); rlm@46: vml.setAttribute('stroked', 'false'); rlm@46: vml.setAttribute('strokecolor','#000000');//lineColor); rlm@46: rlm@46: rlm@46: } rlm@46: rlm@46: else if (shape == 'text') rlm@46: { rlm@46: rlm@46: var data =textMessaje; rlm@46: vml = this.container.ownerDocument.createElement('v:shape'); rlm@46: vml.style.position="absolute"; rlm@46: //vml.setAttribute('coordorigin',left+', '+top); rlm@46: //vml.style.coorsize= ''; rlm@46: coordorigin="0, 0" rlm@46: vml.style.width= textSize+'px';//tokens[2]+'px' rlm@46: vml.style.height=textSize+'px'; rlm@46: vml.style.left=(left+"px"); rlm@46: vml.style.top=(top-(textSize*1/4)+"px"); rlm@46: vml.style.margin=0+"px"; rlm@46: vml.style.padding=0+"px"; rlm@46: vml.setAttribute('path','m '+0+' '+0+' r '+(textSize*data.length)+' '+0+' e'); rlm@46: var textPathObj = this.container.ownerDocument.createElement("v:textpath"); rlm@46: textPathObj.setAttribute('string', data); rlm@46: textPathObj.setAttribute('fitshape','false'); rlm@46: textPathObj.setAttribute('trim', 'false'); rlm@46: textPathObj.setAttribute('fitpath', 'false'); rlm@46: textPathObj.setAttribute('on','true'); rlm@46: textPathObj.style.fontFamily=textFamily; rlm@46: textPathObj.style.fontSize=textSize+'px'; rlm@46: textPathObj.setAttribute('vTextKern','true'); rlm@46: textPathObj.setAttribute('text-align','center'); rlm@46: rlm@46: var pathObj = this.container.ownerDocument.createElement("v:path"); rlm@46: pathObj.setAttribute('textpathok', 'true'); rlm@46: vml.appendChild(textPathObj); rlm@46: vml.appendChild(pathObj); rlm@46: rlm@46: rlm@46: } rlm@46: rlm@46: rlm@46: rlm@46: else if (shape == 'texto') rlm@46: { rlm@46: vml = this.container.ownerDocument.createElement('v:shape'); rlm@46: vml.style.position="absolute"; rlm@46: rlm@46: vml.style.coordsize=1000+', '+1000; rlm@46: vml.style.width= 1000; rlm@46: vml.style.height=1000; rlm@46: vml.style.left=left; rlm@46: vml.style.top=top-parseFloat(textSize); rlm@46: rlm@46: vml.style.padding=0; rlm@46: var textBox = this.container.ownerDocument.createElement("v:textbox"); rlm@46: textBox.setAttribute('mso-rotate-with-shape',true) rlm@46: var divtext = this.container.ownerDocument.createElement("div"); rlm@46: divtext.style.coordorigin=0+', '+(0); rlm@46: divtext.style.margin=0; rlm@46: divtext.style.fontFamily=textFamily; rlm@46: divtext.style.margin=0; rlm@46: divtext.style.padding=0; rlm@46: divtext.style.vRotateLetters=true; rlm@46: divtext.style.fontSize=parseFloat(textSize); rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: divtext.style.color=fillColor; rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: //divtext.setAttribute('v-rotate-letters','true'); rlm@46: if(transform.indexOf('rotate')>=0) rlm@46: { rlm@46: rlm@46: myRotate1=transform.split('rotate('); rlm@46: myRotate2=myRotate1[1].split(')'); rlm@46: myRotate3=myRotate2[0].split(','); rlm@46: rlm@46: //divtext.setAttribute('mso-rotate',myRotate3[0]); rlm@46: //textBox.style.msoRotate= myRotate3[0]; rlm@46: //textBox.style.centerX=myRotate3[1]; rlm@46: //textBox.style.centerY=myRotate3[2]; rlm@46: //vml.style.rotation= myRotate3[0]; rlm@46: //vml.style.centerX=myRotate3[1]; rlm@46: //vml.style.centerY=myRotate3[2]; rlm@46: vml.setAttribute('rotation',myRotate3[0]+'Deg'); rlm@46: } rlm@46: rlm@46: divtext.innerHTML=textMessaje; rlm@46: textBox.appendChild(divtext); rlm@46: rlm@46: vml.appendChild(textBox); rlm@46: rlm@46: } rlm@46: else if (shape == 'group') { rlm@46: vml = this.container.ownerDocument.createElement('v:group'); rlm@46: vml.style.left=left+"px"; rlm@46: vml.style.top=top+"px"; rlm@46: } rlm@46: rlm@46: if(shape == 'zoom') rlm@46: { rlm@46: rlm@46: }else rlm@46: { rlm@46: if(transform.indexOf('rotate')>=0) rlm@46: { rlm@46: myRotate1=transform.split('rotate('); rlm@46: myRotate2=myRotate1[1].split(')'); rlm@46: myRotate3=myRotate2[0].split(','); rlm@46: rlm@46: vml.style.rotation= myRotate3[0]+'Deg'; rlm@46: vml.style.centerX=myRotate3[1]; rlm@46: vml.style.centerY=myRotate3[2]; rlm@46: rlm@46: } rlm@46: rlm@46: if(shape != 'image' ) rlm@46: { rlm@46: rlm@46: if (fillColor != '' || fillColor != 'none') rlm@46: { rlm@46: vml.setAttribute('filled', 'true'); rlm@46: vml.setAttribute('fillcolor', fillColor); rlm@46: rlm@46: } rlm@46: else rlm@46: { rlm@46: vml.setAttribute('filled', 'false'); rlm@46: } rlm@46: rlm@46: rlm@46: if(lineWidth==0 || lineWidth=='none' || lineColor== 'none' ) rlm@46: { rlm@46: vml.setAttribute('stroked', 'false'); rlm@46: } rlm@46: else rlm@46: { rlm@46: rlm@46: vml.setAttribute('stroked', 'true'); rlm@46: vml.setAttribute('strokecolor', lineColor); rlm@46: vml.setAttribute('strokeweight', lineWidth); rlm@46: var stroke = this.container.ownerDocument.createElement('v:stroke'); rlm@46: stroke.setAttribute("opacity", parseFloat(lineOpac)); rlm@46: vml.appendChild(stroke); rlm@46: } rlm@46: rlm@46: if (fillOpac != '') rlm@46: { rlm@46: if (fillOpac == 'none' || fillColor=='none'){fillOpac=0;} rlm@46: var fill = this.container.ownerDocument.createElement('v:fill'); rlm@46: fill.setAttribute("opacity",parseFloat(fillOpac)); rlm@46: //alert(fillOpac) rlm@46: vml.appendChild(fill); rlm@46: } rlm@46: } rlm@46: } rlm@46: if(parent==''){ rlm@46: this.container.appendChild(vml); rlm@46: }else{ rlm@46: var parentShape = document.getElementById(parent); rlm@46: parentShape.appendChild(vml); rlm@46: } rlm@46: //var parentDoc = document.getElementById('mydraw'); rlm@46: //parentDoc.appendChild(vml); rlm@46: return vml; rlm@46: }; rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.zoom = function(clicx,clicy) rlm@46: { rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.datacreate = function(fillColor, lineColor, fillOpac, lineOpac, lineWidth, left, top, width, height, textMessaje, textSize, textFamily, imageHref, transform) rlm@46: { rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.duplicate = function(shape) rlm@46: { rlm@46: var vml; rlm@46: vml =shape.cloneNode(false); rlm@46: //vml.setAttribute('fillcolor', "#aa00aa"); rlm@46: //vml.setAttribute('filled', "false"); rlm@46: this.container.appendChild(vml); rlm@46: return vml; rlm@46: rlm@46: }; rlm@46: rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.index = function(shape,order) { rlm@46: rlm@46: if(order==-1) rlm@46: { rlm@46: this.container.appendChild( shape ); rlm@46: } rlm@46: if(order==0){ rlm@46: rlm@46: this.container.insertBefore( shape, shape.parentNode.firstChild ); rlm@46: } rlm@46: rlm@46: if(order==1 || order==2) rlm@46: { rlm@46: var id=shape.getAttribute('id'); rlm@46: //alert(id); rlm@46: rlm@46: rlm@46: var numNodes=this.container.childNodes.length; rlm@46: //alert(numNodes); rlm@46: rlm@46: var num=0; rlm@46: for(var i = 1; i < numNodes; i++) rlm@46: { rlm@46: rlm@46: var etiq=this.container.childNodes[i].getAttribute('id'); rlm@46: if (etiq==id) rlm@46: { rlm@46: num=i; rlm@46: rlm@46: } rlm@46: } rlm@46: //alert(num); rlm@46: if(order==1) rlm@46: { rlm@46: if((num-1)>=-1) rlm@46: { rlm@46: this.container.insertBefore( shape, this.container.childNodes[num-1]); rlm@46: } rlm@46: } rlm@46: if(order==2){ rlm@46: if((num+1)1) rlm@46: //{ shap.style.position="absolute"; rlm@46: shape.style.width=100+"px"; rlm@46: shape.style.height=100+"px"; rlm@46: shape.style.left=toX+"px"; rlm@46: shape.style.top=toY+"px"; rlm@46: shape.style.margin=0+"px"; rlm@46: shape.style.padding=0+"px"; rlm@46: shape.appendChild(path01); rlm@46: //} rlm@46: } rlm@46: else rlm@46: { rlm@46: shape.style.position="absolute"; rlm@46: shape.style.width= 700+"px"; rlm@46: shape.style.height=500+"px"; rlm@46: shape.style.left="0px"; rlm@46: shape.style.top="0px"; rlm@46: //shape.setAttribute('coordsize', '700,500'); rlm@46: shape.appendChild(path01); rlm@46: } rlm@46: rlm@46: //shape.setAttribute('position', 'absolute'); rlm@46: //shape.translate(xpArray[conta+1]+','+ypArray[conta+1]); rlm@46: //shape.setAttribute('coordsize', '700,500'); rlm@46: // shape.v.Value ='M '+thispath1+ ' C'+thispath2+' x e'; rlm@46: //shape.v.Value = 'M '+thispath+ ' c '+thispath2; rlm@46: //shape.setAttribute("v", 'M '+thispath+ ' C '+thispath2); rlm@46: //shape.setAttribute('path','M '+thispath+ ' C '+thispath2); rlm@46: } rlm@46: } rlm@46: rlm@46: }; rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.tocurve = function() { rlm@46: rlm@46: rlm@46: }; rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.info = function(shape) rlm@46: { rlm@46: var shInfo = {}; rlm@46: shInfo.id = shape.id; rlm@46: shInfo.type = shape.tagName; rlm@46: if (shape.tagName == 'rect') rlm@46: { rlm@46: shInfo.left = parseFloat(shape.getAttribute( 'x')); rlm@46: shInfo.top = parseFloat(shape.getAttribute( 'y')); rlm@46: shInfo.width = parseFloat(shape.getAttribute('width')); rlm@46: shInfo.height = parseFloat(shape.getAttribute('height')); rlm@46: //++ rlm@46: //shInfo.rotate = parseFloat(shape.getAttribute('rotation')); rlm@46: } rlm@46: else if (shape.tagName == 'oval') rlm@46: { rlm@46: shInfo.width = parseFloat(shape.getAttribute('rx'))*2; rlm@46: shInfo.height = parseFloat(shape.getAttribute('ry'))*2; rlm@46: shInfo.left = (shInfo.width * 2) - parseFloat(shape.getAttribute('rx')); rlm@46: shInfo.top = (shInfo.height * 2) - parseFloat(shape.getAttribute('ry')); rlm@46: rlm@46: } rlm@46: else if (shape.tagName == 'roundrect') rlm@46: { rlm@46: shInfo.left = parseFloat(shape.getAttribute('x')); rlm@46: shInfo.top = parseFloat(shape.getAttribute('y')); rlm@46: shInfo.width = parseFloat(shape.getAttribute('width')); rlm@46: shInfo.height = parseFloat(shape.getAttribute('height')); rlm@46: rlm@46: } rlm@46: else if (shape.tagName == 'line') rlm@46: { rlm@46: shInfo.left = parseFloat(shape.getAttribute('x1')); rlm@46: shInfo.top = parseFloat(shape.getAttribute('y1')); rlm@46: rlm@46: } rlm@46: else if (shape.tagName == 'polyline') rlm@46: { rlm@46: shInfo.points = shape.getAttribute('points'); rlm@46: } rlm@46: else if (shape.tagName == 'image') rlm@46: { rlm@46: shInfo.left = parseFloat(shape.getAttribute('x')); rlm@46: shInfo.top = parseFloat(shape.getAttribute('y')); rlm@46: shInfo.width = parseFloat(shape.getAttribute('width')); rlm@46: shInfo.height = parseFloat(shape.getAttribute('height')); rlm@46: shInfo.src = shape.getAttribute('src'); rlm@46: } rlm@46: else rlm@46: rlm@46: if (shape.tagName == 'shape') rlm@46: { rlm@46: if(shape.children[0].tagName=='path') { rlm@46: shInfo.d = shape.getAttribute('v'); rlm@46: this.editor.log(shape.getAttribute('v')); rlm@46: rlm@46: } rlm@46: if(shape.children[0].tagName=='textpath') { rlm@46: shInfo['font-family'] = shape.children[0].getAttribute('font-family') rlm@46: shInfo['font-size'] = parseInt(shape.children[0].getAttribute('font-size')) rlm@46: shInfo.top = parseFloat(shape.children[0].getAttribute('y')) rlm@46: shInfo.left = parseFloat(shape.children[0].getAttribute('x')) rlm@46: shInfo.text = shape.textContent rlm@46: rlm@46: } rlm@46: } rlm@46: return shInfo; rlm@46: rlm@46: rlm@46: } rlm@46: VMLRenderer.prototype.transformShape = function(shape,data,transform) rlm@46: { rlm@46: rlm@46: if(shape.tagName == 'rect') rlm@46: { rlm@46: rlm@46: var box = this.bounds(shape); rlm@46: var sdata=data.split(';'); rlm@46: rlm@46: //alert(data[0]); rlm@46: shape.style.top = parseFloat(sdata[0]) + 'px'; rlm@46: shape.style.left = parseFloat(sdata[1]) + 'px'; rlm@46: shape.style.width = parseFloat(sdata[2]) + 'px'; rlm@46: shape.style.height = parseFloat(sdata[3]) + 'px'; rlm@46: rlm@46: rlm@46: rlm@46: // var centerx=parseFloat(sdata[0])+parseFloat(box.width/2); rlm@46: // var centery=parseFloat(sdata[1])+parseFloat(box.height/2); rlm@46: shape.style.rotation=parseFloat(sdata[4]); rlm@46: rlm@46: //shape.nodparseFloatue=data; rlm@46: } rlm@46: else rlm@46: if(shape.tagName == 'text') rlm@46: { rlm@46: if(data.indexOf('<;>',0)==-1 ) rlm@46: { rlm@46: shape.textContent = data; rlm@46: } rlm@46: else rlm@46: { rlm@46: var sdata=data.split('<;>'); //????????? rlm@46: shape.textContent = sdata[0]; rlm@46: shape.setAttribute('font-size',parseFloat(sdata[1])); rlm@46: shape.setAttribute('font-family',sdata[2]); rlm@46: } rlm@46: //shape.nodparseFloatue=data; rlm@46: } rlm@46: else rlm@46: if (shape.tagName == 'polyline') rlm@46: { rlm@46: shape.setAttribute('points',data); rlm@46: } rlm@46: else rlm@46: if (shape.tagName == 'image') rlm@46: { rlm@46: //alert(data); rlm@46: if(data.indexOf(';',0)==-1 ) rlm@46: { rlm@46: shape.setAttribute('src',data); rlm@46: } rlm@46: else rlm@46: { rlm@46: var box = this.bounds(shape); rlm@46: var sdata=data.split(';'); rlm@46: shape.style.top = parseFloat(sdata[0]) + 'px'; rlm@46: shape.style.left = parseFloat(sdata[1]) + 'px'; rlm@46: shape.style.width = parseFloat(sdata[2]) + 'px'; rlm@46: shape.style.height = parseFloat(sdata[3]) + 'px'; rlm@46: var centerx=parseFloat(sdata[0])+parseFloat(box.width/2); rlm@46: var centery=parseFloat(sdata[1])+parseFloat(box.height/2); rlm@46: shape.style.rotation=parseFloat(sdata[4]); rlm@46: rlm@46: rlm@46: } rlm@46: rlm@46: } rlm@46: else rlm@46: if (shape.tagName == 'path') rlm@46: { rlm@46: if(data.indexOf(';',0)==-1 ) rlm@46: { rlm@46: //shape.setAttribute( 'd', data); //???????? rlm@46: //shape.setAttribute( 'transform', transform); rlm@46: } rlm@46: else rlm@46: { rlm@46: var box = this.bounds(shape); rlm@46: var sdata=data.split(';'); rlm@46: var centerx=parseFloat(sdata[0])+parseFloat(box.width/2); rlm@46: var centery=parseFloat(sdata[1])+parseFloat(box.height/2); rlm@46: //++shape.setAttribute( 'transform','scale('+parseFloat(sdata[2])+','+parseFloat(sdata[3])+')'+' rotate('+parseFloat(sdata[4])+','+centerx+','+centery+')'+' translate('+parseFloat(sdata[0])+','+parseFloat(sdata[1])+')'); rlm@46: rlm@46: rlm@46: } rlm@46: } rlm@46: rlm@46: rlm@46: } rlm@46: VMLRenderer.prototype.editShape = function(shape,data) rlm@46: { rlm@46: if(shape.tagName == 'text'){ rlm@46: shape.textContent = data rlm@46: }else rlm@46: if (shape.tagName == 'polyline') rlm@46: { rlm@46: shape.setAttribute('points',data); rlm@46: } rlm@46: else rlm@46: rlm@46: if (shape.tagName == 'path') rlm@46: { rlm@46: shape.setAttribute('v', data); rlm@46: rlm@46: } rlm@46: rlm@46: rlm@46: } rlm@46: VMLRenderer.prototype.editCommand = function(shape, cmd, value) rlm@46: { rlm@46: if (shape != null) { rlm@46: if (cmd == 'fillcolor') { rlm@46: if (value != '') { rlm@46: shape.filled = 'true'; rlm@46: shape.fillcolor = value; rlm@46: } rlm@46: else { rlm@46: shape.filled = 'false'; rlm@46: shape.fillcolor = ''; rlm@46: } rlm@46: } rlm@46: else if (cmd == 'linecolor') { rlm@46: if (value != '') { rlm@46: shape.stroked = 'true'; rlm@46: shape.strokecolor = value; rlm@46: } rlm@46: else { rlm@46: shape.stroked = 'false'; rlm@46: shape.strokecolor = ''; rlm@46: } rlm@46: } rlm@46: else if (cmd == 'linewidth') { rlm@46: shape.strokeweight = parseInt(value) + 'px'; rlm@46: } rlm@46: else if (cmd == 'fillopacity') { rlm@46: rlm@46: shape.fill.opacity= parseFloat(value); rlm@46: //shape.style.fill.setAttribute("opacity", parseFloat(value)); rlm@46: rlm@46: } rlm@46: } rlm@46: } rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.queryCommand = function(shape, cmd) rlm@46: { rlm@46: if (shape != null) { rlm@46: if (cmd == 'fillcolor') { rlm@46: if (shape.filled == 'false') rlm@46: return ''; rlm@46: else rlm@46: return shape.fillcolor; rlm@46: } rlm@46: else if (cmd == 'linecolor') { rlm@46: if (shape.stroked == 'false') rlm@46: return ''; rlm@46: else rlm@46: return shape.strokecolor; rlm@46: } rlm@46: else if (cmd == 'linewidth') { rlm@46: if (shape.stroked == 'false') { rlm@46: return ''; rlm@46: } rlm@46: else { rlm@46: // VML always transforms the pixels to points, so we have to convert them back rlm@46: return (parseFloat(shape.strokeweight) * (screen.logicalXDPI / 72)) + 'px'; rlm@46: } rlm@46: } rlm@46: } rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.getProperties = function(shape) rlm@46: { rlm@46: var result = ''; rlm@46: rlm@46: if (shape != null) rlm@46: { rlm@46: result = shape.getAttribute('fillcolor'); rlm@46: if (result == 'none') rlm@46: { rlm@46: mefillColor.visible = 'hidden'; rlm@46: mefillColor.hex = '#000000'; rlm@46: filldraw=true; rlm@46: setbe(1,'img_okfill'); rlm@46: } rlm@46: else rlm@46: { rlm@46: //alert(mefillColor.hex+' '+result); rlm@46: mefillColor.visible = 'visible'; rlm@46: mefillColor.hex = result; rlm@46: var rgb=hex2rgb(result) rlm@46: mefillColor.r=rgb[0]; rlm@46: mefillColor.g=rgb[1]; rlm@46: mefillColor.b=rgb[2]; rlm@46: filldraw=false; rlm@46: setbe(1,'img_okfill'); rlm@46: rlm@46: } rlm@46: rlm@46: result = shape.getAttribute('strokecolor'); rlm@46: if (result == 'none') rlm@46: { rlm@46: mestrokeColor.visible = 'hidden'; rlm@46: mestrokeColor.hex = '#000000'; rlm@46: mestrokeColor.width = 0; rlm@46: strokedraw=true; rlm@46: setbe(2,'img_okstroke'); rlm@46: rlm@46: } rlm@46: else rlm@46: { rlm@46: mestrokeColor.visible = 'visible'; rlm@46: mestrokeColor.hex = result; rlm@46: var rgb=hex2rgb(result) rlm@46: mestrokeColor.r=rgb[0]; rlm@46: mestrokeColor.g=rgb[1]; rlm@46: mestrokeColor.b=rgb[2]; rlm@46: strokedraw=false; rlm@46: setbe(2,'img_okstroke'); rlm@46: rlm@46: } rlm@46: rlm@46: result = shape.getAttribute('strokeweight'); rlm@46: mestrokeColor.width = result; rlm@46: rlm@46: result = shape.fill.getAttribute('opacity'); rlm@46: mefillColor.opacity = result; rlm@46: rlm@46: result = shape.stroke.getAttribute('opacity'); rlm@46: mestrokeColor.opacity = result; rlm@46: rlm@46: setProperties(); rlm@46: } rlm@46: } rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.showMultiSelect = function(iniX,iniY) { rlm@46: var tracker = document.getElementById('trackerMultiSelect'); rlm@46: if (tracker) { rlm@46: this.remove(tracker); rlm@46: } rlm@46: var coord=this.editor.inputxy; rlm@46: toX=parseFloat(coord[0]); rlm@46: toY=parseFloat(coord[1]); rlm@46: rlm@46: tracker = this.container.ownerDocument.createElement('v:rect'); rlm@46: rlm@46: tracker.style.position = 'relative'; rlm@46: tracker.style.left = iniX; rlm@46: tracker.style.top = iniY; rlm@46: tracker.style.width = toX ; rlm@46: tracker.style.height = toY; rlm@46: tracker.setAttribute('filled', 'false'); rlm@46: tracker.setAttribute('stroked', 'true'); rlm@46: tracker.setAttribute('strokecolor', 'blue'); rlm@46: tracker.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: this.container.appendChild(tracker); rlm@46: } rlm@46: rlm@46: function mouseCoord() rlm@46: { rlm@46: var coord=this.editor.inputxy; rlm@46: coord[0]=parseFloat(coord[0]); rlm@46: coord[1]=parseFloat(coord[1]); rlm@46: return coord rlm@46: } rlm@46: rlm@46: var memoNode=null; rlm@46: var memoPrevControl=new Array(); rlm@46: var memoNextControl=new Array(); rlm@46: VMLRenderer.prototype.nodeMove = function(newx,newy) { rlm@46: var mypath=$('control_codebase').value; rlm@46: var x= $('option_path_x').value; rlm@46: var y= $('option_path_y').value; rlm@46: var precoord=x+','+y; rlm@46: rlm@46: $('option_path_x').value=newx; rlm@46: $('option_path_y').value=newy; rlm@46: rlm@46: var cadx= newx; rlm@46: var cady= newy; rlm@46: rlm@46: var coord=cadx+','+cady; rlm@46: var cad1=new RegExp(precoord,"g"); rlm@46: rlm@46: rlm@46: var result=mypath.replace(cad1, coord); rlm@46: rlm@46: rlm@46: $('control_codebase').value=result; rlm@46: rlm@46: $('someinfo').value=precoord; rlm@46: setShape(); rlm@46: rlm@46: } rlm@46: rlm@46: function drawNodeControl(vml,numId){ rlm@46: var color1='#0066ff'; rlm@46: // if(parseInt(memoNode.id)==a){ rlm@46: rlm@46: var pointprev=memoPrevControl[numId].split(','); rlm@46: var controlNode1 = this.container.ownerDocument.createElement('v:rect'); rlm@46: controlNode1.setAttribute('x', pointprev[0]-2); rlm@46: controlNode1.setAttribute('y', pointprev[1]-2); rlm@46: rlm@46: controlNode1.setAttribute('width', 4); rlm@46: controlNode1.setAttribute('height', 4); rlm@46: controlNode1.setAttribute('fillcolor', color1); rlm@46: controlNode1.setAttribute('strokecolor', '#000000'); rlm@46: controlNode1.setAttribute('strokeweight', '0'); rlm@46: controlNode1.setAttribute('id', 'controlNode1'); rlm@46: controlNode1.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttribute('strokeweight', 0 );} memoNode=this; this.setAttribute('fillcolor', '#ffff00' );this.setAttribute('strokeweight', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttribute('x'))+2; $('option_path_y').value=parseFloat(this.getAttribute('y'))+2; }, false); rlm@46: vml.appendChild(controlNode1); rlm@46: rlm@46: var pointnext=memoNextControl[numId].split(','); rlm@46: rlm@46: rlm@46: var controlNode2 =this.container.ownerDocument.createElement('v:rect'); rlm@46: controlNode2.setAttribute('x', pointnext[0]-2); rlm@46: controlNode2.setAttribute('y', pointnext[1]-2); rlm@46: rlm@46: controlNode2.setAttribute('width', 4); rlm@46: controlNode2.setAttribute('height', 4); rlm@46: controlNode2.setAttribute('fillcolor', color1); rlm@46: controlNode2.setAttribute('strokecolor', '#000000'); rlm@46: controlNode2.setAttribute('strokeweight', '0'); rlm@46: controlNode2.setAttribute('id', 'controlNode1'); rlm@46: controlNode2.addEventListener("mousedown", function(event) {if(memoNode != null){memoNode.setAttribute('strokeweight', 0 );} memoNode=this; this.setAttribute('fillcolor', '#ffff00' );this.setAttribute('strokeweight', 1 );$('option_path_num').value=this.getAttributeNS(null,'id'); $('option_path_x').value=parseFloat(this.getAttribute('x'))+2; $('option_path_y').value=parseFloat(this.getAttribute('y'))+2; }, false); rlm@46: vml.appendChild(controlNode2); rlm@46: rlm@46: //} rlm@46: rlm@46: rlm@46: } rlm@46: rlm@46: VMLRenderer.prototype.showNodesCurve = function(path){ rlm@46: var points=path.split('c'); rlm@46: var chain=''; rlm@46: var segment=' '; rlm@46: var numpoints=points.length-1; rlm@46: for(var a=1;a max.x) { rlm@46: max.x = x; rlm@46: } rlm@46: if (y < min.y) { rlm@46: min.y = y; rlm@46: } rlm@46: else if (y > max.y) { rlm@46: max.y = y; rlm@46: } rlm@46: } rlm@46: rlm@46: rlm@46: var border_square = this.container.ownerDocument.createElement('v:rect'); rlm@46: rlm@46: border_square.style.position = 'relative'; rlm@46: border_square.style.left = 0 - 10; rlm@46: border_square.style.top = 0 - 10; rlm@46: border_square.style.width = box.width + 20; rlm@46: border_square.style.height = box.height + 20; rlm@46: border_square.setAttribute('filled', 'false'); rlm@46: border_square.setAttribute('stroked', 'true'); rlm@46: border_square.setAttribute('strokecolor', 'blue'); rlm@46: border_square.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: rlm@46: var border_angle = this.container.ownerDocument.createElement('v:polyline'); rlm@46: border_angle.style.position = 'relative'; rlm@46: rlm@46: //border_angle.setAttribute('from',(box.width+10) + 'px,' + (box.height/2) + 'px'); rlm@46: //border_angle.setAttribute('to', (box.width+10+25) + 'px,' + (box.width+10) + 'px'); rlm@46: border_angle.setAttribute('filled', 'false'); rlm@46: border_angle.setAttribute('stroked', 'true'); rlm@46: border_angle.setAttribute('strokecolor', 'blue'); rlm@46: border_angle.setAttribute('strokeweight', '1px'); rlm@46: border_angle.setAttribute("points", (box.width+10)+","+((box.height/2))+", " rlm@46: +(box.width+10+25)+","+((box.height/2)) ); rlm@46: rlm@46: rlm@46: /* var path01 = this.container.ownerDocument.createElement('v:path'); rlm@46: //path01.setAttribute("v", "m "+thispath+" c"+ thispath2+" e "); rlm@46: path01.setAttribute("v", "m"+(min.x-10)+","+ (min.y-10)+" r"+(box.width+20)+","+(0)+" r"+(0)+","+(box.height+20)+" r"+(-box.width-20)+','+(0)+"x e m"+(box.x+box.width+10)+","+ (box.y+(box.height/2))+" r"+(25)+",0 e "); rlm@46: border.appendChild(path01) rlm@46: */ rlm@46: //border.setAttribute('stroke-width', '1'); rlm@46: rlm@46: // createRect(min.x, min.y, max.x - min.x, max.y - min.y); rlm@46: rlm@46: rlm@46: /* tracker = this.container.ownerDocument.createElement('v:rect'); rlm@46: tracker.id = 'tracker'; rlm@46: tracker.style.position = 'absolute'; rlm@46: tracker.style.left = box.x - 10; rlm@46: tracker.style.top = box.y - 10; rlm@46: tracker.style.width = box.width + 20; rlm@46: tracker.style.height = box.height + 20; rlm@46: tracker.setAttribute('filled', 'false'); rlm@46: tracker.setAttribute('stroked', 'true'); rlm@46: tracker.setAttribute('strokecolor', 'blue'); rlm@46: tracker.setAttribute('strokeweight', '1px'); rlm@46: this.container.appendChild(tracker); rlm@46: */ rlm@46: var circle1 = this.container.ownerDocument.createElement('v:oval'); rlm@46: circle1.style.position = 'relative'; rlm@46: circle1.style.left = ( (box.width+40)-5); rlm@46: circle1.style.top = ( (box.height / 2) -5); rlm@46: circle1.style.width = (10); rlm@46: circle1.style.height = (10); rlm@46: circle1.setAttribute('filled', 'true'); rlm@46: circle1.setAttribute('stroked', 'true'); rlm@46: circle1.setAttribute('fillcolor', '#ffffff'); rlm@46: circle1.setAttribute('strokecolor', 'green'); rlm@46: circle1.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: rlm@46: var rect1 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rect1.style.position = 'relative'; rlm@46: rect1.style.left = - 10-5; rlm@46: rect1.style.top = - 10-5; rlm@46: rect1.style.width = 10; rlm@46: rect1.style.height = 10; rlm@46: rect1.setAttribute('filled', 'true'); rlm@46: rect1.setAttribute('stroked', 'true'); rlm@46: rect1.setAttribute('fillcolor', '#ffffff'); rlm@46: rect1.setAttribute('strokecolor', 'green'); rlm@46: rect1.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: rlm@46: var rect2 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rect2.style.position = 'relative'; rlm@46: rect2.style.left = box.width +5; rlm@46: rect2.style.top = -10 -5; rlm@46: rect2.style.width = 10; rlm@46: rect2.style.height = 10; rlm@46: rect2.setAttribute('filled', 'true'); rlm@46: rect2.setAttribute('stroked', 'true'); rlm@46: rect2.setAttribute('fillcolor', '#ffffff'); rlm@46: rect2.setAttribute('strokecolor', 'green'); rlm@46: rect2.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: rlm@46: var rect3 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rect3.style.position = 'relative'; rlm@46: rect3.style.left = box.width+5; rlm@46: rect3.style.top = box.height+5; rlm@46: rect3.style.width = 10; rlm@46: rect3.style.height = 10; rlm@46: rect3.setAttribute('filled', 'true'); rlm@46: rect3.setAttribute('stroked', 'true'); rlm@46: rect3.setAttribute('fillcolor', '#ffffff'); rlm@46: rect3.setAttribute('strokecolor', 'green'); rlm@46: rect3.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: var rect4 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rect4.style.position = 'relative'; rlm@46: rect4.style.left = -10-5; rlm@46: rect4.style.top = box.height+5; rlm@46: rect4.style.width = 10; rlm@46: rect4.style.height = 10; rlm@46: rect4.setAttribute('filled', 'true'); rlm@46: rect4.setAttribute('stroked', 'true'); rlm@46: rect4.setAttribute('fillcolor', '#ffffff'); rlm@46: rect4.setAttribute('strokecolor', 'green'); rlm@46: rect4.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: rlm@46: rlm@46: var rectmid12 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rectmid12.style.position = 'relative'; rlm@46: rectmid12.style.left = (box.width/2) -5; rlm@46: rectmid12.style.top =- 10-5; rlm@46: rectmid12.style.width = 10; rlm@46: rectmid12.style.height = 10; rlm@46: rectmid12.setAttribute('filled', 'true'); rlm@46: rectmid12.setAttribute('stroked', 'true'); rlm@46: rectmid12.setAttribute('fillcolor', '#ffffff'); rlm@46: rectmid12.setAttribute('strokecolor', 'green'); rlm@46: rectmid12.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: var rectmid23 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rectmid23.style.position = 'relative'; rlm@46: rectmid23.style.left = box.width +5; rlm@46: rectmid23.style.top = (box.height/2)-5; rlm@46: rectmid23.style.width = 10; rlm@46: rectmid23.style.height = 10; rlm@46: rectmid23.setAttribute('filled', 'true'); rlm@46: rectmid23.setAttribute('stroked', 'true'); rlm@46: rectmid23.setAttribute('fillcolor', '#ffffff'); rlm@46: rectmid23.setAttribute('strokecolor', 'green'); rlm@46: rectmid23.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: var rectmid34 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rectmid34.style.position = 'relative'; rlm@46: rectmid34.style.left = (box.width/2)-5; rlm@46: rectmid34.style.top = box.height+5; rlm@46: rectmid34.style.width = 10; rlm@46: rectmid34.style.height = 10; rlm@46: rectmid34.setAttribute('filled', 'true'); rlm@46: rectmid34.setAttribute('stroked', 'true'); rlm@46: rectmid34.setAttribute('fillcolor', '#ffffff'); rlm@46: rectmid34.setAttribute('strokecolor', 'green'); rlm@46: rectmid34.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: rlm@46: var rectmid41 = this.container.ownerDocument.createElement('v:rect'); rlm@46: rectmid41.style.position = 'relative'; rlm@46: rectmid41.style.left = -10-5 ; rlm@46: rectmid41.style.top =(box.height/2)-5; rlm@46: rectmid41.style.width = 10; rlm@46: rectmid41.style.height = 10; rlm@46: rectmid41.setAttribute('filled', 'true'); rlm@46: rectmid41.setAttribute('stroked', 'true'); rlm@46: rectmid41.setAttribute('fillcolor', '#ffffff'); rlm@46: rectmid41.setAttribute('strokecolor', 'green'); rlm@46: rectmid41.setAttribute('strokeweight', '1px'); rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: var colorin="#ff0000"; rlm@46: var colorout="#ffffff" rlm@46: rlm@46: circle1.attachEvent("onmouseover", function(event) {circle1.style.cursor= 's-resize'; circle1.setAttribute('fillcolor', colorin ); typeTransform='Rotate'; scaleType='nw'; }, false); rlm@46: circle1.attachEvent("onmouseout", function(event) {circle1.style.cursor= 'default'; circle1.setAttribute('fillcolor', colorout ); typeTransform='Rotate'; }, false); //typeTransform='rotate' rlm@46: rlm@46: rlm@46: rect1.attachEvent("onmouseover", function(event) {rect1.style.cursor= 'nw-resize'; rect1.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='nw'; }, false); rlm@46: rect1.attachEvent("onmouseout", function(event) {rect1.style.cursor= 'default'; rect1.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); //typeTransform='rotate' rlm@46: rlm@46: rect2.attachEvent("onmouseover", function(event) {rect2.style.cursor= 'ne-resize'; rect2.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='ne';}, false); rlm@46: rect2.attachEvent("onmouseout", function(event) {rect2.style.cursor= 'default'; rect2.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); rlm@46: rlm@46: rect3.attachEvent("onmouseover", function(event) {rect3.style.cursor= 'se-resize'; rect3.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='se';}, false); rlm@46: rect3.attachEvent("onmouseout", function(event) {rect3.style.cursor= 'default'; rect3.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); rlm@46: rlm@46: rect4.attachEvent("onmouseover", function(event) {rect4.style.cursor= 'sw-resize'; rect4.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='sw';}, false); rlm@46: rect4.attachEvent("onmouseout", function(event) {rect4.style.cursor= 'default'; rect4.setAttribute('fillcolor', colorout ); typeTransform='Scale'; }, false); rlm@46: rlm@46: rectmid12.attachEvent("onmouseover", function(event) {rectmid12.style.cursor= 'n-resize'; rectmid12.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='n';}, false); rlm@46: rectmid12.attachEvent("onmouseout", function(event) {rectmid12.style.cursor= 'default'; rectmid12.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); rlm@46: rlm@46: rectmid23.attachEvent("onmouseover", function(event) {rectmid23.style.cursor= 'e-resize'; rectmid23.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='e';}, false); rlm@46: rectmid23.attachEvent("onmouseout", function(event) {rectmid23.style.cursor= 'default'; rectmid23.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); rlm@46: rlm@46: rectmid34.attachEvent("onmouseover", function(event) {rectmid34.style.cursor= 's-resize'; rectmid34.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='s';}, false); rlm@46: rectmid34.attachEvent("onmouseout", function(event) {rectmid34.style.cursor= 'default'; rectmid34.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); rlm@46: rlm@46: rectmid41.attachEvent("onmouseover", function(event) {rectmid41.style.cursor= 'w-resize'; rectmid41.setAttribute('fillcolor', colorin ); typeTransform='Scale'; scaleType='w'; }, false); rlm@46: rectmid41.attachEvent("onmouseout", function(event) {rectmid41.style.cursor= 'default'; rectmid41.setAttribute('fillcolor', colorout ); typeTransform=''; }, false); rlm@46: //tracker.setAttribute('transform',trshape); rlm@46: rlm@46: rlm@46: rlm@46: tracker.appendChild(border_square); rlm@46: tracker.appendChild(border_angle); rlm@46: rlm@46: tracker.appendChild(circle1); rlm@46: rlm@46: tracker.appendChild(rect1); rlm@46: tracker.appendChild(rect2); rlm@46: tracker.appendChild(rect3); rlm@46: tracker.appendChild(rect4); rlm@46: tracker.appendChild(rectmid12); rlm@46: tracker.appendChild(rectmid23); rlm@46: tracker.appendChild(rectmid34); rlm@46: tracker.appendChild(rectmid41); rlm@46: rlm@46: /* rlm@46: rlm@46: rlm@46: rlm@46: */ rlm@46: rlm@46: rlm@46: this.container.appendChild(tracker); rlm@46: rlm@46: rlm@46: rlm@46: } rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.getMarkup = function() { rlm@46: rlm@46: return this.container.innerHTML; rlm@46: } rlm@46: rlm@46: rlm@46: rlm@46: ///////////////////////////////// rlm@46: rlm@46: rlm@46: rlm@46: var rotatexxx=0; rlm@46: rlm@46: var scaleType=''; rlm@46: var xrot=0; rlm@46: var yrot=0; rlm@46: rlm@46: var point = {x:0, y:0, width: 0, height:0}; rlm@46: rlm@46: function createPoint (x, y, width, height) { rlm@46: //var point = {x:34, y:22, width: 22, height:23}; rlm@46: //point.x = x; rlm@46: //point.y = y; rlm@46: point = {x:x, y:y, width: width, height:height}; rlm@46: return point; rlm@46: } rlm@46: rlm@46: rlm@46: ///////////////////////////////// rlm@46: rlm@46: VMLRenderer.prototype.restruct= function(shape) rlm@46: { rlm@46: }; rlm@46: rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.transform = function() { rlm@46: rlm@46: }; rlm@46: rlm@46: VMLRenderer.prototype.scaleShape = function(shape, previus,toX, toY) { rlm@46: // document.forms[0].code.value="escala"; rlm@46: rlm@46: //document.forms[0].code.value="escala"; rlm@46: var box = this.bounds(shape); rlm@46: var prevbox=this.bounds(previus); rlm@46: var centerx= box.x+(box.width/2); rlm@46: var centery= box.y+(box.height/2); rlm@46: var coord=this.editor.inputxy; rlm@46: toX=parseFloat(coord[0]); rlm@46: toY=parseFloat(coord[1]); rlm@46: var d2p_center=dist2p(centerx,centery,toX,toY); rlm@46: rlm@46: var d2p=dist2p(box.x,box.y,toX,toY); rlm@46: rlm@46: var shareScale=box.width/d2p; rlm@46: rlm@46: var trans_ShareScale=''; rlm@46: var tx, ty, tw, yh; rlm@46: rlm@46: if(scaleType.length==1){ rlm@46: if(scaleType== 'w') rlm@46: { rlm@46: trans_ShareScale=shareScale+",1"; rlm@46: tx=toX; rlm@46: ty=prevbox.y; rlm@46: var dist=prevbox.x-toX; rlm@46: var w=dist+prevbox.width; rlm@46: if(w<1){w=1;} rlm@46: tw=w; rlm@46: th=prevbox.height; rlm@46: //document.forms[0].code.value=box.x+' '+toX+' '+dist+''; rlm@46: } rlm@46: if(scaleType== 'e') rlm@46: { rlm@46: trans_ShareScale=shareScale+",1"; rlm@46: tx=prevbox.x; rlm@46: ty=prevbox.y; rlm@46: var dist=toX-(prevbox.x+prevbox.width); //dist2p(toX,b,c,d); rlm@46: var w=dist+prevbox.width; rlm@46: if(w<1){w=1;} rlm@46: tw=w; rlm@46: th=prevbox.height; rlm@46: rlm@46: } rlm@46: if(scaleType== 'n') rlm@46: { rlm@46: trans_ShareScale="1,"+shareScale; rlm@46: rlm@46: tx=prevbox.x; rlm@46: ty=toY; rlm@46: var dist=prevbox.y-toY; rlm@46: var h=dist+prevbox.height; rlm@46: if(h<1){h=1;} rlm@46: tw=prevbox.width; rlm@46: th=h; rlm@46: rlm@46: } rlm@46: if( scaleType== 's') rlm@46: { rlm@46: trans_ShareScale="1,"+shareScale; rlm@46: rlm@46: tx=prevbox.x; rlm@46: ty=prevbox.y; rlm@46: var dist=toY-(prevbox.y+prevbox.height); //dist2p(toX,b,c,d); rlm@46: var h=dist+prevbox.height; rlm@46: if(h<1){h=1;} rlm@46: tw=prevbox.width; rlm@46: th=h; rlm@46: rlm@46: } rlm@46: } rlm@46: if(scaleType.length==2){ rlm@46: if(scaleType== 'nw'){ rlm@46: trans_ShareScale=shareScale+","+shareScale; rlm@46: rlm@46: //var angle_diagonal=getAngle(prevbox.width,prevbox.height); rlm@46: var angle_diagonal=ang2v(prevbox.x,prevbox.y,prevbox.x+prevbox.width,prevbox.y+prevbox.height) rlm@46: rlm@46: var ax= prevbox.x; rlm@46: var ay= prevbox.y; rlm@46: var bx= prevbox.x+prevbox.width; rlm@46: var by= prevbox.y+prevbox.height; rlm@46: rlm@46: var cx= toX; rlm@46: var cy= toY; rlm@46: var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); rlm@46: var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); rlm@46: var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: this.editor.log(angle_diagonal* 180 / Math.PI); rlm@46: rlm@46: var tx= section_a[1]; rlm@46: var ty= section_a[2]; rlm@46: rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= 0; rlm@46: var by= section_a[2] ; rlm@46: rlm@46: var cx=prevbox.x+prevbox.width; rlm@46: var cy= prevbox.y; rlm@46: rlm@46: var dx= prevbox.x+prevbox.width; rlm@46: var dy= 0; rlm@46: rlm@46: rlm@46: var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); rlm@46: rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= section_a[1] rlm@46: var by= 0; rlm@46: rlm@46: var cx= prevbox.x; rlm@46: var cy= prevbox.y+prevbox.height; rlm@46: rlm@46: var dx= 0; rlm@46: var dy= prevbox.y+prevbox.height; rlm@46: rlm@46: rlm@46: var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: if(distx<1){distx=1;} rlm@46: rlm@46: rlm@46: if(disty<1){disty=1;} rlm@46: //document.forms[0].code.value=distx+' '+disty; rlm@46: tw=distx; rlm@46: th=disty; rlm@46: rlm@46: rlm@46: } rlm@46: rlm@46: //////////////////// SE rlm@46: rlm@46: if( scaleType== 'se'){ rlm@46: trans_ShareScale=shareScale+","+shareScale; rlm@46: rlm@46: rlm@46: //var angle_diagonal=getAngle(prevbox.width,prevbox.height); rlm@46: var angle_diagonal=ang2v(prevbox.x,prevbox.y,prevbox.x+prevbox.width,prevbox.y+prevbox.height) rlm@46: rlm@46: rlm@46: rlm@46: var ax= prevbox.x; rlm@46: var ay= prevbox.y; rlm@46: var bx= prevbox.x+prevbox.width; rlm@46: var by= prevbox.y+prevbox.height; rlm@46: rlm@46: var cx= toX; rlm@46: var cy= toY; rlm@46: var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); rlm@46: var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); rlm@46: rlm@46: var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: rlm@46: rlm@46: ////////// rlm@46: var tx= prevbox.x; rlm@46: var ty= prevbox.y; rlm@46: rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= 0; rlm@46: var by= section_a[2] ; rlm@46: rlm@46: var cx=prevbox.x; rlm@46: var cy= prevbox.y; rlm@46: rlm@46: var dx= prevbox.x; rlm@46: var dy= 0; rlm@46: rlm@46: rlm@46: var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: ///////////////// rlm@46: rlm@46: rlm@46: var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); rlm@46: rlm@46: rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= section_a[1] rlm@46: var by= 0; rlm@46: rlm@46: var cx= prevbox.x; rlm@46: var cy= prevbox.y; rlm@46: rlm@46: var dx=0; rlm@46: var dy= prevbox.y; rlm@46: rlm@46: rlm@46: var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: /////////////// rlm@46: rlm@46: var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); rlm@46: rlm@46: rlm@46: rlm@46: if(distx<1){distx=1;} rlm@46: rlm@46: rlm@46: if(disty<1){disty=1;} rlm@46: rlm@46: tw=distx; rlm@46: th=disty; rlm@46: rlm@46: rlm@46: } rlm@46: rlm@46: if(scaleType== 'ne'){ rlm@46: rlm@46: trans_ShareScale=shareScale+","+shareScale; rlm@46: rlm@46: var angle_diagonal=ang2v(prevbox.x,prevbox.y+prevbox.height,prevbox.x+prevbox.width,prevbox.y) rlm@46: //var angle_diagonal=getAngle(prevbox.width,prevbox.height); rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: var ax= prevbox.x; rlm@46: var ay= prevbox.y+prevbox.height; rlm@46: var bx= prevbox.x+prevbox.width; rlm@46: var by= prevbox.y; rlm@46: rlm@46: var cx= toX; rlm@46: var cy= toY; rlm@46: var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); rlm@46: var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); rlm@46: rlm@46: rlm@46: this.editor.log(angle_diagonal); rlm@46: rlm@46: rlm@46: var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: rlm@46: rlm@46: ////////// rlm@46: var tx= prevbox.x; rlm@46: var ty= section_a[2]; rlm@46: rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= 0; rlm@46: var by= section_a[2] ; rlm@46: rlm@46: var cx=prevbox.x; rlm@46: var cy= prevbox.y; rlm@46: rlm@46: var dx= prevbox.x; rlm@46: var dy= 0; rlm@46: rlm@46: rlm@46: var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: ///////////////// rlm@46: rlm@46: rlm@46: var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); rlm@46: rlm@46: rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= section_a[1]; rlm@46: var by= 0; rlm@46: rlm@46: var cx= prevbox.x; rlm@46: var cy= prevbox.y+prevbox.height; rlm@46: rlm@46: var dx=0; rlm@46: var dy= prevbox.y+prevbox.height; rlm@46: rlm@46: rlm@46: var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: /////////////// rlm@46: rlm@46: var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); rlm@46: rlm@46: rlm@46: rlm@46: if(distx<1){distx=1;} rlm@46: rlm@46: rlm@46: if(disty<1){disty=1;} rlm@46: //document.forms[0].code.value=distx+' '+disty; rlm@46: tw=distx; rlm@46: th=disty; rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: } rlm@46: if(scaleType== 'sw'){ rlm@46: trans_ShareScale=shareScale+","+shareScale; rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: var angle_diagonal=ang2v(prevbox.x,prevbox.y+prevbox.height,prevbox.x+prevbox.width,prevbox.y) rlm@46: //var angle_diagonal=getAngle(prevbox.width,prevbox.height); rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: var ax= prevbox.x; rlm@46: var ay= prevbox.y+prevbox.height; rlm@46: var bx= prevbox.x+prevbox.width; rlm@46: var by= prevbox.y; rlm@46: rlm@46: var cx= toX; rlm@46: var cy= toY; rlm@46: var dx= toX+10*Math.cos(angle_diagonal+(Math.PI/2)); rlm@46: var dy= toY+10*Math.sin(angle_diagonal+(Math.PI/2)); rlm@46: rlm@46: rlm@46: this.editor.log(angle_diagonal); rlm@46: rlm@46: rlm@46: var section_a=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: rlm@46: rlm@46: ////////// rlm@46: var tx= section_a[1]; rlm@46: var ty= prevbox.y; rlm@46: rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= 0; rlm@46: var by= section_a[2] ; rlm@46: rlm@46: var cx=prevbox.x+prevbox.width; rlm@46: var cy= prevbox.y+prevbox.height; rlm@46: rlm@46: var dx= prevbox.x+prevbox.width; rlm@46: var dy= 0; rlm@46: rlm@46: rlm@46: var section_b=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: var distx=dist2p(section_a[1],section_a[2],section_b[1],section_b[2]); rlm@46: rlm@46: ///////////////// rlm@46: var ax= section_a[1]; rlm@46: var ay= section_a[2]; rlm@46: var bx= section_a[1]; rlm@46: var by= 0; rlm@46: rlm@46: var cx= prevbox.x; rlm@46: var cy= prevbox.y; rlm@46: rlm@46: var dx=0; rlm@46: var dy= prevbox.y; rlm@46: rlm@46: rlm@46: var section_c=ntrsccn2rb(ax,ay,bx,by,cx,cy,dx,dy); rlm@46: var disty=dist2p(section_a[1],section_a[2],section_c[1],section_c[2]); rlm@46: /////////////// rlm@46: rlm@46: rlm@46: rlm@46: if(distx<1){distx=1;} rlm@46: rlm@46: rlm@46: if(disty<1){disty=1;} rlm@46: //document.forms[0].code.value=distx+' '+disty; rlm@46: tw=distx; rlm@46: th=disty; rlm@46: rlm@46: } rlm@46: rlm@46: } rlm@46: rlm@46: rlm@46: rlm@46: if(shape.tagName == 'rect') rlm@46: { rlm@46: //alert(data[0]); rlm@46: rlm@46: rlm@46: shape.style.left = tx + 'px'; rlm@46: shape.style.top = ty + 'px'; rlm@46: shape.style.height = th + 'px'; rlm@46: shape.style.width = tw + 'px'; rlm@46: rlm@46: } rlm@46: else rlm@46: if(shape.tagName == 'text') rlm@46: { rlm@46: /* rlm@46: shape.setAttribute('x',tx); rlm@46: shape.setAttribute('y',ty); rlm@46: shape.setAttribute('width', tw); rlm@46: shape.setAttribute('height', th); rlm@46: rlm@46: //previus.setAttribute('transform', "scale("+trans_ShareScale+")"); rlm@46: shape.setAttribute('x', tx + 'px'); rlm@46: shape.setAttribute('y', ty + 'px'); rlm@46: rlm@46: shape.setAttribute('textLength', parseInt(Math.round(tw))); rlm@46: rlm@46: */ rlm@46: } rlm@46: else rlm@46: if(shape.tagName == 'oval') rlm@46: { rlm@46: //shape.getAttribute('transform) rlm@46: rlm@46: shape.style.left = tx + 'px'; rlm@46: shape.style.top = ty + 'px'; rlm@46: shape.style.height = th + 'px'; rlm@46: shape.style.width = tw + 'px'; rlm@46: rlm@46: rlm@46: } rlm@46: else rlm@46: if(shape.tagName == 'line') rlm@46: { rlm@46: shape.setAttribute('to',tx + 'px,' + ty + 'px'); rlm@46: shape.setAttribute('from', tw + 'px,' + th + 'px'); rlm@46: rlm@46: rlm@46: } rlm@46: else rlm@46: if (shape.tagName == 'polyline') rlm@46: { rlm@46: rlm@46: } rlm@46: else rlm@46: if (shape.tagName == 'image') rlm@46: { rlm@46: rlm@46: shape.style.left = tx + 'px'; rlm@46: shape.style.top = ty + 'px'; rlm@46: shape.style.height = th + 'px'; rlm@46: shape.style.width = tw + 'px'; rlm@46: rlm@46: } rlm@46: else rlm@46: if (shape.tagName == 'shape') rlm@46: { rlm@46: rlm@46: shape.style.left = tx + 'px'; rlm@46: shape.style.top = ty + 'px'; rlm@46: shape.style.height = th + 'px'; rlm@46: shape.style.width = tw + 'px'; rlm@46: rlm@46: //document.forms[0].code.value=''; rlm@46: //shape.setAttribute('transform', "scale("+trans_ShareScale+")"); rlm@46: rlm@46: } rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: }; rlm@46: rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.rotateShape = function(shape, previus,toX, toY) { rlm@46: rlm@46: rlm@46: rlm@46: //document.forms[0].code.value=$('xyinput').innerHTML; rlm@46: //document.getElementById('richdraw').style.cursor='e-resize'; rlm@46: var box = this.bounds(shape); rlm@46: var prevbox=this.bounds(previus); rlm@46: var centerx= box.x+(box.width/2); rlm@46: var centery= box.y+(box.height/2); rlm@46: var coord=this.editor.inputxy; rlm@46: rlm@46: var actual_angle=ang2v(centerx,centery,coord[0], coord[1]); rlm@46: rlm@46: if(xrot"9"?p:""; rlm@46: n = Math.round(c.substring(d!="") * 100); rlm@46: l+= (d+n+" "); rlm@46: } rlm@46: LX[i] = l; rlm@46: code = ''; rlm@46: VML.insertAdjacentHTML("beforeEnd",code); rlm@46: } else { rlm@46: L[i] = LX[i] = "" rlm@46: VML.insertAdjacentHTML("beforeEnd",""); rlm@46: } rlm@46: } rlm@46: */ rlm@46: //http://msdn2.microsoft.com/en-us/library/bb263897(VS.85).aspx rlm@46: //http://www.w3.org/TR/NOTE-VML rlm@46: //http://trac.openlayers.org/changeset/5285 rlm@46: //http://vectorconverter.sourceforge.net/index.html rlm@46: //http://www.dhteumeuleu.com/colorsyntax/viewJS.php?src=svg2vml1.html rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.getshapes = function(){ rlm@46: return this.container.childNodes; rlm@46: } rlm@46: rlm@46: rlm@46: VMLRenderer.prototype.reflect = function(HorV) { rlm@46: }; rlm@46: rlm@46: rlm@46: rlm@46: