es.prodevelop.gvsig.mobile.fmap.driver.raster.memory.wkformat
Class WKFRasterDriver

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.driver.raster.memory.wkformat.WKFRasterDriver
All Implemented Interfaces:
Driver, GeorreferencedRasterDriver, RasterDriver

public class WKFRasterDriver
extends java.lang.Object
implements GeorreferencedRasterDriver

Raster driver for well known image formats (PNg, JPG, GIF). These images have to be loaded completely in memory, so the size is limited to a few hundred thousands pixels.

Author:
jldominguez
See Also:
AffineTransform

Field Summary
 
Fields inherited from interface es.prodevelop.gvsig.mobile.fmap.driver.raster.RasterDriver
ONE_PIXEL_IMAGE_ERROR, ONE_PIXEL_NO_DATA
 
Constructor Summary
WKFRasterDriver(ViewPort vp)
          Constructor.
 
Method Summary
 void close()
          Closes the driver.
 void draw(java.awt.Graphics2D g, ViewPort viewPort)
          Draws the image.
 boolean fileAccepted(java.io.File fName)
          Define los tipos de fichero que puede leer el driver.
 java.awt.geom.AffineTransform getAffineTransform()
          Obtiene la matriz de transformación
 java.lang.Object getData(int x, int y, int band)
           
 java.lang.String getFilePath()
           
 java.awt.geom.Rectangle2D getFullExtent()
          Obtiene la extensión en coordenadas del mundo real que ocupa este raster
 java.lang.String getName()
          Debe devolver un objeto que se asociará en el manager al driver.
 int getNumBands()
          Obtiene el número de bandas del raster
 int[] getPixel(double wcx, double wcy)
          Gets the RGB values of the pixel of interest
 IProjection getProjection()
          Obtiene la proyección en la que está el raster
 int getRasterDataType()
           
 int getTransparency()
           
 void initialize()
          Initializes the driver.
 void initialize(IProjection p)
          Initializes the driver.
 boolean isGeoreferenced()
          Obtiene el flag que dice si la imagen está o no georreferenciada
 void open(java.io.File f)
          Opens the specified file and expands it complete in memory.
 void setAffineTransform(java.awt.geom.AffineTransform t)
          Sets a new affine transformation.
 void setProjection(IProjection p)
          Sets a new projection
 void setTransparency(int t)
          Sets the transparency level of this image
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WKFRasterDriver

public WKFRasterDriver(ViewPort vp)
Constructor.

Parameters:
vp - current view port, used for geographic computations
Method Detail

initialize

public void initialize(IProjection p)
                throws java.io.IOException
Initializes the driver. Simply sets the projection.

Specified by:
initialize in interface GeorreferencedRasterDriver
Parameters:
p - the current projection
Throws:
java.io.IOException

getProjection

public IProjection getProjection()
Description copied from interface: GeorreferencedRasterDriver
Obtiene la proyección en la que está el raster

Specified by:
getProjection in interface GeorreferencedRasterDriver
Returns:
the current projection

setProjection

public void setProjection(IProjection p)
Sets a new projection

Specified by:
setProjection in interface GeorreferencedRasterDriver
Parameters:
p - the new projection to be set.

getFullExtent

public java.awt.geom.Rectangle2D getFullExtent()
Description copied from interface: GeorreferencedRasterDriver
Obtiene la extensión en coordenadas del mundo real que ocupa este raster

Specified by:
getFullExtent in interface GeorreferencedRasterDriver
Returns:
the full extent of the raster

isGeoreferenced

public boolean isGeoreferenced()
Description copied from interface: GeorreferencedRasterDriver
Obtiene el flag que dice si la imagen está o no georreferenciada

Specified by:
isGeoreferenced in interface GeorreferencedRasterDriver
Returns:
whether this raster is georrefernced. Returns true.

setAffineTransform

public void setAffineTransform(java.awt.geom.AffineTransform t)
Sets a new affine transformation.

Specified by:
setAffineTransform in interface GeorreferencedRasterDriver
Parameters:
t - the new affine transform

getAffineTransform

public java.awt.geom.AffineTransform getAffineTransform()
Description copied from interface: GeorreferencedRasterDriver
Obtiene la matriz de transformación

Specified by:
getAffineTransform in interface GeorreferencedRasterDriver
Returns:
the current affine transform

fileAccepted

public boolean fileAccepted(java.io.File fName)
Description copied from interface: RasterDriver
Define los tipos de fichero que puede leer el driver. Si devuelve true, el fichero está aceptado (es de los que el driver puede leer), si devuelve false es porque no lo puede leer.

Specified by:
fileAccepted in interface RasterDriver
Returns:
whether the provided file object is acceptable as an input raster file.

open

public void open(java.io.File f)
          throws java.io.IOException
Opens the specified file and expands it complete in memory. This is the biggest issue with this type of image files (png, jpg, gif). Their size is very limited because they cannot be accessed for a limited zone of interest.

Specified by:
open in interface RasterDriver
Parameters:
f - the raster file to be opened
Throws:
java.io.IOException

initialize

public void initialize()
                throws java.io.IOException
Initializes the driver. Right now it's an empty method.

Specified by:
initialize in interface RasterDriver
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the driver. Right now it's an empty method.

Specified by:
close in interface RasterDriver
Throws:
java.io.IOException

getNumBands

public int getNumBands()
Description copied from interface: RasterDriver
Obtiene el número de bandas del raster

Specified by:
getNumBands in interface RasterDriver
Returns:
the number of bands in this raster.

getTransparency

public int getTransparency()
Specified by:
getTransparency in interface RasterDriver
Returns:
the current transparency level of this image

setTransparency

public void setTransparency(int t)
Sets the transparency level of this image

Specified by:
setTransparency in interface RasterDriver
Parameters:
t - the new transparecncy level

draw

public void draw(java.awt.Graphics2D g,
                 ViewPort viewPort)
          throws FMapDriverException
Draws the image. This method tries to behave in the less memory-consuming way. If the view is larger than the image, the image is resampled down. If the image is larger than the view, a new buffered image is created , then the image is painted on it (clipping), then the buffered image is resampled up.

Specified by:
draw in interface RasterDriver
Parameters:
g - the graphics object where the image has to be painted
viewPort - the current viewport.
Throws:
FMapDriverException

getRasterDataType

public int getRasterDataType()
Specified by:
getRasterDataType in interface RasterDriver
Returns:
the raster data type, that is, the data type of the individual bands.

getData

public java.lang.Object getData(int x,
                                int y,
                                int band)
Specified by:
getData in interface RasterDriver
Parameters:
x - the x coordinate of the pixel
y - the y coordinate of the pixel
band - the 0-based band index
Returns:
the data associated with a specified pixel and a particular band

getPixel

public int[] getPixel(double wcx,
                      double wcy)
Gets the RGB values of the pixel of interest

Specified by:
getPixel in interface RasterDriver
Parameters:
wcx - x coordinate in map units
wcy - y coordinate in map units
Returns:
array of RGB values of the pixel of interest

getName

public java.lang.String getName()
Description copied from interface: Driver
Debe devolver un objeto que se asociará en el manager al driver. El DriverManager recibirá peticiones de un objeto y deberá devolver el driver asociado

Specified by:
getName in interface Driver
Returns:
the driver name

getFilePath

public java.lang.String getFilePath()
Specified by:
getFilePath in interface RasterDriver
Returns:
the raster file full path