xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Cruzdal <ccruz...@yahoo.com>
Subject JSVGCanvas/getURI() returns wrong (?) URI
Date Mon, 09 Feb 2004 12:17:08 GMT

I have a class which extends JSVGCanvas and overloads
the loadSVGDocument(String uri) method. Basically,
what I do in there is check whether uri is an SVG, and
then display it, or, whether it is not, and then I
pass the uri on to another handler which takes over
and does the appropriate thing with it.

If I get an SVG file, basically the core of the
loadSVGDocument(String uri) method comes down to
simply calling super.loadSVGDocument(uri).

Now, I am, though experiencing the following problem:
after I click on a link in the SVG document, and the
new SVG document opened, I can call getURI(), but it
will always return the uri of the very first document
in the canvas. I looked at the code of setURI() in
JSVGCanvas and loadSVGDocument in JSVGComponent, but
there it seems to me as if everything is correctly
setting the uri, hence I think I am doing something in
the wrong order in my code.

What is the difference between setURI() and
loadSVGDocument()? I mean, when I want to update, I am
usually calling setURI(), because that in turn calls
loadSVGDocument(), but is this correct? Thanks for any

My overriden method can be seen below.

Dazed and confused,


This is more or less the method (strapped by a few
other things):

	public void loadSVGDocument(String uri) {
		try {
			URL url = new URL(uri);
			URLConnection connection = url.openConnection();
			String contentType = connection.getContentType();
			// Evaluate content type.
			if (contentType == null)
				throw new MalformedURLException();
			// Does one have an SVG file?
			if (contentType.indexOf("xml") >= 0 ||
contentType.indexOf("svg") >= 0) {
				// Process as the super would.

				// @DEBUG
				// This is where the uri never changes, no matter
whether I call
				// this.uri or getURI(). In addition, if I call
this.uri or getURI() much
				// later manually via a button in the user
interface, nothing changed, either.
				System.err.println("@DEBUG:" + this.uri);

				// Register with the history.
				history.enter(uri, Actions.LINK_ACTION);
			} else {
				browser.showDocument(uri, Targets.SIDEBAR);
			connection = null;
		} catch (MalformedURLException e) {
				"The requested document is not available or it
does not exist!");
		} catch (IOException e) {
				"The requested document is not available or it
does not exist. Please check your internet
Chris Crzudal

Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.

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

View raw message