hello thomas,
i do what you says me thomas , this my code:
public static void main(String[] args) throws Exception {
String Entree = "batik3D.svg";
String Sortie = "sortie.svg";
//declaration variable
String rep="c:/pierrestage/JavaApplication1/";
//int width = Integer.parseInt(parama);
//int height = Integer.parseInt(paramb);
// Ouverture du fichier svg
String svgURI = new File(rep+Entree).toURL().toString();
FileInputStream instream = new FileInputStream(rep+Entree);
System.out.println("svgURI = "+svgURI);
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
System.out.println("svgNS = "+svgNS);
Document doc1 = impl.createDocument(svgNS, "svg", null);
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
Document doc2 = f.createDocument(svgURI);
/***** methode de thomas *****/
/*SVGDocument svgDoc;
UserAgent userAgent;
DocumentLoader loader;
BridgeContext ctx;
GVTBuilder builder;
GraphicsNode gn;*/
UserAgent userAgent = new UserAgentAdapter();
GVTBuilder builder = new GVTBuilder();
DocumentLoader docload = new DocumentLoader(userAgent);
Document doc = docload.loadDocument(svgURI,instream);
//doc = docload.checkCache(svgURI);
BridgeContext ctx = new BridgeContext(userAgent,docload);
System.out.println("ctx = "+ctx);
System.out.println("doc = "+doc);
System.out.println("doc1 = "+doc1);
System.out.println("doc2 = "+doc2);
GraphicsNode gn = builder.build(ctx,doc);
SVGGraphics2D sg2D = new SVGGraphics2D(doc);
GraphicsNode gn1 = builder.build(ctx,doc1);
SVGGraphics2D sg2D1 = new SVGGraphics2D(doc1);
GraphicsNode gn2 = builder.build(ctx,doc2);
SVGGraphics2D sg2D2 = new SVGGraphics2D(doc2);
System.out.println("svg2D = "+sg2D);
System.out.println("svg2D1 = "+sg2D1);
System.out.println("svg2D2 = "+sg2D2);
System.out.println("gn = "+gn);
System.out.println("gn1 = "+gn1);
System.out.println("gn2 = "+gn2);
//gn.paint(sg2D2);
//gn1.paint(sg2D);
gn2.paint(sg2D2);
gn2.setVisible(true);
/***** *****/
//fais le clipping un rectangle
//dimension du clipping
sg2D.setClip(0,0,200,300);
//different test d affichage ca marche
sg2D.drawString("test marche ou pas",10,150);
sg2D.drawLine(200,200,110,200);
//dimension de l image finale
//sg2D.setSVGCanvasSize(new Dimension(640,480));
//ecrit normalement sur le fichier de sortie mon clipping
sg2D.stream(rep+Sortie);
System.out.println("fichier " + Sortie + " a été généré");
}
/************************************/
when i compil it i wrote this at the referrences of gn2.paint(sg2D2) :
Exception in thread "main" java.lang.NullPointerException
at org.apache.batik.ext.awt.image.GraphicsUtil.getDestination(Unknown
Source)
at
org.apache.batik.ext.awt.image.GraphicsUtil.getDestinationColorModel(Unknown
Source)
at
org.apache.batik.ext.awt.image.GraphicsUtil.getDestinationColorSpace(Unknown
Source)
at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(Unknown Source)
at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(Unknown Source)
at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
at org.apache.batik.gvt.ShapeNode.paint(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown
Source)
at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown
Source)
at org.apache.batik.gvt.CanvasGraphicsNode.primitivePaint(Unknown
Source)
at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
at javaapplication1.Main.main(Main.java:122)
i verify my sg2D and the doc it'snt null : what the problem.
if a comment //gn2.paint(sg2D2) he dont show the clipping of my svg
file(batik3D.svg)
thanks for your help
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]