com.sun.jimi.core.raster
Class JimiRasterImageSupport

java.lang.Object
  |
  +--com.sun.jimi.core.raster.JimiRasterImageSupport
Direct Known Subclasses:
MemoryBitRasterImage, MemoryByteRasterImage, MemoryIntRasterImage, MemoryLongRasterImage

public abstract class JimiRasterImageSupport
extends java.lang.Object
implements MutableJimiRasterImage, java.awt.image.ImageProducer

Base support class for implementations of JimiRasterImage derivatives. Primarily provides support for ImageProducer functionality.


Field Summary
protected  boolean abort
           
protected  java.awt.image.ColorModel colorModel
          color model for interpreting image data
protected  boolean error
           
protected  boolean finished
          set to true when a full frame of image data is set, when there are is no unset data
protected  boolean forceRGB
           
protected  boolean modified
          set to true after first modification
protected  boolean newFrameData
          true if new data has been set since a frame was completed
protected  boolean productionAllowed
          set to true when production is allowed to be started
protected  boolean productionStarted
          set to true when some image data is set
protected  java.util.Hashtable properties
           
protected  int[] rowBuf
           
protected  java.awt.image.ColorModel sourceColorModel
           
protected  boolean waitForOptions
           
 
Constructor Summary
protected JimiRasterImageSupport(int w, int h, java.awt.image.ColorModel cm)
          Construct the storage with given dimensions
 
Method Summary
 void addConsumer(java.awt.image.ImageConsumer consumer)
          Add a new consumer.
protected  void addDirectConsumer(java.awt.image.ImageConsumer consumer)
           
protected  void addWaitingConsumer(java.awt.image.ImageConsumer consumer)
           
protected  boolean catchupConsumer(java.awt.image.ImageConsumer consumer)
          Default implementation, does not attempt to catch up and returns failure.
protected  java.awt.image.ColorModel getAppropriateColorModel(java.awt.image.ColorModel cm)
          Return a ColorModel appropriate for use with image production.
 void getChannelRectangle(int channel, int x, int y, int width, int height, byte[] buffer, int offset, int scansize)
           
 void getChannelRow(int channel, int y, byte[] buffer, int offset)
           
 java.awt.image.ColorModel getColorModel()
           
 java.awt.image.ImageProducer getCroppedImageProducer(int x, int y, int width, int height)
           
protected  MulticastImageConsumer getDirectConsumer()
           
 JimiImageFactory getFactory()
          Get the JimiImageFactory this image was created by.
 int getHeight()
          Get the height of the storage space.
 java.awt.image.ImageProducer getImageProducer()
          Get an ImageProducer to send image data from the storage.
 FormatOptionSet getOptions()
          Get the FormatOptionSet associated with the image.
 java.util.Hashtable getProperties()
           
 void getRectangleARGBChannels(int x, int y, int width, int height, byte[] buffer, int offset, int scansize)
           
 void getRectangleRGBAChannels(int x, int y, int width, int height, byte[] buffer, int offset, int scansize)
           
 void getRectangleRGBChannels(int x, int y, int width, int height, byte[] buffer, int offset, int scansize)
           
 int getWidth()
          Get the width of the storage space.
protected  boolean hasDirectConsumer()
           
protected  void initConsumer(java.awt.image.ImageConsumer consumer)
           
 boolean isConsumer(java.awt.image.ImageConsumer consumer)
           
 boolean isError()
          Check whether the image has been marked as an error.
 boolean mustWaitForOptions()
           
 void produceCroppedImage(java.awt.image.ImageConsumer consumer, java.awt.Rectangle region)
           
 void removeConsumer(java.awt.image.ImageConsumer consumer)
           
 void requestTopDownLeftRightResend(java.awt.image.ImageConsumer consumer)
           
protected abstract  void sendRegionToConsumerFully(java.awt.image.ImageConsumer consumer, java.awt.Rectangle region)
           
protected abstract  void sendToConsumerFully(java.awt.image.ImageConsumer consumer)
           
 void setColorModel(java.awt.image.ColorModel cm)
          Set the source ColorModel of the image.
 void setDecodingController(JimiDecodingController controller)
           
 void setError()
          Declare that the image is an error, and should not be used.
 void setFactory(JimiImageFactory factory)
          Set the factory which the image belongs to.
 void setFinished()
          Signal that the image is complete.
 void setImageConsumerHints(int hints)
          Set hints about how the data will be delivered.
protected  void setModified()
           
 void setOptions(FormatOptionSet options)
          Associate a FormatOptionSet with the image.
 void setWaitForOptions(boolean wait)
           
 void startProduction(java.awt.image.ImageConsumer consumer)
           
 void waitFinished()
           
 void waitInfoAvailable()
          Required information is known from creation time, so no need to wait.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

error

protected boolean error

abort

protected boolean abort

productionStarted

protected boolean productionStarted
set to true when some image data is set

modified

protected boolean modified
set to true after first modification

productionAllowed

protected boolean productionAllowed
set to true when production is allowed to be started

finished

protected boolean finished
set to true when a full frame of image data is set, when there are is no unset data

newFrameData

protected boolean newFrameData
true if new data has been set since a frame was completed

colorModel

protected java.awt.image.ColorModel colorModel
color model for interpreting image data

properties

protected java.util.Hashtable properties

sourceColorModel

