Hi Andrej,
"Andrej T." <[EMAIL PROTECTED]> wrote on 01/05/2008 06:48:50 AM:
> I have the following. A class McPanel which extends JSVGScrollPane.
> I also have a method loadImage(String fileName) which uses
canvas.setURI,
> the problem is I want this method to wait until the document has been
> rendered. I have tried with a flag, as can be seen in the code below,
but it
> doesn't work. Any suggestions?
You can't block the Swing thread. So if 'load' is called from
the Swing thread (which it looks like it should be) then it can't
block until the load completes. You have to move the blocking call
out of the Swing thread.
> public class McPanel extends JSVGScrollPane implements EventListener,
> ActionListener {
>
> // Indicate whether the image has already been loaded
> boolean imageLoaded = false;
>
> public McPanel(EquipView aCreator) {
> super(new JSVGCanvas());
>
> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>
> // Set the JSVGCanvas listeners.
> canvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter()
{
> public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
> System.out.println("Document Loading...");
> }
>
> public void documentLoadingCompleted(SVGDocumentLoaderEvent e)
{
> System.out.println("Document Loaded.");
> }
> });
>
> canvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
> public void gvtBuildStarted(GVTTreeBuilderEvent e) {
> System.out.println("Build Started...");
> }
>
> public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
> System.out.println("Build Done.");
> }
> });
>
> canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
> public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
> System.out.println("Rendering Started...");
> }
>
> public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
> System.out.println("Rendering Done.");
> canvas.repaint();
> imageLoaded = true;
> });
> }
>
> public boolean loadImage(String fileName) {
> imageLoaded=false;
> canvas.setURI(fileName);
> while (true) {
> if (imageLoaded)
> break;
> }
> return true;
> }
>
> Thanks for any help.
> Andrej.
> --
> View this message in context: http://www.nabble.com/Problem-with-
>
canvas.setURI-and-waiting-for-everything-to-finish-tp14632305p14632305.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>