Pages

Sunday, November 27, 2005

Open Source Swing: Jmol renderer runs!

Where I was able to mention earlier that JChemPaint now runs with free (as in open source) Java virtual machines, I just tried to run the core Jmol renderer, using the Integration.java which comes as an example:




The screenshot was made with jamvm 1.3.3 and classpath 0.19.

It is very slow, however. I have not tried it with other free virtual machines, which are supposedly faster. It is a good start nevertheless: it means that a Jmol based Bioclipse plugin will work with free virtual machines too.

Update: added a nicer screenshot.

1 comment:

  1. This is one of the tweaks needed to get Jmol going with CP+jamv:

    $ java -Djava.version=1.1 -jar Jmol.jar

    To fix the Jmol source code you need this patch. It relates to the RGB issue mentioned at the ClassPath FreeSwing wiki page:

    diff -r -u Jmol-HEAD/src/org/jmol/g3d/Awt3D.java Jmol-HEAD.broken/src/org/jmol/g3d/Awt3D.java
    --- Jmol-HEAD/src/org/jmol/g3d/Awt3D.java 2005-11-10 16:52:39.000000000 +0100
    +++ Jmol-HEAD.broken/src/org/jmol/g3d/Awt3D.java 2005-11-27 22:52:47.000000000 +0100
    @@ -26,6 +26,7 @@

    import java.awt.Component;
    import java.awt.Graphics;
    +import java.awt.Toolkit;
    import java.awt.Image;
    import java.awt.image.ImageProducer;
    import java.awt.image.ImageConsumer;
    @@ -55,7 +56,8 @@

    Awt3D(Component component) {
    this.component = component;
    - colorModelRGB = ColorModel.getRGBdefault();
    + // old code: colorModelRGB = ColorModel.getRGBdefault();
    + colorModelRGB = Toolkit.getDefaultToolkit().getColorModel();
    }

    Image allocateImage() {
    @@ -70,7 +72,8 @@
    Image allocateOffscreenImage(int width, int height) {
    // System.out.println("allocateOffscreenImage(" + width + "," + height + ")");
    Image img = component.createImage(width, height);
    - // System.out.println("img=" + img);
    + System.out.println("img=" + img);
    + System.out.println("class(img)=" + img.getClass().getName());
    return img;
    }

    @@ -102,6 +105,7 @@
    ImageConsumer.COMPLETESCANLINES |
    ImageConsumer.SINGLEPASS);
    }
    + for(int i=0;i<pBuffer.length;i++) pBuffer[i] |= 0xFF000000;
    ic.setPixels(0, 0, windowWidth, windowHeight, colorModelRGB,
    pBuffer, 0, windowWidth);
    ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE);

    ReplyDelete