quicktime.app.image
Class ImagePresenter

java.lang.Object
  |
  +--quicktime.app.image.ImagePresenter
All Implemented Interfaces:
Compositable, Drawable, ImageSettable, ImageSpec, Listener, QTDrawable, Transformable
Direct Known Subclasses:
MoviePresenter, QTEffectPresenter

public class ImagePresenter
extends java.lang.Object
implements QTDrawable, Compositable, ImageSettable

This class represents an image that is loaded into memory. Its focus is on performance so if the image data that is presented to the ImagePresenter is in a format that is non-optimal for drawing the data will generally be converted to a format that is optimal, at the expense of a greater usage of memory (see setImageData methods). This process is controlled by the optimised redrawing flag, which if true (the default), may convert the image to a better format for drawing performance.


Constructor Summary
ImagePresenter(QDRect initialSize)
          Creates an emtpy ImagePresenter object - you will need to set the image data and description before this object is usable.
 
Method Summary
 void addedTo(java.lang.Object interest)
          This method is called by the specified object when the instance of the class that implements this interface is added to the object that is the source of the interest.
protected  void doDraw()
          This is the method that blits the data directly to the destination QDGraphics.
static ImagePresenter fromFile(QTFile qtFile)
          This creates an ImagePresenter object from a file.
static ImagePresenter fromGraphicsImporter(GraphicsImporter importer)
          This creates an ImagePresenter object from a GraphicsImporter.
static ImagePresenter fromGraphicsImporterDrawer(GraphicsImporterDrawer imageFile)
          This creates an ImagePresenter object from an GraphicsImporterDrawer object.
static ImagePresenter fromGWorld(QDGraphics grafPort)
          This creates an ImagePresenter object from the PixMap of the QDGraphics object.
static ImagePresenter fromGWorld(QDGraphics port, QDRect rect, int colorDepth, int quality, int codecType, CodecComponent codec)
          This creates an ImagePresenter object from PixMap source, bounds QDRect, color depth, compression quality, codec type, and codec component.
static ImagePresenter fromImageSequence(ImageDataSequence image, int nth)
          This creates an ImagePresenter object from nth first image of any ImageDataSequence object
static ImagePresenter fromImageSpec(ImageSpec image)
          This creates an ImagePresenter object from an ImageSpec object.
static ImagePresenter fromPict(Pict p)
          This creates an ImagePresenter object from a Pict object that is stored in memory.
