xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rishabh Rao <rishabhs...@gmail.com>
Subject How to use org.apache.batik.bridge.UpdateManager?
Date Sun, 25 Apr 2010 05:23:44 GMT
Hello!
We are a team 3 students who are developing an opensource application called
Chart Glazer. The application helps the users draw charts (process diagrams,
organization charts etc.) easily. It is very much similar to Microsoft
Office 2007's SmartArt.
We're using Apache Batik and Java Swing for our development. Our project is
hosted at http://kenai.com/projects/chartglazer.
The FAQ at http://xmlgraphics.apache.org/batik/faq.html talks about using
the UpdateManager.
We are facing the exact same problem, as in section 3.3 of the FAQ, "When I
change the document in Java it only updates if I move the mouse over the
canvas?"
We have reproduced our problem into a smaller application (called
SVGApplication), using NetBeans. It has a JButton (called
loadDocumentJButton) and a JSVGCanvas (called myJSVGCanvas) present inside a
JScrollPane object.
Our requirement is that when we click this "loadDocumentJButton" button, the
the "myJSVGCanvas" object must display the "myRectangle" (see code below.)
Here is the "actionPerformed" event handler for "loadDocumentJButton"...
private void loadDocumentJButtonActionPerformed(java.awt.event.ActionEvent
evt)
{
DOMImplementation myDOMImplementation =
SVGDOMImplementation.getDOMImplementation();
Document myDocument =
myDOMImplementation.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
"svg", null);
Element svgRoot = myDocument.getDocumentElement();

SVGGraphics2D mySVGGraphics2D = new SVGGraphics2D(myDocument);
mySVGGraphics2D.setSVGCanvasSize(new Dimension(320, 240));

myJSVGCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
myJSVGCanvas.setDocument(myDocument);

Rectangle myRectangle = new Rectangle(10, 10, 60, 40);

mySVGGraphics2D.draw(myRectangle);

svgRoot.appendChild(mySVGGraphics2D.getRoot());
}
The rectangle is being displayed only when we move the mouse over the
"myJSVGCanvas" object in the Swing GUI window.

We understand that we must use UpdateManager to solve this problem. But we
don't know how to use it. We searched a lot on the Internet and
mail-archives, but we are not able to figure things out. We did not find any
example programs. If we get an example program that demonstrates the use of
UpdateManager, we will figure it out on our own. It would be great if you
provide us with such an example program.
Please help us.
We are attaching the 3 files of "SVGApplication" (created usingNetBeans) for
your reference. The above event handler function is located in the
SVGView.java. Probably, the other two files will not be required; we have
just attached it for completeness' sake.
Thank you very much!
Regards,
Rishabh Rao, Narendra G S and Praveen K S

Mime
View raw message