com.sun.jimi.core.compat
Class JimiDecoderBase

java.lang.Object
  |
  +--com.sun.jimi.core.util.ProgressMonitorSupport
        |
        +--com.sun.jimi.core.compat.JimiDecoderBase
Direct Known Subclasses:
BMPDecoder, CURDecoder, GIFDecoder, ICODecoder, PCXDecoder, PICTDecoder, PNGDecoder, PSDDecoder, SunRasterDecoder, TGADecoder, TIFDecoder

public abstract class JimiDecoderBase
extends ProgressMonitorSupport
implements JimiDecoder, java.lang.Runnable

Compatibility adapter for ease of porting Jimi 1.0 decoders to Jimi 1.1


Field Summary
protected  boolean busyDecoding
           
protected  java.util.Vector cleanupCommands
           
protected  JimiDecodingController currentController
           
protected  JimiImageHandle currentHandle
           
protected  java.lang.Object decodingLock
           
protected  boolean error
           
static int ERROR
          The decoder has encountered an error.
protected  JimiImageFactory factory
           
protected  boolean finishedDecoding
           
static int IMAGEAVAIL
          The decoder has decode an image into the JIMImage structure.
static int INFOAVAIL
          The decoder has decoded enough of the image into JIMIImage structure to allow the initialiasing of image consumers
protected  java.io.InputStream input
           
protected  AdaptiveRasterImage jimiImage
           
static int MOREIMAGES
          The decoder considers it is possible that there are more images available in this InputStream.
static int MULTIIMAGE
          This decoder is capable of decoding multiple images if the input source of the image data contains multiple images.
static int UNKNOWNCOUNT
          Constant meaning the number of images is not known.
 
Fields inherited from class com.sun.jimi.core.util.ProgressMonitorSupport
currentProgressLevel, progressListener
 
Constructor Summary
JimiDecoderBase()
           
 
Method Summary
 void addCleanupCommand(java.lang.Runnable run)
          Commands to run when decoding has ended.
protected  AdaptiveRasterImage createAdaptiveRasterImage()
          Factory method for creating new adaptive raster images.
protected  AdaptiveRasterImage createAdaptiveRasterImage(int w, int h, java.awt.image.ColorModel cm)
          Factory method for creating new adaptive raster images.
protected  JimiDecodingController decodeNextImage()
          Decode the next available image.
protected abstract  boolean driveDecoder()
          Called repeatedly during image operations.
protected  void finishedDecode()
          Called when decoding an image has finished.
protected abstract  void freeDecoder()
          Called when no more decoding requests will be made.
protected  int getCapabilities()
          Query for special capabilities.
 int getNumberOfImages()
          Find out how many images are available.
protected abstract  int getState()
          Get the decoding state.
protected abstract  void initDecoder(java.io.InputStream in, AdaptiveRasterImage ji)
          Called before any requests for images are made.
 ImageSeriesDecodingController initDecoding(JimiImageFactory factory, java.io.InputStream input)
          Initialize decoding of a single image.
protected  void jimiImageCreated(MutableJimiImage jimiImage)
          Callback used when the back-end of an AdaptiveRasterImage has been created.
 boolean mustWaitForOptions()
          Check whether the decoder returns images which must be fully decoded before their options are available.
 void run()
          Drive the encoder
 void setFinished()
          Called if no further images will be needed.
 void skipImage()
          Skip the next image.
 boolean usesChanneledData()
          Check whether the format needs to set individual channels of image data separately.
protected  void waitReady()
          Wait until the decoder is idle.
 
Methods inherited from class com.sun.jimi.core.util.ProgressMonitorSupport
setProgress, setProgressListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
The decoder has encountered an error.

INFOAVAIL

public static final int INFOAVAIL
The decoder has decoded enough of the image into JIMIImage structure to allow the initialiasing of image consumers

IMAGEAVAIL

public static final int IMAGEAVAIL
The decoder has decode an image into the JIMImage structure. There are no further Images do decode

MOREIMAGES

public static final int MOREIMAGES
The decoder considers it is possible that there are more images available in this InputStream.

MULTIIMAGE

public static final int MULTIIMAGE
This decoder is capable of decoding multiple images if the input source of the image data contains multiple images. This value is one of the bit flags that maybe returned by getCapabilities

UNKNOWNCOUNT

public static final int UNKNOWNCOUNT
Constant meaning the number of images is not known.

jimiImage

protected AdaptiveRasterImage jimiImage

factory

protected JimiImageFactory factory

input

protected java.io.InputStream input

currentController

protected JimiDecodingController currentController

currentHandle

protected JimiImageHandle currentHandle

error

protected boolean error

busyDecoding

protected volatile boolean busyDecoding

decodingLock

protected java.lang.Object decodingLock

cleanupCommands

protected java.util.Vector cleanupCommands

finishedDecoding

protected boolean finishedDecoding
Constructor Detail

JimiDecoderBase

public JimiDecoderBase()
Method Detail

initDecoding

public ImageSeriesDecodingController initDecoding(JimiImageFactory factory,
                                                  java.io.InputStream input)
Initialize decoding of a single image.
Specified by:
initDecoding in interface JimiDecoder
Parameters:
factory - the factory to create a JimiImage from
input - the stream to read image data from

jimiImageCreated

protected void jimiImageCreated(MutableJimiImage jimiImage)
Callback used when the back-end of an AdaptiveRasterImage has been created.

run

public void run()
Drive the encoder
Specified by:
run in interface java.lang.Runnable

createAdaptiveRasterImage

protected AdaptiveRasterImage createAdaptiveRasterImage()
Factory method for creating new adaptive raster images.

createAdaptiveRasterImage

protected AdaptiveRasterImage createAdaptiveRasterImage(int w,
                                                        int h,
                                                        java.awt.image.ColorModel cm)
Factory method for creating new adaptive raster images.

decodeNextImage

protected JimiDecodingController decodeNextImage()
Decode the next available image.

finishedDecode

protected void finishedDecode()
Called when decoding an image has finished.

waitReady

protected void waitReady()
Wait until the decoder is idle.

initDecoder

protected abstract void initDecoder(java.io.InputStream in,
                                    AdaptiveRasterImage ji)
                             throws JimiException
Called before any requests for images are made.

driveDecoder

protected abstract boolean driveDecoder()
                                 throws JimiException
Called repeatedly during image operations.
Returns:
true if the decoder is continuing in the same state, false if a state change has been reached

freeDecoder

protected abstract void freeDecoder()
                             throws JimiException
Called when no more decoding requests will be made.

getState

protected abstract int getState()
Get the decoding state.

getCapabilities

protected int getCapabilities()
Query for special capabilities. None defined.

skipImage

public void skipImage()
               throws JimiException
Skip the next image. Must be overridden in subclasses which handle mulit-image formats.

getNumberOfImages

public int getNumberOfImages()
Find out how many images are available. Must be overridden in subclasses which handle mulit-image formats.

usesChanneledData

public boolean usesChanneledData()
Check whether the format needs to set individual channels of image data separately.

mustWaitForOptions

public boolean mustWaitForOptions()
Check whether the decoder returns images which must be fully decoded before their options are available.

setFinished

public void setFinished()
Called if no further images will be needed.
Specified by:
setFinished in interface JimiDecoder

addCleanupCommand

public void addCleanupCommand(java.lang.Runnable run)
Commands to run when decoding has ended.
Specified by:
addCleanupCommand in interface JimiDecoder