xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jones, John JH SITI-ITADED" <john.jo...@shell.com>
Subject Failure to generate XML after using SVGGraphics2D apparently OK.
Date Mon, 03 May 2004 14:44:05 GMT
Hi,
I am using W2000 and Oracle Jdeveloper 9.0.3. I downloaded BATIK 1.5.1 on 17th April.

I have 30+ years of software experience but am a beginner at JAVA and BATIK and mailing lists
. This is my first graphics program. (I have read the BATIK FAQ but quite a lot of it has
no meaning for me.)

The program appears to work when I do not attempt to generate the XML. i.e the frame displays
what I am expecting. I am trying to capture the XML in order to view the diagram in a browser.
I have followed http://xml.apache.org/batik/svggen.html .

When I try to generate the XML after displaying the output,  there are no exceptions raised
or other messages but all I get is :
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg style="stroke-dasharray:none; shape-rendering:auto; font-family:&apos;Arial&apos;;
text-rendering:auto; fill-opacity:1; color-rendering:auto; color-interpolation:auto; font-size:12;
fill:black; stroke:black; image-rendering:auto; stroke-miterlimit:10; stroke-linecap:square;
stroke-linejoin:miter; font-style:normal; stroke-width:1; stroke-dashoffset:0; font-weight:normal;
stroke-opacity:1;" xmlns="http://www.w3.org/2000/svg" width="700" contentScriptType="text/ecmascript"
preserveAspectRatio="xMidYMid meet" xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify"
version="1.0" contentStyleType="text/css" height="700">
  <!--Generated by the Batik Graphics2D SVG Generator-->
  <defs id="genericDefs" />
  <g />
</svg>

Here are my imports and what I think to be the relevant bit of the main method:

package helen;
//import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.UIManager;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.Toolkit;
import org.apache.batik.swing.*;
import org.apache.batik.svggen.*;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.w3c.dom.*;
import org.w3c.dom.svg.*;
import java.awt.geom.*;
import java.awt.*;
import java.io.*;
      .................
// SVG set-up
    DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
    SVGDocument doc = (SVGDocument)impl.createDocument(svgNS, "svg", null);

    SVGGraphics2D g = new SVGGraphics2D(doc);

    Diag d = new Diag(g, xlim, ylim, xorig, yorig, 3600);

// Draw into g. For example:
    d.buildDiag();        //Builds the internal representation of diagram
    d.drawDiag();        //Uses SVGGraphics2D to draw the diagram
    g.setSVGCanvasSize(dim);

//  The following populates the document root with the 
//  generated SVG content.
    Element root = doc.getDocumentElement();
    g.getRoot(root);

// Now, display the document
    JSVGCanvas canvas = new JSVGCanvas();
    frame.getContentPane().add(canvas);
    canvas.setSVGDocument(doc);
//  frame.pack(); 
    frame.setVisible(true);
    
    System.out.println("Back from DrawDiag & display.");
    try
    { OutputStream outStream= new FileOutputStream("C:\\TEMP\\Helen_plasmid1.xml", false);
      Writer out = new OutputStreamWriter(outStream, "UTF-8");
//      Writer out = new OutputStreamWriter(System.out, "UTF-8");
//
      g.stream(out,true);
      Thread.sleep(10000);   // In case something is being slow.
      out.close();
    } catch (Exception e)
    { System.out.println("Failed to write xml version.");
    };  
    System.out.println("Back from xml gen.");
  }
          ........................

Any suggestions please?

 John 


Mime
View raw message