Hi,everybody!

First, let me apologize for taking so long to get back.  I had a 
number of complex, time-consuming problems to take care of, and few 
were related to SVG :)

My javascript problems stemmed from code I was entering as I followed 
along in the book SVG Unleashed by SAMS publishing (now InformIT).  
As I progressed I discovered the more the code adhered to W3C 
ECMAScript standard (and the less the code used ASV-specific calls) 
the more likely it was to run in Batik.

This is the code that prompted me to ask for help. Note the DOM 
method calls:

   <script type="text/javascript">
        <![CDATA[
                var MyRect;
                var SVGDoc;
                var ZoomFactor = 1.5;
                var Growing = true;
                window.status = ZoomFactor;
                        
                function Initialize(evt){
                        SVGDoc = evt.getTarget().getOwnerDocument();
                        SVGRoot = SVGDoc.getDocumentElement();
                        MyRect = SVGDoc.getElementById("MyRect");
                        SVGDoc.getElementById("SVG").addEventListener
("click", ZoomOnClick, false);
                        }
                        
                function ZoomOnClick(evt){
                
                        if (SVGRoot.currentScale > 20)
                        { Growing = false;
                        } //end if
                        else if (SVGRoot.currentScale < 0.1)
                        { Growing = true;
                        } // end else
                                
                        if (Growing == true){
                                ZoomFactor = ZoomFactor * 1.5}
                        else{
                                ZoomFactor = ZoomFactor * 0.5;
                        }
                                
                        SVGRoot.setCurrentScale(ZoomFactor);
                        window.status = SVGRoot.currentScale;
                                
                        } //End function ZoomOnClick()  
                ]]>
        </script>

This following code throws a "null" error in Batik, though for the 
life of me I don't know why:
                        
         var wavePath, waveLength, waveText;
                                 
     function Initialize(){
                wavePath = document.getElementById('wavePath');
                waveLength = wavePath.getTotalLength();
                waveText = document.getElementById('waveText');
                waveText.setAttribute('startOffset', waveLength);
                moveText();
          }
                                        
         function moveText(){
                var currentOffset = parseInt(waveText.getAttribute
('startOffset'));
                var newOffset = (currentOffset < -waveLength)? 
waveLength: currentOffset - 5;
                waveText.setAttribute('startOffset', newOffset);
                setTimeout('moveText()', 100);
                }

This code works perfectly both in ASV and Batik:

        <svg width="100%" height="100%" onload="Initialize(evt)">
                <script>
                        <![CDATA[
                                var up = false;
              var scaleFactor = 1;
              var newTransform;
              
              function Initialize() {
                SVGRoot = document.documentElement;
                myCircle = SVGRoot.getElementById('theCircle');
              }
              
              function adjustScale() {
                if (up==true) {
                        scaleFactor = scaleFactor * 1.25;
                        newTransform = "translate(100, 150), scale(" 
+ scaleFactor + ")";
                        myCircle.setAttribute('transform', 
newTransform);
                }// end if
                else {
                        scaleFactor = scaleFactor / 1.25;
                        newTransform = "translate(100, 150), scale(" 
+ scaleFactor + ")";
                        myCircle.setAttribute('transform', 
newTransform);
                }// end else
              }
                        ]]>
                </script>
                <g transform="translate(200,200)">
                        <text x="75" y="75" 
onclick="up=true;adjustScale(evt)">Up</text>
                        <text x="115" y="75" 
onclick="up=false;adjustScale(evt)">Down</text>
                        <circle id="theCircle" cx="0" cy="0" r="50" 
transform="translate(100, 150) scale(1.0)"
                                fill="none" stroke="#ff00ff" stroke-
width="4" pointer-events="none"/>
                </g>
        </svg>

I have also learned:
    *Fills and gradients don't animate too well in Batik, using 
either declarative or script animation,
    *Batik doesn't comprende event listeners to well,
    *and how Batik renders this animation is just weird:        

        <svg width="1000px" height="600px">
        
                <defs>
                </defs>
           <!-- Animation renders properly in ASV but not in Batik -->
                 <path d="M200 200 l200 0 0 200 -200 0 z" fill="none" 
stroke="black" stroke-width="4"/>
                 <g fill="none" stroke="red" stroke-width="7" 
transform="translate(200, 200)">
                        <animateMotion path="M0 0 l200 0 0 200 -200 0 
z" begin="2s" dur="8s" repeatCount="indefinite" rotate="auto" />
                        <line x1="0" y1="0" x2="50" y2="0"/>
                        <line x1="50" y1="" x2="35" y2="-15"/>
                        <line x1="50" y1="" x2="35" y2="15"/>
                </g>
                
        </svg>
        
In short, I figure the closer to ECMAScript I stick--and the less I 
rely on things like event listeners the more likely my code is to 
work cross-platform.
Am I wrong?

Thanks, everyone for the help,
Tony            



