svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / RasterFilter.java @ 2167
History | View | Annotate | Download (2.08 KB)
1 |
/*
|
---|---|
2 |
* Created on 25-feb-2005
|
3 |
*/
|
4 |
package org.cresques.io.raster; |
5 |
|
6 |
import java.awt.Image; |
7 |
import java.util.Hashtable; |
8 |
import java.util.Vector; |
9 |
|
10 |
/**
|
11 |
* Filtro para raster. Ancestro de todos los filtros.
|
12 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
13 |
*/
|
14 |
public abstract class RasterFilter implements IRasterFilter{ |
15 |
protected RasterBuf raster = null; |
16 |
protected RasterStats stats = null; |
17 |
protected Image image = null; |
18 |
protected int [] px = new int[4]; |
19 |
protected int height = 0; |
20 |
protected int width = 0; |
21 |
protected Hashtable params = new Hashtable(); |
22 |
protected int incX = 1; |
23 |
protected int incY = 1; |
24 |
protected boolean exec = true; //Si est? a false no se ejecuta el filtro |
25 |
|
26 |
public RasterFilter(){}
|
27 |
|
28 |
/**
|
29 |
* Aplica el filtro sobre el raster pasado pixel a pixel
|
30 |
*/
|
31 |
public void execute() { |
32 |
pre(); |
33 |
if(exec){
|
34 |
for (int y=0; y<height; y=y+incY) |
35 |
for (int x=0; x<width; x=x+incX) { |
36 |
process(x, y); |
37 |
} |
38 |
} |
39 |
post(); |
40 |
} |
41 |
|
42 |
/**
|
43 |
* Aplica el filtro sobre el raster pasado por lineas
|
44 |
*/
|
45 |
public void executeLines() { |
46 |
if(exec){
|
47 |
for (int y=0; y<height; y++) |
48 |
processLine(y); |
49 |
} |
50 |
} |
51 |
|
52 |
/**
|
53 |
* A?ade un par?metro al filtro
|
54 |
*/
|
55 |
public void addParam(String name, Object param){ |
56 |
params.put(name, param); |
57 |
} |
58 |
|
59 |
/**
|
60 |
* Funci?n que contiene el c?digo a ejecutar antes de aplicar el filtro
|
61 |
*/
|
62 |
abstract public void pre(); |
63 |
|
64 |
/**
|
65 |
* Funci?n que contiene el c?digo a ejecutar despues de aplicar el filtro
|
66 |
*/
|
67 |
abstract public void post(); |
68 |
|
69 |
/**
|
70 |
* Ejecuci?n del filtro para un pixel de la imagen
|
71 |
*/
|
72 |
abstract public void process(int x, int y); |
73 |
|
74 |
/**
|
75 |
* Ejecuci?n del filtro para una l?nea de la imagen
|
76 |
*/
|
77 |
abstract public void processLine(int y); |
78 |
|
79 |
/**
|
80 |
* Obtiene el tipo de datos del raster de entrada
|
81 |
*/
|
82 |
abstract public int getInRasterDataType(); |
83 |
|
84 |
/**
|
85 |
* Obtiene el tipo de datos del raster de salida
|
86 |
*/
|
87 |
abstract public int getOutRasterDataType(); |
88 |
|
89 |
/**
|
90 |
* Obtiene el resultado del filtro despues de su ejecuci?n a trav?s de una clave
|
91 |
* @param name clave para obtener un objeto resultado del filtro.
|
92 |
*/
|
93 |
abstract public Object getResult(String name); |
94 |
} |
95 |
|