com.tensegrity.graphics.swt
Class SWTImageOperations

java.lang.Object
  extended bycom.tensegrity.graphics.swt.SWTImageOperations
All Implemented Interfaces:
ImageOperations

public class SWTImageOperations
extends java.lang.Object
implements ImageOperations

This is the SWT implementation of the ImageOperations interface.

Version:
$Id: SWTImageOperations.java,v 1.10 2005/07/27 07:06:48 SebastienGuyon Exp $
Author:
MKegel, S�bastien Guyon

Constructor Summary
SWTImageOperations()
          Default constructor.
SWTImageOperations(java.lang.Class referenceClass)
           Constructor initializing the new instance of SWTImageOperations with a given reference class which is used in order to load images in loadImageResource(String) for instance.
SWTImageOperations(java.lang.Object referenceObject)
           Constructor initializing the new instance of SWTImageOperations with a given reference object which is used in order to load images in loadImageResource(String) for instance.
 
Method Summary
static java.lang.String convertImageToValueString(org.eclipse.swt.graphics.Image image)
          Converts the given image data to a string.
 org.eclipse.swt.widgets.Display getReferenceDisplay()
           Returns the internal Display or the default display if none is internally referenced.
 byte[] jpegEncode(int width, int height, int[] pixels, float quality, boolean forceBaseline)
          Encodes the given pixel data to JPEG data.
 Raster loadImage(java.lang.String imagepath)
           
 Raster loadImage(java.net.URL imagepath)
           
 Raster loadImageResource(java.lang.Class refClass, java.lang.String imagepath)
           
 Raster loadImageResource(java.lang.String imagepath)
           
 void registerReferenceClass(java.lang.Class refClass)
           Registers the Class which is used in order to load images in loadImageResource(String) for instance.
 void registerReferenceDisplay(org.eclipse.swt.widgets.Display display)
           Constructor initializing the new instance of SWTImageOperations with a given Display which is used in order to create images in loadImage(String) for instance.
 void registerReferenceObject(java.lang.Object object)
           Registers the Object which is used in order to load images in loadImageResource(String) for instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SWTImageOperations

public SWTImageOperations()
Default constructor.


SWTImageOperations

public SWTImageOperations(java.lang.Object referenceObject)

Constructor initializing the new instance of SWTImageOperations with a given reference object which is used in order to load images in loadImageResource(String) for instance.

Parameters:
referenceObject - an Object used as reference in order to load images.
See Also:
registerReferenceObject(Object)

SWTImageOperations

public SWTImageOperations(java.lang.Class referenceClass)

Constructor initializing the new instance of SWTImageOperations with a given reference class which is used in order to load images in loadImageResource(String) for instance.

Parameters:
referenceClass - a Class used as reference in order to load images.
See Also:
registerReferenceObject(Object)
Method Detail

registerReferenceDisplay

public final void registerReferenceDisplay(org.eclipse.swt.widgets.Display display)

Constructor initializing the new instance of SWTImageOperations with a given Display which is used in order to create images in loadImage(String) for instance.

Parameters:
display - SWT Display used in order to create images.

registerReferenceObject

public final void registerReferenceObject(java.lang.Object object)

Registers the Object which is used in order to load images in loadImageResource(String) for instance.

Parameters:
object - an Object used as reference in order to load images.
See Also:
registerReferenceClass(Class)

registerReferenceClass

public final void registerReferenceClass(java.lang.Class refClass)

Registers the Class which is used in order to load images in loadImageResource(String) for instance.

Parameters:
refClass - a Class used as reference in order to load images.

loadImageResource

public Raster loadImageResource(java.lang.String imagepath)
Specified by:
loadImageResource in interface ImageOperations

loadImageResource

public Raster loadImageResource(java.lang.Class refClass,
                                java.lang.String imagepath)
Specified by:
loadImageResource in interface ImageOperations

loadImage

public Raster loadImage(java.lang.String imagepath)
Specified by:
loadImage in interface ImageOperations

loadImage

public Raster loadImage(java.net.URL imagepath)
Specified by:
loadImage in interface ImageOperations

jpegEncode

public byte[] jpegEncode(int width,
                         int height,
                         int[] pixels,
                         float quality,
                         boolean forceBaseline)
Description copied from interface: ImageOperations
Encodes the given pixel data to JPEG data.

Specified by:
jpegEncode in interface ImageOperations
Parameters:
width - The width of the image
height - The height of the image
pixels - The pixel array width a size of width*height containing the colors encoded as 0xRRGGBB
quality - The JPEG quality (0.0f - 1.0f)
forceBaseline - The force baseline setting for the JPEG encoder
Returns:
The bytes of the JPEG file

convertImageToValueString

public static final java.lang.String convertImageToValueString(org.eclipse.swt.graphics.Image image)
Converts the given image data to a string. This string can be used to store the image in a text document.

Parameters:
image - the image to be represented in a string.
Returns:
a string carrying the image data.

getReferenceDisplay

public org.eclipse.swt.widgets.Display getReferenceDisplay()

Returns the internal Display or the default display if none is internally referenced.

Returns:
the internal Display or the default display if none is internally referenced.
See Also:
Display.getDefault()


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.