One other side effect of replacing the subtree is that listeners get called, such as mouseout.
I think I'll try creating a rect subtree behind the text that highlights the text areas next. ----- Original Message ----- From: "Thomas DeWeese" <[EMAIL PROTECTED]> To: "Batik Users" <[EMAIL PROTECTED]> Sent: Thursday, August 21, 2003 12:54 PM Subject: Re: tspan.setAttributeNS(null, "class", "normal") null pointer exception > Denis Bohm wrote: > > Thanks for the tips. I'll try replacing the DOM subtree to avoid the > > performance issue. The only immediate downside to that seems to be that > > text selections can get lost... > > Well if you are willing to talk directly to the JSVGCanvas you can > get the text selection from that and use it to restore it after you > add the node back in (once I fix text selection DOM APIs - BTW don't bother putting > togeather an example for that I'm going to rework some internal examples to use this > API). > > > > > ----- Original Message ----- > > From: "Thomas DeWeese" <[EMAIL PROTECTED]> > > To: "Batik Users" <[EMAIL PROTECTED]> > > Sent: Thursday, August 21, 2003 12:24 PM > > Subject: Re: tspan.setAttributeNS(null, "class", "normal") null pointer > > exception > > > > > > > >>Denis Bohm wrote: > >> > >>>I changed my sources so that if the old property value is null then it > >>>considers it as a change (rather than throwing a null pointer > > > > exception). > > > >>>Now changing the attribute seems to work. > >> > >> This is essentially the patch I was going to make. > >> > >> > >>>However, it seems very very very > >>>slow to refresh when changing class attributes that result in simple > > > > style > > > >>>changes. > >> > >> In SVG there is no such thing as a 'simple style change'. So for > > > > example > > > >>if the text uses an SVG font then the font now needs to inherit the > > > > modified > > > >>fill color. Also consider that your one element can in certain cases > >>be mapped into several disjoint pieces by BIDI reordering. This is really > >>amazingly complex stuff. The text code in Batik is by a fair bit the > >>most complex piece, the code has been almost completely rewritten three > > > > times > > > >>already and serveral weeks of effort have gone into trying to optimize it > >>and still it sucks! :) > >> > >> > >>>In my case, the class change only results in changing the fill > >>>color - which shouldn't effect the bounds of the elements. Changing the > >>>class for about 25 tspan elements (making up one short line of text) > > > > takes > > > >>>about 1.5 seconds. I ran OptimizeIt on the code and it appears that > > > > each > > > >>>time the class property is changed on one tspan element the glyphs go > >>>through relayout down in the gvt layer. > >> > >> I've just taken a look through the code and I may try and optimize this > >>case a bit (although SVG Fonts are very problematic). > >> > >> > >>>This results in the creation of > >>>around 27,000 points during the process. > >> > >> Hmm, thanks for pointing this out, not that I think this is the bottle > > > > neck > > > >>but it was easy to fix most of these :). > >> > >> > >>>Any tips for speeding up changing the color of text runs? For example, > > > > is > > > >>>there some way to batch changes to the DOM? > >> > >> The best you can do (and it is probably pretty good) is remove the > > > > elements from > > > >>the rendering tree: text.parentNode.removeChild(text) Then make all your > > > > changes > > > >>and add it back in - this will keep Batik from trying to keep the > > > > rendering tree > > > >>in sync with the modified elements. > >> > >> > >>>Thanks, > >>> Denis > >>> > >>>----- Original Message ----- > >>>From: "Denis Bohm" <[EMAIL PROTECTED]> > >>>To: "Batik Users" <[EMAIL PROTECTED]> > >>>Sent: Thursday, August 21, 2003 8:26 AM > >>>Subject: Re: tspan.setAttributeNS(null, "class", "normal") null pointer > >>>exception > >>> > >>> > >>> > >>> > >>>>I've attached a standalone version that shows the problem. > >>>> > >>>>----- Original Message ----- > >>>>From: "Thomas DeWeese" <[EMAIL PROTECTED]> > >>>>To: "Batik Users" <[EMAIL PROTECTED]> > >>>>Sent: Thursday, August 21, 2003 5:19 AM > >>>>Subject: Re: tspan.setAttributeNS(null, "class", "normal") null pointer > >>>>exception > >>>> > >>>> > >>>> > >>>> > >>>>>Denis Bohm wrote: > >>>>> > >>>>> > >>>>>>Setting color to the Shadow?When I try to append a tspan to a text > >>>> > >>>>element > >>>> > >>>> > >>>>>>and then set the tspan class: > >>>>>> > >>>>>> Element tspan = document.createElementNS( > >>>>>> SVGDOMImplementation.SVG_NAMESPACE_URI, "tspan" > >>>>>> ); > >>>>>> tspan.appendChild(document.createCDATASection(text)); > >>>>>> text.appendChild(tspan); > >>>>>> tspan.setAttributeNS(null, "class", "normal"); > >>>>>> > >>>>>>I get a null pointer exception: > >>>>> > >>>>> Can you provide a standalone version of this problem? > >>>>>Looking at the line indicated below it isn't real clear why you > >>>>>would get an NPE. > >>>>> > >>>>> > >>>>> > >>>>>>In Event > >>>>>>java.lang.NullPointerException > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:18 > > > >>>>>>91) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.css.engine.CSSEngine$DOMAttrModifiedListener.handleEvent(CS > > > >>>>>>SEngine.java:2280) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.jav > > > >>>>>>a:268) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:240 > > > >>>>>>) > >>>>>> at > >>>>>>org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:455) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElemen > > > >>>>>>t.java:544) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.AbstractElement$NamedNodeHashMap.setNamedItem(AbstractE > > > >>>>>>lement.java:725) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.AbstractElement$NamedNodeHashMap.setNamedItemNS(Abstrac > > > >>>>>>tElement.java:672) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.AbstractElement.setAttributeNS(AbstractElement.java:271 > > > >>>>>>) > >>>>>> at > >>> > >>>com.hp.hpl.epc.evaluator.DemoUI.appendTSpan(DemoUI.java:209) > >>> > >>> > >>>>>> at com.hp.hpl.epc.evaluator.DemoUI.mouseMove(DemoUI.java:409) > >>>>>> at > >>>> > >>>>com.hp.hpl.epc.evaluator.DemoUI$2.handleEvent(DemoUI.java:276) > >>>> > >>>> > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.jav > > > >>>>>>a:268) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:240 > > > >>>>>>) > >>>>>> at > >>>>>>org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:455) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(Bridg > > > >>>>>>eEventSupport.java:372) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.bridge.BridgeEventSupport$Listener.mouseMoved(BridgeEventSu > > > >>>>>>pport.java:286) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.gvt.event.AWTEventDispatcher.processMouseEvent(AWTEventDisp > > > >>>>>>atcher.java:538) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.gvt.event.AWTEventDispatcher.dispatchMouseEvent(AWTEventDis > > > >>>>>>patcher.java:502) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(AWTEventDispatch > > > >>>>>>er.java:391) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.gvt.event.AWTEventDispatcher.mouseMoved(AWTEventDispatcher. > > > >>>>>>java:244) > >>>>>> at > >>>>>> > >>>> > > org.apache.batik.swing.svg.JSVGComponent$1MouseMovedRunnable.run(JSVGCompone > > > >>>>>>nt.java:1989) > >>>>>> at > >>>> > >>>>org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:204) > >>>> > >>>> > >>>>>> at java.lang.Thread.run(Thread.java:534) > >>>>>> > >>>>>> > >>>>>>Am I doing something wrong? > >>>>>> > >>>>>>Thanks, > >>>>>> Denis > >>>>>> > >>>>>> > >>>>>>--------------------------------------------------------------------- > >>>>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>>>>> > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>--------------------------------------------------------------------- > >>>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>>>> > >>>>> > >>>> > >>> > >>-------------------------------------------------------------------------- > > > > -- > > > >>>---- > >>> > >>> > >>> > >>> > >>>>--------------------------------------------------------------------- > >>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >>>--------------------------------------------------------------------- > >>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >> > >> > >> > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]