[solved]extending framework advice

I need to write a bit of code which will load in a different texture type(pfm).  I wanted to extend TextureManager and override the method below, but TextureManager is final.  Can I request this be changed, or some advice on an alternative approach? 



Cheers

Code:
public static com.jme.image.Image loadImage(String fileExt,             InputStream stream, boolean flipped) {

        com.jme.image.Image imageData = null;
        try {
            ImageLoader loader = loaders.get(fileExt.toLowerCase());
            if (loader != null)
                imageData = loader.load(stream);
            else if (".TGA".equalsIgnoreCase(fileExt)) { // TGA, direct to
                // imageData
                imageData = TGALoader.loadImage(stream, flipped);
            } else if (".DDS".equalsIgnoreCase(fileExt)) { // DDS, direct to
                // imageData
                imageData = DDSLoader.loadImage(stream, flipped);
            } else if (".BMP".equalsIgnoreCase(fileExt)) { // BMP, awtImage to
                // imageData
                java.awt.Image image = loadBMPImage(stream);
                imageData = loadImage(image, flipped);
            } else { // Anything else
                java.awt.Image image = ImageIO.read(stream); // readImage(fileExt, stream);
                imageData = loadImage(image, flipped);
            }
            if (imageData == null) {
                logger
                        .warning("loadImage(String fileExt, InputStream stream, boolean flipped): no imageData found.  defaultTexture used.");
                imageData = TextureState.getDefaultTextureImage();
            }
        } catch (IOException e) {
            logger.log(Level.WARNING, "Could not load Image.", e);
            imageData = TextureState.getDefaultTextureImage();
        }
        return imageData;
    }


Not sure why it is final



You could use your own class to wrap it and delegate calls out to texture manager where needed, but its a lot of work…

jME has a modular image loading system. Just implement ImageLoader then register it with TextureManager.registerLoader().

Thanks for your replies, I'll look into that Momoko_fan.  For the moment I've just implemented my own PFMLoader and just call the static methods directly.

theprism said:

You could use your own class to wrap it and delegate calls out to texture manager where needed, but its a lot of work....


With eclipse is:

1) Create Class -> Choose name
2) Add a TextureManager field
3) Right click on the class -> Source -> Generate Delegate Methods
4) Select all and click ok

And your wrapper is almost ready to go 

Thanks JJMontes, top tip noted

Momoko_Fan said:

jME has a modular image loading system. Just implement ImageLoader then register it with TextureManager.registerLoader().


This works.

      TextureManager.registerHandler(".pfm", new PFMLoader());
      image = TextureManager.loadImage(TestSubImage.class
            .getClassLoader().getResource(fileName), false);


PFM, isn't that a floating point format? Are you planning to release the image loader when you finish? I have an HDRLoader from long ago, but I had issues getting float images working with jME2. It would be useful for jME to support some HDR formats 

Momoko_Fan said:

PFM, isn't that a floating point format? Are you planning to release the image loader when you finish? I have an HDRLoader from long ago, but I had issues getting float images working with jME2. It would be useful for jME to support some HDR formats 

I'll have to ask people at work in the know on copyright issues here.  It's paid work, so there's a good chance I don't own anything I write.
harsha said:

Momoko_Fan said:

PFM, isn't that a floating point format? Are you planning to release the image loader when you finish? I have an HDRLoader from long ago, but I had issues getting float images working with jME2. It would be useful for jME to support some HDR formats 

I'll have to ask people at work in the know on copyright issues here.  It's paid work, so there's a good chance I don't own anything I write.


I've actually been given permission to hand this bit of code over.