June 2005 Archives

New <canvas> tag in Firefox and Safari

| 5 Comments

I've been reading about the new <canvas> tag supported by the latest Safari and by the latest alpha release (codenamed Deer Park) of Firefox.

It is very cool: it exposes a sophisticated 2D drawing API (comparable to Java2D, but without text support) to client-side JavaScript.

My demo is here. It uses the canvas tag to draw a quadratic bezier curve and allows you to drag the control point around to change the curve.

It doesn't work for me in Safari 1.3, but it does work in Deer Park (a.k.a.Firefox 1.1) Alpha1

Almost reason enough to download a new browser!

Update: In comments, Berndt Jung links to a version of my demo that does work in Safari. He takes the text out from inside the <canvas*gt; tags, since Safari always renders it. But mostly, he figured out that due to a bug (being fixed) , the quadraticCurveTo() method is not actually bound.. The workaround is to use quadraticCurveToPoint() instead, on Safari only.

URL vs URI class for URL-to-File conversion

| 3 Comments

My Jude 1.00 release shipped with the following method in it to determine its own installation directory:

    static File getInstallationDirectory() {
	java.net.URL url = Main.class.getResource("Main.class");
	String protocol = url.getProtocol();
	File f = null;
	if (protocol.equals("file")) {
	    // Go up twice for jude/Main.class
	    f = new File(url.getPath()).getParentFile().getParentFile();
	}
	else if (protocol.equals("jar")) {
	    String s = url.toString();
	    int pos = s.lastIndexOf('!'); // ! marks beginning of jar entry
	    s = s.substring(9, pos); // 9 is the length of "jar:file:"
	    f = new File(s).getParentFile();
	}
	
	return f;
    }

It uses Class.getResource() to get a URL for one of its own class files. Then it parses this URL (which may be a file: or jar: URL) to determine the installation directory. I think its a clever thing to do. But ithere is a bug (which has been fixed in Jude 1.01, which I've just releases). Can you spot it? (The answer is below)

JavaScript in Mustang build 40

As promised below, Mustang build 40 incorporates JSR 223, Scripting for the Java Platform, and includes the Rhino JavaScript interpreter.

Java 6.0 'Mustang' Details

| 1 Comment

Here is a nice summary of new features in the core platform (i.e. not desktop features) for Java 6.0

I came upon this almost by accident (thanks, google!). It is dated 6 days from now, so I think it must be pretty new.

The detail that is most interesting to me is that the JSR-233 JSR-223 (Scripting for the Java Platform) implementation will be included in build 40 (in a week or two, I think). And, it will include the Rhino JavaScript engine! So every Java 6.0 application will automatically have an embedded JavaScript interpreter. (And readers of Java in a Nutshell will go out and buy JavaScript: The Definitive Guide! :-)

Jude 1.00 Released!

| 8 Comments

After years and years of development, I've finally released version 1.00 of Jude. Jude is an alternative to javadoc. It displays definitive API documentation from documentation comments in Java source code. But its output is easier to browse than javadoc, it is better looking than javadoc. And it is searchable. And customizable. Want to see methods listed alphabetically? Jude does that. Want them grouped functionally instead? A single keystroke will toggle between these two views!

There are too many features to describe here. If you haven't tried Jude yet (or recently), please give it a spin:

  • Read more about Jude (and view screenshots) on the home page, and in the User's Guide and Administrator's Guide.
  • Download the Jude 1.00 release here.
  • Get an evaluation license to make the release work here
  • And, if you like it, you can buy a license (for less than you'd spend on a good Java reference book) here.

Books

Comprehensive coverage of Ruby 1.8 and 1.9

"The New Most Important Ruby Book"
Peter Cooper,
rubyinside.com

Completely updated for Ajax and Web 2.0

"A must-have reference"
Brendan Eich,
creator of JavaScript

The classic Java quick-reference