Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.api / src / main / java / org / gvsig / fmap / dal / coverage / grid / render / Render.java @ 1057

History | View | Annotate | Download (9.47 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.dal.coverage.grid.render;
23

    
24
import java.awt.Graphics2D;
25
import java.awt.geom.Dimension2D;
26

    
27
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
28
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData;
29
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
30
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
31
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
32
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList;
33
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
34
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
35
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
36
import org.gvsig.tools.dispose.Disposable;
37
import org.gvsig.tools.task.Cancellable;
38
import org.gvsig.tools.task.TaskStatus;
39

    
40

    
41

    
42
/**
43
 * Renders a Grid object 
44
 * @author Nacho Brodin (nachobrodin@gmail.com)
45
 */
46
public interface Render extends Runnable, Disposable {
47
        
48
        /**
49
         * Obtiene las lista de filtros aplicados en la renderizaci?n
50
         * @return RasterFilterList
51
         */
52
        public RasterFilterList getFilterList();
53
        
54
        /**
55
         * Asigna la lista de filtros que se usar? en el renderizado
56
         * @param RasterFilterList
57
         */
58
        public void setFilterList(RasterFilterList filterList);
59
        
60
        /**
61
         * Asigna el ?ltimo estado de transparencia de la renderizaci?n.
62
         * @param lastTransparency
63
         */
64
        public void setLastTransparency(Transparency lastTransparency);
65
        
66
        /**
67
         * Obtiene el ?ltimo objeto transparencia aplicado en la renderizaci?n
68
         * @return Transparency
69
         */
70
        public Transparency getLastTransparency();
71
        
72
        /**
73
         * Gets the last alpha band number
74
         * @return
75
         */
76
        public int getLastAlphaBandNumber();
77
        
78
        /**
79
         * Obtiene el ?ltimo buffer renderizado.
80
         * @return Buffer
81
         */
82
        public Buffer getLastRenderBuffer();
83

    
84
        /**
85
         * Asigna el ?ltimo renderizado.
86
         * @param buf
87
         */
88
        public void setLastRenderBuffer(Buffer buf);
89
        
90
        /**
91
         * Informa de si el raster tiene tabla de color asociada o no.
92
         * @return true si tiene tabla de color y false si no la tiene.
93
         */
94
        public boolean existColorTable();
95
        
96
        /**
97
         * Gets a data store
98
         * @return
99
         */
100
        public RasterDataStore getDataStore();
101
        
102
        /**
103
         * Sets a data store
104
         * @param dataStore
105
         */
106
        public void setDataStore(RasterDataStore dataStore);
107
        
108
        /**
109
         * Gets the color table 
110
         * @return 
111
         */
112
        public ColorTable getColorTable();
113
        
114
        /**
115
         * Asigna un listener a la lista que ser? informado cuando cambie una
116
         * propiedad visual en la renderizaci?n.
117
         * @param listener VisualPropertyListener
118
         */
119
        public void addVisualPropertyListener(VisualPropertyListener listener);
120
        
121
        /**
122
         * Devuelve si la asignacion de las bandas a renderizar representa una capa
123
         * en escala de grises
124
         * @return
125
         */
126
        public boolean isRenderingAsGray();
127

    
128
        /**
129
         * Asigna el n?mero de bandas y el orden de renderizado. Cada posici?n del vector es una banda
130
         * del buffer y el contenido de esa posici?n es la banda de la imagen que se dibujar?
131
         * sobre ese buffer. A la hora de renderizar hay que tener en cuenta que solo se renderizan las
132
         * tres primeras bandas del buffer por lo que solo se tienen en cuenta los tres primeros
133
         * elementos. Por ejemplo, el array {1, 0, 3} dibujar? sobre el Graphics las bandas 1,0 y 3 de un
134
         * raster que tiene al menos 4 bandas. La notaci?n con -1 en alguna posici?n del vector solo tiene sentido
135
         * en la visualizaci?n pero no se puede as?gnar una banda del buffer a null.
136
         * Algunos ejemplos:
137
         * <P>
138
         * {-1, 0, -1} Dibuja la banda 0 del raster en la G de la visualizaci?n.
139
         * Si replicateBand es true R = G = B sino R = B = 0
140
         * {1, 0, 3} La R = banda 1 del raster, G = 0 y B = 3
141
         * {0} La R = banda 0 del raster. Si replicateBand es true R = G = B sino G = B = 0
142
         * </P>
143
         *
144
         *
145
         * @param renderBands: bandas y su posici?n
146
         */
147
        public void setRenderBands(int[] renderBands);
148
        
149
        /**
150
         * Obtiene el n?mero de bandas y el orden de renderizado. Cada posici?n del
151
         * vector es una banda del buffer y el contenido de esa posici?n es la banda
152
         * de la imagen que se dibujar? sobre ese buffer. A la hora de renderizar hay
153
         * que tener en cuenta que solo se renderizan las tres primeras bandas del
154
         * buffer por lo que solo se tienen en cuenta los tres primeros elementos. Por
155
         * ejemplo, el array {1, 0, 3} dibujar? sobre el Graphics las bandas 1,0 y 3
156
         * de un raster de al menos 4 bandas. La notaci?n con -1 en alguna posici?n
157
         * del vector solo tiene sentido en la visualizaci?n pero no se puede as?gnar
158
         * una banda del buffer a null. Algunos ejemplos:
159
         * <P>
160
         * <UL>
161
         * <LI> {-1, 0, -1} Dibuja la banda 0 del raster en la G de la visualizaci?n. Si
162
         * replicateBand es true R = G = B sino R = B = 0 </LI>
163
         * <LI> {1, 0, 3} La R = banda 1 del raster, G = 0 y B = 3 </LI>
164
         * <LI> {0} La R = banda 0 del raster. Si replicateBand es true R = G = B
165
         * sino G = B = 0</LI>
166
         * </UL>
167
         * </P>
168
         *
169
         * @return bandas y su posici?n
170
         */
171
        public int[] getRenderBands();
172
        
173
        /**
174
         * Dibuja el raster sobre el Graphics. Para ello debemos de pasar el viewPort que corresponde a la
175
         * vista. Este viewPort es ajustado a los tama?os m?ximos y m?nimos de la imagen por la funci?n
176
         * calculateNewView. Esta funci?n tambi?n asignar? la vista a los drivers. Posteriormente se calcula
177
         * el alto y ancho de la imagen a dibujar (wImg, hImg), as? como el punto donde se va a pintar dentro
178
         * del graphics (pt). Finalmente se llama a updateImage del driver para que pinte y una vez dibujado
179
         * se pasa a trav?s de la funci?n renderizeRaster que es la encargada de aplicar la pila de filtros
180
         * sobre el Image que ha devuelto el driver.
181
         *
182
         * Para calcular en que coordenada pixel (pt) se empezar? a pintar el BufferedImage con el raster le?do
183
         * se aplica sobre la esquina superior izquierda de esta la matriz de transformaci?n del ViewPortData
184
         * pasado vp.mat.transform(pt, pt). Si el raster no est? rotado este punto es el resultante de la
185
         * funci?n calculateNewView que devuelve la petici?n ajustada al extent de la imagen (sin rotar). Si
186
         * el raster est? rotado necesitaremos para la transformaci?n el resultado de la funci?n coordULRotateRaster.
187
         * Lo que hace esta ?ltima es colocar la petici?n que ha sido puesta en coordenadas de la imagen sin rotar
188
         * (para pedir al driver de forma correcta) otra vez en coordenadas de la imagen rotada (para calcular su
189
         * posici?n de dibujado).
190
         *
191
         * Para dibujar sobre el Graphics2D el raster rotado aplicaremos la matriz de transformaci?n con los
192
         * par?metros de Shear sobre este Graphics de forma inversa. Como hemos movido el fondo tendremos que
193
         * recalcular ahora el punto donde se comienza a dibujar aplicandole la transformaci?n sobre este
194
         * at.inverseTransform(pt, pt);. Finalmente volcamos el BufferedImage sobre el Graphics volviendo a dejar
195
         * el Graphics en su posici?n original al acabar.
196
         *
197
         * @param g Graphics sobre el que se pinta
198
         * @param vp ViewPort de la extensi?n a dibujar
199
         * @param taskStatus 
200
         * @throws InvalidSetViewException
201
         * @throws ArrayIndexOutOfBoundsException
202
         */
203
        public void draw(Graphics2D g, ViewPortData vp, TaskStatus taskStatus)
204
                throws RasterDriverException, InvalidSetViewException, ProcessInterruptedException;
205
        
206
        /**
207
         * Este m?todo dibuja sobre el Graphics a partir de un Viewport sin ajustar. Los tiles que van llegando
208
         * no est?n en el tama?o ajustado sino que llegan en su tama?o origina, tipicamente 256x256 p?xeles. Estos
209
         * son reescalados al ir a dibujarlos sobre el Graphics.
210
         * @param g
211
         * @param vp
212
         * @throws RasterDriverException
213
         * @throws InvalidSetViewException
214
         * @throws ProcessInterruptedException
215
         */
216
        public void drawTiledService(Graphics2D g, ViewPortData vp, Dimension2D viewDimension, TaskStatus status)
217
                throws RasterDriverException, InvalidSetViewException, ProcessInterruptedException;
218
        
219
        /**
220
         * <p>
221
         * This method throws the draw call in a Thread. This is useful to draw tiles.
222
         * </p>
223
         * <p>
224
         * Strategy:
225
         * <ul>
226
         * <li>If the image is out of the view the thread won't be thrown</li>
227
         * <li>Throw the thread to draw</li>
228
         * <li>The main thread waits until the secondary thread ends</li>
229
         * <li>When the buffer of a new tile has been received then nextBuffer is called from the store</li>
230
         * <li>When the last tile has been received then endReading is called from the store. This method unlocks the main
231
         * thread and will finish the process</li>
232
         * <li></li>
233
         * </ul> 
234
         * </p>
235
         * 
236
         * @see draw
237
         */
238
        public void drawThread(Graphics2D g, ViewPortData vp);
239
        
240
        /**
241
         * Sets the view structures to draw
242
         * @param g
243
         * @param vp
244
         */
245
        public void setGraphicInfo(Graphics2D g, ViewPortData vp);
246
        
247
        public void setReading(boolean reading);
248
        
249
        /**
250
         * Temporal hasta que est? disponible TaskStatus
251
         * @deprecated
252
         * @param cancel
253
         */
254
        public void setCancel(Cancellable cancel);
255
}