http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Overview
FAQ
Demo
License
Download
Install

Viewer
Rasterizer
SVG Applet
Generator

Who we are
Status
CVS Repository
Mail Archive
Bug Database

Glossary
Regression tool
API (Javadoc)



Introduction

Batik SVG Applet

This page describes how to use Batik to display SVG content in an applet. It discusses the following:


Setting up the SVG Applet on a web site

In order to display SVG content in an applet, you need to:

  • Create a page that will either load the applet properly for the user or let him get the Java Pluggin(tm) needed to view the applet
  • Copy the batik jar to the same location as the HTML page
Creating a page for the SVG Applet

In the body of the page where you want to embed the SVG applet, add the following:

      <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
              width="600" 
              height="400"  
             codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
        <PARAM NAME="code" VALUE="org.apache.batik.apps.applet.JSVGApplet" >
        <PARAM NAME="archive" VALUE="<batikDirectory>/batik-svgviewer.jar" >
        <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
        <PARAM NAME="svg" VALUE="<svgFileURI>">
        <COMMENT>
	        <EMBED type="application/x-java-applet;version=1.3" 
	               width="600" 
	               height="400"
	               archive="<batikDirectory>/batik-svgviewer.jar"
	               code="org.apache.batik.apps.applet.JSVGApplet" 
	               svg="<svgFileURI>">
	  
	            <NOEMBED>
	                 No JDK 1.2 support found!
	            </NOEMBED>
	        </EMBED>
        </COMMENT>
    </OBJECT>
                

This will ensure that the user viewing the page uses the Java Pluggin to load the Batik SVG applet and be directed to the proper download area if he or she does not already have the Java Pluggin installed.


Copy Batik Jar on server

In order for the client to be able to load the Batik viewer applet, you need to copy the Batik JAR to the server where the html page is located. For example, if the applet HTML page is in the [htmlRoot] directory, you can expand the batik-1.0beta.zip file under [htmlRoot\batik] and setup the HTML page accordingly:

      <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
              width="600" 
              height="400"  
             codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
        <PARAM NAME="code" VALUE="org.apache.batik.apps.applet.JSVGApplet" >
        <PARAM NAME="archive" VALUE="batik/batik-svgviewer.jar" >
        <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
        <PARAM NAME="svg" VALUE="batik/samples/lotoTexture.svg">
        <COMMENT>
	        <EMBED type="application/x-java-applet;version=1.3" 
	               width="600" 
	               height="400"
	               archive="batik/batik-svgviewer.jar"
	               code="org.apache.batik.apps.applet.JSVGApplet" 
	               svg="batik/samples/logoTexture.svg">
	  
	            <NOEMBED>
	                 No JDK 1.2 support found!
	            </NOEMBED>
	        </EMBED>
        </COMMENT>
    </OBJECT>
                


Live SVG Applet Demo

Below is the Applet that uses the technique described on this page.



Copyright © 2000 The Apache Software Foundation. All Rights Reserved.