Hi, I am trying to create line at different points through Path command. But it is printing the line on the basis of last co-ordinates. I have placed the path command in the for loop. Please help because after this I have to append this svg file with another svg file having used the path command.
Below is my code: import java.io.*; import org.apache.batik.transcoder.image.JPEGTranscoder; import org.apache.batik.transcoder.svg2svg.SVGTranscoder; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.w3c.dom.DOMImplementation; import org.apache.batik.dom.svg.SVGDOMImplementation; import org.apache.batik.bridge.ViewBox; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.DOMImplementation; class svgGenerating extends ViewBox { public Document documentGenerating() { DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); Element svgRoot,rectangle,rectangle1,rectangle2,rectangle3,rectangle4,path1; // we are using a constant available on the SVGDOMImplementation // but we could have used "http://www.w3.org/2000/svg" String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; Document doc = impl.createDocument(svgNS, "svg", null); // get the root element (the svg element) svgRoot = doc.getDocumentElement(); boolean hasViewBox = true; float viewBox = 30000; boolean preserveAspectRatio = true; boolean meet = true; if (hasViewBox) { System.out.println("Hello"); } // create the rectangle rectangle = doc.createElementNS(svgNS, "rect"); rectangle.setAttributeNS(null, "x", "10"); rectangle.setAttributeNS(null, "y", "10"); rectangle.setAttributeNS(null, "width", "10"); rectangle.setAttributeNS(null, "height", "10"); rectangle.setAttributeNS(null, "style", "fill:red"); svgRoot.appendChild(rectangle); rectangle1 = doc.createElementNS(svgNS, "rect"); rectangle1.setAttributeNS(null, "x", "10"); rectangle1.setAttributeNS(null, "y", "30"); rectangle1.setAttributeNS(null, "width", "10"); rectangle1.setAttributeNS(null, "height", "10"); rectangle1.setAttributeNS(null, "style", "fill:green"); svgRoot.appendChild(rectangle1); rectangle2 = doc.createElementNS(svgNS, "rect"); rectangle2.setAttributeNS(null, "x", "10"); rectangle2.setAttributeNS(null, "y", "50"); rectangle2.setAttributeNS(null, "width", "10"); rectangle2.setAttributeNS(null, "height", "10"); rectangle2.setAttributeNS(null, "style", "fill:blue"); svgRoot.appendChild(rectangle2); rectangle3 = doc.createElementNS(svgNS, "rect"); rectangle3.setAttributeNS(null, "x", "10"); rectangle3.setAttributeNS(null, "y", "70"); rectangle3.setAttributeNS(null, "width", "10"); rectangle3.setAttributeNS(null, "height", "10"); rectangle3.setAttributeNS(null, "style", "fill:yellow"); svgRoot.appendChild(rectangle3); rectangle4 = doc.createElementNS(svgNS, "rect"); rectangle4.setAttributeNS(null, "x", "10"); rectangle4.setAttributeNS(null, "y", "90"); rectangle4.setAttributeNS(null, "width", "10"); rectangle4.setAttributeNS(null, "height", "10"); rectangle4.setAttributeNS(null, "style", "fill:black"); // attach the rectangle to the svg root element svgRoot.appendChild(rectangle4); path1 = doc.createElementNS(svgNS, "path"); for(int i=10;i<100;i=i+10) { for(int j=110;j<210;j=j+10) { path1.setAttributeNS(null, "d", "M25 "+j+"L"+j+" 5"); System.out.println("d,M20 "+j+"L"+j+" 5"); path1.setAttributeNS(null, "style", "fill:black;stroke-width:2000"); svgRoot.appendChild(path1); } } // attach the rectangle to the svg root element return doc; } public void save(Document document) throws Exception { FileOutputStream outputS = new FileOutputStream("map.svg"); Writer outS= new OutputStreamWriter(outputS, "UTF-8"); TranscoderInput inputS = new TranscoderInput(document); TranscoderOutput outputS2 = new TranscoderOutput(outS); SVGTranscoder t = new SVGTranscoder(); t.transcode(inputS, outputS2); // this is the line 338 } public static void main(String [] args) throws Exception { svgGenerating generator = new svgGenerating(); Document document = generator.documentGenerating(); generator.save(document); System.exit(0); } } Arvind _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]