Mercurial > laserkard
view onlypaths/js/format_mini.js @ 55:41d66ff99136 laserkard
[svn r56] FINALLY got that damn copyright working
author | rlm |
---|---|
date | Wed, 17 Feb 2010 02:26:33 -0500 |
parents | 26c2b3ad21c7 |
children |
line wrap: on
line source
1 /*2 JSON Richdraw Abstraction Layer4 ---------------------5 Also,7 JSON Rich Draw Format9 ---------------------12 What data is not stored (yet)13 -Transforms15 */19 function canvas(richdraw,format){20 var rawshapes = richdraw.getshapes()21 var newshapes = [];22 for(var i = 0; i < rawshapes.length; i++){23 newshapes.push(richdraw.renderer.info(rawshapes[i]));24 }25 return newshapes;26 }29 var fullscreen=false;30 function load(code,draw)31 {33 var noattachlistener=false;34 var renderdoc=false;35 var renderinfo=false36 for(var i = 0; i < code.length; i++)37 {38 var rendering=true;40 if(code[i].type == "info")41 {42 rendering=false;43 renderinfo=true;44 if(code[i].loop!=null)45 {46 timerNext=code[i].loop;47 }else{48 timerNext=0;49 }50 }52 if(code[i].type == "doc")53 {54 rendering=false;55 renderdoc=true;56 if(fullscreen==false)57 {58 draw.renderer.view(59 code[i].left,60 code[i].top,61 code[i].width,62 code[i].height,63 code[i].viewBox,64 (code[i].bgcolor!=null)?code[i].fillColor:""65 );66 }67 else68 {69 draw.renderer.view(70 0,71 0,72 screenW,73 screenH,74 code[i].viewBox,75 ''76 );77 }78 }80 if( rendering==true)81 {82 var co = draw.renderer.create(code[i].type,83 (code[i].fillColor!=null)?code[i].fillColor:"",84 (code[i].lineColor)?code[i].lineColor:"",85 (code[i].fillOpac)?code[i].fillOpac:"",86 (code[i].lineOpac)?code[i].lineOpac:"",87 (code[i].lineWidth)?code[i].lineWidth:"",88 (code[i].left)?code[i].left:"",89 (code[i].top)?code[i].top:"",90 (code[i].width)?code[i].width:"",91 (code[i].height)?code[i].height:"",92 (code[i].text)?code[i].text:'',93 (code[i].textSize)?code[i].textSize:"",94 (code[i].textFamily)?code[i].textFamily:'Arial',95 (code[i].href)?code[i].href:'',96 (code[i].points)?code[i].points:'',97 (code[i].transform)?code[i].transform:'',98 (code[i].parent)?code[i].parent:'');100 co.id = ""+code[i].id;101 if (!noattachlistener)102 {103 Ext.get(co).on("mousedown", draw.onHit, draw);105 /*106 co.addEventListener("click", function(event) { myfunction(this.id,draw,event); }, false);107 co.addEventListener("mouseover", function(event) {myOverFunction(this.id,draw,event); }, false);108 co.addEventListener("mouseout", function(event) {myOutFunction(this.id,draw,event); }, false);109 co.addEventListener("mouseup", function(event) {myUpFunction(this.id,draw,event); }, false);110 co.addEventListener("mousedown", function(event) {myDownFunction(this.id,draw,event); }, false);111 co.addEventListener("mousemove", function(event) {myMoveFunction(this.id,draw,event); }, false);112 co.addEventListener("dblclick", function(event) {myDblclickFunction(this.id,draw,event); }, false);113 */114 }115 }116 }117 if(renderdoc == false)118 {119 if(fullscreen==false)120 {121 draw.renderer.view(0,0,canvasWidth,canvasHeight,'0 0 700 400','');122 }123 else124 {125 draw.renderer.view(0,0,screenW,screenH,'0 0 700 400','');126 }127 }128 if(renderinfo == false)129 {130 }131 }141 function load03(code,richdraw){143 //var co =richdraw.renderer.create('group', '', '', 1, '', '', 0, 0, '', '', '', '', '', '', '', '','');144 //co.id = 'frame'+frameNum;145 // var co ={};146 var renderdoc=false;147 var renderinfo=false148 for(var i = 0; i < code.length; i++){149 // code[i].parent='frame'+frameNum;150 var rendering=true;151 if(code[i].type == "info")152 {153 rendering=false;154 renderinfo=true;155 if(code[i].loop!=null)156 {157 timerNext=code[i].loop;158 }else{159 timerNext=0;160 }161 }162 if(code[i].type == "doc")163 {164 rendering=false;165 renderdoc=true;166 if(fullscreen==false){167 richdraw.renderer.view(168 code[i].left,169 code[i].top,170 code[i].width,171 code[i].height,172 code[i].viewBox173 );174 }else{175 richdraw.renderer.view(176 0,177 0,178 scr_w,179 scr_h,180 code[i].viewBox181 );184 }185 /*richdraw.renderer.view((code[i].left)?code[i].left:NaN,186 (code[i].top)?code[i].top:NaN,187 (code[i].width)?code[i].width:NaN,188 (code[i].height)?code[i].height:NaN,189 (code[i].viewBox)?code[i].viewBox:''190 */192 }194 if( rendering==true)195 {196 var co = richdraw.renderer.create(code[i].type,197 (code[i].fillColor!=null)?code[i].fillColor:"",198 (code[i].lineColor)?code[i].lineColor:"",199 (code[i].fillOpac)?code[i].fillOpac:"",200 (code[i].lineOpac)?code[i].lineOpac:"",201 (code[i].lineWidth)?code[i].lineWidth:"",202 (code[i].left)?code[i].left:"",203 (code[i].top)?code[i].top:"",204 (code[i].width)?code[i].width:"",205 (code[i].height)?code[i].height:"",206 (code[i].text)?code[i].text:'',207 (code[i].textSize)?code[i].textSize:"",208 (code[i].textFamily)?code[i].textFamily:'Arial',209 (code[i].href)?code[i].href:'',210 (code[i].points)?code[i].points:'',211 (code[i].transform)?code[i].transform:'',212 (code[i].parent)?code[i].parent:'');213 //(code[i].filter)?code[i].filter:'');214 if(code[i].id==null){215 var nid='shape:' + createUUID();216 co.id = nid;217 }else{218 co.id = code[i].id;219 }221 //var cad=code[i].points;222 //co.id = ""+code[i].id;223 //co.addEventListener("click", function(event) { myfunction(this.id); }, false);224 //co.addEventListener("mouseover", function(event) {myOverFunction(this.id); }, false);225 //co.addEventListener("mouseout", function(event) {myOutFunction(this.id); }, false);228 }229 Ext.get(co).on("mousedown", richdraw.onHit, richdraw);231 }232 if(renderdoc == false)233 {234 if(fullscreen==false){235 richdraw.renderer.view(0,0,canvasWidth,canvasHeight,'0 0 700 400');236 }else{237 richdraw.renderer.view(0,0,scr_w,scr_h,'0 0 700 400');238 }239 //richdraw.renderer.view(0,0,document.getElementById("richdraw").style.width,document.getElementById("richdraw").style.height,zoominit);241 }243 if(renderinfo == false){245 }247 }249 function load01(code,richdraw){251 for(var i = 0; i < code.length; i++){254 var co = richdraw.renderer.create(code[i].type, //Shape255 (code[i].fillColor)?code[i].fillColor:"red",256 (code[i].lineColor)?code[i].lineColor:"black",257 (code[i].fillOpac)?code[i].fillOpac:1,258 (code[i].lineOpac)?code[i].lineOpac:1,259 (code[i].lineWidth)?code[i].lineWidth:1,260 (code[i].left)?code[i].left:100,261 (code[i].top)?code[i].top:100,262 (code[i].width)?code[i].width:100,263 (code[i].height)?code[i].height:100,264 (code[i].text)?code[i].text:'',265 (code[i].textSize)?code[i].textSize:19,266 (code[i].textFamily)?code[i].textFamily:'Arial',267 (code[i].href)?code[i].href:'',268 (code[i].points)?code[i].points:'',269 (code[i].transform)?code[i].transform:'',270 (code[i].parent)?code[i].parent:'');274 co.id = "shape:"+code[i].id;276 /*277 HACKS! HACKS!! NOT GOOD!!!278 */279 if(code[i].type=="polyline"){281 //richdraw.renderer.editShape(co,code[i].points)282 }else if(code[i].type=="path"){284 // richdraw.renderer.editShape(co,code[i].d)285 }else if(code[i].type == "text"){286 //--287 //richdraw.renderer.editShape(co,code[i].text,null);288 //richdraw.renderer.editShape(co,code[i].text)289 }291 /*292 End Evil Hacks293 */296 //Event.observe(co, "mousedown", richdraw.onHitListener);298 Ext.get(co).on("mousedown", richdraw.onHit, richdraw);299 }302 //create = function(shape, fillColor, lineColor, lineWidth, left, top, width, height)303 }