protected java.awt.image.ColorModel sourceColorModel

forceRGB

protected boolean forceRGB

rowBuf

protected int[] rowBuf

waitForOptions

protected boolean waitForOptions
Constructor Detail

JimiRasterImageSupport

protected JimiRasterImageSupport(int w,
                                 int h,
                                 java.awt.image.ColorModel cm)
Construct the storage with given dimensions
Parameters:
w - width in pixels of storage space
h - height in pixels of storage space
cm - the ColorModel to use
Method Detail

getWidth

public int getWidth()
Get the width of the storage space.
Returns:
width in pixels

getHeight

public int getHeight()
Get the height of the storage space.
Returns:
height in pixels

setColorModel

public void setColorModel(java.awt.image.ColorModel cm)
Set the source ColorModel of the image.

setImageConsumerHints

public void setImageConsumerHints(int hints)
Set hints about how the data will be delivered. The hints constants from ImageConsumer are used.
See Also:
java.awt.ImageConsumer

isError

public boolean isError()
Check whether the image has been marked as an error.

setError

public void setError()
Declare that the image is an error, and should not be used.

setFactory

public void setFactory(JimiImageFactory factory)
Set the factory which the image belongs to.

getFactory

public JimiImageFactory getFactory()
Get the JimiImageFactory this image was created by.

setOptions

public void setOptions(FormatOptionSet options)
Associate a FormatOptionSet with the image.

getOptions

public FormatOptionSet getOptions()
Get the FormatOptionSet associated with the image.

setFinished

public void setFinished()
Signal that the image is complete.

waitInfoAvailable

public void waitInfoAvailable()
Required information is known from creation time, so no need to wait.

waitFinished

public void waitFinished()

setDecodingController

public void setDecodingController(JimiDecodingController controller)

addConsumer

public void addConsumer(java.awt.image.ImageConsumer consumer)
Add a new consumer.
Specified by:
addConsumer in interface java.awt.image.ImageProducer
Parameters:
consumer - the consumer

addDirectConsumer

protected void addDirectConsumer(java.awt.image.ImageConsumer consumer)

addWaitingConsumer

protected void addWaitingConsumer(java.awt.image.ImageConsumer consumer)

catchupConsumer

protected boolean catchupConsumer(java.awt.image.ImageConsumer consumer)
Default implementation, does not attempt to catch up and returns failure.
Returns:
true if the consumer has been brought up-to-date

getImageProducer

public java.awt.image.ImageProducer getImageProducer()
Get an ImageProducer to send image data from the storage.
Returns:
an ImageProducer to produce and image based on the data in the store

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer consumer)
Specified by:
isConsumer in interface java.awt.image.ImageProducer

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer consumer)
Specified by:
removeConsumer in interface java.awt.image.ImageProducer

startProduction

public void startProduction(java.awt.image.ImageConsumer consumer)
Specified by:
startProduction in interface java.awt.image.ImageProducer

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer consumer)
Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer

getColorModel

public java.awt.image.ColorModel getColorModel()

getProperties

public java.util.Hashtable getProperties()

getCroppedImageProducer

public java.awt.image.ImageProducer getCroppedImageProducer(int x,
                                                            int y,
                                                            int width,
                                                            int height)

produceCroppedImage

public void produceCroppedImage(java.awt.image.ImageConsumer consumer,
                                java.awt.Rectangle region)

getDirectConsumer

protected MulticastImageConsumer getDirectConsumer()

hasDirectConsumer

protected boolean hasDirectConsumer()

sendToConsumerFully

protected abstract void sendToConsumerFully(java.awt.image.ImageConsumer consumer)
                                     throws ImageAccessException

sendRegionToConsumerFully

protected abstract void sendRegionToConsumerFully(java.awt.image.ImageConsumer consumer,
                                                  java.awt.Rectangle region)
                                           throws ImageAccessException

initConsumer

protected void initConsumer(java.awt.image.ImageConsumer consumer)

getAppropriateColorModel

protected java.awt.image.ColorModel getAppropriateColorModel(java.awt.image.ColorModel cm)
Return a ColorModel appropriate for use with image production.

setModified

protected void setModified()

getChannelRectangle

public void getChannelRectangle(int channel,
                                int x,
                                int y,
                                int width,
                                int height,
                                byte[] buffer,
                                int offset,
                                int scansize)
                         throws ImageAccessException

getChannelRow

public void getChannelRow(int channel,
                          int y,
                          byte[] buffer,
                          int offset)
                   throws ImageAccessException

getRectangleRGBChannels

public void getRectangleRGBChannels(int x,
                                    int y,
                                    int width,
                                    int height,
                                    byte[] buffer,
                                    int offset,
                                    int scansize)
                             throws ImageAccessException

getRectangleARGBChannels

public void getRectangleARGBChannels(int x,
                                     int y,
                                     int width,
                                     int height,
                                     byte[] buffer,
                                     int offset,
                                     int scansize)
                              throws ImageAccessException

getRectangleRGBAChannels

public void getRectangleRGBAChannels(int x,
                                     int y,
                                     int width,
                                     int height,
                                     byte[] buffer,
                                     int offset,
                                     int scansize)
                              throws ImageAccessException

setWaitForOptions

public void setWaitForOptions(boolean wait)

mustWaitForOptions

public boolean mustWaitForOptions()