Hello!

I'm using Batik and it's very useful. Now, I have a problem and I don't find
the mistake.
I'm trying to put many SVG in a java.swing.JTabbedPane where every tab
contain a SVG. When SVG are big, SVG are'nt displayed.

This is the function where I create a SVG:

        public SVGDocument generaGraficoSVG() {
                int number_elements=101;
                DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
                String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
                SVGDocument doc = (SVGDocument)impl.createDocument(svgNS,
"svg", null);

                // obtenemos el elemento raiz (svg)
                Element svgRoot = doc.getDocumentElement();

                Element script = doc.createElement("script");
                script.setAttributeNS(null,"type","text/ecmascript");
                Text txt = doc.createTextNode("function showDialog(msg) {
alert(msg); }");
                script.appendChild(txt);
                svgRoot.appendChild(script);

                //creamos lineas de separaci�n entre subestaciones
                Element grup_lineas = doc.createElementNS(svgNS, "g");
                grup_lineas.setAttributeNS(null, "id", "lineas_subs");

                int space=0;
                for(int i=0;i<number_elements;i++) {
                        Element linea = doc.createElementNS(svgNS, "line");
        
linea.setAttributeNS(null,"x1",String.valueOf(space));
                        linea.setAttributeNS(null,"y1","0");
        
linea.setAttributeNS(null,"x2",String.valueOf(space));
                        linea.setAttributeNS(null,"y2","300");
                        linea.setAttributeNS(null,"stroke","black");
                        grup_lineas.appendChild(linea);
                        Element linea_valor = doc.createElementNS(svgNS,
"line");
        
linea_valor.setAttributeNS(null,"x1",String.valueOf(space+25));
                        linea_valor.setAttributeNS(null,"y1","50");
        
linea_valor.setAttributeNS(null,"x2",String.valueOf(space+25));
                        linea_valor.setAttributeNS(null,"y2","300");
                        linea_valor.setAttributeNS(null,"stroke","red");
        
linea_valor.setAttributeNS(null,"style","stroke-width:5");
        
linea_valor.setAttributeNS(null,"onclick","showDialog('"+i+"')");
                        grup_lineas.appendChild(linea_valor);

                        space+=50;
                }
                svgRoot.appendChild(grup_lineas);

                // asignamos atributos a elemento raiz
                svgRoot.setAttributeNS(null, "width",
String.valueOf(space));
                svgRoot.setAttributeNS(null, "height", "300");
                
                return doc;
        }

if number_elements is 11, for example, then the program works. This is the
function where I put every SVG in a tab (where there is a JSVGCanvas in
every tab):

        public void dibujaReports(ListaReportsGraficos lista_reports) {
                LinkedList reports=lista_reports.getReports();
                ReportGrafico report;

                try {
                        for (Iterator i=reports.iterator();i.hasNext();) {
                                report=(ReportGrafico)i.next();
                                JSVGCanvas svgCanvas = new JSVGCanvas();
        
svgCanvas.setSVGDocument(report.generaGraficoSVG());
                                JScrollPane sc=new JScrollPane(svgCanvas);
                                etiquetas_reports.addTab(
report.getNombre(),null,sc,"" );
                        }
                } catch (Exception e) {
                        System.out.println(e.getMessage());
                }
        }

        where etiquetas_reports is a java.swing.JTabbedPane

It doesn't catch any exception.

I have another problem. The function showDialog in SVG doesn't work. When
you click on a line appears:

scripting error: "showDialog" is not defined.

Could you help me?

Thanks a lot.
Josep M�


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to