xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: AW: Xlink Problem
Date Thu, 07 Aug 2008 09:54:29 GMT
Hi Kerschbaum,

"Kerschbaum Michael " <m.kerschbaum@pke.at> wrote on 08/07/2008 04:14:10 
AM:

> I thing i get the problem. The application uses SymbolEventListener 
> and MouseListener from the Swing Component. And the MouseListener 
> listen to mouseMoved... everyTime when mouseMoved the Location from 
> the Mouse is captured and the application tries to find a Node on 
> this position.... If a node was found, the element for this node is 
> located and then some action is made... Now i use only EventListener
> from Batik and the Link problem does not accure anymore...

   It is not safe to interact with the DOM or GVT tree outside of
the UpdateManager Runnable queue.  It is very possible that your
calling nodeHitAt from the AWT thread was disrupting the normal
DOM event dispatch and/or the repaint.

> I mean sometimes a NPE in public GraphicsNode nodeHitAt(Point2D p) 
> in the class org.apache.batik.gvt.CompositeGraphicsNode occured. 
> This method calls this method... and in this method a NPE occures....

   During a drawing operation say in response to changing the stroke
of an element we will clear cached geometry information like 
'sensitiveBounds'.  If you are in the middle of updating the sensitive
bounds (which is done during a call to nodeHitAt) then the clear 
will cause sensitiveBounds to suddenly become null in the middle of 
the call.

