Hi Jean,

Jean-Christophe Arnu wrote:

changing the ViewBox works, but this restricts my ability to pan and zoom the other area (IMHO) here are some explanation : I have a map (a town). My initial ViewBox is ok. I zoom and pan to view a particuliar point. Then I store my viewbox. I return to the initial viewbox. When I recall the stored one, I get an exception (see exception & code here after).

   The NPE exception appears to be a bug in Batik.  The out of memory
error reminds me that setting the viewBox is a fairly inefficient method
of changing the view as it generally leads to a rebuild of the entire
graphics tree for the document (to handle percentages properly).

   I'll look into this bug and may request a reproducible test case if
I have some problems reproducing it on my own.  In the mean time I
would suggest looking into using the currentScale currentTranslate API's
on the SVGSVGElement to adjust the view.  When you have the viewBox the
adjustment is fairly simple.  The simplest method is to set
currentTranslate to the x,y of the viewBox you want, and then set
the currentScale to min(viewBox.width/viewport.width,
                        viewBox.height/viewport.height).

   This won't quite center the view to do that you would need to tweak
the translate for cases where the aspect ratio of the viewBox doesn't
match that of the viewport.

I get a java.lang.OutOfMemoryError: Java heap space + a NullPointerException with Batik 1.5.1 and ony the NullPointerException with Batik 1.6 .

So maybe my pan/zoom ability is limited by the viewBox OR is it limited by the exception generated?
   What can I do to get rid of this Null Pointer Exception?


Thanks again

Trace
--------------------------------------
Asking view => camargue
Loaded view : [760651.625, 2059615.125, 83312.625, 69719.125]
Node = viewBox value = 744061.25 1859809.125 109900.0 91968.5
----------------------------------------
Exception
-----------------------------------------


java.lang.NullPointerException
at org.apache.batik.bridge.SVGSVGElementBridge.handleDOMAttrModifiedEvent(Unknown Source) at org.apache.batik.bridge.BridgeContext$DOMAttrModifiedEventListener.handleEvent(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.AbstractElement.fireDOMAttrModifiedEvent(Unknown Source)
       at org.apache.batik.dom.AbstractAttr.setNodeValue(Unknown Source)
at com.paratronic.supervisor.ui.SVGDisplay$JSVGCanvas2.loadView(SVGDisplay.java:331)
--------------------------------------

Here is the code snippet
--------------------------------------
       Vector v = (Vector)savedViews.get(viewId);
       System.out.println("Loaded view : "+v);

       double translateX=((Double)v.get(0)).doubleValue();
       double translateY=((Double)v.get(1)).doubleValue();
       double width = ((Double)v.get(2)).doubleValue();
       double height = ((Double)v.get(3)).doubleValue();

NamedNodeMap attrs = this.getSVGDocument().getRootElement().getAttributes();
       Node s = attrs.getNamedItem("viewBox");
System.out.println("Node = "+s.getNodeName()+" value = "+s.getNodeValue());

       if((translateX==0)&&(translateY==0)&&
           (width==0)&&(height==0)){
       try{
           s.setNodeValue(initialViewBox);          }
       catch(Exception x){
           x.printStackTrace();
       }
       }
       else{
       try{
               // Generates exception into the SVGUserAgent!
s.setNodeValue(""+translateX+" "+translateY+" "+(width)+" "+(height));
       }
       catch(Exception x){
           x.printStackTrace();
       }
       }
---------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to