Hello,
I'm having trouble setting width and height attributes while using
SVGGraphics2D. It seems that the default width and height get set to
"2147483647" when using SVGGraphics2D. When I try to set these
attributes by manipulating the DOM I get strange results. In the
following code, I attempt to set the attributes by hand. However when
run (with Batik 1.0, JDK 1.3.0, RedHat Linux 7.1) my changes never
appear in the resulting XML output.
import java.io.*;
import java.awt.*;
import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.*;
public class SVGTest {
public static void main(String[] args) {
DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
// get the root element (the svg element)
Element svgRoot = doc.getDocumentElement();
// set the width and height attribute on the root svg element
svgRoot.setAttributeNS(svgNS, "width", "1024");
svgRoot.setAttributeNS(svgNS, "height", "768");
// Create an instance of the SVG Generator
SVGGraphics2D g = new SVGGraphics2D(doc);
// set background to white
g.setColor(Color.white);
g.fill(new Rectangle(0, 0, 1024, 768));
g.setColor(Color.red);
g.fill(new Rectangle(100, 100, 100, 100));
try {
FileWriter writer = new FileWriter(new File("svgtest.xml"));
g.stream(writer, false);
writer.flush();
writer.close();
} catch (IOException e) {
System.err.println(e.getMessage());
System.exit(1);
}
System.exit(0);
}
}
Also, I notice that I need to explicitly call System.exit(), else my
main never exits... are there lingering threads in the batik code?
Thanks for your help.
PS: I'd like to say thanks to all the Batik developers; this is a
great package! I've been meaning to send a "thank you" email to you
guys ever since the JavaOne talk back in June. Great job!
--
George Armhold
Rutgers University
Bioinformatics Initiative
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]