From 0f49234e4d2fbc1df888643eb2f9b3f4b0a79b03 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Wed, 11 Sep 2013 12:44:01 +0000 Subject: [PATCH] $1 --- admin/admin.db | Bin 209920 -> 0 bytes classesjs/dicionario_ajuda.js | 2 +- documentacao/manual-i3geo-5_0-pt.odt | Bin 10877860 -> 0 bytes documentacao/manual-i3geo-5_0-pt.pdf | Bin 2464512 -> 0 bytes ferramentas/graficointerativo1/dicionario.js | 21 +++++++++++++++++---- ferramentas/graficointerativo1/index.js | 2159 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- pacotes/base64.js | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pacotes/canvas2image.js | 235 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pacotes/canvg.js | 2886 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pacotes/rgbcolor.js | 288 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pacotes/svg2img.php | 31 +++++++++++++++++++++++++++++++ 11 files changed, 4697 insertions(+), 1038 deletions(-) create mode 100755 pacotes/base64.js create mode 100755 pacotes/canvas2image.js create mode 100755 pacotes/canvg.js create mode 100755 pacotes/rgbcolor.js create mode 100755 pacotes/svg2img.php diff --git a/admin/admin.db b/admin/admin.db index ba4ea63..b4c02f6 100644 Binary files a/admin/admin.db and b/admin/admin.db differ diff --git a/classesjs/dicionario_ajuda.js b/classesjs/dicionario_ajuda.js index 753526a..a771214 100644 --- a/classesjs/dicionario_ajuda.js +++ b/classesjs/dicionario_ajuda.js @@ -693,7 +693,7 @@ g_traducao_ajuda = { }, "84": { titulo: "Gráfico interativo", - diretorio:"i3geo/ferramentas/graficointerativo", + diretorio:"i3geo/ferramentas/graficointerativo1", categoria:"3", pt:"Gerador de representação gráfica de dados tabulares. Abre uma janela flutuante onde o usuário pode escolher os dados e o tipo de gráfico desejado. Os dados são baseados em um dos temas existentes no mapa.", complemento:"Existem várias opções de tratamento dos dados que permitem, por exemplo, mostrar os percentuais ou os dados brutos. Pode-se ainda ativar a navegação dināmica, o que permite atualizar o gráfico conforme é feita a navegação sobre o mapa.", diff --git a/documentacao/manual-i3geo-5_0-pt.odt b/documentacao/manual-i3geo-5_0-pt.odt index 0ce10b6..ec9bf3a 100644 Binary files a/documentacao/manual-i3geo-5_0-pt.odt and b/documentacao/manual-i3geo-5_0-pt.odt differ diff --git a/documentacao/manual-i3geo-5_0-pt.pdf b/documentacao/manual-i3geo-5_0-pt.pdf index cd08502..01991bf 100644 Binary files a/documentacao/manual-i3geo-5_0-pt.pdf and b/documentacao/manual-i3geo-5_0-pt.pdf differ diff --git a/ferramentas/graficointerativo1/dicionario.js b/ferramentas/graficointerativo1/dicionario.js index e5b86f0..d410dd5 100755 --- a/ferramentas/graficointerativo1/dicionario.js +++ b/ferramentas/graficointerativo1/dicionario.js @@ -67,7 +67,7 @@ i3GEOF.graficointerativo1.dicionario = { it:"" }], 12: [{ - pt:"Escolha os dados que comporão o gráfico", + pt:"Configuração do gráfico", en:"", es:"", it:"" @@ -128,7 +128,8 @@ i3GEOF.graficointerativo1.dicionario = { }], 22: [{ pt:"Utiliza valores acumulados", - en:"", + en:"",titleFont: 'bold 14px sans-serif', + titlePosition: "top", es:"", it:"" }], @@ -193,7 +194,7 @@ i3GEOF.graficointerativo1.dicionario = { it:"" }], 33: [{ - pt:"Digite o título", + pt:"Digite o título para legenda", en:"", es:"", it:"" @@ -295,7 +296,19 @@ i3GEOF.graficointerativo1.dicionario = { it:"" }], 50: [{ - pt:"", + pt:"Título", + en:"", + es:"", + it:"" + }], + 51: [{ + pt:"Título do eixo X", + en:"", + es:"", + it:"" + }], + 52: [{ + pt:"Título do eixo Y", en:"", es:"", it:"" diff --git a/ferramentas/graficointerativo1/index.js b/ferramentas/graficointerativo1/index.js index 4b42f41..499b2f2 100755 --- a/ferramentas/graficointerativo1/index.js +++ b/ferramentas/graficointerativo1/index.js @@ -45,199 +45,230 @@ if (typeof (i3GEOF) === 'undefined') { * */ i3GEOF.graficointerativo1 = { - /* - * Variavel: aguarde - * - * Estilo do objeto DOM com a imagem de aguarde existente no - * cabeçalho da janela. - */ - aguarde : "", - /* - * Propriedade: dados - * - * Dados que serao utilizados. Pode ser passado como parametro. - * - * Default: {false} - */ - dados : false, - /* - * Propriedade: titulo - * - * Título do gráfico. Se for vazio, será obtido do nome - * do tema selecionado - */ - titulo : "", - /* - * Propriedade: tipo - * - * Tipo de gráfico escolhido pelo usuário. - */ - tipo : "", - /* - * Propriedade: acumula - * - * Acumula os valores ao gerar o gráfico - * - * Type: {boolean} - * - * Default: {false} - */ - acumula : false, - /* - * Propriedade: relativa - * - * Utiliza valores relativos ao criar o gráfico - * - * Type: {boolean} - * - * Default: {false} - */ - relativa : false, - /* - * Propriedade: dadospuros - * - * Não faz nenhum tipo de processamento nos dados antes de gerar o - * gráfico - * - * Type: {boolean} - * - * Default: {false} - */ - dadospuros : false, - /* - * Propriedade: navegacao - * - * Ativa ou não a navegação dināmica do mapa - * - * Type: {boolean} - * - * Default: {false} - */ - navegacao : false, + /* + * Variavel: aguarde + * + * Estilo do objeto DOM com a imagem de aguarde existente no + * cabeçalho da janela. + */ + aguarde : "", + /* + * Propriedade: dados + * + * Dados que serao utilizados. Pode ser passado como parametro. + * + * Default: {false} + */ + dados : false, + /* + * Propriedade: titulo + * + * Título do gráfico. Se for vazio, será obtido do nome + * do tema selecionado + */ + titulo : "", + /* + * Propriedade: tipo + * + * Tipo de gráfico escolhido pelo usuário. + */ + tipo : "", + /* + * Propriedade: acumula + * + * Acumula os valores ao gerar o gráfico + * + * Type: {boolean} + * + * Default: {false} + */ + acumula : false, + /* + * Propriedade: relativa + * + * Utiliza valores relativos ao criar o gráfico + * + * Type: {boolean} + * + * Default: {false} + */ + relativa : false, + /* + * Propriedade: dadospuros + * + * Não faz nenhum tipo de processamento nos dados antes de gerar o + * gráfico + * + * Type: {boolean} + * + * Default: {false} + */ + dadospuros : false, + /* + * Propriedade: navegacao + * + * Ativa ou não a navegação dināmica do mapa + * + * Type: {boolean} + * + * Default: {false} + */ + navegacao : false, - /* - * Para efeitos de compatibilidade antes da versão 4.7 que não - * tinha dicionário - */ - criaJanelaFlutuante : function(dados) { - if (dados) { - i3GEOF.graficointerativo1.dados = dados; - } - i3GEOF.graficointerativo1.iniciaDicionario(); - }, - /* - * Function: iniciaDicionario - * - * Carrega o dicionário e chama a função que inicia a - * ferramenta - * - * O Javascript é carregado com o id - * i3GEOF.nomedaferramenta.dicionario_script - */ - iniciaDicionario : function(dados) { - if (dados) { - i3GEOF.graficointerativo1.dados = dados; - } - if (typeof (i3GEOF.graficointerativo1.dicionario) === 'undefined') { - i3GEO.util.scriptTag(i3GEO.configura.locaplic - + "/ferramentas/graficointerativo1/dependencias.php", - "i3GEOF.graficointerativo1.iniciaJanelaFlutuante()", - "i3GEOF.graficointerativo1.dicionario_script"); - } else { - i3GEOF.graficointerativo1.iniciaJanelaFlutuante(dados); - } - }, - /* - * Function: inicia - * - * Inicia a ferramenta. É chamado por criaJanelaFlutuante - * - * Parametros: - * - * iddiv {String} - id do div que receberá o conteudo HTML da - * ferramenta - * - * dados {JSON} - dados para o gráfico (opcional) exemplo - * ["n;x","'Argentina';33796870","'Paraguay';4773464","'Brazil';151525400","'Chile';13772710"] - */ - inicia : function(iddiv) { - // try{ - $i(iddiv).innerHTML += i3GEOF.graficointerativo1.html(); - $i("i3GEOgraficointerativo1Acumula").checked = i3GEOF.graficointerativo1.acumula; - $i("i3GEOgraficointerativo1Relativa").checked = i3GEOF.graficointerativo1.relativa; - $i("i3GEOgraficointerativo1DadosPuros").checked = i3GEOF.graficointerativo1.dadospuros; - if (i3GEOF.graficointerativo1.navegacao === true) { - i3GEOF.graficointerativo1.ativaNavegacao(true); - } - // eventos das guias - $i("i3GEOgraficointerativo1guia1").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia1", - "i3GEOgraficointerativo1guia"); - $i("i3GEOgraficointerativo1Grafico").style.display = "none"; - }; - $i("i3GEOgraficointerativo1guia2").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia2", - "i3GEOgraficointerativo1guia"); - i3GEOF.graficointerativo1.configuraDados(); - $i("i3GEOgraficointerativo1Grafico").style.display = "none"; - }; - $i("i3GEOgraficointerativo1guia3").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia3", - "i3GEOgraficointerativo1guia"); - $i("i3GEOgraficointerativo1Grafico").style.display = "none"; - }; - $i("i3GEOgraficointerativo1guia4").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia4", - "i3GEOgraficointerativo1guia"); - var t = $i("i3GEOgraficointerativo1Grafico"); - t.style.display = "block"; - t.style.position = "relative"; - t.style.top = "-5px"; - t.visibility = "visible"; - i3GEOF.graficointerativo1.tabela2dados(); - }; - $i("i3GEOgraficointerativo1guia5").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia5", - "i3GEOgraficointerativo1guia"); - $i("i3GEOgraficointerativo1Grafico").style.display = "none"; - $i("i3GEOgraficointerativo1guia5obj").innerHTML = ""; - }; - - i3GEOF.graficointerativo1.ativaFoco(); - i3GEOF.graficointerativo1.comboTemas(); - new YAHOO.widget.Button("i3GEOgraficointerativo1botao1", { - onclick : { - fn : i3GEOF.graficointerativo1.obterDados + }; + $i("i3GEOgraficointerativo1guia6").onclick = function() { + if(i3GEOF.graficointerativo1.tipo === ""){ + alert($trad(4, i3GEOF.graficointerativo1.dicionario)); + return; + } + if($i("i3GEOgraficointerativo1Dados").innerHTML === ""){ + return; + } + var w,h,form = $i("i3GEOgraficointerativo1PNG"), + isvg = form.getElementsByTagName("input")[0], + svg = $i("i3GEOgraficointerativo1guia4objCanvas").firstChild; + h = svg.getAttributeNS(null, 'height'); + w = svg.getAttributeNS(null, 'width'); + if (typeof XMLSerializer != "undefined"){ + svg = (new XMLSerializer()).serializeToString(svg); + } else { + svg = svg.html(); + } + isvg.value = svg; + form.action = form.action+"?"+"w="+w+"&h="+h; + form.submit(); + }; + i3GEOF.graficointerativo1.ativaFoco(); + i3GEOF.graficointerativo1.comboTemas(); + new YAHOO.widget.Button("i3GEOgraficointerativo1botao1", { + onclick : { + fn : i3GEOF.graficointerativo1.obterDados + } + }); + if (i3GEOF.graficointerativo1.dados + && i3GEOF.graficointerativo1.dados != "undefined") { + i3GEOF.graficointerativo1 + .montaTabelaDados(i3GEOF.graficointerativo1.dados); + $i("i3GEOgraficointerativo1guia4").onclick.call(); } - }); - if (i3GEOF.graficointerativo1.dados - && i3GEOF.graficointerativo1.dados != "undefined") { - // i3GEOF.graficointerativo1.tipo = "pizza2d"; - // var retorno = - // {"attributes":{"id":""},"data":{"dados":["n;x","'4';3839572","'8';81710320","'7';24631314","'2';10967753","'1';24496400","'3';18752482","'5';13574480","'6';216507515"]}}; - i3GEOF.graficointerativo1 - .montaTabelaDados(i3GEOF.graficointerativo1.dados); - $i("i3GEOgraficointerativo1guia4").onclick.call(); - } - i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia1", - "i3GEOgraficointerativo1guia"); - // } - // catch(erro){i3GEO.janela.tempoMsg(erro);} - }, - /* - * Function: html - * - * Gera o código html para apresentação das - * opções da ferramenta - * - * Retorno: - * - * String com o código html - */ - html : function() { - var locaplic = i3GEO.configura.locaplic, ins = '' + i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia1", + "i3GEOgraficointerativo1guia"); + }, + /* + * Function: html + * + * Gera o código html para apresentação das + * opções da ferramenta + * + * Retorno: + * + * String com o código html + */ + html : function() { + var locaplic = i3GEO.configura.locaplic, ins = '' + '
' + ' ' + '

' + //tipos de grafico + ' ' + //obtencao dos dados e parametros + '' + //propriedades adicionais + '' + + '

' + + '' + //aqui vai o grafico + '' + //csv + '' + //png + + '' + ''; - return ins; - }, - /* - * Function: iniciaJanelaFlutuante - * - * Cria a janela flutuante para controle da ferramenta. - * - * Parametro - * - * dados {JSON} - dados para o gráfico - */ - iniciaJanelaFlutuante : function(dados) { - if (dados) { - i3GEOF.graficointerativo1.dados = dados; - } - var minimiza, cabecalho, janela, divid, temp, titulo; - // cria a janela flutuante - cabecalho = function() { - i3GEOF.graficointerativo1.ativaFoco(); - }; - minimiza = function() { - i3GEO.janela.minimiza("i3GEOF.graficointerativo1"); - }; - titulo = "   " + return ins; + }, + /* + * Function: iniciaJanelaFlutuante + * + * Cria a janela flutuante para controle da ferramenta. + * + * Parametro + * + * dados {JSON} - dados para o gráfico + */ + iniciaJanelaFlutuante : function(dados) { + if (dados) { + i3GEOF.graficointerativo1.dados = dados; + } + var minimiza, cabecalho, janela, divid, temp, titulo; + // cria a janela flutuante + cabecalho = function() { + i3GEOF.graficointerativo1.ativaFoco(); + }; + minimiza = function() { + i3GEO.janela.minimiza("i3GEOF.graficointerativo1"); + }; + titulo = "   " + $trad("t37b") + "    "; - janela = i3GEO.janela.cria("380px", "310px", "", "", "", titulo, - "i3GEOF.graficointerativo1", false, "hd", cabecalho, minimiza); - divid = janela[2].id; - i3GEOF.graficointerativo1.aguarde = $i("i3GEOF.graficointerativo1_imagemCabecalho").style; - $i("i3GEOF.graficointerativo1_corpo").style.backgroundColor = "white"; - $i("i3GEOF.graficointerativo1_corpo").style.overflow = "auto"; - i3GEOF.graficointerativo1.inicia(divid); - if (i3GEO.Interface) { - temp = function() { - if (i3GEO.Interface.ATUAL !== "googlemaps" + janela = i3GEO.janela.cria("480px", "450px", "", "", "", titulo, + "i3GEOF.graficointerativo1", false, "hd", cabecalho, minimiza); + divid = janela[2].id; + i3GEOF.graficointerativo1.aguarde = $i("i3GEOF.graficointerativo1_imagemCabecalho").style; + $i("i3GEOF.graficointerativo1_corpo").style.backgroundColor = "white"; + $i("i3GEOF.graficointerativo1_corpo").style.overflow = "auto"; + i3GEOF.graficointerativo1.inicia(divid); + if (i3GEO.Interface) { + temp = function() { + if (i3GEO.Interface.ATUAL !== "googlemaps" && i3GEO.Interface.ATUAL !== "googleearth") { - i3GEO.eventos.NAVEGAMAPA - .remove("i3GEOF.graficointerativo1.obterDados()"); - } - if (i3GEO.Interface.ATUAL == "googlemaps") { - google.maps.event.removeListener(graficointerativo1Dragend); - google.maps.event.removeListener(graficointerativo1Zoomend); - } - if (i3GEO.Interface.ATUAL === "googleearth") { - google.earth.removeEventListener(graficointerativo1Dragend); - } + i3GEO.eventos.NAVEGAMAPA + .remove("i3GEOF.graficointerativo1.obterDados()"); + } + if (i3GEO.Interface.ATUAL == "googlemaps") { + google.maps.event.removeListener(graficointerativo1Dragend); + google.maps.event.removeListener(graficointerativo1Zoomend); + } + if (i3GEO.Interface.ATUAL === "googleearth") { + google.earth.removeEventListener(graficointerativo1Dragend); + } + if (i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search( + "i3GEOF.graficointerativo1.comboTemas()") > 0) { + i3GEO.eventos.ATUALIZAARVORECAMADAS + .remove("i3GEOF.graficointerativo1.comboTemas()"); + } + }; + YAHOO.util.Event.addListener(janela[0].close, "click", temp); if (i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search( - "i3GEOF.graficointerativo1.comboTemas()") > 0) { + "i3GEOF.graficointerativo1.comboTemas()") < 0) { i3GEO.eventos.ATUALIZAARVORECAMADAS - .remove("i3GEOF.graficointerativo1.comboTemas()"); + .push("i3GEOF.graficointerativo1.comboTemas()"); } - }; - YAHOO.util.Event.addListener(janela[0].close, "click", temp); - if (i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search( - "i3GEOF.graficointerativo1.comboTemas()") < 0) { - i3GEO.eventos.ATUALIZAARVORECAMADAS - .push("i3GEOF.graficointerativo1.comboTemas()"); } - } - }, - /* - * Function: ativaFoco - * - * Refaz a interface da ferramenta quando a janela flutuante tem seu foco - * ativado - */ - ativaFoco : function() { - if (i3GEO.Interface) { - i3GEO.barraDeBotoes.ativaIcone("graficointerativo1"); - } - var i = $i("i3GEOF.graficointerativo1_c").style; - i3GEO.janela.ULTIMOZINDEX++; - i.zIndex = i3GEO.janela.ULTIMOZINDEX; - }, - novaJanela : function() { - var janela = "", divid, g = $i("i3GEOgraficointerativo1guia4objCanvas"), v = g - .cloneNode(true), cabecalho = function() { - }, id = YAHOO.util.Dom.generateId(), minimiza = function() { - i3GEO.janela.minimiza(id); - }, titulo = "   " + i3GEOF.graficointerativo1.titulo; - janela = i3GEO.janela.cria("380px", "280px", "", "", "", titulo, id, - false, "hd", cabecalho, minimiza); - divid = janela[2].id; - $i(divid).style.marginTop = "0px"; - v.id = id + "ngrafico"; - v.style.marginTop = "0px"; - $i(divid).appendChild(v); - }, - /* - * Function: comboTemas - * - * Monta o combo para escolha do tema que será utilizado no - * gráfico - */ - comboTemas : function() { - if (!i3GEO.Interface) { - return; - } - i3GEO.util - .comboTemas( - "i3GEOgraficointerativo1ComboTemasId", - function(retorno) { - $i("i3GEOgraficointerativo1ComboTemas").innerHTML = retorno.dados; - $i("i3GEOgraficointerativo1ComboTemas").style.display = "block"; - if ($i("i3GEOgraficointerativo1ComboTemasId")) { - $i("i3GEOgraficointerativo1ComboTemasId").onchange = function() { - i3GEO.mapa - .ativaTema($i("i3GEOgraficointerativo1ComboTemasId").value); - i3GEOF.graficointerativo1.comboItensSel(); - }; - } - if (i3GEO.temaAtivo !== "") { - $i("i3GEOgraficointerativo1ComboTemasId").value = i3GEO.temaAtivo; - $i("i3GEOgraficointerativo1ComboTemasId").onchange - .call(); - } - }, "i3GEOgraficointerativo1ComboTemas", "", false, - "ligados", "font-size:12px;width:350px"); - }, - /* - * Function: ativaTipo - * - * Define a variável com o tipo de gráfico e mostra a guia 2 - */ - ativaTipo : function(obj) { - i3GEOF.graficointerativo1.tipo = obj.value; - if ($i("i3GEOgraficointerativo1Grafico").innerHTML === "" + }, + /* + * Function: ativaFoco + * + * Refaz a interface da ferramenta quando a janela flutuante tem seu foco + * ativado + */ + ativaFoco : function() { + if (i3GEO.Interface) { + i3GEO.barraDeBotoes.ativaIcone("graficointerativo1"); + } + var i = $i("i3GEOF.graficointerativo1_c").style; + i3GEO.janela.ULTIMOZINDEX++; + i.zIndex = i3GEO.janela.ULTIMOZINDEX; + }, + novaJanela : function() { + var janela = "", divid, g = $i("i3GEOgraficointerativo1guia4objCanvas"), v = g + .cloneNode(true), cabecalho = function() { + }, id = YAHOO.util.Dom.generateId(), minimiza = function() { + i3GEO.janela.minimiza(id); + }, titulo = "   " + i3GEOF.graficointerativo1.titulo; + janela = i3GEO.janela.cria("380px", "280px", "", "", "", titulo, id, + false, "hd", cabecalho, minimiza); + divid = janela[2].id; + $i(divid).style.marginTop = "0px"; + v.id = id + "ngrafico"; + v.style.marginTop = "0px"; + $i(divid).appendChild(v); + }, + /* + * Function: comboTemas + * + * Monta o combo para escolha do tema que será utilizado no + * gráfico + */ + comboTemas : function() { + if (!i3GEO.Interface) { + return; + } + i3GEO.util + .comboTemas( + "i3GEOgraficointerativo1ComboTemasId", + function(retorno) { + $i("i3GEOgraficointerativo1ComboTemas").innerHTML = retorno.dados; + $i("i3GEOgraficointerativo1ComboTemas").style.display = "block"; + if ($i("i3GEOgraficointerativo1ComboTemasId")) { + $i("i3GEOgraficointerativo1ComboTemasId").onchange = function() { + i3GEO.mapa + .ativaTema($i("i3GEOgraficointerativo1ComboTemasId").value); + i3GEOF.graficointerativo1.comboItensSel(); + }; + } + if (i3GEO.temaAtivo !== "") { + $i("i3GEOgraficointerativo1ComboTemasId").value = i3GEO.temaAtivo; + $i("i3GEOgraficointerativo1ComboTemasId").onchange + .call(); + } + }, "i3GEOgraficointerativo1ComboTemas", "", false, + "ligados", "font-size:12px;width:350px"); + }, + /* + * Function: ativaTipo + * + * Define a variável com o tipo de gráfico e mostra a guia 2 + */ + ativaTipo : function(obj) { + i3GEOF.graficointerativo1.tipo = obj.value; + if ($i("i3GEOgraficointerativo1Grafico").innerHTML === "" || $i("i3GEOgraficointerativo1tabeladados").innerHTML == "") { - $i("i3GEOgraficointerativo1guia2").onclick.call(); - } else { - $i("i3GEOgraficointerativo1guia4").onclick.call(); - } - }, - /* - * Function: configuraDados - * - * Configura o formulário para obtenção dos dados para - * cada tipo de gráfico - */ - configuraDados : function() { - var ativa = function(comboxlinha, comboylinha, ajudapizza) { - try { - $i("i3GEOgraficointerativo1ComboXlinha").style.display = comboxlinha; - $i("i3GEOgraficointerativo1ComboYlinha").style.display = comboylinha; - $i("i3GEOgraficointerativo1AjudaPizza").style.display = ajudapizza; - } catch (e) { + $i("i3GEOgraficointerativo1guia2").onclick.call(); + } else { + $i("i3GEOgraficointerativo1guia4").onclick.call(); } - }; - if (i3GEOF.graficointerativo1.tipo === "") { - i3GEO.janela.tempoMsg($trad(31, - i3GEOF.graficointerativo1.dicionario)); - i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia1", - "i3GEOgraficointerativo1guia"); - return; - } - if (i3GEOF.graficointerativo1.tipo === "pizza2d") { - ativa.call("block", "block", "block"); - } - }, - /* - * Function: comboItensSel - * - * Cria um combo para selecionar os itens do tema escolhido - * - * Veja: - * - * - */ - comboItensSel : function() { - var tema = $i("i3GEOgraficointerativo1ComboTemasId").value; - i3GEO.util - .comboItens( - "i3GEOgraficointerativo1ComboXid", - tema, - function(retorno) { - if (retorno.tipo === "erro") { - $i("i3GEOgraficointerativo1ComboX").innerHTML = "

" - + $trad( - 32, - i3GEOF.graficointerativo1.dicionario) + }, + /* + * Function: configuraDados + * + * Configura o formulário para obtenção dos dados para + * cada tipo de gráfico + */ + configuraDados : function() { + var ativa = function(comboxlinha, comboylinha, ajudapizza) { + try { + $i("i3GEOgraficointerativo1ComboXlinha").style.display = comboxlinha; + $i("i3GEOgraficointerativo1ComboYlinha").style.display = comboylinha; + $i("i3GEOgraficointerativo1AjudaPizza").style.display = ajudapizza; + } catch (e) { + } + }; + if (i3GEOF.graficointerativo1.tipo === "") { + i3GEO.janela.tempoMsg($trad(31, + i3GEOF.graficointerativo1.dicionario)); + i3GEO.guias.mostraGuiaFerramenta("i3GEOgraficointerativo1guia1", + "i3GEOgraficointerativo1guia"); + return; + } + if (i3GEOF.graficointerativo1.tipo === "pizza2d") { + ativa.call("block", "block", "block"); + } + }, + /* + * Function: comboItensSel + * + * Cria um combo para selecionar os itens do tema escolhido + * + * Veja: + * + * + */ + comboItensSel : function() { + var tema = $i("i3GEOgraficointerativo1ComboTemasId").value; + i3GEO.util + .comboItens( + "i3GEOgraficointerativo1ComboXid", + tema, + function(retorno) { + if (retorno.tipo === "erro") { + $i("i3GEOgraficointerativo1ComboX").innerHTML = "

" + + $trad( + 32, + i3GEOF.graficointerativo1.dicionario) + "

"; - $i("i3GEOgraficointerativo1ComboY").innerHTML = "

" - + $trad( - 32, - i3GEOF.graficointerativo1.dicionario) + $i("i3GEOgraficointerativo1ComboY").innerHTML = "

" + + $trad( + 32, + i3GEOF.graficointerativo1.dicionario) + "

"; - } else { - $i("i3GEOgraficointerativo1ComboY").innerHTML = "
" - + retorno.dados - + " 
"; - $i("i3GEOgraficointerativo1ComboXid").id = "i3GEOgraficointerativo1ComboYid"; - $i("i3GEOgraficointerativo1ComboX").innerHTML = "
" - + retorno.dados - + " 
"; - $i("i3GEOgraficointerativo1ComboXid").style.width = "160px"; - $i("i3GEOgraficointerativo1ComboYid").style.width = "160px"; + } else { + $i("i3GEOgraficointerativo1ComboY").innerHTML = "
" + + retorno.dados + + " " + + " " + + "aquarela.gif
"; - $i("i3GEOgraficointerativo1ComboXid").onchange = function() { - $i(this.id + "Titulo").value = this.options[this.selectedIndex].label; - }; - var adicionaFilho = function() { - var no = document.createElement("div"), tit = $i(this.id - + "Titulo"), novoselect; - if (tit) { - tit.value = this.options[this.selectedIndex].label; - } - no.innerHTML = retorno.dados + "
"; - novoselect = no.getElementsByTagName("select")[0]; - novoselect.id = ""; - novoselect.onchange = adicionaFilho; - novoselect.style.width = "160px"; - $i("i3GEOgraficointerativo1ComboY").appendChild(no); - }; - $i("i3GEOgraficointerativo1ComboYid").onchange = adicionaFilho; - } - }, "i3GEOgraficointerativo1ComboX", ""); - }, - /* - * Function: obterDados - * - * Obtém os dados que serão utilizados no gráfico - * - * Veja: - * - * - */ - obterDados : function() { - if (!i3GEO.Interface) { - return; - } - if (i3GEOF.graficointerativo1.aguarde.visibility === "visible") { - return; - } - var tema = $i("i3GEOgraficointerativo1ComboTemasId").value, excluir = $i("i3GEOgraficointerativo1excluir").value, cp = new cpaint(), tipo = $i("i3GEOgraficointerativo1TipoAgregacao").value, ordenax = "sim", monta, p, x, y, i, n, temp; + $i("i3GEOgraficointerativo1ComboXid").id = "i3GEOgraficointerativo1ComboYid"; + $i("i3GEOgraficointerativo1ComboX").innerHTML = "
" + + retorno.dados + + " 
"; + $i("i3GEOgraficointerativo1ComboXid").style.width = "160px"; + $i("i3GEOgraficointerativo1ComboYid").style.width = "160px"; + + var adicionaFilho = function() { + var no = document.createElement("div"), + id = "CorG"+parseInt(Math.random()*100000,10), + novoselect; + no.innerHTML = retorno.dados + + " " + + " " + + "aquarela.gif
"; + novoselect = no.getElementsByTagName("select")[0]; + novoselect.id = ""; + novoselect.onchange = adicionaFilho; + novoselect.style.width = "160px"; + $i("i3GEOgraficointerativo1ComboY").appendChild(no); + }; + $i("i3GEOgraficointerativo1ComboYid").onchange = adicionaFilho; + } + }, "i3GEOgraficointerativo1ComboX", ""); + }, + /* + * Function: obterDados + * + * Obtém os dados que serão utilizados no gráfico + * + * Veja: + * + * + */ + obterDados : function() { + if (!i3GEO.Interface) { + return; + } + if (i3GEOF.graficointerativo1.aguarde.visibility === "visible") { + return; + } + var tema = $i("i3GEOgraficointerativo1ComboTemasId").value, excluir = $i("i3GEOgraficointerativo1excluir").value, cp = new cpaint(), tipo = $i("i3GEOgraficointerativo1TipoAgregacao").value, ordenax = "sim", monta, p, x, y, i, n, temp; - // pega os itens - temp = $i("i3GEOgraficointerativo1ComboX"); - x = temp.getElementsByTagName("select")[0].value; - temp = $i("i3GEOgraficointerativo1ComboY"); - temp = temp.getElementsByTagName("select"); - n = temp.length; - if (n === 1) { - y = temp[0].value; - } else { - y = []; - for (i = 0; i < n; i++) { - if (temp[i].value != "") { - y.push(temp[i].value); + // pega os itens + temp = $i("i3GEOgraficointerativo1ComboX"); + x = temp.getElementsByTagName("select")[0].value; + temp = $i("i3GEOgraficointerativo1ComboY"); + temp = temp.getElementsByTagName("select"); + n = temp.length; + if (n === 1) { + y = temp[0].value; + } else { + y = []; + for (i = 0; i < n; i++) { + if (temp[i].value != "") { + y.push(temp[i].value); + } } + y = y.join(","); } - y = y.join(","); - } - p = i3GEO.configura.locaplic - + "/ferramentas/graficointerativo1/exec.php?g_sid=" - + i3GEO.configura.sid + "&funcao=graficoSelecao&tema=" + tema - + "&itemclasses=" + x + "&itemvalores=" + y + "&exclui=" - + excluir + "&ext=" + i3GEO.parametros.mapexten; + p = i3GEO.configura.locaplic + + "/ferramentas/graficointerativo1/exec.php?g_sid=" + + i3GEO.configura.sid + "&funcao=graficoSelecao&tema=" + tema + + "&itemclasses=" + x + "&itemvalores=" + y + "&exclui=" + + excluir + "&ext=" + i3GEO.parametros.mapexten; - if ($i("i3GEOgraficointerativo1DadosPuros").checked) { - tipo = "nenhum"; - } else { - if (x === y) { - tipo = "conta"; + if ($i("i3GEOgraficointerativo1DadosPuros").checked) { + tipo = "nenhum"; + } else { + if (x === y) { + tipo = "conta"; + } + } + if (!$i("i3GEOgraficointerativo1OrdenaX").checked) { + ordenax = "nao"; } - } - if (!$i("i3GEOgraficointerativo1OrdenaX").checked) { - ordenax = "nao"; - } - if (tema === "") { - i3GEO.janela.tempoMsg($trad(34, - i3GEOF.graficointerativo1.dicionario)); - return; - } - if (x === "") { - i3GEO.janela.tempoMsg($trad(35, - i3GEOF.graficointerativo1.dicionario)); - return; - } - if (y === "") { - i3GEO.janela.tempoMsg($trad(36, - i3GEOF.graficointerativo1.dicionario)); - return; - } - monta = function(retorno) { - i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; - i3GEOF.graficointerativo1.montaTabelaDados(retorno); - $i("i3GEOgraficointerativo1guia4").onclick.call(); - // verifica para nao ficar mostrando a janela toda vez que redesenha - // o mapa - if ($i("i3GEOFgraficointerativo1ativaNavegacao").checked == false) { - i3GEO.janela.tempoMsg($trad(37, + if (tema === "") { + i3GEO.janela.tempoMsg($trad(34, i3GEOF.graficointerativo1.dicionario)); + return; } - }; - i3GEOF.graficointerativo1.aguarde.visibility = "visible"; - cp.set_response_type("JSON"); - cp.call(p + "&tipo=" + tipo + "&ordenax=" + ordenax, "graficoSelecao", - monta); - }, - /* - * Pega os nomes das colunas - */ - nomesColunas: function(){ - //pega os nomes das clunas - var i,n, + if (x === "") { + i3GEO.janela.tempoMsg($trad(35, + i3GEOF.graficointerativo1.dicionario)); + return; + } + if (y === "") { + i3GEO.janela.tempoMsg($trad(36, + i3GEOF.graficointerativo1.dicionario)); + return; + } + monta = function(retorno) { + i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; + i3GEOF.graficointerativo1.montaTabelaDados(retorno); + $i("i3GEOgraficointerativo1guia4").onclick.call(); + // verifica para nao ficar mostrando a janela toda vez que redesenha + // o mapa + if ($i("i3GEOFgraficointerativo1ativaNavegacao").checked == false) { + i3GEO.janela.tempoMsg($trad(37, + i3GEOF.graficointerativo1.dicionario)); + } + }; + i3GEOF.graficointerativo1.aguarde.visibility = "visible"; + cp.set_response_type("JSON"); + cp.call(p + "&tipo=" + tipo + "&ordenax=" + ordenax, "graficoSelecao", + monta); + }, + /* + * Pega os nomes das colunas + */ + nomesColunas: function(){ + //pega os nomes das clunas + var i,n,p, temp = $i("i3GEOgraficointerativo1ComboX"), - colunas = []; - colunas.push(temp.getElementsByTagName("select")[0].value); - temp = $i("i3GEOgraficointerativo1ComboY"); - temp = temp.getElementsByTagName("select"); - n = temp.length; - for(i=0;i" - + $trad(38, i3GEOF.graficointerativo1.dicionario) - + "

"); - //pega os nomes das clunas - colunas = i3GEOF.graficointerativo1.nomesColunas(); - ncolunas = colunas.length; - for(i=0;i  " - + colunas[i] - + ""); - } - ins.push(""); - n = dados.length; - for (i = 1; i < n; i++) { - v = dados[i].split(";"); - // ins += v[0]+" "+v[1]; - id = "i3GEOgraficointerativo1Dados" + i; // layer+indice da classe - ins.push(""); - ins.push(""); - for(j=0;j"); - ins.push($inputText("", "", id + colunas[j], $trad(43, - i3GEOF.graficointerativo1.dicionario), 20, v[j], colunas[j])); + if (!retorno.dados && retorno.data != undefined) { + dados = retorno.data.dados; + } else { + dados = retorno; + } + ins.push("

" + + $trad(38, i3GEOF.graficointerativo1.dicionario) + + "

" - + $trad(41, i3GEOF.graficointerativo1.dicionario) - + "
"); - ins.push("
"); + //pega os nomes das clunas + colunas = i3GEOF.graficointerativo1.nomesColunas()[0]; + ncolunas = colunas.length; + for(i=0;i  " + + colunas[i] + + ""); + } + ins.push(""); + n = dados.length; + for (i = 1; i < n; i++) { + v = dados[i].split(";"); + // ins += v[0]+" "+v[1]; + id = "i3GEOgraficointerativo1Dados" + i; // layer+indice da classe + ins.push(""); ins.push(""); + for(j=0;j"); + ins.push($inputText("", "", id + colunas[j], $trad(43, + i3GEOF.graficointerativo1.dicionario), 20, v[j], colunas[j])); + ins.push(""); + } + + ins.push(""); } + ins.push("
" + + $trad(41, i3GEOF.graficointerativo1.dicionario) + + "
"); + ins.push(""); + if ($i("i3GEOgraficointerativo1CoresA").checked) { + cor = i3GEO.util.rgb2hex(i3GEO.util.randomRGB()); + } + // verifica se no objeto com os dados existe um terceiro valor com + // as cores + if (v[ncolunas + 1]) { + cor = i3GEO.util.rgb2hex(v[ncolunas + 1]); + } + ins.push($inputText("", "", id + "_cor", "", 12, cor, $trad(41, + i3GEOF.graficointerativo1.dicionario))); + ins.push(""); + ins.push("aquarela.gif"); + ins.push("

"); + $i("i3GEOgraficointerativo1Dados").innerHTML = ins.join(""); + }, + /* + * Function: tabela2csv + * + * Obtém os dados da tabela em CSV + */ + tabela2csv : function() { + var colunas = i3GEOF.graficointerativo1.nomesColunas(), + ncolunas = colunas[0].length, + inputs = $i("i3GEOgraficointerativo1Dados").getElementsByTagName("input"), + ninputs = inputs.length, + i,j, + temp, + csv = []; - ins.push(""); - if ($i("i3GEOgraficointerativo1CoresA").checked) { - cor = i3GEO.util.rgb2hex(i3GEO.util.randomRGB()); + csv.push(colunas[0].join(";")); + for (i = 0; i < ninputs; i = (i + 1 + ncolunas)){ + temp = []; + for(j=0;j"); - ins.push("aquarela.gif"); - ins.push(""); - } - ins.push("
"); - $i("i3GEOgraficointerativo1Dados").innerHTML = ins.join(""); - }, - /* - * Function: tabela2csv - * - * Obtém os dados da tabela em CSV - */ - tabela2csv : function() { - var inputs = $i("i3GEOgraficointerativo1Dados").getElementsByTagName("input"), - ninputs = inputs.length, - i, - legendaX = "", - legendaY = "", - csv = []; - if ($i("i3GEOgraficointerativo1ComboXid")) { - legendaX = $i("i3GEOgraficointerativo1ComboXid").value; - } - if ($i("i3GEOgraficointerativo1ComboYid")) { - legendaY = $i("i3GEOgraficointerativo1ComboYid").value; - } - csv.push(legendaX + ";" + legendaY); - for (i = 0; i < ninputs; i = i + 3) { - csv.push(inputs[i].value + ";" + inputs[i + 1].value * 1); - } - return csv; - }, - /* - * Function: tabela2dados - * - * Obtém os dados da tabela para compor o gráfico - */ - tabela2dados : function() { - if (i3GEOF.graficointerativo1.aguarde.visibility === "visible") { - return; - } - i3GEOF.graficointerativo1.aguarde.visibility = "visible"; - var colunas = i3GEOF.graficointerativo1.nomesColunas(), - ncolunas = colunas.length, + i3GEOF.graficointerativo1.aguarde.visibility = "visible"; + var colunas = i3GEOF.graficointerativo1.nomesColunas(), + ncolunas = colunas[0].length, temp = 0, ultimo = 0, inputs = $i("i3GEOgraficointerativo1Dados").getElementsByTagName("input"), @@ -849,465 +928,479 @@ i3GEOF.graficointerativo1 = { metadados = [], i,j, acumulado = [], acum, cores = [], par = [], total = 0, menor = inputs[1].value * 1, maior = 0, legendaX = "", legendaY = "", dados = {}, xInclinado = $i("i3GEOgraficointerativo1xInclinado").checked; - if ($i("i3GEOgraficointerativo1ComboTemasId")) { - titulo = $i("i3GEOgraficointerativo1ComboTemasId").options[$i("i3GEOgraficointerativo1ComboTemasId").options.selectedIndex].text; - } - if (i3GEOF.graficointerativo1.titulo != "") { - titulo = i3GEOF.graficointerativo1.titulo; - } - if ($i("i3GEOgraficointerativo1ComboXid")) { - legendaX = $i("i3GEOgraficointerativo1ComboXidTitulo").value; - } - if ($i("i3GEOgraficointerativo1ComboYid")) { - legendaY = $i("i3GEOgraficointerativo1ComboYidTitulo").value; - } - if(ncolunas === 2){ - for (i = 0; i < ninputs; i = i + 3) { - temp = inputs[i + 1].value * 1; - total += temp; - cores.push(inputs[i + 2].value); + if ($i("i3GEOgraficointerativo1ComboTemasId")) { + titulo = $i("i3GEOgraficointerativo1ComboTemasId").options[$i("i3GEOgraficointerativo1ComboTemasId").options.selectedIndex].text; + } + if (i3GEOF.graficointerativo1.titulo != "") { + titulo = i3GEOF.graficointerativo1.titulo; } - for (i = 0; i < ninputs; i = (i + 1 + ncolunas)) { - temp = inputs[i + 1].value * 1; - acum = ultimo + temp; - acumulado.push(acum); - ultimo = ultimo + temp; - if (temp > maior) { - maior = temp; + if ($i("i3GEOgraficointerativo1ComboXid")) { + legendaX = $i("i3GEOgraficointerativo1ComboXidTitulo").value; + } + if ($i("i3GEOgraficointerativo1ComboYid")) { + legendaY = $i("i3GEOgraficointerativo1ComboYidTitulo").value; + } + if(ncolunas === 2){ + for (i = 0; i < ninputs; i = i + 3) { + temp = inputs[i + 1].value * 1; + total += temp; + cores.push(inputs[i + 2].value); } - if (temp < menor) { - menor = temp; + for (i = 0; i < ninputs; i = (i + 1 + ncolunas)) { + temp = inputs[i + 1].value * 1; + acum = ultimo + temp; + acumulado.push(acum); + ultimo = ultimo + temp; + if (temp > maior) { + maior = temp; + } + if (temp < menor) { + menor = temp; + } + temp = inputs[i + 1].value * 1; + if ($i("i3GEOgraficointerativo1Acumula").checked) { + temp = acum; + } + if ($i("i3GEOgraficointerativo1Relativa").checked) { + temp = (temp * 100) / total; + } + par.push([ inputs[i].value + " ", temp ]); } - temp = inputs[i + 1].value * 1; if ($i("i3GEOgraficointerativo1Acumula").checked) { - temp = acum; - } - if ($i("i3GEOgraficointerativo1Relativa").checked) { - temp = (temp * 100) / total; + maior = 0; } - par.push([ inputs[i].value + " ", temp ]); } - if ($i("i3GEOgraficointerativo1Acumula").checked) { - maior = 0; - } - } - else{ - total = 0; - for (i = 0; i < ninputs; i = (i + 1 + ncolunas)){ - temp = []; - for(j=0;j 0); - p.parentNode.removeChild(p); - }, - /* - * Function: corj - * - * Abre a janela para o usuário selecionar uma cor interativamente - */ - corj : function(obj) { - i3GEO.util.abreCor("", obj, "hex"); - }, - /* - * Function: ordenaColuna - * - * Ordena uma coluna da tabela - */ - ordenaColuna : function(coluna, cid) { - var tabela = $i("i3GEOgraficointerativo1Dados").getElementsByTagName( - "table")[0], trs, ntrs = 0, psort = [], t = 0, ins = "", p = 0, e, temp, chaves = [], numero = false; + for(j=0;j 0); + p.parentNode.removeChild(p); + }, + /* + * Function: corj + * + * Abre a janela para o usuário selecionar uma cor interativamente + */ + corj : function(obj) { + i3GEO.util.abreCor("", obj, "hex"); + }, + /* + * Function: ordenaColuna + * + * Ordena uma coluna da tabela + */ + ordenaColuna : function(coluna, cid) { + var tabela = $i("i3GEOgraficointerativo1Dados").getElementsByTagName( + "table")[0], trs, ntrs = 0, psort = [], t = 0, ins = "", p = 0, e, temp, chaves = [], numero = false; - trs = tabela.getElementsByTagName("tr"); - ntrs = trs.length; + trs = tabela.getElementsByTagName("tr"); + ntrs = trs.length; - function sortNumber(a, b) { - return a - b; - } - for (t = 1; t < ntrs; t++) { - temp = trs[t].childNodes[cid]; - if (temp) { - psort.push(temp.childNodes[0].value); - chaves[temp.childNodes[0].value] = t; - if (temp.childNodes[0].value * 1) { - numero = true; - } + function sortNumber(a, b) { + return a - b; } - } - // recosntroi a tabela - if (numero === true) { - psort = psort.sort(sortNumber); - } else { - psort = psort.sort(); - } - ins = "" + trs[0].innerHTML + ""; - for (p = 0; p < psort; p++) { - e = chaves[psort[p]]; - if (trs[e] !== undefined) { - ins += "" + trs[e].innerHTML + ""; + for (t = 1; t < ntrs; t++) { + temp = trs[t].childNodes[cid]; + if (temp) { + psort.push(temp.childNodes[0].value); + chaves[temp.childNodes[0].value] = t; + if (temp.childNodes[0].value * 1) { + numero = true; + } + } } - } - tabela.innerHTML = ins; - }, - /* - * Function: ativaNavegacao - * - * Ativa ou desativa a atualização automática ao - * navegar no mapa - */ - ativaNavegacao : function(obj) { - if (!i3GEO.Interface) { - return; - } - if (obj === true) { - if (i3GEO.Interface.ATUAL !== "googlemaps" - && i3GEO.Interface.ATUAL !== "googleearth") { - i3GEO.eventos.NAVEGAMAPA - .push("i3GEOF.graficointerativo1.obterDados()"); + // recosntroi a tabela + if (numero === true) { + psort = psort.sort(sortNumber); + } else { + psort = psort.sort(); } - if (i3GEO.Interface.ATUAL === "googlemaps") { - graficointerativo1Dragend = GEvent.addListener(i3GeoMap, - "dragend", function() { - i3GEOF.graficointerativo1.obterDados(); - }); - graficointerativo1Zoomend = GEvent.addListener(i3GeoMap, - "zoomend", function() { - i3GEOF.graficointerativo1.obterDados(); - }); + ins = "" + trs[0].innerHTML + ""; + for (p = 0; p < psort; p++) { + e = chaves[psort[p]]; + if (trs[e] !== undefined) { + ins += "" + trs[e].innerHTML + ""; + } } - if (i3GEO.Interface.ATUAL === "googleearth") { - graficointerativo1Dragend = google.earth.addEventListener( - i3GeoMap.getView(), "viewchangeend", function() { - i3GEOF.graficointerativo1.obterDados(); - }); + tabela.innerHTML = ins; + }, + /* + * Function: ativaNavegacao + * + * Ativa ou desativa a atualização automática ao + * navegar no mapa + */ + ativaNavegacao : function(obj) { + if (!i3GEO.Interface) { + return; } - } else { - if (i3GEO.Interface.ATUAL !== "googlemaps" + if (obj === true) { + if (i3GEO.Interface.ATUAL !== "googlemaps" && i3GEO.Interface.ATUAL !== "googleearth") { - i3GEO.eventos.NAVEGAMAPA - .remove("i3GEOF.graficointerativo1.obterDados()"); + i3GEO.eventos.NAVEGAMAPA + .push("i3GEOF.graficointerativo1.obterDados()"); + } + if (i3GEO.Interface.ATUAL === "googlemaps") { + graficointerativo1Dragend = GEvent.addListener(i3GeoMap, + "dragend", function() { + i3GEOF.graficointerativo1.obterDados(); + }); + graficointerativo1Zoomend = GEvent.addListener(i3GeoMap, + "zoomend", function() { + i3GEOF.graficointerativo1.obterDados(); + }); + } + if (i3GEO.Interface.ATUAL === "googleearth") { + graficointerativo1Dragend = google.earth.addEventListener( + i3GeoMap.getView(), "viewchangeend", function() { + i3GEOF.graficointerativo1.obterDados(); + }); + } + } else { + if (i3GEO.Interface.ATUAL !== "googlemaps" + && i3GEO.Interface.ATUAL !== "googleearth") { + i3GEO.eventos.NAVEGAMAPA + .remove("i3GEOF.graficointerativo1.obterDados()"); + } + if (i3GEO.Interface.ATUAL === "googlemaps") { + GEvent.removeListener(graficointerativo1Dragend); + GEvent.removeListener(graficointerativo1Zoomend); + } + if (i3GEO.Interface.ATUAL === "googleearth") { + google.earth.removeEventListener(graficointerativo1Dragend); + } } - if (i3GEO.Interface.ATUAL === "googlemaps") { - GEvent.removeListener(graficointerativo1Dragend); - GEvent.removeListener(graficointerativo1Zoomend); + }, + configDefault : function(dados, maior, cores, legendaY, legendaX) { + var config = { + canvas : "i3GEOgraficointerativo1guia4objCanvas", + width : dados.resultset.length * $i("i3GEOgraficointerativo1FatorTamanho").value, + height : parseInt($i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, + orthoAxisTitle : legendaY, + valuesFont : 'normal 9px sans-serif ', + baseAxisTitle : legendaX, + baseAxisTitleAlign : 'center', + tooltipEnabled : true, + tooltipArrowVisible : true, + tooltipFade : false, + tooltipFollowMouse : false, + tooltipFormat : function(scene) { + var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms['value'].value; + return "" + cat + "
" + + format("#.###,", val); + }, + baseAxisTitleFont : '9px sans-serif', + yAxisTickFormatter : function(valor) { + valor = valor + ""; + valor = format("#.###,", valor); + return valor; + }, + valueFormat : function(valor) { + valor = valor + ""; + valor = format("#.###,", valor); + return valor; + }, + valuesAnchor : 'top', + valuesVisible : false, + orthoAxisOriginIsZero : false, + titleAlign : 'center', + titleFont: 'bold 14px sans-serif', + baseAxisTitleFont : '12px sans-serif', + orthoAxisTitleFont : '12px sans-serif', + titlePosition: "top", + orientation : 'vertical', + baseAxisTicks : true, + stacked : false, + animate : true, + hoverable : false, + axisGrid : true, + contentMargins : 5, + axisOffset : 0.02, + panelSizeRatio : 0.8, + orthoAxisLabelSpacingMin : 2, + selectable : false, + extensionPoints : { + continuousAxisTicks_strokeStyle : 'gray', + axisGrid_strokeStyle : 'lightgray', + xAxisLabel_textStyle : 'black', + label_textBaseline : "bottom", + xAxisLabel_font : 'normal 10px sans-serif' + } + }; + if(maior > 0){ + config.orthoAxisFixedMax = maior; } - if (i3GEO.Interface.ATUAL === "googleearth") { - google.earth.removeEventListener(graficointerativo1Dragend); + if($i("i3GEOgraficointerativo1Titulo").value != ""){ + config.title = $i("i3GEOgraficointerativo1Titulo").value; } - } - }, - configDefault : function(dados, maior, cores, legendaY, legendaX) { - var config = { - canvas : "i3GEOgraficointerativo1guia4objCanvas", - width : dados.resultset.length - * $i("i3GEOgraficointerativo1FatorTamanho").value, - height : parseInt( - $i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, - orthoAxisTitle : legendaY, - valuesFont : 'normal 9px sans-serif ', - baseAxisTitle : legendaX, - baseAxisTitleAlign : 'left', - tooltipEnabled : true, - tooltipArrowVisible : true, - tooltipFade : false, - tooltipFollowMouse : false, - tooltipFormat : function(scene) { - var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms['value'].value; - return "" + cat + "
" - + format("#.###,", val); - }, - baseAxisTitleFont : '9px sans-serif', - yAxisTickFormatter : function(valor) { - valor = valor + ""; - valor = format("#.###,", valor); - return valor; - }, - valueFormat : function(valor) { - valor = valor + ""; - valor = format("#.###,", valor); - return valor; - }, - valuesAnchor : 'top', - valuesVisible : false, - orthoAxisOriginIsZero : false, - titleAlign : 'center', - orientation : 'vertical', - baseAxisTicks : true, - stacked : false, - animate : true, - hoverable : false, - axisGrid : true, - contentMargins : 5, - axisOffset : 0.02, - panelSizeRatio : 0.8, - orthoAxisLabelSpacingMin : 2, - selectable : false, - extensionPoints : { - continuousAxisTicks_strokeStyle : 'gray', - axisGrid_strokeStyle : 'lightgray', - xAxisLabel_textStyle : 'black', - label_textBaseline : "bottom", - xAxisLabel_font : 'normal 10px sans-serif' + if($i("i3GEOgraficointerativo1TituloX").value != ""){ + config.baseAxisTitle = $i("i3GEOgraficointerativo1TituloX").value; } - }; - if(maior > 0){ - config.orthoAxisFixedMax = maior; - } - return config; - }, - barras : function(dados, maior, cores, legendaY, legendaX, xInclinado, tipo) { - var ct = true, + if($i("i3GEOgraficointerativo1TituloY").value != ""){ + config.orthoAxisTitle = $i("i3GEOgraficointerativo1TituloY").value; + } + return config; + }, + barras : function(dados, maior, cores, legendaY, legendaX, xInclinado, tipo) { + var ct = true, sr = false, - config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores, - legendaY, legendaX); - if(cores != ""){ - config.extensionPoints.bar_fillStyle = function(d) { - return cores[this.index]; - }; - } - if (tipo === "horizontal") { - config.orientation = 'horizontal'; - } - if (xInclinado == true) { - config.extensionPoints.xAxisLabel_textAngle = -Math.PI / 3; - config.extensionPoints.xAxisLabel_textBaseline = 'top'; - config.extensionPoints.xAxisLabel_textAlign = 'right'; - } - if(dados.resultset[0].length > 2){ - config.stacked = $i("i3GEOFgraficointerativo1ativaStacked").checked; - config.legend = true; - ct = true; - sr = $i("i3GEOFgraficointerativo1ativaRowsInColumns").checked; - } - new pvc.BarChart(config).setData(dados, { - crosstabMode : ct, - seriesInRows: sr - }).render(); - i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; - }, - linhas : function(dados, maior, cores, legendaY, legendaX, xInclinado, tipo) { - var ct = false, + config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores,legendaY, legendaX); + if (tipo === "horizontal") { + config.orientation = 'horizontal'; + } + if (xInclinado == true) { + config.extensionPoints.xAxisLabel_textAngle = -Math.PI / 3; + config.extensionPoints.xAxisLabel_textBaseline = 'top'; + config.extensionPoints.xAxisLabel_textAlign = 'right'; + } + if(dados.resultset[0].length > 2){ + config.stacked = $i("i3GEOFgraficointerativo1ativaStacked").checked; + config.legend = true; + ct = true; + sr = $i("i3GEOFgraficointerativo1ativaRowsInColumns").checked; + config.colors = cores; + } + else{ + if(cores != ""){ + config.extensionPoints.bar_fillStyle = function(d) { + return cores[this.index]; + }; + } + } + new pvc.BarChart(config).setData(dados, { + crosstabMode : ct, + seriesInRows: sr + }).render(); + i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; + }, + linhas : function(dados, maior, cores, legendaY, legendaX, xInclinado, tipo) { + var ct = false, sr = false, config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores, - legendaY, legendaX); - if (xInclinado == true) { - config.extensionPoints.xAxisLabel_textAngle = -Math.PI / 3; - config.extensionPoints.xAxisLabel_textBaseline = 'top'; - config.extensionPoints.xAxisLabel_textAlign = 'right'; - } - config.dotsVisible = true; + legendaY, legendaX); + if (xInclinado == true) { + config.extensionPoints.xAxisLabel_textAngle = -Math.PI / 3; + config.extensionPoints.xAxisLabel_textBaseline = 'top'; + config.extensionPoints.xAxisLabel_textAlign = 'right'; + } + config.dotsVisible = true; - if(dados.resultset[0].length > 2){ - config.stacked = $i("i3GEOFgraficointerativo1ativaStacked").checked; - config.legend = true; - ct = true; - sr = $i("i3GEOFgraficointerativo1ativaRowsInColumns").checked; - } - new pvc.LineChart(config).setData(dados, { - crosstabMode : ct, - seriesInRows: sr - }).render(); - i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; - }, - areas : function(dados, maior, cores, legendaY, legendaX, xInclinado, tipo) { - var ct = false, + if(dados.resultset[0].length > 2){ + config.stacked = $i("i3GEOFgraficointerativo1ativaStacked").checked; + config.legend = true; + ct = true; + sr = $i("i3GEOFgraficointerativo1ativaRowsInColumns").checked; + config.colors = cores; + } + new pvc.LineChart(config).setData(dados, { + crosstabMode : ct, + seriesInRows: sr + }).render(); + i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; + }, + areas : function(dados, maior, cores, legendaY, legendaX, xInclinado, tipo) { + var ct = false, sr = false, config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores, - legendaY, legendaX); - if (xInclinado == true) { - config.extensionPoints.xAxisLabel_textAngle = -Math.PI / 3; - config.extensionPoints.xAxisLabel_textBaseline = 'top'; - config.extensionPoints.xAxisLabel_textAlign = 'right'; - } - config.dotsVisible = true; - config.areasVisible = true; + legendaY, legendaX); + if (xInclinado == true) { + config.extensionPoints.xAxisLabel_textAngle = -Math.PI / 3; + config.extensionPoints.xAxisLabel_textBaseline = 'top'; + config.extensionPoints.xAxisLabel_textAlign = 'right'; + } + config.dotsVisible = true; + config.areasVisible = true; - if(dados.resultset[0].length > 2){ - config.stacked = $i("i3GEOFgraficointerativo1ativaStacked").checked; - config.legend = true; - ct = true; - sr = $i("i3GEOFgraficointerativo1ativaRowsInColumns").checked; - } - new pvc.LineChart(config).setData(dados, { - crosstabMode : ct, - seriesInRows: sr - }).render(); - i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; - }, - arvores : function(dados, maior, cores, legendaY, legendaX, tipo) { - // config = - // i3GEOF.graficointerativo1.configDefault(dados,maior,cores,legendaY,legendaX); - // config.rootCategoryLabel = legendaX; - config = { - canvas : "i3GEOgraficointerativo1guia4objCanvas", - width : dados.resultset.length + if(dados.resultset[0].length > 2){ + config.stacked = $i("i3GEOFgraficointerativo1ativaStacked").checked; + config.legend = true; + ct = true; + sr = $i("i3GEOFgraficointerativo1ativaRowsInColumns").checked; + config.colors = cores; + } + new pvc.LineChart(config).setData(dados, { + crosstabMode : ct, + seriesInRows: sr + }).render(); + i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; + }, + arvores : function(dados, maior, cores, legendaY, legendaX, tipo) { + // config = + // i3GEOF.graficointerativo1.configDefault(dados,maior,cores,legendaY,legendaX); + // config.rootCategoryLabel = legendaX; + config = { + canvas : "i3GEOgraficointerativo1guia4objCanvas", + width : dados.resultset.length * $i("i3GEOgraficointerativo1FatorTamanho").value, - height : parseInt( - $i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, - title : legendaY, - titleFont : 'italic 14px sans-serif', - selectable : true, - hoverable : true, - legend : false, - tooltipEnabled : true, - legendPosition : 'right', - rootCategoryLabel : legendaX, - tooltipFormat : function(scene) { - var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms.size.value; - return "" + cat + "
" - + format("#.###,", val); + height : parseInt( + $i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, + title : legendaY, + titleFont : 'italic 14px sans-serif', + selectable : true, + hoverable : true, + legend : false, + tooltipEnabled : true, + legendPosition : 'right', + rootCategoryLabel : legendaX, + tooltipFormat : function(scene) { + var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms.size.value; + return "" + cat + "
" + + format("#.###,", val); + } + }; + if(cores != ""){ + config.colors = cores; } - }; - if(cores != ""){ - config.colors = cores; - } - new pvc.TreemapChart(config).setData(dados, { - crosstabMode : false - }).render(); - i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; - }, - pizzas : function(dados, maior, cores, legendaY, legendaX, tipo) { - config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores, - legendaY, legendaX); - var config = { - canvas : "i3GEOgraficointerativo1guia4objCanvas", - width : dados.resultset.length + new pvc.TreemapChart(config).setData(dados, { + crosstabMode : false + }).render(); + i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; + }, + pizzas : function(dados, maior, cores, legendaY, legendaX, tipo) { + config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores, + legendaY, legendaX); + var config = { + canvas : "i3GEOgraficointerativo1guia4objCanvas", + width : dados.resultset.length * $i("i3GEOgraficointerativo1FatorTamanho").value, - height : parseInt( - $i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, - animate : true, - selectable : true, - hoverable : true, - valuesVisible : true, - valuesLabelStyle : 'inside', - valuesMask : "{category}", - tooltipFormat : function(scene) { - var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms['value'].value; - return "" + cat + "
" - + format("#.###,", val); - }, - extensionPoints : { - slice_strokeStyle : 'white' + height : parseInt( + $i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, + animate : true, + selectable : true, + hoverable : true, + valuesVisible : true, + valuesLabelStyle : 'inside', + valuesMask : "{category}", + tooltipFormat : function(scene) { + var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms['value'].value; + return "" + cat + "
" + + format("#.###,", val); + }, + extensionPoints : { + slice_strokeStyle : 'white' + } + }; + if(cores != ""){ + config.colors = cores; } - }; - if(cores != ""){ - config.colors = cores; - } - new pvc.PieChart(config).setData(dados, { - crosstabMode : false - }).render(); - i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; - }, - pontos : function(dados, maior, cores, legendaY, legendaX, tipo) { - config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores, - legendaY, legendaX); - var config = { - canvas : "i3GEOgraficointerativo1guia4objCanvas", - width : dados.resultset.length + new pvc.PieChart(config).setData(dados, { + crosstabMode : false + }).render(); + i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; + }, + pontos : function(dados, maior, cores, legendaY, legendaX, tipo) { + config = i3GEOF.graficointerativo1.configDefault(dados, maior, cores, + legendaY, legendaX); + var config = { + canvas : "i3GEOgraficointerativo1guia4objCanvas", + width : dados.resultset.length * $i("i3GEOgraficointerativo1FatorTamanho").value, - height : parseInt( - $i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, - animate : true, - selectable : true, - hoverable : true, - valuesVisible : false, - orthoAxisTitle : legendaY, - valuesFont : 'normal 9px sans-serif ', - baseAxisTitle : legendaX, - yAxisTickFormatter : function(valor) { - valor = valor + ""; - valor = format("#.###,", valor); - return valor; - }, - valueFormat : function(valor) { - valor = valor + ""; - valor = format("#.###,", valor); - return valor; - }, - tooltipFormat : function(scene) { - var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms['value'].value; - return "X: " + cat + "
Y: " - + format("#.###,", val); + height : parseInt( + $i("i3GEOF.graficointerativo1_corpo").style.height, 10) - 80, + animate : true, + selectable : true, + hoverable : true, + valuesVisible : false, + orthoAxisTitle : legendaY, + valuesFont : 'normal 9px sans-serif ', + baseAxisTitle : legendaX, + yAxisTickFormatter : function(valor) { + valor = valor + ""; + valor = format("#.###,", valor); + return valor; + }, + valueFormat : function(valor) { + valor = valor + ""; + valor = format("#.###,", valor); + return valor; + }, + tooltipFormat : function(scene) { + var cat = this.scene.datum.atoms['category'].value, val = this.scene.datum.atoms['value'].value; + return "X: " + cat + "
Y: " + + format("#.###,", val); + } + }; + if(cores != ""){ + config.colors = cores; } - }; - if(cores != ""){ - config.colors = cores; + new pvc.DotChart(config).setData(dados, { + crosstabMode : false + }).render(); + i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; } - new pvc.DotChart(config).setData(dados, { - crosstabMode : false - }).render(); - i3GEOF.graficointerativo1.aguarde.visibility = "hidden"; - } }; diff --git a/pacotes/base64.js b/pacotes/base64.js new file mode 100755 index 0000000..3bad6d8 --- /dev/null +++ b/pacotes/base64.js @@ -0,0 +1,113 @@ +/* Copyright (C) 1999 Masanao Izumo + * Version: 1.0 + * LastModified: Dec 25 1999 + * This library is free. You can redistribute it and/or modify it. + */ + +/* + * Interfaces: + * b64 = base64encode(data); + * data = base64decode(b64); + */ + +(function() { + +var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var base64DecodeChars = new Array( + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1); + +function base64encode(str) { + var out, i, len; + var c1, c2, c3; + + len = str.length; + i = 0; + out = ""; + while(i < len) { + c1 = str.charCodeAt(i++) & 0xff; + if(i == len) + { + out += base64EncodeChars.charAt(c1 >> 2); + out += base64EncodeChars.charAt((c1 & 0x3) << 4); + out += "=="; + break; + } + c2 = str.charCodeAt(i++); + if(i == len) + { + out += base64EncodeChars.charAt(c1 >> 2); + out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); + out += base64EncodeChars.charAt((c2 & 0xF) << 2); + out += "="; + break; + } + c3 = str.charCodeAt(i++); + out += base64EncodeChars.charAt(c1 >> 2); + out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); + out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)); + out += base64EncodeChars.charAt(c3 & 0x3F); + } + return out; +} + +function base64decode(str) { + var c1, c2, c3, c4; + var i, len, out; + + len = str.length; + i = 0; + out = ""; + while(i < len) { + /* c1 */ + do { + c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; + } while(i < len && c1 == -1); + if(c1 == -1) + break; + + /* c2 */ + do { + c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; + } while(i < len && c2 == -1); + if(c2 == -1) + break; + + out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4)); + + /* c3 */ + do { + c3 = str.charCodeAt(i++) & 0xff; + if(c3 == 61) + return out; + c3 = base64DecodeChars[c3]; + } while(i < len && c3 == -1); + if(c3 == -1) + break; + + out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2)); + + /* c4 */ + do { + c4 = str.charCodeAt(i++) & 0xff; + if(c4 == 61) + return out; + c4 = base64DecodeChars[c4]; + } while(i < len && c4 == -1); + if(c4 == -1) + break; + out += String.fromCharCode(((c3 & 0x03) << 6) | c4); + } + return out; +} + +if (!window.btoa) window.btoa = base64encode; +if (!window.atob) window.atob = base64decode; + +})(); \ No newline at end of file diff --git a/pacotes/canvas2image.js b/pacotes/canvas2image.js new file mode 100755 index 0000000..f90c5bb --- /dev/null +++ b/pacotes/canvas2image.js @@ -0,0 +1,235 @@ +/* + * Canvas2Image v0.1 + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk + * MIT License [http://www.opensource.org/licenses/mit-license.php] + */ + +var Canvas2Image = (function() { + + // check if we have canvas support + var bHasCanvas = false; + var oCanvas = document.createElement("canvas"); + if (oCanvas.getContext("2d")) { + bHasCanvas = true; + } + + // no canvas, bail out. + if (!bHasCanvas) { + return { + saveAsBMP : function(){}, + saveAsPNG : function(){}, + saveAsJPEG : function(){} + } + } + + var bHasImageData = !!(oCanvas.getContext("2d").getImageData); + var bHasDataURL = !!(oCanvas.toDataURL); + var bHasBase64 = !!(window.btoa); + + var strDownloadMime = "image/octet-stream"; + + // ok, we're good + var readCanvasData = function(oCanvas) { + var iWidth = parseInt(oCanvas.width); + var iHeight = parseInt(oCanvas.height); + return oCanvas.getContext("2d").getImageData(0,0,iWidth,iHeight); + } + + // base64 encodes either a string or an array of charcodes + var encodeData = function(data) { + var strData = ""; + if (typeof data == "string") { + strData = data; + } else { + var aData = data; + for (var i=0;i object containing the imagedata + var makeImageObject = function(strSource) { + var oImgElement = document.createElement("img"); + oImgElement.src = strSource; + return oImgElement; + } + + var scaleCanvas = function(oCanvas, iWidth, iHeight) { + if (iWidth && iHeight) { + var oSaveCanvas = document.createElement("canvas"); + oSaveCanvas.width = iWidth; + oSaveCanvas.height = iHeight; + oSaveCanvas.style.width = iWidth+"px"; + oSaveCanvas.style.height = iHeight+"px"; + + var oSaveCtx = oSaveCanvas.getContext("2d"); + + oSaveCtx.drawImage(oCanvas, 0, 0, oCanvas.width, oCanvas.height, 0, 0, iWidth, iHeight); + return oSaveCanvas; + } + return oCanvas; + } + + return { + + saveAsPNG : function(oCanvas, bReturnImg, iWidth, iHeight) { + if (!bHasDataURL) { + return false; + } + var oScaledCanvas = scaleCanvas(oCanvas, iWidth, iHeight); + var strData = oScaledCanvas.toDataURL("image/png"); + if (bReturnImg) { + return makeImageObject(strData); + } else { + saveFile(strData.replace("image/png", strDownloadMime)); + } + return true; + }, + + saveAsJPEG : function(oCanvas, bReturnImg, iWidth, iHeight) { + if (!bHasDataURL) { + return false; + } + + var oScaledCanvas = scaleCanvas(oCanvas, iWidth, iHeight); + var strMime = "image/jpeg"; + var strData = oScaledCanvas.toDataURL(strMime); + + // check if browser actually supports jpeg by looking for the mime type in the data uri. + // if not, return false + if (strData.indexOf(strMime) != 5) { + return false; + } + + if (bReturnImg) { + return makeImageObject(strData); + } else { + saveFile(strData.replace(strMime, strDownloadMime)); + } + return true; + }, + + saveAsBMP : function(oCanvas, bReturnImg, iWidth, iHeight) { + if (!(bHasImageData && bHasBase64)) { + return false; + } + + var oScaledCanvas = scaleCanvas(oCanvas, iWidth, iHeight); + + var oData = readCanvasData(oScaledCanvas); + var strImgData = createBMP(oData); + if (bReturnImg) { + return makeImageObject(makeDataURI(strImgData, "image/bmp")); + } else { + saveFile(makeDataURI(strImgData, strDownloadMime)); + } + return true; + } + }; + +})(); \ No newline at end of file diff --git a/pacotes/canvg.js b/pacotes/canvg.js new file mode 100755 index 0000000..2628e53 --- /dev/null +++ b/pacotes/canvg.js @@ -0,0 +1,2886 @@ +/* + * canvg.js - Javascript SVG parser and renderer on Canvas + * MIT Licensed + * Gabe Lerner (gabelerner@gmail.com) + * http://code.google.com/p/canvg/ + * + * Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/ + */ +(function(){ + // canvg(target, s) + // empty parameters: replace all 'svg' elements on page with 'canvas' elements + // target: canvas element or the id of a canvas element + // s: svg string, url to svg file, or xml document + // opts: optional hash of options + // ignoreMouse: true => ignore mouse events + // ignoreAnimation: true => ignore animations + // ignoreDimensions: true => does not try to resize canvas + // ignoreClear: true => does not clear canvas + // offsetX: int => draws at a x offset + // offsetY: int => draws at a y offset + // scaleWidth: int => scales horizontally to width + // scaleHeight: int => scales vertically to height + // renderCallback: function => will call the function after the first render is completed + // forceRedraw: function => will call the function on every frame, if it returns true, will redraw + this.canvg = function (target, s, opts) { + // no parameters + if (target == null && s == null && opts == null) { + var svgTags = document.getElementsByTagName('svg'); + for (var i=0; i]*>/, ''); + var xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); + xmlDoc.async = 'false'; + xmlDoc.loadXML(xml); + return xmlDoc; + } + } + + svg.Property = function(name, value) { + this.name = name; + this.value = value; + } + svg.Property.prototype.getValue = function() { + return this.value; + } + + svg.Property.prototype.hasValue = function() { + return (this.value != null && this.value !== ''); + } + + // return the numerical value of the property + svg.Property.prototype.numValue = function() { + if (!this.hasValue()) return 0; + + var n = parseFloat(this.value); + if ((this.value + '').match(/%$/)) { + n = n / 100.0; + } + return n; + } + + svg.Property.prototype.valueOrDefault = function(def) { + if (this.hasValue()) return this.value; + return def; + } + + svg.Property.prototype.numValueOrDefault = function(def) { + if (this.hasValue()) return this.numValue(); + return def; + } + + // color extensions + // augment the current color value with the opacity + svg.Property.prototype.addOpacity = function(opacity) { + var newValue = this.value; + if (opacity != null && opacity != '' && typeof(this.value)=='string') { // can only add opacity to colors, not patterns + var color = new RGBColor(this.value); + if (color.ok) { + newValue = 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + opacity + ')'; + } + } + return new svg.Property(this.name, newValue); + } + + // definition extensions + // get the definition from the definitions table + svg.Property.prototype.getDefinition = function() { + var name = this.value.match(/#([^\)'"]+)/); + if (name) { name = name[1]; } + if (!name) { name = this.value; } + return svg.Definitions[name]; + } + + svg.Property.prototype.isUrlDefinition = function() { + return this.value.indexOf('url(') == 0 + } + + svg.Property.prototype.getFillStyleDefinition = function(e, opacityProp) { + var def = this.getDefinition(); + + // gradient + if (def != null && def.createGradient) { + return def.createGradient(svg.ctx, e, opacityProp); + } + + // pattern + if (def != null && def.createPattern) { + if (def.getHrefAttribute().hasValue()) { + var pt = def.attribute('patternTransform'); + def = def.getHrefAttribute().getDefinition(); + if (pt.hasValue()) { def.attribute('patternTransform', true).value = pt.value; } + } + return def.createPattern(svg.ctx, e); + } + + return null; + } + + // length extensions + svg.Property.prototype.getDPI = function(viewPort) { + return 96.0; // TODO: compute? + } + + svg.Property.prototype.getEM = function(viewPort) { + var em = 12; + + var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize); + if (fontSize.hasValue()) em = fontSize.toPixels(viewPort); + + return em; + } + + svg.Property.prototype.getUnits = function() { + var s = this.value+''; + return s.replace(/[0-9\.\-]/g,''); + } + + // get the length as pixels + svg.Property.prototype.toPixels = function(viewPort, processPercent) { + if (!this.hasValue()) return 0; + var s = this.value+''; + if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort); + if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0; + if (s.match(/px$/)) return this.numValue(); + if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0); + if (s.match(/pc$/)) return this.numValue() * 15; + if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54; + if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4; + if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort); + if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort); + var n = this.numValue(); + if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort); + return n; + } + + // time extensions + // get the time as milliseconds + svg.Property.prototype.toMilliseconds = function() { + if (!this.hasValue()) return 0; + var s = this.value+''; + if (s.match(/s$/)) return this.numValue() * 1000; + if (s.match(/ms$/)) return this.numValue(); + return this.numValue(); + } + + // angle extensions + // get the angle as radians + svg.Property.prototype.toRadians = function() { + if (!this.hasValue()) return 0; + var s = this.value+''; + if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0); + if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0); + if (s.match(/rad$/)) return this.numValue(); + return this.numValue() * (Math.PI / 180.0); + } + + // fonts + svg.Font = new (function() { + this.Styles = 'normal|italic|oblique|inherit'; + this.Variants = 'normal|small-caps|inherit'; + this.Weights = 'normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit'; + + this.CreateFont = function(fontStyle, fontVariant, fontWeight, fontSize, fontFamily, inherit) { + var f = inherit != null ? this.Parse(inherit) : this.CreateFont('', '', '', '', '', svg.ctx.font); + return { + fontFamily: fontFamily || f.fontFamily, + fontSize: fontSize || f.fontSize, + fontStyle: fontStyle || f.fontStyle, + fontWeight: fontWeight || f.fontWeight, + fontVariant: fontVariant || f.fontVariant, + toString: function () { return [this.fontStyle, this.fontVariant, this.fontWeight, this.fontSize, this.fontFamily].join(' ') } + } + } + + var that = this; + this.Parse = function(s) { + var f = {}; + var d = svg.trim(svg.compressSpaces(s || '')).split(' '); + var set = { fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false } + var ff = ''; + for (var i=0; i this.x2) this.x2 = x; + } + + if (y != null) { + if (isNaN(this.y1) || isNaN(this.y2)) { + this.y1 = y; + this.y2 = y; + } + if (y < this.y1) this.y1 = y; + if (y > this.y2) this.y2 = y; + } + } + this.addX = function(x) { this.addPoint(x, null); } + this.addY = function(y) { this.addPoint(null, y); } + + this.addBoundingBox = function(bb) { + this.addPoint(bb.x1, bb.y1); + this.addPoint(bb.x2, bb.y2); + } + + this.addQuadraticCurve = function(p0x, p0y, p1x, p1y, p2x, p2y) { + var cp1x = p0x + 2/3 * (p1x - p0x); // CP1 = QP0 + 2/3 *(QP1-QP0) + var cp1y = p0y + 2/3 * (p1y - p0y); // CP1 = QP0 + 2/3 *(QP1-QP0) + var cp2x = cp1x + 1/3 * (p2x - p0x); // CP2 = CP1 + 1/3 *(QP2-QP0) + var cp2y = cp1y + 1/3 * (p2y - p0y); // CP2 = CP1 + 1/3 *(QP2-QP0) + this.addBezierCurve(p0x, p0y, cp1x, cp2x, cp1y, cp2y, p2x, p2y); + } + + this.addBezierCurve = function(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) { + // from http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html + var p0 = [p0x, p0y], p1 = [p1x, p1y], p2 = [p2x, p2y], p3 = [p3x, p3y]; + this.addPoint(p0[0], p0[1]); + this.addPoint(p3[0], p3[1]); + + for (i=0; i<=1; i++) { + var f = function(t) { + return Math.pow(1-t, 3) * p0[i] + + 3 * Math.pow(1-t, 2) * t * p1[i] + + 3 * (1-t) * Math.pow(t, 2) * p2[i] + + Math.pow(t, 3) * p3[i]; + } + + var b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i]; + var a = -3 * p0[i] + 9 * p1[i] - 9 * p2[i] + 3 * p3[i]; + var c = 3 * p1[i] - 3 * p0[i]; + + if (a == 0) { + if (b == 0) continue; + var t = -c / b; + if (0 < t && t < 1) { + if (i == 0) this.addX(f(t)); + if (i == 1) this.addY(f(t)); + } + continue; + } + + var b2ac = Math.pow(b, 2) - 4 * c * a; + if (b2ac < 0) continue; + var t1 = (-b + Math.sqrt(b2ac)) / (2 * a); + if (0 < t1 && t1 < 1) { + if (i == 0) this.addX(f(t1)); + if (i == 1) this.addY(f(t1)); + } + var t2 = (-b - Math.sqrt(b2ac)) / (2 * a); + if (0 < t2 && t2 < 1) { + if (i == 0) this.addX(f(t2)); + if (i == 1) this.addY(f(t2)); + } + } + } + + this.isPointInBox = function(x, y) { + return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2); + } + + this.addPoint(x1, y1); + this.addPoint(x2, y2); + } + + // transforms + svg.Transform = function(v) { + var that = this; + this.Type = {} + + // translate + this.Type.translate = function(s) { + this.p = svg.CreatePoint(s); + this.apply = function(ctx) { + ctx.translate(this.p.x || 0.0, this.p.y || 0.0); + } + this.unapply = function(ctx) { + ctx.translate(-1.0 * this.p.x || 0.0, -1.0 * this.p.y || 0.0); + } + this.applyToPoint = function(p) { + p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]); + } + } + + // rotate + this.Type.rotate = function(s) { + var a = svg.ToNumberArray(s); + this.angle = new svg.Property('angle', a[0]); + this.cx = a[1] || 0; + this.cy = a[2] || 0; + this.apply = function(ctx) { + ctx.translate(this.cx, this.cy); + ctx.rotate(this.angle.toRadians()); + ctx.translate(-this.cx, -this.cy); + } + this.unapply = function(ctx) { + ctx.translate(this.cx, this.cy); + ctx.rotate(-1.0 * this.angle.toRadians()); + ctx.translate(-this.cx, -this.cy); + } + this.applyToPoint = function(p) { + var a = this.angle.toRadians(); + p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]); + p.applyTransform([Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]); + p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]); + } + } + + this.Type.scale = function(s) { + this.p = svg.CreatePoint(s); + this.apply = function(ctx) { + ctx.scale(this.p.x || 1.0, this.p.y || this.p.x || 1.0); + } + this.unapply = function(ctx) { + ctx.scale(1.0 / this.p.x || 1.0, 1.0 / this.p.y || this.p.x || 1.0); + } + this.applyToPoint = function(p) { + p.applyTransform([this.p.x || 0.0, 0, 0, this.p.y || 0.0, 0, 0]); + } + } + + this.Type.matrix = function(s) { + this.m = svg.ToNumberArray(s); + this.apply = function(ctx) { + ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]); + } + this.applyToPoint = function(p) { + p.applyTransform(this.m); + } + } + + this.Type.SkewBase = function(s) { + this.base = that.Type.matrix; + this.base(s); + this.angle = new svg.Property('angle', s); + } + this.Type.SkewBase.prototype = new this.Type.matrix; + + this.Type.skewX = function(s) { + this.base = that.Type.SkewBase; + this.base(s); + this.m = [1, 0, Math.tan(this.angle.toRadians()), 1, 0, 0]; + } + this.Type.skewX.prototype = new this.Type.SkewBase; + + this.Type.skewY = function(s) { + this.base = that.Type.SkewBase; + this.base(s); + this.m = [1, Math.tan(this.angle.toRadians()), 0, 1, 0, 0]; + } + this.Type.skewY.prototype = new this.Type.SkewBase; + + this.transforms = []; + + this.apply = function(ctx) { + for (var i=0; i=0; i--) { + this.transforms[i].unapply(ctx); + } + } + + this.applyToPoint = function(p) { + for (var i=0; i= this.tokens.length - 1; + } + + this.isCommandOrEnd = function() { + if (this.isEnd()) return true; + return this.tokens[this.i + 1].match(/^[A-Za-z]$/) != null; + } + + this.isRelativeCommand = function() { + switch(this.command) + { + case 'm': + case 'l': + case 'h': + case 'v': + case 'c': + case 's': + case 'q': + case 't': + case 'a': + case 'z': + return true; + break; + } + return false; + } + + this.getToken = function() { + this.i++; + return this.tokens[this.i]; + } + + this.getScalar = function() { + return parseFloat(this.getToken()); + } + + this.nextCommand = function() { + this.previousCommand = this.command; + this.command = this.getToken(); + } + + this.getPoint = function() { + var p = new svg.Point(this.getScalar(), this.getScalar()); + return this.makeAbsolute(p); + } + + this.getAsControlPoint = function() { + var p = this.getPoint(); + this.control = p; + return p; + } + + this.getAsCurrentPoint = function() { + var p = this.getPoint(); + this.current = p; + return p; + } + + this.getReflectedControlPoint = function() { + if (this.previousCommand.toLowerCase() != 'c' && + this.previousCommand.toLowerCase() != 's' && + this.previousCommand.toLowerCase() != 'q' && + this.previousCommand.toLowerCase() != 't' ){ + return this.current; + } + + // reflect point + var p = new svg.Point(2 * this.current.x - this.control.x, 2 * this.current.y - this.control.y); + return p; + } + + this.makeAbsolute = function(p) { + if (this.isRelativeCommand()) { + p.x += this.current.x; + p.y += this.current.y; + } + return p; + } + + this.addMarker = function(p, from, priorTo) { + // if the last angle isn't filled in because we didn't have this point yet ... + if (priorTo != null && this.angles.length > 0 && this.angles[this.angles.length-1] == null) { + this.angles[this.angles.length-1] = this.points[this.points.length-1].angleTo(priorTo); + } + this.addMarkerAngle(p, from == null ? null : from.angleTo(p)); + } + + this.addMarkerAngle = function(p, a) { + this.points.push(p); + this.angles.push(a); + } + + this.getMarkerPoints = function() { return this.points; } + this.getMarkerAngles = function() { + for (var i=0; i 1) { + rx *= Math.sqrt(l); + ry *= Math.sqrt(l); + } + // cx', cy' + var s = (largeArcFlag == sweepFlag ? -1 : 1) * Math.sqrt( + ((Math.pow(rx,2)*Math.pow(ry,2))-(Math.pow(rx,2)*Math.pow(currp.y,2))-(Math.pow(ry,2)*Math.pow(currp.x,2))) / + (Math.pow(rx,2)*Math.pow(currp.y,2)+Math.pow(ry,2)*Math.pow(currp.x,2)) + ); + if (isNaN(s)) s = 0; + var cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx); + // cx, cy + var centp = new svg.Point( + (curr.x + cp.x) / 2.0 + Math.cos(xAxisRotation) * cpp.x - Math.sin(xAxisRotation) * cpp.y, + (curr.y + cp.y) / 2.0 + Math.sin(xAxisRotation) * cpp.x + Math.cos(xAxisRotation) * cpp.y + ); + // vector magnitude + var m = function(v) { return Math.sqrt(Math.pow(v[0],2) + Math.pow(v[1],2)); } + // ratio between two vectors + var r = function(u, v) { return (u[0]*v[0]+u[1]*v[1]) / (m(u)*m(v)) } + // angle between two vectors + var a = function(u, v) { return (u[0]*v[1] < u[1]*v[0] ? -1 : 1) * Math.acos(r(u,v)); } + // initial angle + var a1 = a([1,0], [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]); + // angle delta + var u = [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]; + var v = [(-currp.x-cpp.x)/rx,(-currp.y-cpp.y)/ry]; + var ad = a(u, v); + if (r(u,v) <= -1) ad = Math.PI; + if (r(u,v) >= 1) ad = 0; + + // for markers + var dir = 1 - sweepFlag ? 1.0 : -1.0; + var ah = a1 + dir * (ad / 2.0); + var halfWay = new svg.Point( + centp.x + rx * Math.cos(ah), + centp.y + ry * Math.sin(ah) + ); + pp.addMarkerAngle(halfWay, ah - dir * Math.PI / 2); + pp.addMarkerAngle(cp, ah - dir * Math.PI); + + bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better + if (ctx != null) { + var r = rx > ry ? rx : ry; + var sx = rx > ry ? 1 : rx / ry; + var sy = rx > ry ? ry / rx : 1; + + ctx.translate(centp.x, centp.y); + ctx.rotate(xAxisRotation); + ctx.scale(sx, sy); + ctx.arc(0, 0, r, a1, a1 + ad, 1 - sweepFlag); + ctx.scale(1/sx, 1/sy); + ctx.rotate(-xAxisRotation); + ctx.translate(-centp.x, -centp.y); + } + } + break; + case 'Z': + case 'z': + if (ctx != null) ctx.closePath(); + pp.current = pp.start; + } + } + + return bb; + } + + this.getMarkers = function() { + var points = this.PathParser.getMarkerPoints(); + var angles = this.PathParser.getMarkerAngles(); + + var markers = []; + for (var i=0; i 1) this.offset = 1; + + var stopColor = this.style('stop-color'); + if (this.style('stop-opacity').hasValue()) stopColor = stopColor.addOpacity(this.style('stop-opacity').value); + this.color = stopColor.value; + } + svg.Element.stop.prototype = new svg.Element.ElementBase; + + // animation base element + svg.Element.AnimateBase = function(node) { + this.base = svg.Element.ElementBase; + this.base(node); + + svg.Animations.push(this); + + this.duration = 0.0; + this.begin = this.attribute('begin').toMilliseconds(); + this.maxDuration = this.begin + this.attribute('dur').toMilliseconds(); + + this.getProperty = function() { + var attributeType = this.attribute('attributeType').value; + var attributeName = this.attribute('attributeName').value; + + if (attributeType == 'CSS') { + return this.parent.style(attributeName, true); + } + return this.parent.attribute(attributeName, true); + }; + + this.initialValue = null; + this.initialUnits = ''; + this.removed = false; + + this.calcValue = function() { + // OVERRIDE ME! + return ''; + } + + this.update = function(delta) { + // set initial value + if (this.initialValue == null) { + this.initialValue = this.getProperty().value; + this.initialUnits = this.getProperty().getUnits(); + } + + // if we're past the end time + if (this.duration > this.maxDuration) { + // loop for indefinitely repeating animations + if (this.attribute('repeatCount').value == 'indefinite' + || this.attribute('repeatDur').value == 'indefinite') { + this.duration = 0.0 + } + else if (this.attribute('fill').valueOrDefault('remove') == 'remove' && !this.removed) { + this.removed = true; + this.getProperty().value = this.initialValue; + return true; + } + else { + return false; // no updates made + } + } + this.duration = this.duration + delta; + + // if we're past the begin time + var updated = false; + if (this.begin < this.duration) { + var newValue = this.calcValue(); // tween + + if (this.attribute('type').hasValue()) { + // for transform, etc. + var type = this.attribute('type').value; + newValue = type + '(' + newValue + ')'; + } + + this.getProperty().value = newValue; + updated = true; + } + + return updated; + } + + this.from = this.attribute('from'); + this.to = this.attribute('to'); + this.values = this.attribute('values'); + if (this.values.hasValue()) this.values.value = this.values.value.split(';'); + + // fraction of duration we've covered + this.progress = function() { + var ret = { progress: (this.duration - this.begin) / (this.maxDuration - this.begin) }; + if (this.values.hasValue()) { + var p = ret.progress * (this.values.value.length - 1); + var lb = Math.floor(p), ub = Math.ceil(p); + ret.from = new svg.Property('from', parseFloat(this.values.value[lb])); + ret.to = new svg.Property('to', parseFloat(this.values.value[ub])); + ret.progress = (p - lb) / (ub - lb); + } + else { + ret.from = this.from; + ret.to = this.to; + } + return ret; + } + } + svg.Element.AnimateBase.prototype = new svg.Element.ElementBase; + + // animate element + svg.Element.animate = function(node) { + this.base = svg.Element.AnimateBase; + this.base(node); + + this.calcValue = function() { + var p = this.progress(); + + // tween value linearly + var newValue = p.from.numValue() + (p.to.numValue() - p.from.numValue()) * p.progress; + return newValue + this.initialUnits; + }; + } + svg.Element.animate.prototype = new svg.Element.AnimateBase; + + // animate color element + svg.Element.animateColor = function(node) { + this.base = svg.Element.AnimateBase; + this.base(node); + + this.calcValue = function() { + var p = this.progress(); + var from = new RGBColor(p.from.value); + var to = new RGBColor(p.to.value); + + if (from.ok && to.ok) { + // tween color linearly + var r = from.r + (to.r - from.r) * p.progress; + var g = from.g + (to.g - from.g) * p.progress; + var b = from.b + (to.b - from.b) * p.progress; + return 'rgb('+parseInt(r,10)+','+parseInt(g,10)+','+parseInt(b,10)+')'; + } + return this.attribute('from').value; + }; + } + svg.Element.animateColor.prototype = new svg.Element.AnimateBase; + + // animate transform element + svg.Element.animateTransform = function(node) { + this.base = svg.Element.AnimateBase; + this.base(node); + + this.calcValue = function() { + var p = this.progress(); + + // tween value linearly + var from = svg.ToNumberArray(p.from.value); + var to = svg.ToNumberArray(p.to.value); + var newValue = ''; + for (var i=0; i startI && child.attribute('x').hasValue()) break; // new group + width += child.measureTextRecursive(ctx); + } + return -1 * (textAnchor == 'end' ? width : width / 2.0); + } + return 0; + } + + this.renderChild = function(ctx, parent, i) { + var child = parent.children[i]; + if (child.attribute('x').hasValue()) { + child.x = child.attribute('x').toPixels('x') + this.getAnchorDelta(ctx, parent, i); + } + else { + if (this.attribute('dx').hasValue()) this.x += this.attribute('dx').toPixels('x'); + if (child.attribute('dx').hasValue()) this.x += child.attribute('dx').toPixels('x'); + child.x = this.x; + } + this.x = child.x + child.measureText(ctx); + + if (child.attribute('y').hasValue()) { + child.y = child.attribute('y').toPixels('y'); + } + else { + if (this.attribute('dy').hasValue()) this.y += this.attribute('dy').toPixels('y'); + if (child.attribute('dy').hasValue()) this.y += child.attribute('dy').toPixels('y'); + child.y = this.y; + } + this.y = child.y; + + child.render(ctx); + + for (var i=0; i0 && text[i-1]!=' ' && i0 && text[i-1]!=' ' && (i == text.length-1 || text[i+1]==' ')) arabicForm = 'initial'; + if (typeof(font.glyphs[c]) != 'undefined') { + glyph = font.glyphs[c][arabicForm]; + if (glyph == null && font.glyphs[c].type == 'glyph') glyph = font.glyphs[c]; + } + } + else { + glyph = font.glyphs[c]; + } + if (glyph == null) glyph = font.missingGlyph; + return glyph; + } + + this.renderChildren = function(ctx) { + var customFont = this.parent.style('font-family').getDefinition(); + if (customFont != null) { + var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize); + var fontStyle = this.parent.style('font-style').valueOrDefault(svg.Font.Parse(svg.ctx.font).fontStyle); + var text = this.getText(); + if (customFont.isRTL) text = text.split("").reverse().join(""); + + var dx = svg.ToNumberArray(this.parent.attribute('dx').value); + for (var i=0; i 0) { + var urlStart = srcs[s].indexOf('url'); + var urlEnd = srcs[s].indexOf(')', urlStart); + var url = srcs[s].substr(urlStart + 5, urlEnd - urlStart - 6); + var doc = svg.parseXml(svg.ajax(url)); + var fonts = doc.getElementsByTagName('font'); + for (var f=0; f + * @link http://www.phpied.com/rgb-color-parser-in-javascript/ + * @license Use it if you like it + */ +function RGBColor(color_string) +{ + this.ok = false; + + // strip any leading # + if (color_string.charAt(0) == '#') { // remove # if any + color_string = color_string.substr(1,6); + } + + color_string = color_string.replace(/ /g,''); + color_string = color_string.toLowerCase(); + + // before getting into regexps, try simple matches + // and overwrite the input + var simple_colors = { + aliceblue: 'f0f8ff', + antiquewhite: 'faebd7', + aqua: '00ffff', + aquamarine: '7fffd4', + azure: 'f0ffff', + beige: 'f5f5dc', + bisque: 'ffe4c4', + black: '000000', + blanchedalmond: 'ffebcd', + blue: '0000ff', + blueviolet: '8a2be2', + brown: 'a52a2a', + burlywood: 'deb887', + cadetblue: '5f9ea0', + chartreuse: '7fff00', + chocolate: 'd2691e', + coral: 'ff7f50', + cornflowerblue: '6495ed', + cornsilk: 'fff8dc', + crimson: 'dc143c', + cyan: '00ffff', + darkblue: '00008b', + darkcyan: '008b8b', + darkgoldenrod: 'b8860b', + darkgray: 'a9a9a9', + darkgreen: '006400', + darkkhaki: 'bdb76b', + darkmagenta: '8b008b', + darkolivegreen: '556b2f', + darkorange: 'ff8c00', + darkorchid: '9932cc', + darkred: '8b0000', + darksalmon: 'e9967a', + darkseagreen: '8fbc8f', + darkslateblue: '483d8b', + darkslategray: '2f4f4f', + darkturquoise: '00ced1', + darkviolet: '9400d3', + deeppink: 'ff1493', + deepskyblue: '00bfff', + dimgray: '696969', + dodgerblue: '1e90ff', + feldspar: 'd19275', + firebrick: 'b22222', + floralwhite: 'fffaf0', + forestgreen: '228b22', + fuchsia: 'ff00ff', + gainsboro: 'dcdcdc', + ghostwhite: 'f8f8ff', + gold: 'ffd700', + goldenrod: 'daa520', + gray: '808080', + green: '008000', + greenyellow: 'adff2f', + honeydew: 'f0fff0', + hotpink: 'ff69b4', + indianred : 'cd5c5c', + indigo : '4b0082', + ivory: 'fffff0', + khaki: 'f0e68c', + lavender: 'e6e6fa', + lavenderblush: 'fff0f5', + lawngreen: '7cfc00', + lemonchiffon: 'fffacd', + lightblue: 'add8e6', + lightcoral: 'f08080', + lightcyan: 'e0ffff', + lightgoldenrodyellow: 'fafad2', + lightgrey: 'd3d3d3', + lightgreen: '90ee90', + lightpink: 'ffb6c1', + lightsalmon: 'ffa07a', + lightseagreen: '20b2aa', + lightskyblue: '87cefa', + lightslateblue: '8470ff', + lightslategray: '778899', + lightsteelblue: 'b0c4de', + lightyellow: 'ffffe0', + lime: '00ff00', + limegreen: '32cd32', + linen: 'faf0e6', + magenta: 'ff00ff', + maroon: '800000', + mediumaquamarine: '66cdaa', + mediumblue: '0000cd', + mediumorchid: 'ba55d3', + mediumpurple: '9370d8', + mediumseagreen: '3cb371', + mediumslateblue: '7b68ee', + mediumspringgreen: '00fa9a', + mediumturquoise: '48d1cc', + mediumvioletred: 'c71585', + midnightblue: '191970', + mintcream: 'f5fffa', + mistyrose: 'ffe4e1', + moccasin: 'ffe4b5', + navajowhite: 'ffdead', + navy: '000080', + oldlace: 'fdf5e6', + olive: '808000', + olivedrab: '6b8e23', + orange: 'ffa500', + orangered: 'ff4500', + orchid: 'da70d6', + palegoldenrod: 'eee8aa', + palegreen: '98fb98', + paleturquoise: 'afeeee', + palevioletred: 'd87093', + papayawhip: 'ffefd5', + peachpuff: 'ffdab9', + peru: 'cd853f', + pink: 'ffc0cb', + plum: 'dda0dd', + powderblue: 'b0e0e6', + purple: '800080', + red: 'ff0000', + rosybrown: 'bc8f8f', + royalblue: '4169e1', + saddlebrown: '8b4513', + salmon: 'fa8072', + sandybrown: 'f4a460', + seagreen: '2e8b57', + seashell: 'fff5ee', + sienna: 'a0522d', + silver: 'c0c0c0', + skyblue: '87ceeb', + slateblue: '6a5acd', + slategray: '708090', + snow: 'fffafa', + springgreen: '00ff7f', + steelblue: '4682b4', + tan: 'd2b48c', + teal: '008080', + thistle: 'd8bfd8', + tomato: 'ff6347', + turquoise: '40e0d0', + violet: 'ee82ee', + violetred: 'd02090', + wheat: 'f5deb3', + white: 'ffffff', + whitesmoke: 'f5f5f5', + yellow: 'ffff00', + yellowgreen: '9acd32' + }; + for (var key in simple_colors) { + if (color_string == key) { + color_string = simple_colors[key]; + } + } + // emd of simple type-in colors + + // array of color definition objects + var color_defs = [ + { + re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, + example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], + process: function (bits){ + return [ + parseInt(bits[1]), + parseInt(bits[2]), + parseInt(bits[3]) + ]; + } + }, + { + re: /^(\w{2})(\w{2})(\w{2})$/, + example: ['#00ff00', '336699'], + process: function (bits){ + return [ + parseInt(bits[1], 16), + parseInt(bits[2], 16), + parseInt(bits[3], 16) + ]; + } + }, + { + re: /^(\w{1})(\w{1})(\w{1})$/, + example: ['#fb0', 'f0f'], + process: function (bits){ + return [ + parseInt(bits[1] + bits[1], 16), + parseInt(bits[2] + bits[2], 16), + parseInt(bits[3] + bits[3], 16) + ]; + } + } + ]; + + // search through the definitions to find a match + for (var i = 0; i < color_defs.length; i++) { + var re = color_defs[i].re; + var processor = color_defs[i].process; + var bits = re.exec(color_string); + if (bits) { + channels = processor(bits); + this.r = channels[0]; + this.g = channels[1]; + this.b = channels[2]; + this.ok = true; + } + + } + + // validate/cleanup values + this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r); + this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g); + this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b); + + // some getters + this.toRGB = function () { + return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')'; + } + this.toHex = function () { + var r = this.r.toString(16); + var g = this.g.toString(16); + var b = this.b.toString(16); + if (r.length == 1) r = '0' + r; + if (g.length == 1) g = '0' + g; + if (b.length == 1) b = '0' + b; + return '#' + r + g + b; + } + + // help + this.getHelpXML = function () { + + var examples = new Array(); + // add regexps + for (var i = 0; i < color_defs.length; i++) { + var example = color_defs[i].example; + for (var j = 0; j < example.length; j++) { + examples[examples.length] = example[j]; + } + } + // add type-in colors + for (var sc in simple_colors) { + examples[examples.length] = sc; + } + + var xml = document.createElement('ul'); + xml.setAttribute('id', 'rgbcolor-examples'); + for (var i = 0; i < examples.length; i++) { + try { + var list_item = document.createElement('li'); + var list_color = new RGBColor(examples[i]); + var example_div = document.createElement('div'); + example_div.style.cssText = + 'margin: 3px; ' + + 'border: 1px solid black; ' + + 'background:' + list_color.toHex() + '; ' + + 'color:' + list_color.toHex() + ; + example_div.appendChild(document.createTextNode('test')); + var list_item_value = document.createTextNode( + ' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex() + ); + list_item.appendChild(example_div); + list_item.appendChild(list_item_value); + xml.appendChild(list_item); + + } catch(e){} + } + return xml; + + } + +} + diff --git a/pacotes/svg2img.php b/pacotes/svg2img.php new file mode 100755 index 0000000..6401eb9 --- /dev/null +++ b/pacotes/svg2img.php @@ -0,0 +1,31 @@ + + + + + + + + + +
+ + + \ No newline at end of file -- libgit2 0.21.2