Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / RasterFilter.java @ 2669

History | View | Annotate | Download (3.21 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

    
28
import java.util.Hashtable;
29

    
30

    
31
/**
32
 * Filtro para raster. Ancestro de todos los filtros.
33
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
34
 */
35
public abstract class RasterFilter implements IRasterFilter {
36
    protected RasterBuf raster = null;
37
    protected RasterStats stats = null;
38
    protected Image image = null;
39
    protected int[] px = new int[4];
40
    protected int height = 0;
41
    protected int width = 0;
42
    protected Hashtable params = new Hashtable();
43
    protected int incX = 1;
44
    protected int incY = 1;
45
    protected boolean exec = true; //Si est? a false no se ejecuta el  filtro
46

    
47
    /**
48
     * Constructor
49
     */
50
    public RasterFilter() {
51
    }
52

    
53
    /**
54
     * Aplica el filtro sobre el raster pasado pixel a pixel
55
     */
56
    public void execute() {
57
        pre();
58

    
59
        if (exec) {
60
            for (int y = 0; y < height; y = y + incY)
61
                for (int x = 0; x < width; x = x + incX) {
62
                    process(x, y);
63
                }
64
        }
65

    
66
        post();
67
    }
68

    
69
    /**
70
     * Aplica el filtro sobre el raster pasado por lineas
71
     */
72
    public void executeLines() {
73
        if (exec) {
74
            for (int y = 0; y < height; y++)
75
                processLine(y);
76
        }
77
    }
78

    
79
    /**
80
     * A?ade un par?metro al filtro
81
     */
82
    public void addParam(String name, Object param) {
83
        params.put(name, param);
84
    }
85

    
86
    /**
87
     * Funci?n que contiene el c?digo a ejecutar antes de aplicar el filtro
88
     */
89
    abstract public void pre();
90

    
91
    /**
92
     * Funci?n que contiene el c?digo a ejecutar despues de aplicar el filtro
93
     */
94
    abstract public void post();
95

    
96
    /**
97
     * Ejecuci?n del filtro para un pixel de la imagen
98
     */
99
    abstract public void process(int x, int y);
100

    
101
    /**
102
     * Ejecuci?n del filtro para una l?nea de la imagen
103
     */
104
    abstract public void processLine(int y);
105

    
106
    /**
107
     * Obtiene el tipo de datos del raster de entrada
108
     */
109
    abstract public int getInRasterDataType();
110

    
111
    /**
112
     * Obtiene el tipo de datos del raster de salida
113
     */
114
    abstract public int getOutRasterDataType();
115

    
116
    /**
117
     * Obtiene el resultado del filtro despues de su ejecuci?n a trav?s de una clave
118
     * @param name        clave para obtener un objeto resultado del filtro.
119
     */
120
    abstract public Object getResult(String name);
121
}