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
|
rlm@46
|
13
|
rlm@46
|
14
|
rlm@46
|
15 function canvas(richdraw,format){
|
rlm@46
|
16
|
rlm@46
|
17 var rawshapes = richdraw.getshapes()
|
rlm@46
|
18 var newshapes = [];
|
rlm@46
|
19 //var view=Ext.util.JSON.encode(myOPF[0])
|
rlm@46
|
20 //newshapes.push(Ext.util.JSON.decode(view));
|
rlm@46
|
21 newshapes.push(myOPF[0]);
|
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].bgcolor:""
|
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
|