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 @ 1676
History | View | Annotate | Download (9.48 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.cresques.cts.ICoordTrans; |
28 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
29 |
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData; |
30 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
31 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
32 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
33 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
34 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
35 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
36 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
37 |
import org.gvsig.tools.dispose.Disposable; |
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 |
* Informa de si el raster tiene tabla de color asociada o no.
|
80 |
* @return true si tiene tabla de color y false si no la tiene.
|
81 |
*/
|
82 |
public boolean existColorTable(); |
83 |
|
84 |
/**
|
85 |
* Gets a data store
|
86 |
* @return
|
87 |
*/
|
88 |
public RasterDataStore getDataStore();
|
89 |
|
90 |
/**
|
91 |
* Sets a data store
|
92 |
* @param dataStore
|
93 |
*/
|
94 |
public void setDataStore(RasterDataStore dataStore); |
95 |
|
96 |
/**
|
97 |
* Gets the color table
|
98 |
* @return
|
99 |
*/
|
100 |
public ColorTable getColorTable();
|
101 |
|
102 |
/**
|
103 |
* Asigna un listener a la lista que ser? informado cuando cambie una
|
104 |
* propiedad visual en la renderizaci?n.
|
105 |
* @param listener VisualPropertyListener
|
106 |
*/
|
107 |
public void addVisualPropertyListener(VisualPropertyListener listener); |
108 |
|
109 |
/**
|
110 |
* Devuelve si la asignacion de las bandas a renderizar representa una capa
|
111 |
* en escala de grises
|
112 |
* @return
|
113 |
*/
|
114 |
public boolean isRenderingAsGray(); |
115 |
|
116 |
/**
|
117 |
* Asigna el n?mero de bandas y el orden de renderizado. Cada posici?n del vector es una banda
|
118 |
* del buffer y el contenido de esa posici?n es la banda de la imagen que se dibujar?
|
119 |
* sobre ese buffer. A la hora de renderizar hay que tener en cuenta que solo se renderizan las
|
120 |
* tres primeras bandas del buffer por lo que solo se tienen en cuenta los tres primeros
|
121 |
* elementos. Por ejemplo, el array {1, 0, 3} dibujar? sobre el Graphics las bandas 1,0 y 3 de un
|
122 |
* raster que tiene al menos 4 bandas. La notaci?n con -1 en alguna posici?n del vector solo tiene sentido
|
123 |
* en la visualizaci?n pero no se puede as?gnar una banda del buffer a null.
|
124 |
* Algunos ejemplos:
|
125 |
* <P>
|
126 |
* {-1, 0, -1} Dibuja la banda 0 del raster en la G de la visualizaci?n.
|
127 |
* Si replicateBand es true R = G = B sino R = B = 0
|
128 |
* {1, 0, 3} La R = banda 1 del raster, G = 0 y B = 3
|
129 |
* {0} La R = banda 0 del raster. Si replicateBand es true R = G = B sino G = B = 0
|
130 |
* </P>
|
131 |
*
|
132 |
*
|
133 |
* @param renderBands: bandas y su posici?n
|
134 |
*/
|
135 |
public void setRenderBands(int[] renderBands); |
136 |
|
137 |
/**
|
138 |
* Obtiene el n?mero de bandas y el orden de renderizado. Cada posici?n del
|
139 |
* vector es una banda del buffer y el contenido de esa posici?n es la banda
|
140 |
* de la imagen que se dibujar? sobre ese buffer. A la hora de renderizar hay
|
141 |
* que tener en cuenta que solo se renderizan las tres primeras bandas del
|
142 |
* buffer por lo que solo se tienen en cuenta los tres primeros elementos. Por
|
143 |
* ejemplo, el array {1, 0, 3} dibujar? sobre el Graphics las bandas 1,0 y 3
|
144 |
* de un raster de al menos 4 bandas. La notaci?n con -1 en alguna posici?n
|
145 |
* del vector solo tiene sentido en la visualizaci?n pero no se puede as?gnar
|
146 |
* una banda del buffer a null. Algunos ejemplos:
|
147 |
* <P>
|
148 |
* <UL>
|
149 |
* <LI> {-1, 0, -1} Dibuja la banda 0 del raster en la G de la visualizaci?n. Si
|
150 |
* replicateBand es true R = G = B sino R = B = 0 </LI>
|
151 |
* <LI> {1, 0, 3} La R = banda 1 del raster, G = 0 y B = 3 </LI>
|
152 |
* <LI> {0} La R = banda 0 del raster. Si replicateBand es true R = G = B
|
153 |
* sino G = B = 0</LI>
|
154 |
* </UL>
|
155 |
* </P>
|
156 |
*
|
157 |
* @return bandas y su posici?n
|
158 |
*/
|
159 |
public int[] getRenderBands(); |
160 |
|
161 |
/**
|
162 |
* Dibuja el raster sobre el Graphics. Para ello debemos de pasar el viewPort que corresponde a la
|
163 |
* vista. Este viewPort es ajustado a los tama?os m?ximos y m?nimos de la imagen por la funci?n
|
164 |
* calculateNewView. Esta funci?n tambi?n asignar? la vista a los drivers. Posteriormente se calcula
|
165 |
* el alto y ancho de la imagen a dibujar (wImg, hImg), as? como el punto donde se va a pintar dentro
|
166 |
* del graphics (pt). Finalmente se llama a updateImage del driver para que pinte y una vez dibujado
|
167 |
* se pasa a trav?s de la funci?n renderizeRaster que es la encargada de aplicar la pila de filtros
|
168 |
* sobre el Image que ha devuelto el driver.
|
169 |
*
|
170 |
* Para calcular en que coordenada pixel (pt) se empezar? a pintar el BufferedImage con el raster le?do
|
171 |
* se aplica sobre la esquina superior izquierda de esta la matriz de transformaci?n del ViewPortData
|
172 |
* pasado vp.mat.transform(pt, pt). Si el raster no est? rotado este punto es el resultante de la
|
173 |
* funci?n calculateNewView que devuelve la petici?n ajustada al extent de la imagen (sin rotar). Si
|
174 |
* el raster est? rotado necesitaremos para la transformaci?n el resultado de la funci?n coordULRotateRaster.
|
175 |
* Lo que hace esta ?ltima es colocar la petici?n que ha sido puesta en coordenadas de la imagen sin rotar
|
176 |
* (para pedir al driver de forma correcta) otra vez en coordenadas de la imagen rotada (para calcular su
|
177 |
* posici?n de dibujado).
|
178 |
*
|
179 |
* Para dibujar sobre el Graphics2D el raster rotado aplicaremos la matriz de transformaci?n con los
|
180 |
* par?metros de Shear sobre este Graphics de forma inversa. Como hemos movido el fondo tendremos que
|
181 |
* recalcular ahora el punto donde se comienza a dibujar aplicandole la transformaci?n sobre este
|
182 |
* at.inverseTransform(pt, pt);. Finalmente volcamos el BufferedImage sobre el Graphics volviendo a dejar
|
183 |
* el Graphics en su posici?n original al acabar.
|
184 |
*
|
185 |
* @param g Graphics sobre el que se pinta
|
186 |
* @param vp ViewPort de la extensi?n a dibujar
|
187 |
* @param taskStatus
|
188 |
* @throws InvalidSetViewException
|
189 |
* @throws ArrayIndexOutOfBoundsException
|
190 |
*/
|
191 |
public Buffer draw(Graphics2D g, ViewPortData vp, TaskStatus taskStatus) |
192 |
throws RasterDriverException, InvalidSetViewException, ProcessInterruptedException;
|
193 |
|
194 |
/**
|
195 |
* Este m?todo dibuja sobre el Graphics a partir de un Viewport sin ajustar. Los tiles que van llegando
|
196 |
* no est?n en el tama?o ajustado sino que llegan en su tama?o origina, tipicamente 256x256 p?xeles. Estos
|
197 |
* son reescalados al ir a dibujarlos sobre el Graphics.
|
198 |
* @param g
|
199 |
* @param vp
|
200 |
* @throws RasterDriverException
|
201 |
* @throws InvalidSetViewException
|
202 |
* @throws ProcessInterruptedException
|
203 |
*/
|
204 |
public void drawTiledService(Graphics2D g, ViewPortData vp, Dimension2D viewDimension, TaskStatus status) |
205 |
throws RasterDriverException, InvalidSetViewException, ProcessInterruptedException;
|
206 |
|
207 |
/**
|
208 |
* <p>
|
209 |
* This method throws the draw call in a Thread. This is useful to draw tiles.
|
210 |
* </p>
|
211 |
* <p>
|
212 |
* Strategy:
|
213 |
* <ul>
|
214 |
* <li>If the image is out of the view the thread won't be thrown</li>
|
215 |
* <li>Throw the thread to draw</li>
|
216 |
* <li>The main thread waits until the secondary thread ends</li>
|
217 |
* <li>When the buffer of a new tile has been received then nextBuffer is called from the store</li>
|
218 |
* <li>When the last tile has been received then endReading is called from the store. This method unlocks the main
|
219 |
* thread and will finish the process</li>
|
220 |
* <li></li>
|
221 |
* </ul>
|
222 |
* </p>
|
223 |
*
|
224 |
* @see draw
|
225 |
*/
|
226 |
public void drawThread(Graphics2D g, ViewPortData vp); |
227 |
|
228 |
/**
|
229 |
* Draws the image with the parameters used in the last drawn.
|
230 |
* @return
|
231 |
*/
|
232 |
public Buffer getLastRenderBuffer() |
233 |
throws RasterDriverException, InvalidSetViewException, ProcessInterruptedException;
|
234 |
|
235 |
/**
|
236 |
* Sets the view structures to draw
|
237 |
* @param g
|
238 |
* @param vp
|
239 |
*/
|
240 |
public void setGraphicInfo(Graphics2D g, ViewPortData vp); |
241 |
|
242 |
public void setReading(boolean reading); |
243 |
|
244 |
public void createReprojectionOnTheFly( |
245 |
RasterDataStore store, |
246 |
ICoordTrans coordTrans, |
247 |
TaskStatus status); |
248 |
|
249 |
public boolean isReprojectingOnTheFly(); |
250 |
} |