Salut

j'utilise Batik pour afficher une image SVG, il lit le fichier sans problème et l'affiche mais si je doit afficher une autre image, j'obtiens l'erreur suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
java.lang.OutOfMemoryError: Java heap space
	at java.awt.image.DataBufferInt.<init>(Unknown Source)
	at java.awt.image.SinglePixelPackedSampleModel.createDataBuffer(Unknown Source)
	at java.awt.image.Raster.createWritableRaster(Unknown Source)
	at org.apache.batik.gvt.renderer.DynamicRenderer.updateWorkingBuffers(DynamicRenderer.java:112)
	at org.apache.batik.gvt.renderer.StaticRenderer.clearOffScreen(StaticRenderer.java:307)
	at org.apache.batik.swing.gvt.GVTTreeRenderer.run(GVTTreeRenderer.java:108)
je ne vois pas où se trouve le problème, voici le code pour afficher l'image :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
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
 
public class AfficheSVG {
 
 
	protected Document doc;
 
	 protected Element svg;
	public void svg(JSVGCanvas canvas, int w, int h){
		try {					
		         // Parse the barChart.svg file into a Document.
		         String parser = XMLResourceDescriptor.getXMLParserClassName();
		         SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);			         
		         doc = f.createDocument(new File("C:/data.svg").toURI().toString());
		         svg = doc.getDocumentElement();
 
		         // Change the document viewBox.
		         svg.setAttributeNS(null, "viewBox", "0 0 "+w+" "+h);
 
		         // Make the text look nice.
		         svg.setAttributeNS(null, "text-rendering", "geometricPrecision");
 
		         // Remove the xml-stylesheet PI.
		         for (Node n = svg.getPreviousSibling();
		                 n != null;
		                 n = n.getPreviousSibling()) {
		             if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
		                 doc.removeChild(n);
		                 break;
		             }
		         }
 
		         // Remove the Batik sample mark 'use' element.
		         for (Node n = svg.getLastChild();
		                 n != null;
		                 n = n.getPreviousSibling()) {
		             if (n.getNodeType() == Node.ELEMENT_NODE
		                     && n.getLocalName().equals("use")) {
		                 svg.removeChild(n);
		                 break;
		             }
		             canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
		             canvas.setDocument(doc);		             
		         }
		     } catch (Exception ex) {
		     }
	}
	public void destroy(JSVGCanvas canvas) {
		canvas.dispose();
    }
}
merci pour votre aide