org.jscience.biology.lsystems.common
Class TextureBuilder

java.lang.Object
  extended by org.jscience.biology.lsystems.common.TextureBuilder

public class TextureBuilder
extends java.lang.Object

This class serves as a factory for Texture and ImageComponent2D objects. It creates these objects from image files (GIF or JPEG). The files must be stored at the same location the as classfile for this class.

Examples: If the TextureBuilder.class is in /home/hrm/j3d/TextureBuilder.class and one calls buildTexture("test.gif"), the there must be a file /home/hrm/j3d/test.gif.

If the TextureBuilder.class is in /home/hrm/j3d/TextureBuilder.class and one calls buildTexture("images/test.gif"), the there must be a file /home/hrm/j3d/images/test.gif.

If the TextureBuilder.class is in C:\j3d\TextureBuilder.class and one calls buildTexture("images/big/test.gif"), the there must be a file C:\j3d\images\big\test.gif.

If the TextureBuilder.class is in http://www.isbiel.ch/~hrm/j3d/TextureBuilder.class and one calls buildTexture("images/big/test.gif"), the there must be a file http://www.isbiel.ch/~hrm/j3d/images/big/test.gif.

If the TextureBuilder.class is in a JAR file under j3d/TextureBuilder.class and one calls buildTexture("images/big/test.gif"), the same JAR file must contain the file j3d/images/big/test.gif.

To create a Texture, do something like: TextureBuilder tb = new TextureBuilder(); Texture t = tb.buildTexture("a.gif");

Note: This class loads images using a polling mechanism. Bad style! I should use MT and synchronization.


Constructor Summary
TextureBuilder()
          Creates a new TextureBuilder object.
 
Method Summary
 javax.media.j3d.ImageComponent2D buildImage(java.lang.String imageName)
          Loads the image file and creates an ImageComponent2D.
 javax.media.j3d.Texture buildTexture(java.lang.String imageName)
          Loads the image file and creates an Texture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextureBuilder

public TextureBuilder()
Creates a new TextureBuilder object.

Method Detail

buildImage

public javax.media.j3d.ImageComponent2D buildImage(java.lang.String imageName)
Loads the image file and creates an ImageComponent2D.

Throws:
java.lang.RuntimeException - if the image does not exist or is corrupted Note: It would be better to throw an IOException, so users would be forced to catch it. But I want to make this class as similiar to the com.sun.j3d.utils.image.TextureLoader (which does not throw checked Exceptions either) as possible.

buildTexture

public javax.media.j3d.Texture buildTexture(java.lang.String imageName)
Loads the image file and creates an Texture.

Throws:
java.lang.RuntimeException - if the image does not exist or is corrupted Note: It would be better to throw an IOException, so users would be forced to catch it. But I want to make this class as similiar to the com.sun.j3d.utils.image.TextureLoader (which does not throw checked Exceptions either) as possible.