xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy E. Denton" <jden...@galdosinc.com>
Subject Dynamic modification of the DOM
Date Tue, 06 Apr 2004 20:21:29 GMT


Hey all,

I would like to be able to modify the DOM live and propogating the change to
the DOM to the rendered image. I've been experimenting but I've not had any
success. The following is a method that I call when the rendering is done.
The call is made to the "drawRect" and I reset the SVGDocument back to the
canvas. (admittedly this is a brute force method). but it doesn't appear to
actually render anything. Though I do note that the "drawRect" is being
called twice so it does go through the rendering process twice.

I would prefer to modify the DOM directly than use the modified Graphics2D
calls. It gives me better control and better access to the SVG model.

	boolean dirty = true;

	private void drawRect() {

		System.out.println("Draw Rect");

		SVGDocument svgDoc = svgCanvas.getSVGDocument();
		if (svgDoc != null) {
			if (dirty) {
				Element rect = svgDoc.createElement("rect");
				rect.setAttribute("x", "100");
				rect.setAttribute("y", "100");
				rect.setAttribute("width", "400");
				rect.setAttribute("height", "400");
				rect.setAttribute("fill", "blue");

				System.out.println(SVGPicture.xmlToString(svgDoc));
				svgDoc.getRootElement().appendChild(rect);
				svgCanvas.setSVGDocument(svgDoc);

				label.setText("Updating");
				dirty = false;
			}
			label.setText("Draw Rect Done.");

		} else {
			System.out.println("Document Root is null");
		}
	}

Any suggestions?

Cheers,
Jeremy


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message