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 "Jakub W. Jozwicki" <ja...@go2.pl> on 2005/11/23 00:03:38 UTC
Synchronization in Batik
Hello,
I added to SVGDocument a listener for "onclick" events.
Pseudocode:
Element elt = SVGdoc.getElementById(objectName);
EventTarget t = (EventTarget)elt;
t.addEventListener("click", new ScriptEventHandler() {
public handleEvent() {
UpdateManager.getUpdateRunnableQueue().invokeLater(new Runnable() {
public void run()
{
elt.setTextContent("bla bla");
}
}
}});
}
And when I do a double click, or a series of fast clicks I get
exception:
java.lang.NullPointerException
at
org.apache.batik.gvt.renderer.StrokingTextPainter.getTextChunkACIs(Unknown
Source)
at
org.apache.batik.gvt.renderer.StrokingTextPainter.getTextRuns(Unknown
Source)
at
org.apache.batik.gvt.renderer.StrokingTextPainter.getHighlightShape(Unknown
Source)
at org.apache.batik.gvt.TextNode.getHighlightShape(Unknown Source)
at
org.apache.batik.gvt.text.ConcreteTextSelector.changeCompleted(Unknown
Source)
at
org.apache.batik.gvt.AbstractGraphicsNode.fireGraphicsNodeChangeCompleted(Unknown
Source)
at
org.apache.batik.gvt.TextNode.setAttributedCharacterIterator(Unknown
Source)
at
org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(Unknown
Source)
at
org.apache.batik.bridge.SVGTextElementBridge.handleDOMSubtreeModifiedEvent(Unknown
Source)
at
org.apache.batik.bridge.SVGTextElementBridge$DOMSubtreeModifiedEventListener.handleEvent(Unknown
Source)
at
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
Source)
at
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
Source)
at org.apache.batik.dom.events.EventSupport.dispatchEvent(Unknown
Source)
at org.apache.batik.dom.AbstractNode.dispatchEvent(Unknown Source)
at
org.apache.batik.dom.AbstractParentNode.fireDOMSubtreeModifiedEvent(Unknown
Source)
at org.apache.batik.dom.AbstractParentNode.removeChild(Unknown Source)
at org.apache.batik.dom.AbstractNode.setTextContent(Unknown Source)
at
pl.edu.pw.mini.pz.ajk.geografia.gui.SVGApplication$2.onclick(SVGApplication.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
pl.edu.pw.mini.pz.ajk.geografia.svgUtils.ScriptExtension$2.run(ScriptExtension.java:188)
at org.apache.batik.util.RunnableQueue.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Shouldn't Batik do some synchronization to avoid concurency issues?
Or should I do it myself?
Regards,
Jimm
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Synchronization in Batik
Posted by th...@kodak.com.
Hi Jakub,
"Jakub W. Jozwicki" <ja...@go2.pl> wrote on 11/22/2005 11:01:22 PM:
> I fixed it.
A cleaner solution is now in SVN, enjoy!
> Because the solution above probably doesn't look good
> I will post some test code where the error can be noticed,
> but after some sleep.
I was able to reproduce it pretty simply from your
original message. Thanks for reporting it.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Synchronization in Batik
Posted by "Jakub W. Jozwicki" <ja...@go2.pl>.
I fixed it.
org\apache\batik\gvt\renderer\StrokingTextPainer:
function: public int[] getSelected():
// get the list of text runs
- List textRuns = getTextRuns(textNode, aci);
+ List textRuns = null;
+ try {
+ textRuns = getTextRuns(textNode, aci);
+ }
+ catch(Exception exc) { return null; }
function: public Shape getHighlightShape()
// get the list of text runs
- List textRuns = getTextRuns(textNode,
textNode.getAttributedCharacterIterator());
+ List textRuns = null;
+ try {
+ textRuns = getTextRuns(textNode,
textNode.getAttributedCharacterIterator());
+ }
+ catch (Exception exc) { return null; }
Because the solution above probably doesn't look good
I will post some test code where the error can be noticed,
but after some sleep.
Regards,
Jakub
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Synchronization in Batik
Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Jakub W. Jozwicki:
> >
> > Try getting the latest code from the Subversion repository to see
> if it
> > fixes the problem.
> >
>
> Tested with SVN version and still the same error.
Hmm, I overlooked this in your first message:
> And when I do a double click, or a series of fast clicks I get
> exception:
so I guess it may be a problem of concurrency. Can you provide the
shortest possible test program that demonstrates the problem?
Thanks,
Cameron
--
Cameron McCormack ICQ: 26955922
cam (at) mcc.id.au MSN: cam (at) mcc.id.au
http://mcc.id.au/ JBR: heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Synchronization in Batik
Posted by "Jakub W. Jozwicki" <ja...@go2.pl>.
>
> Try getting the latest code from the Subversion repository to see
if it
> fixes the problem.
>
Tested with SVN version and still the same error.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Synchronization in Batik
Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Archie Cobbs:
> Hmm... are you sure? The UpdateManager thread != the Swing thread..
Sorry you're right, I got myself confused. The UpdateManager thread is
separate from the Swing thread, but event handlers are always run from
the UpdateManager thread so there is still no need to use the
invokeLater call.
--
Cameron McCormack ICQ: 26955922
cam (at) mcc.id.au MSN: cam (at) mcc.id.au
http://mcc.id.au/ JBR: heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Synchronization in Batik
Posted by Archie Cobbs <ar...@dellroad.org>.
Cameron McCormack wrote:
> It doesn't sound like a concurrency problem. In this case you do not
> need to use the UpdateManager to schedule your change to the DOM, since
> event handlers are run from the Swing thread anyway.
Hmm... are you sure? The UpdateManager thread != the Swing thread..
-Archie
__________________________________________________________________________
Archie Cobbs * CTO, Awarix * http://www.awarix.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Synchronization in Batik
Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Hi Jakub.
Jakub W. Jozwicki:
> I added to SVGDocument a listener for "onclick" events.
> Pseudocode:
I can't be sure, but this sounds similar to a bug that caused an NPE
when using the textContent property of an SVG 1.2 flow text element.
It doesn't sound like a concurrency problem. In this case you do not
need to use the UpdateManager to schedule your change to the DOM, since
event handlers are run from the Swing thread anyway.
Try getting the latest code from the Subversion repository to see if it
fixes the problem.
Cameron
--
e-mail : cam (at) mcc.id.au icq : 26955922
web : http://mcc.id.au/ msn : cam-msn (at) aka.mcc.id.au
office : +61399055779 jabber : heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org