Hi,
You seem to be missing certain jar files on the classpath.
Specifically, the batik-ext.jar file in the lib directory (if you
downloaded the binary distribution.) You can copy this to your
project's lib folder and add it to its classpath through Project ->
Properties -> Java Build Path -> Libraries and Add External JARs, or
by modifying the .classpath file.
Jasleen
On 4/13/07, jtan <[EMAIL PROTECTED]> wrote:
I am relatively new to Java and very new to SVG. I wrote a small svg-based
program using Eclipse to experiment with Batic's bridge, but it does not
want to compile and this is probably due to my lack of skills with Eclipse
(sorry).
Any comments why Eclipse can not find ... import
org.w3c.dom.svg.SVGDocument; in the attached code?
msg:
"The type org.w3c.dom.svg.SVGDocument cannot be resolved. It is indirectly
referenced from required .class files"
Your help is greatly appreciated,
jtan
package graphics;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.gvt.GVTTreeRendererAdapter;
import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
import org.apache.batik.swing.svg.GVTTreeBuilderAdapter;
import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
import org.apache.batik.swing.svg.SVGDocumentLoaderAdapter;
import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.svg.SVGLoadEventDispatcherAdapter;
import org.apache.batik.swing.svg.SVGLoadEventDispatcherEvent;
import org.apache.batik.script.Window;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.svg.SVGDocument; //<------- Eclipse can not resolve it
import org.apache.batik.dom.svg12.SVG12DOMImplementation;
/**
* Experimenting with SVG files using Batik.
*/
public class BatikDisplay extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 0L;
Document document;
Window window;
public BatikDisplay(String title,String url)
{
// Set up the window
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle(title);
setSize(830,850); // Big enough to show the title bar &
components
final JSVGCanvas canvas = new JSVGCanvas();
canvas.setEnableImageZoomInteractor(true);
// Forces the canvas to always be dynamic even if the current
// document does not contain scripting or animation.
canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
canvas.setSize(1000,1000);
// Set the JSVGCanvas listeners.
canvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
System.out.println("Document Loading...");
}
public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
System.out.println("Document Loaded.");
}
});
canvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
public void gvtBuildStarted(GVTTreeBuilderEvent e) {
System.out.println("Build Started...");
}
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
System.out.println("Build Done.");
}
});
canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
System.out.println("Rendering Started...");
}
public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
System.out.println("Rendering Done.");
}
});
canvas.addSVGLoadEventDispatcherListener
(new SVGLoadEventDispatcherAdapter() {
public void svgLoadEventDispatchStarted
(SVGLoadEventDispatcherEvent e) {
// At this time the document is
available...
document = canvas.getSVGDocument();
// ...and the window object too.
window = canvas.getUpdateManager().
getScriptingEnvironment().createWindow();
// Registers the listeners on the document
// just before the SVGLoad event is dispatched.
registerListeners();
// It is time to pack the frame.
frame.pack();
}
});
// Set up the PLAY button test
JButton play = new JButton("PLAY");
play.addActionListener(new ActionListener() // Listen for button
selection
{
public void actionPerformed(ActionEvent e)
{
; // some action here will follow
}
}
);
canvas.setURI(url);
// Add the combobox and the button to the application window
Container content = getContentPane();
content.add(canvas, BorderLayout.CENTER);
//lrLabel.setVerticalTextPosition(JLabel.CENTER);
content.add(play,BorderLayout.SOUTH);
}
public void registerListeners() {
// Gets an element from the loaded document.
Element elt = document.getElementById("elt-id");
EventTarget t = (EventTarget)elt;
// Adds a 'onload' listener
t.addEventListener("SVGLoad", new OnLoadAction(), false);
// Adds a 'onclick' listener
t.addEventListener("click", new OnClickAction(), false);
};
public static void main(String[] args)
throws IOException {
File file = new File("test3.svg");
String url = file.toURL().toString();
System.out.println(url);
final BatikDisplay player = new BatikDisplay("A GRAPH", url); //
Create the application object
player.setVisible(true); // and show the
window
}
}
--
View this message in context:
http://www.nabble.com/SVG-Java-Newbie-tf3569729.html#a9972813
Sent from the Batik - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]