You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Andreas Neumann <ne...@karto.baug.ethz.ch> on 2006/06/06 22:38:44 UTC

suspendRedraw(), unsuspendRedraw()

Hi,

I am wondering if SVGSVGElement.suspendRedraw() and 
SVGSVGElement.unsuspendRedraw() should work in Batik?

If I try to see if it is available, it says yes, but when I try to use 
it, it gives me an error message.

Here is an example on how I used it:

http://www.carto.net/neumann/temp/suspendDrawTest.svg

When I use SVGSVGElement.suspendRedraw() in my example I get the 
following error:

---------

java.lang.Error
        at 
org.apache.batik.dom.svg.SVGOMSVGElement.suspendRedraw(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

-------

My impression is, that the method is there, but not functional?

Because when I do:

if (document.documentElement.suspendRedraw) {
    alert("suspendRedraw implemented");
}
else {
    alert("suspendRedraw not implemented");
}

Batik seems to report that it is implemented.

Thanks for shedding some light on my problem.

Andreas

-- 
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by th...@kodak.com.
Hi Andreas,

Andreas Neumann <ne...@karto.baug.ethz.ch> wrote on 06/12/2006 08:12:20 
AM:

> >>Sometimes I have a longer script execution and want to show the user 
> >>progress (like e.g. calculating a surface profile from a digital 
> >>elevation model).
> >
> >   I know it's a pain but it really would be better to break the loop
> >and return.  Anyway you can now use forceRedraw if you want.
> >
> What is the drawback if I use forceRedraw, besides the fact that I can't 

> use it in some SVG viewers or older Batik versions?

  All event processing backs up and they will all happen after
the processing completes.  So for example it would be impossible to
have a 'cancel' button.   Also any key/button presses will suddenly play 
back after the script completes - seconds or more after the actual
key press/button press.  We really can't dispatch multiple events
at the same time as I doubt most script is really designed to be
re-entrant/multi-threaded.


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
>>>Since they [suspend/force Repaint] seem like they might start being 
>>>useful it may be worth trying to implement them...
>>>      
>>>
>>yes, I'd be interested in using that feature.
>>    
>>
>
>   This is now implemented in SVN.
>  
>

thank you, much appreciated. I will test it in my applications.

>>Sometimes I have a longer script execution and want to show the user 
>>progress (like e.g. calculating a surface profile from a digital 
>>elevation model).
>>    
>>
>
>   I know it's a pain but it really would be better to break the loop
>and return.  Anyway you can now use forceRedraw if you want.
>
>  
>
What is the drawback if I use forceRedraw, besides the fact that I can't 
use it in some SVG viewers or older Batik versions?

Thank you,
Andreas

-- 
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by th...@kodak.com.
Hi Andreas,

Andreas Neumann <ne...@karto.baug.ethz.ch> wrote on 06/07/2006 10:01:52 
PM:

> > Since they [suspend/force Repaint] seem like they might start being 
> > useful it may be worth trying to implement them...
> 
> yes, I'd be interested in using that feature.

   This is now implemented in SVN.

> Sometimes I have a longer script execution and want to show the user 
> progress (like e.g. calculating a surface profile from a digital 
> elevation model).

   I know it's a pain but it really would be better to break the loop
and return.  Anyway you can now use forceRedraw if you want.


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
>   The second sentence is true, Batik never updates the screen while it
>is executing a script.  The first part is not, in theory script could call
>'suspendRedraw', set a timeout, let the script function exit, then 
>sometime
>later in the timeout call 'unsuspendRedraw', Batik would likely redraw
>once the script function exited even though it should not...
>
>  
>

yes, thanks for clarifying.

>>Does Batik allow to update the screen on demand? It doesn't yet support 
>>SVGSVGElement.forceRedraw() - is there any other method as a workaround?
>>    
>>
>
>   No there is currently no way for script to trigger a repaint in the 
>middle
>of script execution.  I should say that implementing these methods 
>probably
>would not be particularly hard (Batik already suspends redraws in some 
>cases,
>so just setting a Boolean should suffice for suspend/unsuspend, 
>forceRedraw
>is mostly just calling the existing 'repaint' method on the UpdateManager.
>
>   Since they seem like they might start being useful it may be worth 
>trying
>to implement them...
>  
>

yes, I'd be interested in using that feature.

Sometimes I have a longer script execution and want to show the user 
progress (like e.g. calculating a surface profile from a digital 
elevation model).

Thanks,
Andreas

-- 
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by th...@kodak.com.
Hi Andreas,

Andreas Neumann <ne...@karto.baug.ethz.ch> wrote on 06/07/2006 11:51:09 
AM:

> I can confirm that try/catch now works with SVN.

   Good.

> As I understand, the current implementation of Batik always reacts like 
> if suspendRedraw()/unsuspendRedraw() would be called. It does not update 

> the screen while it is executing a script.

   The second sentence is true, Batik never updates the screen while it
is executing a script.  The first part is not, in theory script could call
'suspendRedraw', set a timeout, let the script function exit, then 
sometime
later in the timeout call 'unsuspendRedraw', Batik would likely redraw
once the script function exited even though it should not...

> Does Batik allow to update the screen on demand? It doesn't yet support 
> SVGSVGElement.forceRedraw() - is there any other method as a workaround?

   No there is currently no way for script to trigger a repaint in the 
middle
of script execution.  I should say that implementing these methods 
probably
would not be particularly hard (Batik already suspends redraws in some 
cases,
so just setting a Boolean should suffice for suspend/unsuspend, 
forceRedraw
is mostly just calling the existing 'repaint' method on the UpdateManager.

   Since they seem like they might start being useful it may be worth 
trying
to implement them...

> >>My problem is that some browsers implement suspendRedraw and others 
> >>don't and I have to test if the method is available.
> >>
> >>I tried with try/catch but it did not work either.
> >> 
> >>
> >
> >Yeah, it?s not ideal that those methods are throwing Errors instead of
> >some other RuntimeException.  I?ve just made a change in SVN for them 
to
> >throw UnsupportedOperationExceptions instead, which makes them
> >capturable from script.
> >
> >This probably doesn?t help you, however, if you want to support any
> >older version of Batik.  I don?t think there?s a reasonable way of
> >sniffing the Batik version, either.
> >
> > 
> >
> 
> 
> -- 
> ----------------------------------------------
> Andreas Neumann
> Institute of Cartography
> ETH Zurich
> Wolfgang-Paulistrasse 15
> CH-8093  Zurich, Switzerland
> 
> Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
> e-mail: neumann@karto.baug.ethz.ch
> www: http://www.carto.net/neumann/
> SVG.Open: http://www.svgopen.org/
> Carto.net: http://www.carto.net/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
Thanks,

I can confirm that try/catch now works with SVN.

As I understand, the current implementation of Batik always reacts like 
if suspendRedraw()/unsuspendRedraw() would be called. It does not update 
the screen while it is executing a script.

Does Batik allow to update the screen on demand? It doesn't yet support 
SVGSVGElement.forceRedraw() - is there any other method as a workaround?

Thanks,
Andreas

>>My problem is that some browsers implement suspendRedraw and others 
>>don't and I have to test if the method is available.
>>
>>I tried with try/catch but it did not work either.
>>    
>>
>
>Yeah, it’s not ideal that those methods are throwing Errors instead of
>some other RuntimeException.  I’ve just made a change in SVN for them to
>throw UnsupportedOperationExceptions instead, which makes them
>capturable from script.
>
>This probably doesn’t help you, however, if you want to support any
>older version of Batik.  I don’t think there’s a reasonable way of
>sniffing the Batik version, either.
>
>  
>


-- 
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi Andreas.

Andreas Neumann:
> is there any clean way to test per ECMAScript whether a DOM method is 
> present and implemented?
> 
> In my case "alert(document.documentElement.suspendRedraw)" returns true, 
> but I can't see if it is actually working.

Yeah, just testing that the method exists is insufficient.  And the
reason all of the methods exist, is that otherwise the Java objects that
implement them would not have implemented the whole Java SVG interface
files.

> My problem is that some browsers implement suspendRedraw and others 
> don't and I have to test if the method is available.
> 
> I tried with try/catch but it did not work either.

Yeah, it’s not ideal that those methods are throwing Errors instead of
some other RuntimeException.  I’ve just made a change in SVN for them to
throw UnsupportedOperationExceptions instead, which makes them
capturable from script.

This probably doesn’t help you, however, if you want to support any
older version of Batik.  I don’t think there’s a reasonable way of
sniffing the Batik version, either.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

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


Re: suspendRedraw(), unsuspendRedraw()

Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
Thanks Cameron,

is there any clean way to test per ECMAScript whether a DOM method is 
present and implemented?

In my case "alert(document.documentElement.suspendRedraw)" returns true, 
but I can't see if it is actually working.

My problem is that some browsers implement suspendRedraw and others 
don't and I have to test if the method is available.

I tried with try/catch but it did not work either.

Thanks for any ideas,
Andreas

Cameron McCormack wrote:

>Hi Andreas.
>
>Andreas Neumann:
>  
>
>>When I use SVGSVGElement.suspendRedraw() in my example I get the 
>>following error:
>>    
>>
>…
>  
>
>>My impression is, that the method is there, but not functional?
>>    
>>
>
>Yes, the methods are present but all they currently do is
>
>  throw new Error();
>
>  
>


-- 
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


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


Re: suspendRedraw(), unsuspendRedraw()

Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi Andreas.

Andreas Neumann:
> When I use SVGSVGElement.suspendRedraw() in my example I get the 
> following error:
…
> My impression is, that the method is there, but not functional?

Yes, the methods are present but all they currently do is

  throw new Error();

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

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