annotate onlypaths/js/format_mini.js @ 63:3d3b8671de71 laserkard

[svn r64] Changed 1. About page text to agreed on 4/1/10 2. top_menu link "The Story" --> "About"
author hong
date Thu, 01 Apr 2010 20:06:28 -0400
parents 26c2b3ad21c7
children
rev   line source
rlm@46 1 /*
rlm@46 2 JSON Richdraw Abstraction Layer
rlm@46 3
rlm@46 4 ---------------------
rlm@46 5 Also,
rlm@46 6
rlm@46 7 JSON Rich Draw Format
rlm@46 8
rlm@46 9 ---------------------
rlm@46 10
rlm@46 11
rlm@46 12 What data is not stored (yet)
rlm@46 13 -Transforms
rlm@46 14
rlm@46 15 */
rlm@46 16
rlm@46 17
rlm@46 18
rlm@46 19 function canvas(richdraw,format){
rlm@46 20 var rawshapes = richdraw.getshapes()
rlm@46 21 var newshapes = [];
rlm@46 22 for(var i = 0; i < rawshapes.length; i++){
rlm@46 23 newshapes.push(richdraw.renderer.info(rawshapes[i]));
rlm@46 24 }
rlm@46 25 return newshapes;
rlm@46 26 }
rlm@46 27
rlm@46 28
rlm@46 29 var fullscreen=false;
rlm@46 30 function load(code,draw)
rlm@46 31 {
rlm@46 32
rlm@46 33 var noattachlistener=false;
rlm@46 34 var renderdoc=false;
rlm@46 35 var renderinfo=false
rlm@46 36 for(var i = 0; i < code.length; i++)
rlm@46 37 {
rlm@46 38 var rendering=true;
rlm@46 39
rlm@46 40 if(code[i].type == "info")
rlm@46 41 {
rlm@46 42 rendering=false;
rlm@46 43 renderinfo=true;
rlm@46 44 if(code[i].loop!=null)
rlm@46 45 {
rlm@46 46 timerNext=code[i].loop;
rlm@46 47 }else{
rlm@46 48 timerNext=0;
rlm@46 49 }
rlm@46 50 }
rlm@46 51
rlm@46 52 if(code[i].type == "doc")
rlm@46 53 {
rlm@46 54 rendering=false;
rlm@46 55 renderdoc=true;
rlm@46 56 if(fullscreen==false)
rlm@46 57 {
rlm@46 58 draw.renderer.view(
rlm@46 59 code[i].left,
rlm@46 60 code[i].top,
rlm@46 61 code[i].width,
rlm@46 62 code[i].height,
rlm@46 63 code[i].viewBox,
rlm@46 64 (code[i].bgcolor!=null)?code[i].fillColor:""
rlm@46 65 );
rlm@46 66 }
rlm@46 67 else
rlm@46 68 {
rlm@46 69 draw.renderer.view(
rlm@46 70 0,
rlm@46 71 0,
rlm@46 72 screenW,
rlm@46 73 screenH,
rlm@46 74 code[i].viewBox,
rlm@46 75 ''
rlm@46 76 );
rlm@46 77 }
rlm@46 78 }
rlm@46 79
rlm@46 80 if( rendering==true)
rlm@46 81 {
rlm@46 82 var co = draw.renderer.create(code[i].type,
rlm@46 83 (code[i].fillColor!=null)?code[i].fillColor:"",
rlm@46 84 (code[i].lineColor)?code[i].lineColor:"",
rlm@46 85 (code[i].fillOpac)?code[i].fillOpac:"",
rlm@46 86 (code[i].lineOpac)?code[i].lineOpac:"",
rlm@46 87 (code[i].lineWidth)?code[i].lineWidth:"",
rlm@46 88 (code[i].left)?code[i].left:"",
rlm@46 89 (code[i].top)?code[i].top:"",
rlm@46 90 (code[i].width)?code[i].width:"",
rlm@46 91 (code[i].height)?code[i].height:"",
rlm@46 92 (code[i].text)?code[i].text:'',
rlm@46 93 (code[i].textSize)?code[i].textSize:"",
rlm@46 94 (code[i].textFamily)?code[i].textFamily:'Arial',
rlm@46 95 (code[i].href)?code[i].href:'',
rlm@46 96 (code[i].points)?code[i].points:'',
rlm@46 97 (code[i].transform)?code[i].transform:'',
rlm@46 98 (code[i].parent)?code[i].parent:'');
rlm@46 99
rlm@46 100 co.id = ""+code[i].id;
rlm@46 101 if (!noattachlistener)
rlm@46 102 {
rlm@46 103 Ext.get(co).on("mousedown", draw.onHit, draw);
rlm@46 104
rlm@46 105 /*
rlm@46 106 co.addEventListener("click", function(event) { myfunction(this.id,draw,event); }, false);
rlm@46 107 co.addEventListener("mouseover", function(event) {myOverFunction(this.id,draw,event); }, false);
rlm@46 108 co.addEventListener("mouseout", function(event) {myOutFunction(this.id,draw,event); }, false);
rlm@46 109 co.addEventListener("mouseup", function(event) {myUpFunction(this.id,draw,event); }, false);
rlm@46 110 co.addEventListener("mousedown", function(event) {myDownFunction(this.id,draw,event); }, false);
rlm@46 111 co.addEventListener("mousemove", function(event) {myMoveFunction(this.id,draw,event); }, false);
rlm@46 112 co.addEventListener("dblclick", function(event) {myDblclickFunction(this.id,draw,event); }, false);
rlm@46 113 */
rlm@46 114 }
rlm@46 115 }
rlm@46 116 }
rlm@46 117 if(renderdoc == false)
rlm@46 118 {
rlm@46 119 if(fullscreen==false)
rlm@46 120 {
rlm@46 121 draw.renderer.view(0,0,canvasWidth,canvasHeight,'0 0 700 400','');
rlm@46 122 }
rlm@46 123 else
rlm@46 124 {
rlm@46 125 draw.renderer.view(0,0,screenW,screenH,'0 0 700 400','');
rlm@46 126 }
rlm@46 127 }
rlm@46 128 if(renderinfo == false)
rlm@46 129 {
rlm@46 130 }
rlm@46 131 }
rlm@46 132
rlm@46 133
rlm@46 134
rlm@46 135
rlm@46 136
rlm@46 137
rlm@46 138
rlm@46 139
rlm@46 140
rlm@46 141 function load03(code,richdraw){
rlm@46 142
rlm@46 143 //var co =richdraw.renderer.create('group', '', '', 1, '', '', 0, 0, '', '', '', '', '', '', '', '','');
rlm@46 144 //co.id = 'frame'+frameNum;
rlm@46 145 // var co ={};
rlm@46 146 var renderdoc=false;
rlm@46 147 var renderinfo=false
rlm@46 148 for(var i = 0; i < code.length; i++){
rlm@46 149 // code[i].parent='frame'+frameNum;
rlm@46 150 var rendering=true;
rlm@46 151 if(code[i].type == "info")
rlm@46 152 {
rlm@46 153 rendering=false;
rlm@46 154 renderinfo=true;
rlm@46 155 if(code[i].loop!=null)
rlm@46 156 {
rlm@46 157 timerNext=code[i].loop;
rlm@46 158 }else{
rlm@46 159 timerNext=0;
rlm@46 160 }
rlm@46 161 }
rlm@46 162 if(code[i].type == "doc")
rlm@46 163 {
rlm@46 164 rendering=false;
rlm@46 165 renderdoc=true;
rlm@46 166 if(fullscreen==false){
rlm@46 167 richdraw.renderer.view(
rlm@46 168 code[i].left,
rlm@46 169 code[i].top,
rlm@46 170 code[i].width,
rlm@46 171 code[i].height,
rlm@46 172 code[i].viewBox
rlm@46 173 );
rlm@46 174 }else{
rlm@46 175 richdraw.renderer.view(
rlm@46 176 0,
rlm@46 177 0,
rlm@46 178 scr_w,
rlm@46 179 scr_h,
rlm@46 180 code[i].viewBox
rlm@46 181 );
rlm@46 182
rlm@46 183
rlm@46 184 }
rlm@46 185 /*richdraw.renderer.view((code[i].left)?code[i].left:NaN,
rlm@46 186 (code[i].top)?code[i].top:NaN,
rlm@46 187 (code[i].width)?code[i].width:NaN,
rlm@46 188 (code[i].height)?code[i].height:NaN,
rlm@46 189 (code[i].viewBox)?code[i].viewBox:''
rlm@46 190 */
rlm@46 191
rlm@46 192 }
rlm@46 193
rlm@46 194 if( rendering==true)
rlm@46 195 {
rlm@46 196 var co = richdraw.renderer.create(code[i].type,
rlm@46 197 (code[i].fillColor!=null)?code[i].fillColor:"",
rlm@46 198 (code[i].lineColor)?code[i].lineColor:"",
rlm@46 199 (code[i].fillOpac)?code[i].fillOpac:"",
rlm@46 200 (code[i].lineOpac)?code[i].lineOpac:"",
rlm@46 201 (code[i].lineWidth)?code[i].lineWidth:"",
rlm@46 202 (code[i].left)?code[i].left:"",
rlm@46 203 (code[i].top)?code[i].top:"",
rlm@46 204 (code[i].width)?code[i].width:"",
rlm@46 205 (code[i].height)?code[i].height:"",
rlm@46 206 (code[i].text)?code[i].text:'',
rlm@46 207 (code[i].textSize)?code[i].textSize:"",
rlm@46 208 (code[i].textFamily)?code[i].textFamily:'Arial',
rlm@46 209 (code[i].href)?code[i].href:'',
rlm@46 210 (code[i].points)?code[i].points:'',
rlm@46 211 (code[i].transform)?code[i].transform:'',
rlm@46 212 (code[i].parent)?code[i].parent:'');
rlm@46 213 //(code[i].filter)?code[i].filter:'');
rlm@46 214 if(code[i].id==null){
rlm@46 215 var nid='shape:' + createUUID();
rlm@46 216 co.id = nid;
rlm@46 217 }else{
rlm@46 218 co.id = code[i].id;
rlm@46 219 }
rlm@46 220
rlm@46 221 //var cad=code[i].points;
rlm@46 222 //co.id = ""+code[i].id;
rlm@46 223 //co.addEventListener("click", function(event) { myfunction(this.id); }, false);
rlm@46 224 //co.addEventListener("mouseover", function(event) {myOverFunction(this.id); }, false);
rlm@46 225 //co.addEventListener("mouseout", function(event) {myOutFunction(this.id); }, false);
rlm@46 226
rlm@46 227
rlm@46 228 }
rlm@46 229 Ext.get(co).on("mousedown", richdraw.onHit, richdraw);
rlm@46 230
rlm@46 231 }
rlm@46 232 if(renderdoc == false)
rlm@46 233 {
rlm@46 234 if(fullscreen==false){
rlm@46 235 richdraw.renderer.view(0,0,canvasWidth,canvasHeight,'0 0 700 400');
rlm@46 236 }else{
rlm@46 237 richdraw.renderer.view(0,0,scr_w,scr_h,'0 0 700 400');
rlm@46 238 }
rlm@46 239 //richdraw.renderer.view(0,0,document.getElementById("richdraw").style.width,document.getElementById("richdraw").style.height,zoominit);
rlm@46 240
rlm@46 241 }
rlm@46 242
rlm@46 243 if(renderinfo == false){
rlm@46 244
rlm@46 245 }
rlm@46 246
rlm@46 247 }
rlm@46 248
rlm@46 249 function load01(code,richdraw){
rlm@46 250
rlm@46 251 for(var i = 0; i < code.length; i++){
rlm@46 252
rlm@46 253
rlm@46 254 var co = richdraw.renderer.create(code[i].type, //Shape
rlm@46 255 (code[i].fillColor)?code[i].fillColor:"red",
rlm@46 256 (code[i].lineColor)?code[i].lineColor:"black",
rlm@46 257 (code[i].fillOpac)?code[i].fillOpac:1,
rlm@46 258 (code[i].lineOpac)?code[i].lineOpac:1,
rlm@46 259 (code[i].lineWidth)?code[i].lineWidth:1,
rlm@46 260 (code[i].left)?code[i].left:100,
rlm@46 261 (code[i].top)?code[i].top:100,
rlm@46 262 (code[i].width)?code[i].width:100,
rlm@46 263 (code[i].height)?code[i].height:100,
rlm@46 264 (code[i].text)?code[i].text:'',
rlm@46 265 (code[i].textSize)?code[i].textSize:19,
rlm@46 266 (code[i].textFamily)?code[i].textFamily:'Arial',
rlm@46 267 (code[i].href)?code[i].href:'',
rlm@46 268 (code[i].points)?code[i].points:'',
rlm@46 269 (code[i].transform)?code[i].transform:'',
rlm@46 270 (code[i].parent)?code[i].parent:'');
rlm@46 271
rlm@46 272
rlm@46 273
rlm@46 274 co.id = "shape:"+code[i].id;
rlm@46 275
rlm@46 276 /*
rlm@46 277 HACKS! HACKS!! NOT GOOD!!!
rlm@46 278 */
rlm@46 279 if(code[i].type=="polyline"){
rlm@46 280
rlm@46 281 //richdraw.renderer.editShape(co,code[i].points)
rlm@46 282 }else if(code[i].type=="path"){
rlm@46 283
rlm@46 284 // richdraw.renderer.editShape(co,code[i].d)
rlm@46 285 }else if(code[i].type == "text"){
rlm@46 286 //--
rlm@46 287 //richdraw.renderer.editShape(co,code[i].text,null);
rlm@46 288 //richdraw.renderer.editShape(co,code[i].text)
rlm@46 289 }
rlm@46 290
rlm@46 291 /*
rlm@46 292 End Evil Hacks
rlm@46 293 */
rlm@46 294
rlm@46 295
rlm@46 296 //Event.observe(co, "mousedown", richdraw.onHitListener);
rlm@46 297
rlm@46 298 Ext.get(co).on("mousedown", richdraw.onHit, richdraw);
rlm@46 299 }
rlm@46 300
rlm@46 301
rlm@46 302 //create = function(shape, fillColor, lineColor, lineWidth, left, top, width, height)
rlm@46 303 }
rlm@46 304
rlm@46 305