svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / RasterFilter.java @ 2312
History | View | Annotate | Download (2.92 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.io.raster; |
25 |
|
26 |
import java.awt.Image; |
27 |
import java.util.Hashtable; |
28 |
|
29 |
/**
|
30 |
* Filtro para raster. Ancestro de todos los filtros.
|
31 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
32 |
*/
|
33 |
public abstract class RasterFilter implements IRasterFilter{ |
34 |
protected RasterBuf raster = null; |
35 |
protected RasterStats stats = null; |
36 |
protected Image image = null; |
37 |
protected int [] px = new int[4]; |
38 |
protected int height = 0; |
39 |
protected int width = 0; |
40 |
protected Hashtable params = new Hashtable(); |
41 |
protected int incX = 1; |
42 |
protected int incY = 1; |
43 |
protected boolean exec = true; //Si est? a false no se ejecuta el filtro |
44 |
|
45 |
/**
|
46 |
* Constructor
|
47 |
*/
|
48 |
public RasterFilter(){}
|
49 |
|
50 |
/**
|
51 |
* Aplica el filtro sobre el raster pasado pixel a pixel
|
52 |
*/
|
53 |
public void execute() { |
54 |
pre(); |
55 |
if(exec){
|
56 |
for (int y=0; y<height; y=y+incY) |
57 |
for (int x=0; x<width; x=x+incX) { |
58 |
process(x, y); |
59 |
} |
60 |
} |
61 |
post(); |
62 |
} |
63 |
|
64 |
/**
|
65 |
* Aplica el filtro sobre el raster pasado por lineas
|
66 |
*/
|
67 |
public void executeLines() { |
68 |
if(exec){
|
69 |
for (int y=0; y<height; y++) |
70 |
processLine(y); |
71 |
} |
72 |
} |
73 |
|
74 |
/**
|
75 |
* A?ade un par?metro al filtro
|
76 |
*/
|
77 |
public void addParam(String name, Object param){ |
78 |
params.put(name, param); |
79 |
} |
80 |
|
81 |
/**
|
82 |
* Funci?n que contiene el c?digo a ejecutar antes de aplicar el filtro
|
83 |
*/
|
84 |
abstract public void pre(); |
85 |
|
86 |
/**
|
87 |
* Funci?n que contiene el c?digo a ejecutar despues de aplicar el filtro
|
88 |
*/
|
89 |
abstract public void post(); |
90 |
|
91 |
/**
|
92 |
* Ejecuci?n del filtro para un pixel de la imagen
|
93 |
*/
|
94 |
abstract public void process(int x, int y); |
95 |
|
96 |
/**
|
97 |
* Ejecuci?n del filtro para una l?nea de la imagen
|
98 |
*/
|
99 |
abstract public void processLine(int y); |
100 |
|
101 |
/**
|
102 |
* Obtiene el tipo de datos del raster de entrada
|
103 |
*/
|
104 |
abstract public int getInRasterDataType(); |
105 |
|
106 |
/**
|
107 |
* Obtiene el tipo de datos del raster de salida
|
108 |
*/
|
109 |
abstract public int getOutRasterDataType(); |
110 |
|
111 |
/**
|
112 |
* Obtiene el resultado del filtro despues de su ejecuci?n a trav?s de una clave
|
113 |
* @param name clave para obtener un objeto resultado del filtro.
|
114 |
*/
|
115 |
abstract public Object getResult(String name); |
116 |
} |
117 |
|