Commit 8f0cef269333cf49b9c0682577cd6b006899aab6

Authored by Edmar Moretti
1 parent 2dd0a17f

--no commit message

Showing 1 changed file with 0 additions and 441 deletions   Show diff stats
ferramentas/graficointerativo/index.js
@@ -1,441 +0,0 @@ @@ -1,441 +0,0 @@
1 -/*  
2 -About: Licença  
3 -  
4 -I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet  
5 -  
6 -Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil  
7 -Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br  
8 -  
9 -Este programa é software livre; você pode redistribuí-lo  
10 -e/ou modificá-lo sob os termos da Licença Pública Geral  
11 -GNU conforme publicada pela Free Software Foundation;  
12 -tanto a versão 2 da Licença.  
13 -Este programa é distribuído na expectativa de que seja útil,  
14 -porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita  
15 -de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.  
16 -Consulte a Licença Pública Geral do GNU para mais detalhes.  
17 -Você deve ter recebido uma cópia da Licença Pública Geral do  
18 -GNU junto com este programa; se não, escreva para a  
19 -Free Software Foundation, Inc., no endereço  
20 -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.  
21 -*/  
22 -  
23 -YAHOO.example.init = function ()  
24 -{  
25 - function onPushButtonsMarkupReady()  
26 - {  
27 - new YAHOO.widget.Button("botao1");  
28 - new YAHOO.widget.Button("botao2");  
29 - new YAHOO.widget.Button("botao3");  
30 - new YAHOO.widget.Button("botao4");  
31 - new YAHOO.widget.Button("botaoGr");  
32 - }  
33 - YAHOO.util.Event.onContentReady("botao1", onPushButtonsMarkupReady);  
34 -}()  
35 -  
36 -//inicializa  
37 -mensagemAjuda("men1",$i("men1").innerHTML)  
38 -parametrosURL()  
39 -aguarde("block")  
40 -ativaGuias("")  
41 -mostraGuia("guia1")  
42 -comboi = ""  
43 -tema = ""  
44 -//eventos das guias  
45 -$i("guia1").onclick = function()  
46 -{mostraGuia("guia1");$i("opc1").style.display="block";$i("botoesopc").style.display="block";}  
47 -$i("guia2").onclick = function()  
48 -{  
49 - mostraGuia("guia2");  
50 - if ($i("comboTemas").value == "")  
51 - {alert("Escolha um tema");}  
52 - $i("opc1").style.display="block";  
53 - $i("botoesopc").style.display="block";  
54 -}  
55 -$i("guia3").onclick = function()  
56 -{  
57 - mostraGuia("guia3")  
58 - comboTemasSel("comboOverlay",function(retorno)  
59 - {  
60 - $i("overlay").innerHTML = retorno.dados  
61 - },"overlay")  
62 - $i("opc1").style.display="block";  
63 - $i("botoesopc").style.display="block";  
64 -}  
65 -$i("guia4").onclick = function()  
66 -{  
67 - mostraGuia("guia4")  
68 - $i("opc1").style.display="block";  
69 - $i("botoesopc").style.display="block";  
70 -}  
71 -$i("guia5").onclick = function()  
72 -{  
73 - var temp = pegaTemasSel().split(",")  
74 - if(temp.length > 1)  
75 - {alert("Escolha apenas um tema!");return;}  
76 - mostraGuia("guia5")  
77 - $i("opc1").style.display="none";  
78 - $i("botoesopc").style.display="none";  
79 - if ($i("comboTemas").value == "")  
80 - {alert("Escolha um tema");}  
81 - else  
82 - {  
83 - if(!$i("itemX"))  
84 - {  
85 - comboitens("itemX",$i("comboTemas").value,function(retorno)  
86 - {  
87 - $i("lugarComboX").innerHTML = retorno.dados;  
88 - },"lugarComboX")  
89 - }  
90 - if(!$i("itemY"))  
91 - {  
92 - comboitens("itemY",$i("comboTemas").value,function(retorno)  
93 - {  
94 - $i("lugarComboY").innerHTML = retorno.dados;  
95 - },"lugarComboY")  
96 - }  
97 - if($i("itemX") && $i("itemY"))  
98 - {atualizaGrafico();}  
99 - }  
100 -}  
101 -  
102 -//combo com o tipo de operacao  
103 -var combot = "<select id=tipoOperacao onchange='operacao(this)' >"  
104 -combot += "<option value='adiciona' >Adiciona</option>"  
105 -combot += "<option value='retira' >Retira</option>"  
106 -combot += "<option value='inverte' >Inverte</option>"  
107 -combot += "<option value='limpa' >Limpa</option>"  
108 -combot += "</select>"  
109 -$i("operacao").innerHTML = combot  
110 -  
111 -function mudaicone()  
112 -{  
113 - $i("selecaopt").style.border = "1px solid gray"  
114 - $i("selecaoext").style.border = "1px solid gray"  
115 - $i("selecaobox").style.border = "1px solid gray"  
116 - $i("selecaopoli").style.border = "1px solid gray"  
117 - if(window.parent.richdraw)  
118 - window.parent.richdraw.fecha()  
119 - if(window.parent.$i("img"))  
120 - window.parent.$i("img").style.cursor="pointer";  
121 -}  
122 -//pega os temas selecionados  
123 -function pegaTemasSel()  
124 -{  
125 - var selObj = $i("comboTemas");  
126 - var selectedArray = new Array();  
127 - for (i=0; i<selObj.options.length; i++) {  
128 - if (selObj.options[i].selected) {  
129 - selectedArray.push(selObj.options[i].value);  
130 - }  
131 - }  
132 - return selectedArray.toString();  
133 -}  
134 -//botoes de tipo  
135 -function tiposel(obj)  
136 -{  
137 - var combotemas = $i("comboTemas");  
138 - window.parent.i3GEO.mapa.ativaTema(pegaTemasSel());  
139 - window.parent.i3GEO.eventos.MOUSEDOWN.remove("i3GEO.selecao.box.inicia()")  
140 - $i("parapoli").style.display = "none";  
141 - var fim = function()  
142 - {aguarde("none");window.parent.i3GEO.atualiza("");}  
143 - if (combotemas.value == ""){alert("Escolha um tema");return;}  
144 -  
145 - if (obj.id == "selecaoext")  
146 - {  
147 - if (window.parent.i3GEO.parametros.mapscale > 500000)  
148 - {alert("A escala do mapa deve ser pelo menos 1:500.000");return;}  
149 - aguarde("block")  
150 - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaoext&tema="+pegaTemasSel()+"&tipo="+$i("tipoOperacao").value  
151 - var cp = new cpaint();  
152 - //cp.set_debug(2)  
153 - cp.set_response_type("JSON");  
154 - cp.call(p,"selecaoEXT",fim);  
155 - }  
156 - if (obj.id == "selecaobox")  
157 - {  
158 - mudaicone()  
159 - obj.style.border = "1px solid white";  
160 - window.parent.g_tipoacao = "selecaobox";  
161 - window.parent.i3GEO.selecao.box.criaBox();  
162 - if(window.parent.i3GEO.eventos.MOUSEDOWN.toString().search("i3GEO.selecao.box.inicia()") < 0)  
163 - {window.parent.i3GEO.eventos.MOUSEDOWN.push("i3GEO.selecao.box.inicia()");}  
164 - }  
165 - if (obj.id == "selecaopt")  
166 - {  
167 - mudaicone()  
168 - obj.style.border = "1px solid white"  
169 - window.parent.g_tipoacao = "selecao";  
170 - if(window.parent.i3GEO.eventos.MOUSECLIQUE.toString().search("i3GEO.selecao.clique()") < 0)  
171 - {window.parent.i3GEO.eventos.MOUSECLIQUE.push("i3GEO.selecao.clique()");}  
172 - }  
173 - if (obj.id == "selecaopoli")  
174 - {  
175 - var temp = pegaTemasSel().split(",")  
176 - if(temp.length > 1)  
177 - {alert("Escolha apenas um tema!");return;}  
178 - mudaicone()  
179 - obj.style.border = "1px solid white"  
180 - window.parent.g_tipoacao = "selecaopoli";  
181 - window.parent.i3GEO.selecao.poligono.inicia()  
182 - }  
183 -}  
184 -  
185 -//cria combo com os temas  
186 -  
187 -comboTemasLigados("comboTemas",function(retorno)  
188 -{  
189 - $i("temas").innerHTML = retorno.dados  
190 - aguarde("none")  
191 - $i("comboTemas").onchange = function()  
192 - {  
193 - $i("lugarComboX").innerHTML = "";  
194 - $i("lugarComboY").innerHTML = "";  
195 - window.parent.i3GEO.mapa.ativaTema(pegaTemasSel());  
196 - comboitens("selItem",$i("comboTemas").value,function(retorno)  
197 - {  
198 - comboi = retorno.dados  
199 - var p = $i("parametros")  
200 - for (i = 0; i < p.childNodes.length;i++)  
201 - {p.removeChild(p.childNodes[i])}  
202 - adicionalinha()  
203 - })  
204 - if ($i("comboTemas").value != "")  
205 - {$i("opc3").style.display="block"}  
206 - else  
207 - {  
208 - alert("Selecione um tema");  
209 - $i("opc3").style.display="block"  
210 - }  
211 - }  
212 -},"temas","",true)  
213 -  
214 -//adiciona uma linha de parametros  
215 -function adicionalinha()  
216 -{  
217 - var comboitens = comboi  
218 - //interrogacao abre a lista de valores  
219 - var interrogacao = document.createElement("img")  
220 - interrogacao.src = '../../imagens/interrogacao.gif'  
221 - interrogacao.title='lista'  
222 - interrogacao.style.cursor="pointer"  
223 - interrogacao.onclick = function()  
224 - {  
225 - var itemTema = (this.parentNode.parentNode.getElementsByTagName("select"))[0].value  
226 - if (itemTema == "")  
227 - {  
228 - alert("Selecione um campo")  
229 - return  
230 - }  
231 - aguarde("block")  
232 - valoresItem  
233 - (  
234 - $i("comboTemas").value,  
235 - itemTema,  
236 - function(retorno)  
237 - {  
238 - aguarde("none")  
239 - $i("valores").innerHTML = "<br>Valores:<br>"+retorno.dados  
240 - }  
241 - ,"valores"  
242 - )  
243 - }  
244 - var operador = "<select>"  
245 - operador += "<option value=',=,'>igual</option>"  
246 - operador += "<option value=',!=,'>dif</option>"  
247 - operador += "<option value=',<,'>menor</option>"  
248 - operador += "<option value=',>,'>maior</option>"  
249 - operador += "<option value=',<=,'><=</option>"  
250 - operador += "<option value=',>=,'>=</option>"  
251 - operador += "<option value=',in,'>in</option>"  
252 - operador += "<option value=',~=,'>regExp</option></select>"  
253 - var valor = document.createElement("input")  
254 - valor.type = "text"  
255 - valor.value = ""  
256 - valor.size = "20"  
257 - var ntb = document.createElement("tbody")  
258 - var ntr = document.createElement("tr")  
259 - ntb.appendChild(ntr)  
260 - var ntd1 = document.createElement("td")  
261 - ntd1.innerHTML = comboi  
262 - ntr.appendChild(ntd1)  
263 - var ntd2 = document.createElement("td")  
264 - ntd2.innerHTML = operador  
265 - ntr.appendChild(ntd2)  
266 - var ntd3 = document.createElement("td")  
267 - ntd3.appendChild(valor)  
268 - ntr.appendChild(ntd3)  
269 - var ntd4 = document.createElement("td")  
270 - ntd4.appendChild(interrogacao)  
271 - ntr.appendChild(ntd4)  
272 - tabela = $i("parametros")  
273 - tabela.appendChild(ntb)  
274 -}  
275 -//executa o tipo de operacao selecionada se for o caso  
276 -function operacao(tipo)  
277 -{  
278 - if ($i("comboTemas").value == ""){alert("Escolha um tema");return;}  
279 - if((tipo.value == "limpa") || (tipo.value == "inverte"))  
280 - {  
281 - aguarde("block")  
282 - var fim = function()  
283 - {aguarde("none");window.parent.i3GEO.atualiza("")}  
284 - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaopt&tema="+pegaTemasSel()+"&tipo="+tipo.value+"&tolerancia="+$i("toleranciapt").value  
285 - var cp = new cpaint();  
286 - //cp.set_debug(2)  
287 - cp.set_response_type("JSON");  
288 - window.parent.g_operacao = "selecao"  
289 - cp.call(p,"selecaoPT",fim);  
290 - }  
291 -}  
292 -//aplica a selecao por atributo  
293 -function aplicaselecao()  
294 -{  
295 - var temp = pegaTemasSel().split(",")  
296 - if(temp.length > 1)  
297 - {alert("Escolha apenas um tema!");return;}  
298 - if ($i("comboTemas").value == ""){alert("Escolha um tema");return;}  
299 - aguarde("block")  
300 - var g = $i("parametros")  
301 - var ipt = g.getElementsByTagName("tr")  
302 - if (ipt.length > 0)  
303 - {  
304 - var filtro = ""  
305 - for (i=0;i<ipt.length; i++)  
306 - {  
307 - var nos = ipt[i].childNodes  
308 - var s = nos[0].getElementsByTagName("select")  
309 - var itemsel = s[0].value  
310 - var s = nos[1].getElementsByTagName("select")  
311 - var operador = s[0].value  
312 - var s = nos[2].getElementsByTagName("input")  
313 - var valor = s[0].value  
314 - }  
315 - var tipo = $i("tipoOperacao").value  
316 - var fim = function()  
317 - {aguarde("none");window.parent.i3GEO.atualiza("")}  
318 - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaoatrib&tipo="+tipo+"&tema="+pegaTemasSel()+"&valor="+valor+"&operador="+operador+"&item="+itemsel  
319 - var cp = new cpaint();  
320 - //cp.set_debug(2)  
321 - cp.set_response_type("JSON");  
322 - window.parent.g_operacao = "selecao"  
323 - cp.call(p,"selecaoAtributos",fim);  
324 - }  
325 -}  
326 -//aplica a selecao por tema  
327 -function aplicaselecaoTema()  
328 -{  
329 - aguarde("block")  
330 - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaotema&temao="+$i("comboOverlay").value+"&tema="+pegaTemasSel()+"&tipo="+$i("tipoOperacao").value  
331 - var cp = new cpaint();  
332 - //cp.set_debug(2)  
333 - cp.set_response_type("JSON");  
334 - window.parent.g_operacao = "selecao"  
335 - cp.call(p,"selecaoTema",mostraSelecaoTema);  
336 -}  
337 -//mostra a seleção por tema  
338 -function mostraSelecaoTema(retorno)  
339 -{  
340 - aguarde("none")  
341 - window.parent.remapaf();  
342 -}  
343 -//cria um novo tema  
344 -function criatemaf()  
345 -{  
346 - var temp = pegaTemasSel().split(",")  
347 - if(temp.length > 1)  
348 - {alert("Escolha apenas um tema!");return;}  
349 - if ($i("comboTemas").value == "")  
350 - {alert("Escolha um tema!");}  
351 - else  
352 - {  
353 - aguarde("block")  
354 - var fim = function()  
355 - {aguarde("none");window.parent.i3GEO.atualiza("")}  
356 - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=criatemasel&tema="+$i("comboTemas").value+"&nome=Novo tema "+$i("comboTemas").value  
357 - var cp = new cpaint();  
358 - //cp.set_debug(2)  
359 - cp.set_response_type("JSON");  
360 - cp.call(p,"selecao2tema",fim);  
361 - }  
362 -}  
363 -function concluidof()  
364 -{  
365 - window.parent.remapaf()  
366 - aguarde("none")  
367 -}  
368 -function concluipoligono()  
369 -{  
370 - $i("parapoli").style.display = "none";  
371 - tiposel($i("selecaopt"))  
372 - var pontos = window.parent.pontosdistobj;  
373 - window.parent.richdraw.fecha()  
374 - var n = pontos.xpt.length;  
375 - if (n > 2)  
376 - {  
377 - aguarde("block")  
378 - var xs = pontos.xpt.toString(",")  
379 - var ys = pontos.ypt.toString(",")  
380 - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=selecaoPoli"  
381 - var cp = new cpaint();  
382 - //cp.set_debug(2)  
383 - cp.set_transfer_mode('POST');  
384 - cp.set_response_type("JSON");  
385 - cp.call(p,"selecaoPoli",concluidof,xs,ys,pegaTemasSel(),$i("tipoOperacao").value);  
386 - }  
387 - else  
388 - {alert("Sao necessarios pelo menos tres pontos");}  
389 -}  
390 -function atualizaGrafico()  
391 -{  
392 - $i("lugarGrafico").innerHTML = ""  
393 - var monta = function(retorno)  
394 - {  
395 - var dados = retorno.data.dados;  
396 - var values = new Array();  
397 - var labels = new Array();  
398 - for (i=1;i<dados.length; i++)  
399 - {  
400 - var celula = dados[i].split(";");  
401 - values.push(eval("["+i+","+celula[1]+"]"));  
402 - var temp = '{v:'+(i)+',label:'+'"'+celula[0]+'"}';  
403 - labels.push(temp);  
404 - }  
405 - var options = {  
406 - "colorScheme": "",  
407 - "padding": {left: 2, right: 2, top: 5, bottom: 2},  
408 - "xTicks": eval("["+labels+"]")  
409 - };  
410 - layout = new Layout("bar", options);  
411 - renderer = new SweetCanvasRenderer($('canvasTest'), layout, options);  
412 - var chartStyle = "bar"; //document.forms["options"].chartStyle[chartStyleSelected].value;  
413 - var colorScheme = "Blue"; //document.forms["options"].colorScheme[colorSchemeSelected].value;  
414 - // setup layout options  
415 - var themeName = "office" + $i("colorScheme").value;  
416 - var theme = PlotKit.Base[themeName]();  
417 - MochiKit.Base.update(options, theme);  
418 - layout.style = $i("chartStyle").value;  
419 - MochiKit.Base.update(layout.options, options);  
420 - MochiKit.Base.update(renderer.options, options);  
421 - layout.addDataset("data", values);  
422 - layout.evaluate();  
423 - renderer.clear();  
424 - renderer.render();  
425 - }  
426 - if(!$i("canvasTest"))  
427 - $i("lugarGrafico").innerHTML = "<canvas id='canvasTest' width='350' height='180' style='border: 1px solid #eee;'></canvas>"  
428 - if ($i("canvasTest").getContext)  
429 - {  
430 - if($i("itemX").value == "" || $i("itemY").value == "")  
431 - {alert("Escolha as colunas primeiro");}  
432 - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&funcao=graficoSelecao&tema="+$i("comboTemas").value+"&itemclasses="+$i("itemX").value+"&itemvalores="+$i("itemY").value  
433 - var cp = new cpaint();  
434 - cp.set_response_type("JSON");  
435 - cp.call(p,"graficoSelecao",monta);  
436 - }  
437 - else  
438 - {  
439 - $i("lugarGrafico").innerHTML = "<span style=color:red >Voc&ecirc; precisa atuallizar seu navegador para que o gr&aacute;fico possa ser mostrado</span>";  
440 - }  
441 -}