static ImagePresenter fromQTImage(EncodedImage data, ImageDescription desc)
          This creates an ImagePresenter object from raw image data and ImageDescription.
 Region getClip()
          Returns a region that defines the current clipping region for the object.
 ImageDescription getDescription()
          This method should return an ImageDescription that describes the image data that the class contains.
 QDRect getDisplayBounds()
          QTCanvas calls this method when it needs to ask the client for its boundary.
 DSequence getDSequence()
          Returns the DSequence that is used by the ImagePresenter.
 GraphicsMode getGraphicsMode()
          This gets the current GraphicsMode for the compositor.
 QDGraphics getGWorld()
          QTCanvas calls this method to get the destination QDGraphics of its client.
 EncodedImage getImage()
          This method returns the actual image data.
 java.awt.Dimension getInitialSize()
          Deprecated. since QTJava 4.0
 Matrix getMatrix()
          This will return the client's current display transformations
 QDDimension getOriginalSize()
          This method returns the original size before the transformations specified in the returned matrix are applied.
 boolean isRedrawOptimised()
          Returns the current state of the optimisation for drawing flag.
 void redraw(Region invalidRgn)
          QTCanvas calls this method when the client should redraw itself.
 void removedFrom(java.lang.Object interest)
          This method is called by the specified object when the instance of the class that implements this interface is removed from the object that is the source of the interest.
 void removeImageData()
          This method removes the previously set encoded image data and description from the ImagePresenter and will remove it from any destination QDGraphics it is currently drawing into.
 void setClip(Region reg)
          Sets a region that will define the clipping region for the object
 void setDisplayBounds(QDRect bounds)
          QTCanvas calls this method when it needs to tell the client to adjust its location, width and/or height.
 void setGraphicsMode(GraphicsMode mode)
          This sets the GraphicsMode for the Compositor when it draws its composited contents to its destination QDGraphics (typically the QTCanvas).
 void setGWorld(QDGraphics cgp)
          QTCanvas calls this method to give the client the QDGraphics object it should use to do its drawing.
 void setImageData(EncodedImage ei)
          If you have already set the image data and you have image data in the same general parameters as previously set (ie.
 void setImageData(EncodedImage data, ImageDescription desc)
          Sets the current image data and description.
 void setLocation(int x, int y)
          A convenience method to set the position of a QTDrawable object.
 void setMatrix(Matrix matrix)
          This method assigns a mapping matrix to the sequence.
 void setRedrawOptimised(boolean flag)
          Returns the state of the optimisation for redraw flag.
 java.lang.String toString()
          Returns a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImagePresenter

public ImagePresenter(QDRect initialSize)
Creates an emtpy ImagePresenter object - you will need to set the image data and description before this object is usable.
Method Detail

fromFile

public static ImagePresenter fromFile(QTFile qtFile)
                               throws java.io.IOException,
                                      QTException
This creates an ImagePresenter object from a file.
Parameters:
qtFile - the QTFile.

fromGraphicsImporter

public static ImagePresenter fromGraphicsImporter(GraphicsImporter importer)
                                           throws java.io.IOException,
                                                  QTException
This creates an ImagePresenter object from a GraphicsImporter.
Parameters:
importer - the GraphicsImporter object.

fromGraphicsImporterDrawer

public static ImagePresenter fromGraphicsImporterDrawer(GraphicsImporterDrawer imageFile)
                                                 throws java.io.IOException,
                                                        QTException
This creates an ImagePresenter object from an GraphicsImporterDrawer object.
Parameters:
imageFile - the image file object

fromImageSpec

public static ImagePresenter fromImageSpec(ImageSpec image)
                                    throws QTException
This creates an ImagePresenter object from an ImageSpec object.
Parameters:
image - the image
nth - the index into the ImageDataSequence object of the image data that should be used

fromImageSequence

public static ImagePresenter fromImageSequence(ImageDataSequence image,
                                               int nth)
                                        throws QTException
This creates an ImagePresenter object from nth first image of any ImageDataSequence object
Parameters:
image - the image
nth - the index into the ImageDataSequence object of the image data that should be used

fromGWorld

public static ImagePresenter fromGWorld(QDGraphics grafPort)
                                 throws QTException
This creates an ImagePresenter object from the PixMap of the QDGraphics object. It will not be compressed.
Parameters:
grafPort - the grafPort that will be used to create the ImagePresenter object from.

fromGWorld

public static ImagePresenter fromGWorld(QDGraphics port,
                                        QDRect rect,
                                        int colorDepth,
                                        int quality,
                                        int codecType,
                                        CodecComponent codec)
                                 throws QTException
This creates an ImagePresenter object from PixMap source, bounds QDRect, color depth, compression quality, codec type, and codec component. This will circumvent the normal restrictions placed on an ImagePresenter in that the data will be kept in the format you specify, even if that is not an optimal format for rendering.
Parameters:
port - a QDGraphics object from which the PixMap will be used.
rect - the QDRect object - this may not be null
colorDepth - the int value.
quality - the int value.
codecType - the int value.
codec - the CodecComponent object.

fromPict

public static ImagePresenter fromPict(Pict p)
                               throws QTException
This creates an ImagePresenter object from a Pict object that is stored in memory.
Parameters:
p - the pict handle

fromQTImage

public static ImagePresenter fromQTImage(EncodedImage data,
                                         ImageDescription desc)
                                  throws QTException
This creates an ImagePresenter object from raw image data and ImageDescription.
Parameters:
data - the image data.
desc - the ImageDescription object.

setImageData

public void setImageData(EncodedImage data,
                         ImageDescription desc)
                  throws QTException
Sets the current image data and description. If the data is specified then it may be recompressed if the format of the data is not optimal for redrawing and the redraw optimised flag is set to true. If you pass in null for the EncodedImage argument then the application must call the setImageData (EncodedImage) method after this to ensure that the ImagePresenter has both required data and description. The data formats that are not recompressed are any known pixel format (which includes the rawCodecType), animation, vector or QuickDraw formats.
Specified by:
setImageData in interface ImageSettable
Parameters:
data - the new image data for display or null to allow the application to keep the data in its preferred format.
desc - describes the format of the image data - this may NOT be null.

setImageData

public void setImageData(EncodedImage ei)
                  throws QTException
If you have already set the image data and you have image data in the same general parameters as previously set (ie. the same ImageDescription will describe the data) then this call can be used to just replace the changed image data.
Parameters:
ei - the new encoded image data

setRedrawOptimised

public void setRedrawOptimised(boolean flag)
Returns the state of the optimisation for redraw flag. If true, then when image data is set the ImagePresenter may decompress the image data to a format that is optimised for performance at the expense of possibly greater memory usage. If false, then setting the image data will not decompress the image data. The default is true. Changing this flag will not alter the current image data format, it only effects consequent calls to the setImageData (EncodedImage, ImageDescription) calls.
Parameters:
flag - the new setting.

isRedrawOptimised

public boolean isRedrawOptimised()
Returns the current state of the optimisation for drawing flag.
Returns:
a boolean

removeImageData

public void removeImageData()
                     throws QTException
This method removes the previously set encoded image data and description from the ImagePresenter and will remove it from any destination QDGraphics it is currently drawing into.

getDescription

public ImageDescription getDescription()
This method should return an ImageDescription that describes the image data that the class contains.
Specified by:
getDescription in interface ImageSpec
Returns:
the ImageDescription of an Image

getDSequence

public DSequence getDSequence()
Returns the DSequence that is used by the ImagePresenter. This object may be null if the ImagePresenter is not currently attached to a valid destination QDGraphics. The application should not cache this sequence object for any length of time - as if the destination QDGraphics is changed the DSequence is thrown away and a new one is created.

getClip

public Region getClip()
               throws QTException
Returns a region that defines the current clipping region for the object.
Specified by:
getClip in interface QTDrawable
Returns:
the clipping region

setClip

public void setClip(Region reg)
             throws StdQTException
Sets a region that will define the clipping region for the object
Specified by:
setClip in interface QTDrawable
Parameters:
reg - the new clipping region

addedTo

public void addedTo(java.lang.Object interest)
This method is called by the specified object when the instance of the class that implements this interface is added to the object that is the source of the interest.
Specified by:
addedTo in interface Listener
Parameters:
interest - the object that is to be the source of interest for the the object that implements this interface.

removedFrom

public void removedFrom(java.lang.Object interest)
This method is called by the specified object when the instance of the class that implements this interface is removed from the object that is the source of the interest.
Specified by:
removedFrom in interface Listener
Parameters:
interest - the object that was the source of interest for the the object that implements this interface.

getMatrix

public Matrix getMatrix()
                 throws StdQTException
This will return the client's current display transformations
Specified by:
getMatrix in interface Transformable
Returns:
the display transformations of the client

setMatrix

public void setMatrix(Matrix matrix)
               throws QTException
This method assigns a mapping matrix to the sequence.

QuickTime::SetDSequenceMatrix

Specified by:
setMatrix in interface Transformable
Parameters:
matrix - a Matrix object that specifies how to transform the image during decompression

getInitialSize

public java.awt.Dimension getInitialSize()
                                  throws QTException
Deprecated. since QTJava 4.0

This method returns the original size before the transformations specified in the returned matrix are applied.
See Also:
()

getOriginalSize

public QDDimension getOriginalSize()
                            throws QTException
This method returns the original size before the transformations specified in the returned matrix are applied.
Specified by:
getOriginalSize in interface Transformable
Returns:
the original size of the image data presented.

getImage

public EncodedImage getImage()
This method returns the actual image data.
Specified by:
getImage in interface ImageSpec
Returns:
the image data

getGWorld

public QDGraphics getGWorld()
QTCanvas calls this method to get the destination QDGraphics of its client.
Specified by:
getGWorld in interface QTDrawable
Returns:
a QDGraphics object or null

setGWorld

public void setGWorld(QDGraphics cgp)
               throws QTException
QTCanvas calls this method to give the client the QDGraphics object it should use to do its drawing. If the incoming QDGraphics is the QDGraphics.scratch then the drawable will not be visible and can disable itself. If a client is unable to set the graphics world it should throw an exception.
Specified by:
setGWorld in interface QTDrawable
Parameters:
cgp - a QDGraphics object

setDisplayBounds

public void setDisplayBounds(QDRect bounds)
                      throws StdQTException
QTCanvas calls this method when it needs to tell the client to adjust its location, width and/or height. All values are in pixels.
Specified by:
setDisplayBounds in interface Drawable
Parameters:
bounds - the new size and location.

setLocation

public void setLocation(int x,
                        int y)
                 throws QTException
A convenience method to set the position of a QTDrawable object.
Specified by:
setLocation in interface QTDrawable
Parameters:
x - the new x location
y - the new y location

getDisplayBounds

public QDRect getDisplayBounds()
QTCanvas calls this method when it needs to ask the client for its boundary. All values are in pixels.
Specified by:
getDisplayBounds in interface Drawable
Returns:
the boundary of the client

redraw

public void redraw(Region invalidRgn)
            throws QTException
QTCanvas calls this method when the client should redraw itself. If the canvas is able to discern that only a part of the client's drawing area needs to be redrawn - then this area shall be passed in using the invalidRgn. Otherwise this will be null in which case the client should redraw itself entirely.
Specified by:
redraw in interface Drawable
Parameters:
invalidRgn - the invalidRgn that the client should redraw

doDraw

protected final void doDraw()
                     throws QTException
This is the method that blits the data directly to the destination QDGraphics.

setGraphicsMode

public void setGraphicsMode(GraphicsMode mode)
                     throws QTException
This sets the GraphicsMode for the Compositor when it draws its composited contents to its destination QDGraphics (typically the QTCanvas).
Specified by:
setGraphicsMode in interface Compositable
Parameters:
mode - the new GraphicsMode for this presenter

getGraphicsMode

public GraphicsMode getGraphicsMode()
This gets the current GraphicsMode for the compositor.
Specified by:
getGraphicsMode in interface Compositable
Returns:
a GraphicsMode

toString

public java.lang.String toString()
Returns a String representation of this object.
Overrides:
toString in class java.lang.Object
Returns:
a String