--- In [email protected], "Andreas Neumann" 
<[EMAIL PROTECTED]> wrote:
>
> Hi Tony,
> 
> Opera is probably the viewer with the most complete SVG support, 
> followed by Batik. The Adobe viewer is much less complete and then 
> followed by Mozilla and Safari. Safari still has a few severe bugs 
> that need to be fixed.
> 
> All of them support patterns (Firefox only in version 3) and 
> gradients and have a useful SVG subset to do sophisticated SVG 
> applications. This is not to say that the situation is bright, but 
> its good enough for a lot of applications. Some of the missing 
> features in many viewers are: SVG font support (missing in Mozilla 
> and Safari), SMIL support (missing in Mozilla and Safari) and 
filters 
> (Mozilla and Safari, a lot of them are implemented in Firefox 3).
> 
> Andreas
> 
> 
> --- In [email protected], "Tony" <tg_harris@> wrote:
> >
> > Hi, Andreas:
> > 
> > I'm mostly using IE7/ASV and Batik Squiggle because in my 
research 
> > these supposedly had the most complete implementation of SVG 1.0; 
> > they support patterns, gradient fills, animation, etc.  Code that 
> > works fine in both Adobe and Batik supposedly "breaks" in 
> > Mozilla/Opera.  If I recall correctly, Mozilla uses the CSIRO 
> viewer, 
> > which does not fully support SVG 1.0 specs.
> > 
> > I'll download them and give them a try anyway, but am I wrong?
> > 
> > Thanks,
> > 
> > Tony
> > 
> > --- In [email protected], "Andreas Neumann" 
> > <neumann@> wrote:
> > >
> > > Hi Tony,
> > > 
> > > does your file work in other browsers like Opera, Firefox, 
> Safari, 
> > > etc?
> > > 
> > > the Adobe viewer was very forgiving when users used non-
standard 
> > > javascript/DOM methods. Other viewers are not. There might be 
> some 
> > > issues when trying to run SVG files specifically designed for 
the 
> > > Adobe viewer. See http://jwatt.org/svg/authoring/ for some 
> details 
> > on 
> > > potential issues. If you follow these guidelines, your examples 
> > > should work fine with all major SVG viewers.
> > > 
> > > Regarding Batik: it might be useful to check the nightlies, 
> > available 
> > > from http://people.apache.org/builds/xml-batik/ or checkout the 
> > > sources with svn. The beta is already quite old compared with 
the 
> > > trunk.
> > > 
> > > Hope you can fix your problems,
> > > Andreas
> > > 
> > > --- In [email protected], "Tony" <tg_harris@> 
wrote:
> > > >
> > > > I'm a developer new to SVG.  I'm using Adobe SVG Viewer and 
> Batik 
> > > > Squiggle 1.7 beta to view my code.  Even though Batik 
> supposedly 
> > > > supports Javascript now, every time I load an SVG with 
embedded 
> > > > Javascript--which runs fine in ASV--I get a security error:
> > > > 
> > > > >Scripts of type (text/javascript) cannot be loaded and 
> executed 
> > > with
> > > > >the current security settings.
> > > > 
> > > > Here are the details:
> > > > >java.lang.SecurityException: Scripts of type 
(text/javascript) 
> > > > cannot be loaded and executed with the current security 
> settings.
> > > > >       at 
> > > > >org.apache.batik.swing.svg.AbstractJSVGComponent
> > > $BridgeUserAgentWrapp
> > > > er.checkLoadScript(Unknown Source)
> > > > >       at 
> > > > 
> > > 
> > 
> 
>org.apache.batik.bridge.BaseScriptingEnvironment.checkCompatibleScrip
> > > > tURL(Unknown Source)
> > > > >       at 
> > > > >org.apache.batik.bridge.BaseScriptingEnvironment.loadScripts
> > > (Unknown 
> > > > Source)
> > > > >       at 
org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent
> > > > (Unknown Source)
> > > > >       at 
org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent
> > > > (Unknown Source)
> > > > >       at 
org.apache.batik.swing.svg.SVGLoadEventDispatcher.run
> > > > (Unknown Source)
> > > > 
> > > > This happens even with the security settings disabled in Edit-
-
> > 
> > > > Preferences.  When I edit the code to remove the 
> > > > type="text/javascript" attribute, or edit it to 
> > > > type="text/ecmascript" the code either throws another error 
or 
> it 
> > > > doesn't work at all.
> > > > 
> > > > Worse, when I try to look up this problem on the Apache Batik 
> web 
> > > > site, or on this forum, no one else seems to have this 
> difficulty.
> > > > 
> > > > Could you tell me if anyone else has had this problem, and 
> what, 
> > if 
> > > > anything, can be done?
> > > > 
> > > > Thank you.
> > > > 
> > > > Tony G. Harris
> > > >
> > >
> >
>




-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to