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 Jean-Christophe Arnu <ar...@paratronic.fr> on 2005/06/01 18:27:09 UTC

Transforms (again) :'(

Hi there,
    I still rowing with my transforms problem :'(. Do you know a way to 
get a device independant transform from a pan+zoomed view? (As example, 
I would like my map to be pointed on a town each time I apply this 
transform on any device at any resolution). I wasn't able to find it in 
the docs :/

Thank you!

-- 
Jean-Christophe Arnu
Paratronic


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


Re: Merging batik jars

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

chandra srinivasan:
> I need to have a single batik jar for my app. Any ideas on how to accomplish
> this? There are like 20 jars in batik lib and in my app I sign all the jars. so
> obviously don't want to sign 20 jars.

If you get the sources and then run

  ./build.sh all-jar

on Unix or

  build all-jar

on Windows, then you'll get a single jar that includes all of Batik.

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


Re: Transforms (again) :'(

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Jean,

Jean-Christophe Arnu wrote:

>    Do you mean I need to do something like this?
>            coords=root.getCurrentTranslate();
>           coord.setX(newX-initialVB.getX());
>           coord.setY(newY-initialVB.getY());
> 

    Yes, something like that (I think that is even
right, for the simple case of matching AR but it's
easy to overlook something that needs to be factored
in).

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


Re: Transforms (again) :'(

Posted by Jean-Christophe Arnu <ar...@paratronic.fr>.

Jean-Christophe Arnu m'expliquait  (le 03.06.2005 21:06):

>>    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.
>>
>    mmm SVGOMSVGElement needs to implement the .getViewBox() ;)
>    Never mind I have dom.svg to do the whole job.

    Do you mean I need to do something like this?
            coords=root.getCurrentTranslate();
           coord.setX(newX-initialVB.getX());
           coord.setY(newY-initialVB.getY());

-- 
Jean-Christophe Arnu
Paratronic


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


Re: Transforms (again) :'(

Posted by Jean-Christophe Arnu <ar...@paratronic.fr>.

Thomas DeWeese m'expliquait  (le 03.06.2005 12:40):

>    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).

That's what I figured, I get more rapidly NPE with 1.6 thant with 1.5.1 :)

>    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.
>
    mmm SVGOMSVGElement needs to implement the .getViewBox() ;)
    Never mind I have dom.svg to do the whole job.

Thanks again, Will try this on monday
See you
   

-- 
Jean-Christophe Arnu
Paratronic


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


Re: Transforms (again) :'(

Posted by Thomas DeWeese <Th...@Kodak.com>.
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: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Transforms (again) :'(

Posted by Jean-Christophe Arnu <ar...@paratronic.fr>.

Thomas DeWeese m'expliquait  (le 01.06.2005 19:40):

> Hi Jean,
>
> Jean-Christophe Arnu wrote:
>
>> Do I simply generate my ViewBox Rect like this :
>>    Create a java.awt.Rect with viewport data
>>    Apply java.awt.AffineTransform with screenCTM^-1 data
>>    apply AffineTransform to Rect
>> Or is there a more straightforward (clever) way to do such an operation?
>
>
>   It can also be done using SVG DOM methods but I don't think they
> have any particular advantage, especially if you are comfortable
> with the Java2D API's.

Hi,
    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).

    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();
        }
        }
---------------------------------------

-- 
Jean-Christophe Arnu
Paratronic


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


Re: Transforms (again) :'(

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Jean,

Jean-Christophe Arnu wrote:

> Do I simply generate my ViewBox Rect like this :
>    Create a java.awt.Rect with viewport data
>    Apply java.awt.AffineTransform with screenCTM^-1 data
>    apply AffineTransform to Rect
> Or is there a more straightforward (clever) way to do such an operation?

   It can also be done using SVG DOM methods but I don't think they
have any particular advantage, especially if you are comfortable
with the Java2D API's.

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


Re: Transforms (again) :'(

Posted by Jean-Christophe Arnu <ar...@paratronic.fr>.

Thomas DeWeese m'expliquait  (le 01.06.2005 18:42):

> Hi Jean,
>
>    I think you want to use the 'viewBox'.  There is
> even something called 'viewbox linking'  which is a
> special fragment identifier that you can put at the
> end of a URL to reference a particular segment of an
> SVG document:
>
>       #svgView(viewBox(235,125,100,100))
>
>    To calculate the current viewBox you need to simply
> transform the 'document.rootElement.viewport' by
> the inverse of the screenCTM.

Thank you Thomas,
    I will make some tests tomorrow :)

Just an additive question here are the results of 
getRootElement().getViewport() and getScreenCTM() :
screenCTM = A=0.020865368,
                         B=0.0,
                         C=0.0,
                         D=0.020865368,
                         E=-16509.213,
                         F=-43343.89   
viewport = X=0.0,
                     Y=0.0,
                    W=1189.0
                    H=995.0
screenCTM^-1 =
    A= 47.926308,
    B= 0.0,
    C=0.0,
    D=47.926308,
    E=791225.56,
    F=2077312.6   

Do I simply generate my ViewBox Rect like this :
    Create a java.awt.Rect with viewport data
    Apply java.awt.AffineTransform with screenCTM^-1 data
    apply AffineTransform to Rect
Or is there a more straightforward (clever) way to do such an operation?

Thanks again for your help!


-- 
Jean-Christophe Arnu
Paratronic


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


Re: Transforms (again) :'(

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Jean,

    I think you want to use the 'viewBox'.  There is
even something called 'viewbox linking'  which is a
special fragment identifier that you can put at the
end of a URL to reference a particular segment of an
SVG document:

       #svgView(viewBox(235,125,100,100))

    To calculate the current viewBox you need to simply
transform the 'document.rootElement.viewport' by
the inverse of the screenCTM.


Jean-Christophe Arnu wrote:
> Hi there,
>    I still rowing with my transforms problem :'(. Do you know a way to 
> get a device independant transform from a pan+zoomed view? (As example, 
> I would like my map to be pointed on a town each time I apply this 
> transform on any device at any resolution). I wasn't able to find it in 
> the docs :/
> 
> Thank you!
> 


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