fr.inria.insitu.glite.managers
Class ImageManager

java.lang.Object
  extended by fr.inria.insitu.glite.managers.ImageManager
All Implemented Interfaces:
LiteManager

public class ImageManager
extends Object
implements LiteManager

ImageManager implements the image rendering mechanism.

Version:
$Revision: 1.3 $
Author:
Jean-Daniel Fekete

Field Summary
static String KEY
          Key for access in PaintConext.
 
Fields inherited from interface fr.inria.insitu.glite.managers.LiteManager
KEY_CLIP, KEY_FONT, KEY_STENCIL, KEY_TESSELATOR, KEY_TRANSFORM, KEY_VERTEX_ARRAY
 
Constructor Summary
ImageManager(javax.media.opengl.GL gl)
          Construct a new ImageManager.
 
Method Summary
 void dispose()
          Releases all the resources maintained by this object.
 void drawImage(BufferedImage img, int x, int y, int w, int h)
          Draws an image at location (x,y) of size (width, height).
 void drawImageFromTexture(Image img, int sx1, int sy1, int sx2, int sy2, Rectangle2D out)
          Draws an image by copying it first in a texture.
static ImageManager get(LitePaintContext ctx)
          Returns an ImageManager from a LitePaintContext, creating it if needed.
 Graphics2D getGraphics()
           
 BufferedImage getImage()
           
 int getTexID()
           
static boolean isOpaque(Image image)
          true if the image is known to have no alpha channel, and false if it may or may not have an alpha channel.
static double linterp(double min, double max, double t)
          Compute a linear interpolation at parameter t from min to max.
 void reset()
          Resets the manager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY

public static final String KEY
Key for access in PaintConext.

See Also:
Constant Field Values
Constructor Detail

ImageManager

public ImageManager(javax.media.opengl.GL gl)
Construct a new ImageManager.

Parameters:
gl - the GL context
Method Detail

get

public static ImageManager get(LitePaintContext ctx)
Returns an ImageManager from a LitePaintContext, creating it if needed.

Parameters:
ctx - the LitePaintContext
Returns:
an ImageManager

reset

public void reset()
Resets the manager.

Specified by:
reset in interface LiteManager

dispose

public void dispose()
Releases all the resources maintained by this object.

Specified by:
dispose in interface LiteManager

getImage

public BufferedImage getImage()
Returns:
the image

getGraphics

public Graphics2D getGraphics()
Returns:
the Graphics2D

getTexID

public int getTexID()
Returns:
the texture ID

drawImage

public void drawImage(BufferedImage img,
                      int x,
                      int y,
                      int w,
                      int h)
Draws an image at location (x,y) of size (width, height).

Use direct OpenGL pixel drawing. Translation is honored but not scale or rotation. Use the texture based image drawing if you use scaling or general transformations.

Parameters:
img - the image to draw
x - the x position where image should be drawn
y - the y position where image should be drawn
w - the width to draw
h - the height to draw

linterp

public static double linterp(double min,
                             double max,
                             double t)
Compute a linear interpolation at parameter t from min to max.

Parameters:
min - the min value
max - the max value
t - the parameter
Returns:
min + t * (max - min)

isOpaque

public static boolean isOpaque(Image image)
true if the image is known to have no alpha channel, and false if it may or may not have an alpha channel.

Parameters:
image - the image
Returns:
true if the image is known to have no alpha channel, and false if it may or may not have an alpha channel

drawImageFromTexture

public void drawImageFromTexture(Image img,
                                 int sx1,
                                 int sy1,
                                 int sx2,
                                 int sy2,
                                 Rectangle2D out)
Draws an image by copying it first in a texture.

Parameters:
img - the image
sx1 - left x
sy1 - lower y
sx2 - right x
sy2 - right y
out - bounds


Copyright © 2006 by Jean-Daniel Fekete and INRIA, France All rights reserved.