>     public Rectangle2D getSensitiveBounds() {
>         if (sensitiveBounds != null)
>             return sensitiveBounds;
[...]
>                 sensitiveBounds.add(cgb); ==> NPE can't tell why ?! ==> 
line 409 !!

> Perhaps someone could tell me why....
> 
> This happens... it seems that the sensitiveBounds is null for a 
> while, as long as this happens the method is called again... and 
> then its not null anymore but, not really ?! 
> 
> [AWT-EventQueue-0] WARN AGComponent - java.lang.NullPointerException
> java.lang.NullPointerException
> at org.apache.batik.gvt.CompositeGraphicsNode.getSensitiveBounds(
> CompositeGraphicsNode.java:409)
[...]
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

   Don't ever call DOM or GVT methods from the Swing thread!

> Von: Kerschbaum Michael [mailto:m.kerschbaum@pke.at] 
> Gesendet: Mittwoch, 06. August 2008 15:30
> An: batik-users@xmlgraphics.apache.org
> Betreff: AW: Xlink Problem

> Hello,
> 
> I tried this but no real success...
> 
> Okay i will explain what i do...
> 
> At creation time of the application i call that ... where 
> AGUserAgent implements SVGUserAgent...
> 
> svgUserAgent = new AGUserAgent(this);
> 
> then when the user wants to load an SVG...
> 
> 1.)Load a SVG Document..by
> 2.)On the do documentLoadingCompleted event i create an Instance of 
> a Object i call SymbolManager.. this object parses some information 
> within the SVG Document like we call "custProps",....  and creates 
> Symbol objects, every Symbol has an Element (org.w3c.dom).. for this
> symbols i add EventListener... like
> 
> ...
>  public void addSymbolListeners(SVGOMElement elt) {
>   elt.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, 
symbolListener,
>     false);
>   elt.addEventListener(SVGConstants.SVG_MOUSEOVER_EVENT_TYPE, 
symbolListener,
>     false);
>  }
> 
> ... 
> 
> at this code it tried useCapture , true and false.... no real 
dífference...
> 
> this is the only code where i add Event Listeners
> 
> We also have "Layers" , for that we use the "layerMember", and some 
> elements are not visible... when they have a not currently displayed 
Layer...
> 
> for that i use the code
> 
> ...
>  for (int i = 0; i < layerMembers.size(); i++) {
>    Element elt = (Element) layerMembers.get(i);
>    if (elt != null) {
> 
>     if (visible) {
>          elt.removeAttributeNS(null, "visibility");
>          elt.setAttributeNS(null, "pointer-events", "all");
>      }
>     else {
>      elt.setAttributeNS(null, "visibility", "hidden");
>      elt.setAttributeNS(null, "pointer-events", "none");
>     }
> ....
> 
> If the application is in that situation, that the Links are not 
> regocnized and the Events Listerns do not call the handleEvent... 
> mostly it helps that i change the visibity of one layer... after 
> this code was executed everythings seems to be normal ... but not 
> 100 % sure.. ?!
> 
> Mit freundlichen Grüßen Michael Kerschbaum
> 
> DI (FH) Michael Kerschbaum
> PKE Electronics AG
> Zentrale Wien / Entwicklung
> Computerstraße 6
> A - 1101 Wien
> TEL: +43 (0) 50 150 - 1210
> m.kerschbaum@pke.at
> www.pke.at 
> 
> Aktiengesellschaft mit dem Sitz in Wien
> Firmenbuchnummer 103264i
> HG Wien, DVR 0159701
> Johann Helf – Vorsitzender des Vorstandes
> Bruno Faustka – Mitglied des Vorstandes
> Christian Prelz – Vorsitzender des Aufsichtsrates
> 
> 
> Von: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
> Gesendet: Mittwoch, 06. August 2008 14:28
> An: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Betreff: Re: Xlink Problem

> 
> Hi Kerschbaum,
> 
> "Kerschbaum Michael " <m.kerschbaum@pke.at> wrote on 08/06/2008 07:54:08 
AM:
> 
> > I have still some problems. Currently with links in an SVG File. 
> > When we define a link via xlink into a nother svg File, sometimes 
> > the area for this link is not recognized as link (normally the mouse
> > courser changed, and when you click on the area the link is exectued
> > via the openLink method in the SVGUserAgent interface) 
> > 
> > I looks like that sometimes the Elements in the SVG Tree does not 
> > react on Events . e.g. 
> 
>    My guess is that you have an event listener somewhere high in the 
tree 
> (like the root SVG node) and you are listening during the 'bubble' phase 

> of event propagation.  Since the Anchor captures the event to change 
> the cursor and handle clicks it never bubbles back to the root of the 
> SVG document.  So the simplest solution would be to change your event 
> listener to listen during the 'capture' phase of event propagation 
> (see the DOM level 2 Events Spec). 
> 
> > 
> > SVGConstants.SVG_MOUSEOUT_EVENT_TYPE
> > SVGConstants.SVG_MOUSEOVER_EVENT_TYPE 
> > 
> > because when this happens the handleEvent Method is never called. 
> > 
> > We defined the link ... like 
> > 
> > .... 
> > <g id="group4975-140" v:layerMember="0">
> > 
> >    <g id="group4976-141" v:layerMember="0">
> > 
> >     <rect x="0" y="597" width="326.25" height="63" class="st15" />
> >     <a xlink:href="LAGEPLAN.svg" 
xmlns:xlink="http://www.w3.org/1999/xlink">
> >      <g id="shape4978-144" transform="translate(256.5,-33.3529)"> 
> > 
> > ... 
> > 
> > When this happens i still get MouseEvents on my JSVGComponent.... 
> > but no events from org.w3c.dom.events.EventListener... ?! There is 
> > no error in the console and no exception is thrown ?!... 
> > 
> > Mit freundlichen Grüßen Michael Kerschbaum 
> > 
> > DI (FH) Michael Kerschbaum 
> > PKE Electronics AG 
> > Zentrale Wien / Entwicklung 
> > Computerstraße 6 
> > A - 1101 Wien 
> > TEL: +43 (0) 50 150 - 1210 
> > m.kerschbaum@pke.at 
> > www.pke.at 
> > 
> > Aktiengesellschaft mit dem Sitz in Wien 
> > Firmenbuchnummer 103264i 
> > HG Wien, DVR 0159701 
> > Johann Helf – Vorsitzender des Vorstandes 
> > Bruno Faustka – Mitglied des Vorstandes 
> > Christian Prelz – Vorsitzender des Aufsichtsrates 
> >  [attachment "test.zip" deleted by Thomas E. DeWeese/449433/EKC] 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org 
Mime
View raw message