Revision 4203
org.gvsig.raster/tags/org.gvsig.raster-2.2.24/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DynObjectIteratorRasterInfo.java | ||
---|---|---|
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.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.feature.Feature; |
|
27 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
28 |
import org.gvsig.tools.dynobject.DynObject; |
|
29 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
30 |
|
|
31 |
/** |
|
32 |
* {@link DynObject} implementation to facade a iterator of a WMTSInfo |
|
33 |
* and allow to be used as a {@link DynObjectSet} iterator. |
|
34 |
* |
|
35 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
36 |
* @version $Id$ |
|
37 |
* |
|
38 |
*/ |
|
39 |
public class DynObjectIteratorRasterInfo implements DisposableIterator { |
|
40 |
|
|
41 |
private ArrayList<Object> infoList = new ArrayList<Object>(); |
|
42 |
private int index = -1; |
|
43 |
|
|
44 |
/** |
|
45 |
* Creates a new DynObjects iterator facade over a feature iterator. |
|
46 |
* Each WMTSInfo will be returned through a new or reused |
|
47 |
* {@link DynObjectWMTSInfo} which allows the {@link Feature} to be |
|
48 |
* used like a DynObject. |
|
49 |
* |
|
50 |
* @param featureIterator |
|
51 |
* to facade |
|
52 |
* @param featureFacade |
|
53 |
* if not null this object will be reused as the facade for the |
|
54 |
* Feature objects of the feature iterator |
|
55 |
*/ |
|
56 |
public DynObjectIteratorRasterInfo(Object info) { |
|
57 |
this.infoList.add(info); |
|
58 |
index = 0; |
|
59 |
} |
|
60 |
|
|
61 |
public void addObject(Object info) { |
|
62 |
this.infoList.add(info); |
|
63 |
if(index == -1) |
|
64 |
index = 0; |
|
65 |
} |
|
66 |
|
|
67 |
public synchronized void dispose() { |
|
68 |
this.infoList.clear(); |
|
69 |
index = -1; |
|
70 |
} |
|
71 |
|
|
72 |
public synchronized boolean hasNext() { |
|
73 |
return (infoList.size() == 0 || index >= infoList.size()) ? false : true; |
|
74 |
} |
|
75 |
|
|
76 |
public synchronized Object next() { |
|
77 |
Object o = infoList.get(index); |
|
78 |
index ++; |
|
79 |
return o; |
|
80 |
} |
|
81 |
|
|
82 |
public synchronized void remove() { |
|
83 |
if(index < infoList.size() && index >= 0) { |
|
84 |
index --; |
|
85 |
infoList.remove(index); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
public long getSize() { |
|
90 |
return infoList.size(); |
|
91 |
} |
|
92 |
} |
|
0 | 93 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.24/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DynObjectSetRasterInfo.java | ||
---|---|---|
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.raster.fmap.layers; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
25 |
import org.gvsig.tools.ToolsLocator; |
|
26 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
27 |
import org.gvsig.tools.dynobject.DynClass; |
|
28 |
import org.gvsig.tools.dynobject.DynField; |
|
29 |
import org.gvsig.tools.dynobject.DynObject; |
|
30 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
31 |
import org.gvsig.tools.dynobject.impl.DefaultDynObject; |
|
32 |
import org.gvsig.tools.exception.BaseException; |
|
33 |
import org.gvsig.tools.observer.Observable; |
|
34 |
import org.gvsig.tools.observer.Observer; |
|
35 |
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable; |
|
36 |
import org.gvsig.tools.visitor.Visitor; |
|
37 |
|
|
38 |
/** |
|
39 |
* {@link DynObject} implementation to facade of a {@link FeatureSet} and allow |
|
40 |
* to be used as a {@link DynObjectSet}. |
|
41 |
* |
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
43 |
* @version $Id$ |
|
44 |
*/ |
|
45 |
public class DynObjectSetRasterInfo extends BaseWeakReferencingObservable |
|
46 |
implements DynObjectSet, Observer { |
|
47 |
private DynObjectIteratorRasterInfo ite = null; |
|
48 |
private DynClass dynClass = null; |
|
49 |
|
|
50 |
/** |
|
51 |
* Creates a new facade over a given info, with fast dynobject |
|
52 |
* iteration. |
|
53 |
*/ |
|
54 |
public DynObjectSetRasterInfo() { |
|
55 |
dynClass = |
|
56 |
ToolsLocator.getDynObjectManager().createDynClass( |
|
57 |
"RasterInfoByPoint", "Raster", "Raster point information"); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Adds a field to the DynObject |
|
62 |
* @param name |
|
63 |
* @param object |
|
64 |
* @param order |
|
65 |
*/ |
|
66 |
public void addField(String name, Object object, int order) { |
|
67 |
DynField field = dynClass.addDynField(name); |
|
68 |
field.setDefaultFieldValue(object); |
|
69 |
if(order != -1) |
|
70 |
field.setOrder(order); |
|
71 |
DefaultDynObject dynObject = new DefaultDynObject(dynClass); |
|
72 |
ite = new DynObjectIteratorRasterInfo(dynObject); |
|
73 |
} |
|
74 |
|
|
75 |
public void dispose() { |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
public void accept(final Visitor visitor, long firstValueIndex) throws BaseException { |
|
80 |
while(ite.hasNext()) { |
|
81 |
visitor.visit(ite.next()); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
public void accept(final Visitor visitor) throws BaseException { |
|
86 |
while(ite.hasNext()) { |
|
87 |
visitor.visit(ite.next()); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
public long getSize() throws BaseException { |
|
92 |
return ite.getSize(); |
|
93 |
} |
|
94 |
|
|
95 |
public DisposableIterator iterator(long index) throws BaseException { |
|
96 |
return iterator(); |
|
97 |
} |
|
98 |
|
|
99 |
public DisposableIterator iterator() throws BaseException { |
|
100 |
return ite; |
|
101 |
} |
|
102 |
|
|
103 |
public boolean isEmpty() throws BaseException { |
|
104 |
return (getSize() == 0); |
|
105 |
} |
|
106 |
|
|
107 |
public boolean isDeleteEnabled() { |
|
108 |
return true; |
|
109 |
} |
|
110 |
|
|
111 |
public void delete(DynObject dynObject) throws BaseException { |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
public boolean isUpdateEnabled() { |
|
116 |
return true; |
|
117 |
} |
|
118 |
|
|
119 |
public void update(DynObject dynObject) throws BaseException { |
|
120 |
} |
|
121 |
|
|
122 |
public void update(Observable observable, Object notification) { |
|
123 |
} |
|
124 |
} |
|
0 | 125 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.24/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/FLyrRaster.java | ||
---|---|---|
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.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.awt.Graphics2D; |
|
25 |
import java.awt.geom.AffineTransform; |
|
26 |
import java.awt.geom.Point2D; |
|
27 |
import java.awt.image.BufferedImage; |
|
28 |
import java.io.File; |
|
29 |
import java.net.URI; |
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.cresques.cts.IProjection; |
|
34 |
|
|
35 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
36 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
|
39 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
40 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
|
41 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
43 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
44 |
import org.gvsig.fmap.dal.coverage.util.Historical; |
|
45 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
46 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
47 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
48 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
49 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
50 |
import org.gvsig.fmap.mapcontext.layers.LayerListener; |
|
51 |
import org.gvsig.raster.roi.ROI; |
|
52 |
import org.gvsig.tools.task.Cancellable; |
|
53 |
|
|
54 |
/** |
|
55 |
* All kind of raster layers should implement this interface. |
|
56 |
* |
|
57 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
58 |
*/ |
|
59 |
@SuppressWarnings("deprecation") |
|
60 |
public interface FLyrRaster extends FLayer { |
|
61 |
/** |
|
62 |
* Sets the layer as initialized. That's implies that the layer has |
|
63 |
* the right filters and is opened, |
|
64 |
* @param initialized |
|
65 |
*/ |
|
66 |
public void setLayerInitialized(boolean initialized); |
|
67 |
|
|
68 |
/** |
|
69 |
* Gets the uniform resource identifier |
|
70 |
* @return |
|
71 |
*/ |
|
72 |
public URI getURI(); |
|
73 |
|
|
74 |
/** |
|
75 |
* Returns true if a color table exists |
|
76 |
* @return |
|
77 |
*/ |
|
78 |
public boolean existColorTable(); |
|
79 |
|
|
80 |
/** |
|
81 |
* Define la ultima leyenda valida de la capa o se pone a null para que la |
|
82 |
* capa busque una leyenda valida. |
|
83 |
* @param ct |
|
84 |
*/ |
|
85 |
public void setLastLegend(ColorTable ct); |
|
86 |
|
|
87 |
/** |
|
88 |
* Crea el objeto renderizador de raster |
|
89 |
* @return Rendering |
|
90 |
*/ |
|
91 |
public Render getRender(); |
|
92 |
|
|
93 |
/** |
|
94 |
* Gets the MapContext object |
|
95 |
* @return |
|
96 |
*/ |
|
97 |
public MapContext getMapContext(); |
|
98 |
|
|
99 |
/** |
|
100 |
* Gets the full extent |
|
101 |
* @return |
|
102 |
*/ |
|
103 |
public Extent getFullRasterExtent(); |
|
104 |
|
|
105 |
/** |
|
106 |
* Gets the DataStore |
|
107 |
* @return |
|
108 |
*/ |
|
109 |
public RasterDataStore getDataStore(); |
|
110 |
|
|
111 |
/** |
|
112 |
* Metodo para consultar si una capa puede ser un RGB. Suponemos que es un RGB |
|
113 |
* si el tipo de datos es de tipo byte y su interpretacion de color tiene |
|
114 |
* asignada los tres colores. |
|
115 |
* @return boolean |
|
116 |
*/ |
|
117 |
public boolean isRGB(); |
|
118 |
|
|
119 |
/** |
|
120 |
* Returns true if the drawn is going to be tiled |
|
121 |
* @return |
|
122 |
*/ |
|
123 |
public boolean isTiled(); |
|
124 |
|
|
125 |
/** |
|
126 |
* Gets the regions of interest |
|
127 |
* @return |
|
128 |
* @throws ROIException |
|
129 |
*/ |
|
130 |
public List<ROI> getRois() throws ROIException; |
|
131 |
|
|
132 |
/** |
|
133 |
* Sets the regions of interest |
|
134 |
*/ |
|
135 |
public void setRois(List<ROI> rois); |
|
136 |
|
|
137 |
/** |
|
138 |
* Sets the files which contain the regions of interest. This method is temporal until |
|
139 |
* after the refactoring of ROIs. |
|
140 |
* @param file |
|
141 |
* @throws RmfSerializerException |
|
142 |
*/ |
|
143 |
public void setROIsFiles(List<File> file) throws RmfSerializerException; |
|
144 |
|
|
145 |
/** |
|
146 |
* Gets the files which contain the regions of interest. This method is temporal until |
|
147 |
* after the refactoring of ROIs. |
|
148 |
* @return |
|
149 |
* @throws RmfSerializerException |
|
150 |
*/ |
|
151 |
public List<File> getROIsFiles() throws RmfSerializerException; |
|
152 |
|
|
153 |
/** |
|
154 |
* Obtiene la proyecci?n del fichero. |
|
155 |
* @return IProjection |
|
156 |
*/ |
|
157 |
public IProjection readProjection() throws RasterDriverException; |
|
158 |
|
|
159 |
/** |
|
160 |
* Gets the tile size |
|
161 |
* @return |
|
162 |
*/ |
|
163 |
public int[] getTileSize(); |
|
164 |
|
|
165 |
/** |
|
166 |
* Obtiene el valor NoData asociado al raster. |
|
167 |
* @return double |
|
168 |
*/ |
|
169 |
public NoData getNoDataValue(); |
|
170 |
|
|
171 |
/** |
|
172 |
* Returs a string with the extension of the first file |
|
173 |
*/ |
|
174 |
public String getFileFormat(); |
|
175 |
|
|
176 |
/** |
|
177 |
* Obtiene el flag que dice si la imagen est? o no georreferenciada |
|
178 |
* @return true si est? georreferenciada y false si no lo est?. |
|
179 |
*/ |
|
180 |
public boolean isGeoreferenced(); |
|
181 |
|
|
182 |
/** |
|
183 |
* Returns the number of bands of each dataset |
|
184 |
* @return |
|
185 |
*/ |
|
186 |
public int[] getBandCountFromDataset(); |
|
187 |
|
|
188 |
/** |
|
189 |
* Gets the projection in well known text format |
|
190 |
* @return |
|
191 |
* @throws RasterDriverException |
|
192 |
*/ |
|
193 |
public String getWktProjection() throws RasterDriverException; |
|
194 |
|
|
195 |
/** |
|
196 |
* Gets the color interpretation |
|
197 |
* @param band |
|
198 |
* @param dataset |
|
199 |
* @return |
|
200 |
*/ |
|
201 |
public String getColorInterpretation(int band, int dataset); |
|
202 |
|
|
203 |
/** |
|
204 |
* When a process is using information of this layer this variable will contain |
|
205 |
* the thread ID. |
|
206 |
* @param readingData |
|
207 |
*/ |
|
208 |
public void setReadingData(String readingData); |
|
209 |
|
|
210 |
/** |
|
211 |
* Sets the nodata value for this layer |
|
212 |
* @param noDataValue the noDataValue to set |
|
213 |
*/ |
|
214 |
public void setNoDataValue(NoData noDataValue); |
|
215 |
|
|
216 |
/** |
|
217 |
* Sets the minimum scale visible. Lower scales won't be drawn. |
|
218 |
* |
|
219 |
* @param minScale the scale > 0, -1 if not defined |
|
220 |
* @see #getMinScale() |
|
221 |
*/ |
|
222 |
public void setMinScale(double minScale); |
|
223 |
|
|
224 |
/** |
|
225 |
* Sets the maximum scale visible. Higher scales won't be drawn. |
|
226 |
* |
|
227 |
* @param maxScale the scale > 0, -1 if not defined |
|
228 |
* @see #getMaxScale() |
|
229 |
*/ |
|
230 |
public void setMaxScale(double maxScale); |
|
231 |
|
|
232 |
/** |
|
233 |
* Returns the maximum scale visible. Higher scales won't be drawn. |
|
234 |
* |
|
235 |
* @return the maximum scale > 0, -1 if not defined |
|
236 |
* @see #setMaxScale(double) |
|
237 |
*/ |
|
238 |
public double getMaxScale(); |
|
239 |
|
|
240 |
/** |
|
241 |
* Returns the minimum scale visible. Lower scales won't be drawn. |
|
242 |
* |
|
243 |
* @return the minimum scale > 0, -1 if not defined |
|
244 |
* @see #setMinScale(double) |
|
245 |
*/ |
|
246 |
public double getMinScale(); |
|
247 |
|
|
248 |
/** |
|
249 |
* @return Returns the removeRasterFlag. |
|
250 |
*/ |
|
251 |
public boolean isRemoveRasterFlag(); |
|
252 |
|
|
253 |
/** |
|
254 |
* Asigna el valor del flag que dice si destruimos la memoria del raster |
|
255 |
* al eliminarlo del TOC o no. |
|
256 |
* @param removeRasterFlag The removeRasterFlag to set. |
|
257 |
*/ |
|
258 |
public void setRemoveRasterFlag(boolean removeRasterFlag); |
|
259 |
|
|
260 |
/** |
|
261 |
* Borra de la lista de listeners el que se pasa como par?metro. |
|
262 |
* |
|
263 |
* @param o LayerListener a borrar. |
|
264 |
* |
|
265 |
* @return True si ha sido correcto el borrado del Listener. |
|
266 |
*/ |
|
267 |
public boolean removeLayerListener(LayerListener o); |
|
268 |
|
|
269 |
/** |
|
270 |
* @throws ReadException |
|
271 |
* @throws ReadDriverException |
|
272 |
* @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage, |
|
273 |
* java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, |
|
274 |
* com.iver.utiles.swing.threads.Cancellable) |
|
275 |
*/ |
|
276 |
public void draw(BufferedImage image, Graphics2D g, ViewPort vp, Cancellable cancel, double scale) throws ReadException; |
|
277 |
|
|
278 |
/** |
|
279 |
* Clones this layer |
|
280 |
* @return |
|
281 |
* @throws Exception |
|
282 |
*/ |
|
283 |
public FLayer cloneLayer() throws Exception; |
|
284 |
|
|
285 |
/** |
|
286 |
* Gets a layer which the source is a file |
|
287 |
* @return |
|
288 |
* @throws RasterDriverException |
|
289 |
*/ |
|
290 |
public FLayer getFileLayer() throws RasterDriverException; |
|
291 |
|
|
292 |
/** |
|
293 |
* Gets the position of the alpha band |
|
294 |
* @return |
|
295 |
*/ |
|
296 |
public int getAlphaBandNumber(); |
|
297 |
|
|
298 |
public String getName(); |
|
299 |
|
|
300 |
/** |
|
301 |
* Gets the projection |
|
302 |
* @return |
|
303 |
*/ |
|
304 |
public IProjection getProjection(); |
|
305 |
|
|
306 |
/** |
|
307 |
* Devuelve si es reproyectable o no la capa |
|
308 |
* @return |
|
309 |
*/ |
|
310 |
public boolean isReproyectable(); |
|
311 |
|
|
312 |
/** |
|
313 |
* Recupera del raster la matriz de transformaci?n que lo situa en cualquier parte de la vista |
|
314 |
* @return AffineTransform |
|
315 |
*/ |
|
316 |
public AffineTransform getAffineTransform(); |
|
317 |
|
|
318 |
/** |
|
319 |
* Obtiene la lista de transformaciones que se han ido aplicando al raster. |
|
320 |
* @return Historical. Lista de AffineTransform |
|
321 |
*/ |
|
322 |
public Historical getAffineTransformHistorical(); |
|
323 |
|
|
324 |
/** |
|
325 |
* Asigna al raster la matriz de transformaci?n para situarlo en cualquier parte de la vista |
|
326 |
* @param transf |
|
327 |
*/ |
|
328 |
public void setAffineTransform(AffineTransform transf); |
|
329 |
|
|
330 |
/** |
|
331 |
* Asigna al raster la matriz de transformaci?n para situarlo en cualquier parte de la vista. |
|
332 |
* Esta versi?n no guarda en el historico. |
|
333 |
* @param transf |
|
334 |
*/ |
|
335 |
public void setAffineTransformWithoutHistorical(AffineTransform transf); |
|
336 |
|
|
337 |
/** |
|
338 |
* Salva la georreferenciaci?n a fichero rmf. |
|
339 |
* @param fName |
|
340 |
* @throws RmfSerializerException |
|
341 |
*/ |
|
342 |
public void saveGeoToRmf() throws RmfSerializerException; |
|
343 |
|
|
344 |
/** |
|
345 |
* Metodo que obtiene si un punto cae dentro de los l?mites de la capa |
|
346 |
* o fuera de ellos. |
|
347 |
* @param p Punto a calcular |
|
348 |
* @return true si est? dentro de los l?mites y false si est? fuera |
|
349 |
*/ |
|
350 |
public boolean isInside(Point2D p); |
|
351 |
|
|
352 |
/** |
|
353 |
* Returns true if this layer is remote |
|
354 |
* @return |
|
355 |
*/ |
|
356 |
public boolean isRemote(); |
|
357 |
|
|
358 |
/** |
|
359 |
* Gets the attribute list |
|
360 |
* <UL> |
|
361 |
* <LI>Filename</LI> |
|
362 |
* <LI>Filesize</LI> |
|
363 |
* <LI>Width</LI> |
|
364 |
* <LI>Height</LI> |
|
365 |
* <LI>Bands</LI> |
|
366 |
* </UL> |
|
367 |
* @return ArrayList<Object> |
|
368 |
*/ |
|
369 |
public ArrayList<Object> getAttributes(); |
|
370 |
|
|
371 |
/** |
|
372 |
* Returns the full bounding box of this layer |
|
373 |
* @return |
|
374 |
*/ |
|
375 |
public Envelope getFullEnvelope(); |
|
376 |
|
|
377 |
/** |
|
378 |
* Ajusta las coordenadas especificadas en el par?metro al ?rea m?xima |
|
379 |
* del raster en p?xeles. |
|
380 |
* @param req Punto a ajustar dentro del extener del raster |
|
381 |
*/ |
|
382 |
public Point2D adjustWorldRequest(Point2D req); |
|
383 |
|
|
384 |
/** |
|
385 |
* Adds a new file. The behavior of this function depends on |
|
386 |
* the kind of provider and its implementation. |
|
387 |
* @param file |
|
388 |
* @throws InvalidSourceException |
|
389 |
*/ |
|
390 |
public void addFile(File file) throws InvalidSourceException; |
|
391 |
|
|
392 |
/** |
|
393 |
* Removes a file. The behavior of this function depends on |
|
394 |
* the kind of provider and its implementation. |
|
395 |
* @param file |
|
396 |
*/ |
|
397 |
public void removeFile(File file); |
|
398 |
|
|
399 |
/** |
|
400 |
* When this flag is true then renderice nodata value as transparent |
|
401 |
* @param t |
|
402 |
*/ |
|
403 |
public void setNoDataTransparent(boolean t); |
|
404 |
|
|
405 |
/** |
|
406 |
* Sets the layer projection |
|
407 |
* @param proj |
|
408 |
*/ |
|
409 |
public void setProjection(IProjection proj, boolean persist) throws RmfSerializerException; |
|
410 |
|
|
411 |
} |
|
0 | 412 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.24/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/GeorefPanListenerImpl.java | ||
---|---|---|
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.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.awt.Image; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
|
|
28 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
29 |
import org.gvsig.fmap.geom.GeometryManager; |
|
30 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
31 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
32 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
33 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
34 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
35 |
import org.gvsig.fmap.mapcontrol.tools.Events.MoveEvent; |
|
36 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PanListener; |
|
37 |
import org.slf4j.Logger; |
|
38 |
import org.slf4j.LoggerFactory; |
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* Implementaci?n de la interfaz PanListener como herramienta para realizar el |
|
44 |
* Pan. |
|
45 |
* |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class GeorefPanListenerImpl implements PanListener { |
|
49 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
50 |
private static final Logger logger = LoggerFactory.getLogger(GeorefPanListenerImpl.class); |
|
51 |
// private final Image ipan = new ImageIcon(MapControl.class.getResource( |
|
52 |
// "images/CruxCursor.png")).getImage(); |
|
53 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(ipan, |
|
54 |
// new Point(16, 16), ""); |
|
55 |
private MapControl mapControl; |
|
56 |
private DefaultFLyrRaster lyrRaster = null; |
|
57 |
private String pathToFile = null; |
|
58 |
|
|
59 |
|
|
60 |
/** |
|
61 |
* Crea un nuevo RectangleListenerImpl. |
|
62 |
* |
|
63 |
* @param mapControl MapControl. |
|
64 |
*/ |
|
65 |
public GeorefPanListenerImpl(MapControl mapControl) { |
|
66 |
this.mapControl = mapControl; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PanListener#move(java.awt.geom.Point2D, |
|
71 |
* java.awt.geom.Point2D) |
|
72 |
*/ |
|
73 |
@SuppressWarnings("deprecation") |
|
74 |
public void move(MoveEvent event) { |
|
75 |
ViewPort vp = mapControl.getMapContext().getViewPort(); |
|
76 |
|
|
77 |
Point2D from = vp.toMapPoint(event.getFrom()); |
|
78 |
Point2D to = vp.toMapPoint(event.getTo()); |
|
79 |
|
|
80 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
81 |
Rectangle2D extent = vp.getExtent(); |
|
82 |
r.x = extent.getX() - (to.getX() - from.getX()); |
|
83 |
r.y = extent.getY() - (to.getY() - from.getY()); |
|
84 |
r.width = extent.getWidth(); |
|
85 |
r.height = extent.getHeight(); |
|
86 |
Envelope env; |
|
87 |
try { |
|
88 |
env = geomManager.createEnvelope(r.getMinX(), r.getMinY(), r |
|
89 |
.getMaxX(), r.getMaxY(), SUBTYPES.GEOM2D); |
|
90 |
vp.setEnvelope(env); |
|
91 |
} catch (CreateEnvelopeException e) { |
|
92 |
logger.error("Error creating the envelope", e); |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
// mapControl.drawMap(); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
|
102 |
*/ |
|
103 |
public boolean cancelDrawing() { |
|
104 |
return true; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* @return Returns the lyrRaster. |
|
109 |
*/ |
|
110 |
public DefaultFLyrRaster getLyrRaster() { |
|
111 |
return lyrRaster; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* @param lyrRaster The lyrRaster to set. |
|
116 |
*/ |
|
117 |
public void setLyrRaster(DefaultFLyrRaster lyrRaster) { |
|
118 |
this.lyrRaster = lyrRaster; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* @return Returns the pathToFile. |
|
123 |
*/ |
|
124 |
public String getPathToFile() { |
|
125 |
return pathToFile; |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* @param pathToFile The pathToFile to set. |
|
130 |
*/ |
|
131 |
public void setPathToFile(String pathToFile) { |
|
132 |
this.pathToFile = pathToFile; |
|
133 |
} |
|
134 |
|
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getImageCursor() |
|
138 |
*/ |
|
139 |
public Image getImageCursor() { |
|
140 |
return null; |
|
141 |
} |
|
142 |
} |
|
0 | 143 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.24/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/RasterDrawStrategy.java | ||
---|---|---|
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.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.HashMap; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
29 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
33 |
|
|
34 |
/** |
|
35 |
* Aplica estrategias de dibujado para las capas raster. Hace que las |
|
36 |
* capas que est?n ocultas por otras no sean dibujadas. Esta estrategia tiene que ser |
|
37 |
* aplicada a capas raster de FMap por falta de eficiencia en el dibujado. Esta clase |
|
38 |
* es totalmente dependiente de FMap y puede ser eliminada en caso de que este no exita. |
|
39 |
* 28/11/2007 |
|
40 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
41 |
*/ |
|
42 |
public class RasterDrawStrategy { |
|
43 |
|
|
44 |
/** |
|
45 |
* Cada mapContext existente lleva asociadad una estrategia de dibujado |
|
46 |
*/ |
|
47 |
public static HashMap<MapContext, HashMap<DefaultFLyrRaster, Boolean>> |
|
48 |
mapContextStrategy = new HashMap<MapContext, HashMap<DefaultFLyrRaster, Boolean>> (); |
|
49 |
|
|
50 |
private MapContext mapContext = null; |
|
51 |
private DefaultFLyrRaster lyrRaster = null; |
|
52 |
|
|
53 |
/** |
|
54 |
* Estructura de datos para almacenar la asociaci?n entre el extent de una capa |
|
55 |
* y su informaci?n de transparencia. Esta es necesaria para la comprobaci?n de si la |
|
56 |
* capa con la que se est? intersectando tiene transparencia o no la tiene. Con esto |
|
57 |
* se puede decidir si dibujar la capa actual o no. |
|
58 |
* 16/06/2008 |
|
59 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
60 |
*/ |
|
61 |
public class LayerIntersection { |
|
62 |
public Extent extent = null; |
|
63 |
public boolean hasTransparency = false; |
|
64 |
/** |
|
65 |
* Constructor. Asigna el Extent y la informaci?n de transparencia |
|
66 |
* @param ext Extent |
|
67 |
* @param transp Transparencia |
|
68 |
*/ |
|
69 |
public LayerIntersection(Extent ext, boolean transp) { |
|
70 |
this.extent = ext; |
|
71 |
this.hasTransparency = transp; |
|
72 |
} |
|
73 |
} |
|
74 |
/** |
|
75 |
* Al constructor le pasamos el contexto de dibujado para la toma de decisi?n. |
|
76 |
* @param mapContext Context |
|
77 |
* @throws ExpansionFileReadException |
|
78 |
* @throws ReadDriverException |
|
79 |
*/ |
|
80 |
public RasterDrawStrategy(MapContext mapContext, DefaultFLyrRaster lyrRaster) { |
|
81 |
this.mapContext = mapContext; |
|
82 |
this.lyrRaster = lyrRaster; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* <P> |
|
87 |
* Estrategia de dibujado para las capas raster que hace que si |
|
88 |
* una capa est? oculta completamente por otra que no tiene transparencias entonces |
|
89 |
* esta no ser? dibujada. |
|
90 |
* </P> |
|
91 |
* <P> |
|
92 |
* La estrategia la calcula solo la primera capa raster que aparezca. El resto |
|
93 |
* de las capas la preguntaran a esta. |
|
94 |
* </P> |
|
95 |
* <P> |
|
96 |
* <code>Estrategia:</code> |
|
97 |
* Analizamos la lista de capas desde la primera que se dibuja en el TOC hasta la ?ltima |
|
98 |
* <UL> |
|
99 |
* <LI>Si la capa tiene rotaci?n se dibuja siempre.</LI> |
|
100 |
* <LI>Si la capa no est? activa en el TOC no se dibuja nunca</LI> |
|
101 |
* <LI>Si la capa no es transparente y no hay extents en la lista se dibuja y se a?ade el extent a la lista</LI> |
|
102 |
* <LI>Si el extent de la capa intersecta con uno de la lista</LI> |
|
103 |
* </UL> |
|
104 |
* Comprobamos si est? detr?s de un extent de la lista. Si es as? no se dibuja |
|
105 |
* Si no est? est? detr?s de un extent comprobamos si tiene transparencias |
|
106 |
* Si no tiene transparencias a?adimos el extent a la lista |
|
107 |
* </P> |
|
108 |
* @param lyrs |
|
109 |
* @throws ReadDriverException |
|
110 |
* @throws ExpansionFileReadException |
|
111 |
*/ |
|
112 |
public void stackStrategy() { |
|
113 |
if(mapContext == null || lyrRaster == null) |
|
114 |
return; |
|
115 |
|
|
116 |
ArrayList<FLayer> listLayers = new ArrayList<FLayer>(); |
|
117 |
FLayers lyrs = mapContext.getLayers(); |
|
118 |
listLayers = getLayerList(lyrs, listLayers); |
|
119 |
|
|
120 |
ArrayList<LayerIntersection> extentList = new ArrayList<LayerIntersection>(); |
|
121 |
|
|
122 |
//Solo la primera capa calcula la estrategia. Las dem?s se la preguntan a esta. |
|
123 |
|
|
124 |
//Calculamos cual es la primera capa raster de FLayers y contamos cuantas capas raster hay |
|
125 |
int posFirstRasterLayer = 0; |
|
126 |
int nRasterLayers = 0; |
|
127 |
boolean firstTime = true; |
|
128 |
for (int i = 0; i < listLayers.size(); i++) { |
|
129 |
FLayer lyr = (FLayer) listLayers.get(i); |
|
130 |
if(firstTime && lyr instanceof DefaultFLyrRaster && lyr.isVisible()) { |
|
131 |
posFirstRasterLayer = i; |
|
132 |
firstTime = false; |
|
133 |
} |
|
134 |
if(lyr instanceof DefaultFLyrRaster) |
|
135 |
nRasterLayers ++; |
|
136 |
} |
|
137 |
|
|
138 |
//Si hay solo una capa raster no se calcula ninguna estrategia |
|
139 |
if(nRasterLayers == 1) { |
|
140 |
mapContextStrategy.put(mapContext, null); |
|
141 |
return; |
|
142 |
} |
|
143 |
|
|
144 |
//Si no es la primera capa se obtiene la estrategia que calcul? la primera capa |
|
145 |
if(lyrRaster != listLayers.get(posFirstRasterLayer)) { |
|
146 |
if(!(listLayers.get(posFirstRasterLayer) instanceof DefaultFLyrRaster)) |
|
147 |
return; |
|
148 |
mapContextStrategy.put(mapContext, ((DefaultFLyrRaster)listLayers.get(posFirstRasterLayer)).getRasterStrategy()); |
|
149 |
return; |
|
150 |
} |
|
151 |
|
|
152 |
HashMap<DefaultFLyrRaster, Boolean> layersToPaint = new HashMap<DefaultFLyrRaster, Boolean>(); |
|
153 |
|
|
154 |
//Calculo de estrategia. Solo llega aqu? la primera capa. |
|
155 |
//La lista de capas en FLayers est? en orden inverso a lo que aparece en el TOC, es decir, la ?ltima capa |
|
156 |
//del TOC es la primera de la lista de FLayers y la primera del TOC es la ?ltima de la lista. |
|
157 |
for (int i = (listLayers.size() - 1); i >= 0; i--) { |
|
158 |
FLayer lyr = (FLayer) listLayers.get(i); |
|
159 |
|
|
160 |
if (!(lyr instanceof DefaultFLyrRaster)) |
|
161 |
continue; |
|
162 |
|
|
163 |
DefaultFLyrRaster rLyr = ((DefaultFLyrRaster)lyr); |
|
164 |
|
|
165 |
if(rLyr.getRender() == null || rLyr.getRender().getFilterList() == null || rLyr.getFullEnvelope() == null) |
|
166 |
continue; |
|
167 |
|
|
168 |
//Si no est? activa y/o visible no se dibuja nunca |
|
169 |
if(!rLyr.isVisible()) { |
|
170 |
layersToPaint.put(rLyr, new Boolean(false)); |
|
171 |
continue; |
|
172 |
} |
|
173 |
|
|
174 |
//Si tiene rotaci?n se dibuja siempre |
|
175 |
if(rLyr.getAffineTransform() != null) { |
|
176 |
if( rLyr.getAffineTransform().getShearX() != 0 || |
|
177 |
rLyr.getAffineTransform().getShearY() != 0) { |
|
178 |
layersToPaint.put(rLyr, new Boolean(true)); |
|
179 |
continue; |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
183 |
//Si es la primera metemos el extent en la lista y se dibuja |
|
184 |
//Si no es la primera y no intersecta con ning?n extent. Metemos el extent y dibujamos |
|
185 |
LayerIntersection li = areIntersecting(extentList, rLyr); |
|
186 |
if((i == (listLayers.size() - 1)) || li == null) { |
|
187 |
boolean colorTableAlpha = false; |
|
188 |
if(rLyr.getRender().getFilterList() != null) { |
|
189 |
Render render = rLyr.getRender(); |
|
190 |
if(render != null) { |
|
191 |
if(render.getColorTable() != null) |
|
192 |
colorTableAlpha = render.getColorTable().hasAlpha(); |
|
193 |
} |
|
194 |
} |
|
195 |
extentList.add(new LayerIntersection(rLyr.getFullRasterExtent(), (rLyr.existsAlphaBand() || rLyr.isTransparent() || colorTableAlpha))); |
|
196 |
layersToPaint.put(rLyr, new Boolean(true)); |
|
197 |
continue; |
|
198 |
} |
|
199 |
|
|
200 |
//Si con la que intersecta no tiene transparencia no se dibuja |
|
201 |
if(li != null && !li.hasTransparency) { |
|
202 |
layersToPaint.put(rLyr, new Boolean(false)); |
|
203 |
continue; |
|
204 |
} |
|
205 |
|
|
206 |
if(!rLyr.isTransparent()) |
|
207 |
li.hasTransparency = false; |
|
208 |
layersToPaint.put(rLyr, new Boolean(true)); |
|
209 |
} |
|
210 |
|
|
211 |
mapContextStrategy.put(mapContext, layersToPaint); |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
/** |
|
216 |
* Obtiene la lista de capas del TOC. Si hay capas agrupadas lo tiene en cuenta y mira |
|
217 |
* dentro de la agrupaci?n. |
|
218 |
* @param srcLyrs |
|
219 |
* @param destLyrs |
|
220 |
* @return |
|
221 |
*/ |
|
222 |
public static ArrayList<FLayer> getLayerList(FLayers srcLyrs, ArrayList<FLayer> destLyrs) { |
|
223 |
for (int i = 0; i < srcLyrs.getLayersCount(); i++) { |
|
224 |
if(srcLyrs.getLayer(i) instanceof DefaultFLyrRaster) |
|
225 |
destLyrs.add(srcLyrs.getLayer(i)); |
|
226 |
if(srcLyrs.getLayer(i) instanceof FLayers) |
|
227 |
destLyrs = getLayerList((FLayers)srcLyrs.getLayer(i), destLyrs); |
|
228 |
} |
|
229 |
return destLyrs; |
|
230 |
} |
|
231 |
|
|
232 |
/** |
|
233 |
* Comprueba si la capa que se pasa por par?metro est? oculta por alguno |
|
234 |
* de los extent de la lista |
|
235 |
* @param extentList Lista de extensiones |
|
236 |
* @param lyr Capa raster |
|
237 |
* @return |
|
238 |
*/ |
|
239 |
private LayerIntersection areIntersecting(ArrayList<LayerIntersection> extentList, DefaultFLyrRaster lyr) { |
|
240 |
for (int i = 0; i < extentList.size(); i++) { |
|
241 |
Extent ex = lyr.getFullRasterExtent(); |
|
242 |
Extent ex1 = ((LayerIntersection)extentList.get(i)).extent; |
|
243 |
if(RasterLocator.getManager().getRasterUtils().isInside(ex, ex1)) |
|
244 |
return ((LayerIntersection)extentList.get(i)); |
|
245 |
} |
|
246 |
return null; |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Obtiene un TreeMap con la lista de capas que se dibujan. Si se al TreeMap se |
|
251 |
* le pasa como par?metro una capa raster y devuelve null es que no se dibuja. |
|
252 |
* |
|
253 |
* @return TreeMap con la lista de capas a dibujar. |
|
254 |
*/ |
|
255 |
public HashMap<DefaultFLyrRaster, Boolean> getStrategy() { |
|
256 |
return (HashMap<DefaultFLyrRaster, Boolean>)mapContextStrategy.get(mapContext); |
|
257 |
} |
|
258 |
} |
|
0 | 259 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.24/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/StatusLayerRaster.java | ||
---|---|---|
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.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
29 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
30 |
import org.gvsig.fmap.dal.coverage.datastruct.TransparencyRange; |
|
31 |
import org.gvsig.fmap.dal.coverage.exception.FileNotFoundInListException; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.FilterManagerException; |
|
33 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
|
34 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
35 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.OperationNotSupportedException; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
38 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
|
39 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
41 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
43 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
44 |
import org.gvsig.tools.ToolsLocator; |
|
45 |
import org.gvsig.tools.dynobject.DynStruct; |
|
46 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
47 |
import org.gvsig.tools.persistence.PersistentState; |
|
48 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
/** |
|
53 |
* Esta clase almacena el estado de un raster en cuanto a las caracteristicas |
|
54 |
* de opacidad, bandas y filtros. Estas caracter?sticas pueden ser salvadas a |
|
55 |
* un xml y recuperadas por la capa a trav?s de las funciones setXMLEntity y |
|
56 |
* getXMLEntity |
|
57 |
* |
|
58 |
* @deprecated |
|
59 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
60 |
*/ |
|
61 |
public class StatusLayerRaster implements IStatusRaster { |
|
62 |
|
|
63 |
public static String defaultClass = "org.gvsig.fmap.raster.layers.StatusLayerRaster"; |
|
64 |
|
|
65 |
//Valor de opacidad global de la imagen |
|
66 |
public int transparency = 255; |
|
67 |
|
|
68 |
//Rangos de transparencia |
|
69 |
public ArrayList<TransparencyRange> |
|
70 |
ranges = new ArrayList<TransparencyRange>(); |
|
71 |
|
|
72 |
//(Selecci?n de bandas)N?mero de banda asignado al Rojo, verde y azul |
|
73 |
public int bandR = 0; |
|
74 |
public int bandG = 1; |
|
75 |
public int bandB = 2; |
|
76 |
|
|
77 |
public List<File> files = new ArrayList<File>(); |
|
78 |
|
|
79 |
//Filtros para poder montar una nueva pila |
|
80 |
public List<String> filters = new ArrayList<String>(); |
|
81 |
private DefaultFLyrRaster layer = null; |
|
82 |
private int alphaBandNumber = -1; |
|
83 |
|
|
84 |
//Utilizado para la persistencia |
|
85 |
private boolean loadClass = false; |
|
86 |
|
|
87 |
public void loadFromState(PersistentState state, DefaultFLyrRaster layer)throws PersistenceException { |
|
88 |
// this.layer = layer; |
|
89 |
// //RECUPERAR PROPIEDADES |
|
90 |
// |
|
91 |
// //Recuperamos las propiedades de los filtros |
|
92 |
// for(int i = 0; i < xml.getPropertyCount(); i++) { |
|
93 |
// if(xml.getPropertyName(i).startsWith("filter.")) |
|
94 |
// filters.add(xml.getPropertyName(i) + "=" + xml.getPropertyValue(i)); |
|
95 |
// } |
|
96 |
// |
|
97 |
// //Rangos de transparencia |
|
98 |
// if (xml.contains("filter.transparency.active") && xml.getBooleanProperty("filter.transparency.active")) { |
|
99 |
// int i = 0; |
|
100 |
// String value = null; |
|
101 |
// while(true) { |
|
102 |
// if(xml.contains("filter.transparency.transparencyRange" + i)) { |
|
103 |
// value = xml.getStringProperty("filter.transparency.transparencyRange" + i); |
|
104 |
// int alpha = 0; |
|
105 |
// if(value.indexOf("@") != 0) { |
|
106 |
// try { |
|
107 |
// alpha = Integer.parseInt(value.substring(value.indexOf("@") + 1, value.length())); |
|
108 |
// } catch (NumberFormatException e) { |
|
109 |
// alpha = 0; |
|
110 |
// } |
|
111 |
// if(value.indexOf("@") != -1) |
|
112 |
// value = value.substring(0, value.indexOf("@")); |
|
113 |
// } |
|
114 |
// TransparencyRange range = new TransparencyRange(value); |
|
115 |
// if(alpha != 0) |
|
116 |
// range.setAlpha(alpha); |
|
117 |
// ranges.add(range); |
|
118 |
// } else |
|
119 |
// break; |
|
120 |
// i ++; |
|
121 |
// } |
|
122 |
// } |
|
123 |
// |
|
124 |
// if(xml.contains("filter.transparency.bandnumber")) |
|
125 |
// alphaBandNumber = xml.getIntProperty("filter.transparency.bandnumber"); |
|
126 |
// |
|
127 |
// if (xml.contains("raster.opacityLevel")) { |
|
128 |
// transparency = xml.getIntProperty("raster.opacityLevel"); |
|
129 |
// //Esto soluciona un problema de compatibilidad entre branch v10 y HEAD. Eliminar en futuras versiones |
|
130 |
// if(nameClass != null && nameClass.compareTo("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster") == 0) |
|
131 |
// transparency = 255 - transparency; |
|
132 |
// } |
|
133 |
// |
|
134 |
// if (xml.contains("raster.bandR")) |
|
135 |
// bandR = xml.getIntProperty("raster.bandR"); |
|
136 |
// |
|
137 |
// if (xml.contains("raster.bandG")) |
|
138 |
// bandG = xml.getIntProperty("raster.bandG"); |
|
139 |
// |
|
140 |
// if (xml.contains("raster.bandB")) |
|
141 |
// bandB = xml.getIntProperty("raster.bandB"); |
|
142 |
// |
|
143 |
// |
|
144 |
// int cont = 0; |
|
145 |
// while(true && cont < 50) { |
|
146 |
// if (xml.contains("raster.file" + cont)) { |
|
147 |
// files.add(xml.getStringProperty("raster.file" + cont)); |
|
148 |
// cont++; |
|
149 |
// }else |
|
150 |
// break; |
|
151 |
// } |
|
152 |
} |
|
153 |
|
|
154 |
|
|
155 |
@SuppressWarnings("unchecked") |
|
156 |
public void loadFromState(PersistentState state) |
|
157 |
throws PersistenceException { |
|
158 |
this.transparency = state.getInt("transparency"); |
|
159 |
this.bandR = state.getInt("bandR"); |
|
160 |
this.bandG = state.getInt("bandG"); |
|
161 |
this.bandB = state.getInt("bandB"); |
|
162 |
this.alphaBandNumber = state.getInt("alphaBandNumber"); |
|
163 |
this.loadClass = state.getBoolean("loadClass"); |
|
164 |
|
|
165 |
this.layer = (DefaultFLyrRaster)state.get("layer"); |
|
166 |
|
|
167 |
this.ranges = new ArrayList(state.getList("ranges")); |
|
168 |
this.files = new ArrayList(state.getList("files")); |
|
169 |
this.filters = new ArrayList(state.getList("filters")); |
|
170 |
} |
|
171 |
|
|
172 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
173 |
state.set("transparency", this.transparency); |
|
174 |
state.set("bandR", this.bandR); |
|
175 |
state.set("bandG", this.bandG); |
|
176 |
state.set("bandB", this.bandB); |
|
177 |
state.set("alphaBandNumber", this.alphaBandNumber); |
|
178 |
state.set("loadClass",this.loadClass); |
|
179 |
state.set("layer", this.layer); |
|
180 |
state.set("ranges", this.ranges); |
|
181 |
state.set("files", this.files); |
|
182 |
state.set("filters",this.filters); |
|
183 |
} |
|
184 |
|
|
185 |
public void setStateProperties(boolean loadClass, DefaultFLyrRaster layer) throws PersistenceException { |
|
186 |
this.layer = layer; |
|
187 |
this.loadClass = loadClass; |
|
188 |
} |
|
189 |
|
|
190 |
public static void registerPersistence() { |
|
191 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
192 |
DynStruct definition = manager.addDefinition(StatusLayerRaster.class, |
|
193 |
"StatusLayerRaster_Persistent", |
|
194 |
"StatusLayerRaster Persistent definition (FIXME loadClass)", null, null); |
|
195 |
definition.addDynFieldInt("transparency"); |
|
196 |
definition.addDynFieldInt("bandR").setMandatory(true); |
|
197 |
definition.addDynFieldInt("bandG").setMandatory(true); |
|
198 |
definition.addDynFieldInt("bandB").setMandatory(true); |
|
199 |
definition.addDynFieldInt("alphaBandNumber"); |
|
200 |
definition.addDynFieldBoolean("loadClass"); |
|
201 |
|
|
202 |
definition.addDynFieldObject("layer") |
|
203 |
.setClassOfValue(DefaultFLyrRaster.class); |
|
204 |
|
|
205 |
definition.addDynFieldList("ranges") |
|
206 |
.setClassOfItems(TransparencyRange.class); |
|
207 |
|
|
208 |
definition.addDynFieldList("files") |
|
209 |
.setClassOfItems(String.class); |
|
210 |
|
|
211 |
definition.addDynFieldList("filters") |
|
212 |
.setClassOfItems(String.class); |
|
213 |
} |
|
214 |
|
|
215 |
public List<String> getFilters() { |
|
216 |
return this.filters; |
|
217 |
} |
|
218 |
|
|
219 |
public void applyStatus(DefaultFLyrRaster layer) throws NotSupportedExtensionException, RasterDriverException, FilterTypeException, FileNotFoundInListException, OperationNotSupportedException, FilterManagerException, InvalidSourceException { |
|
220 |
|
|
221 |
//Eliminamos el fichero inicial y cargamos las bandas si hay para que se carguen |
|
222 |
//en el orden correcto |
|
223 |
if(layer instanceof DefaultFLyrRaster) { |
|
224 |
if(files != null && files.size() != 0){ |
|
225 |
//((FLyrRasterSE)layer).delFile((String)files.get(0)); |
|
226 |
for (int i = 1; i < files.size(); i++) |
|
227 |
((DefaultFLyrRaster)layer).addFile(files.get(i)); |
|
228 |
} |
|
229 |
} |
|
230 |
|
|
231 |
//Asigna las bandas |
|
232 |
String[] valuesCI = new String[layer.getDataStore().getBandCount()]; |
|
233 |
valuesCI[bandR] = ColorInterpretation.RED_BAND; |
|
234 |
valuesCI[bandG] = ColorInterpretation.GREEN_BAND; |
|
235 |
valuesCI[bandB] = ColorInterpretation.BLUE_BAND; |
|
236 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation(valuesCI); |
|
237 |
if(layer.getRender() != null) |
|
238 |
layer.getRender().setRenderColorInterpretation(ci); |
|
239 |
|
|
240 |
//Asigna la transparencia |
|
241 |
Transparency transp = layer.getRender().getRenderingTransparency(); |
|
242 |
if(transp != null && transparency != 255) { |
|
243 |
transp.setOpacity(transparency); |
|
244 |
transp.activeTransparency(); |
|
245 |
} |
|
246 |
|
|
247 |
//Rangos de transparencia |
|
248 |
if(transp != null && ranges != null) { |
|
249 |
transp.setTransparencyRangeList(ranges); |
|
250 |
transp.activeTransparency(); |
|
251 |
} |
|
252 |
|
|
253 |
//Banda de transparencia |
|
254 |
if(transp != null && alphaBandNumber != -1) { |
|
255 |
transp.setTransparencyBand(alphaBandNumber); |
|
256 |
transp.activeTransparency(); |
|
257 |
} |
|
258 |
|
|
259 |
//Filtros |
|
260 |
/*if (layer.getRender().getFilterList() != null) { |
|
261 |
layer.getRender().getFilterList().createFilterListFromStrings((ArrayList<String>)filters); |
|
262 |
enhancedCompV10((ArrayList<String>)filters, layer); |
|
263 |
//sortFilters(layer.getRenderFilterList()); |
|
264 |
}*/ |
|
265 |
|
|
266 |
//Refrescamos todas las vistas |
|
267 |
layer.getMapContext().invalidate(); |
|
268 |
/*IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
269 |
for (int i = 0; i < w.length; i++) { |
|
270 |
if(w[i] != null && w[i] instanceof AbstractViewPanel) |
|
271 |
((AbstractViewPanel)w[i]).getMapControl().getMapContext().invalidate(); |
|
272 |
}*/ |
|
273 |
} |
|
274 |
|
|
275 |
/** |
|
276 |
* M?todo para mantener la compatibilidad con la v10 del realce. El realce de la v10 no |
|
277 |
* aporta suficiente informaci?n por lo que se a?ade un filtro de realce generico v1.9 |
|
278 |
* @param filterArguments |
|
279 |
* @param layer |
|
280 |
* @param filterListManager |
|
281 |
* @throws FilterTypeException |
|
282 |
* @throws FilterManagerException |
|
283 |
*/ |
|
284 |
public static void enhancedCompV10(ArrayList<String> filterArguments, DefaultFLyrRaster layer) throws FilterTypeException, FilterManagerException { |
|
285 |
RasterFilterList filterList = layer.getRender().getFilterList(); |
|
286 |
filterList.remove("enhanced_stretch"); |
|
287 |
filterList.remove("tailTrim"); |
|
288 |
|
|
289 |
/*boolean removed = false; |
|
290 |
RasterFilterList list = layer.getRender().getFilterList(); |
|
291 |
for (int i = 0; i < list.lenght(); i++) { |
|
292 |
RasterFilter f = list.get(i); |
|
293 |
if(f instanceof TailTrimFilter || f instanceof LinearEnhancementFilter) { |
|
294 |
list.remove(f.getName()); |
|
295 |
removed = true; |
|
296 |
} |
|
297 |
} |
|
298 |
if(removed) |
|
299 |
list.controlTypes();*/ |
|
300 |
|
|
301 |
//Para compatibilidad de realce con proyectos antiguos |
|
302 |
for (int i = 0; i < filterArguments.size(); i++) { |
|
303 |
if(((String)filterArguments.get(i)).startsWith("filter.enhanced.active=true")) { |
|
304 |
RasterFilterListManager enhancementManager = filterList.getManagerByID("EnhancementStretch"); |
|
305 |
Params params = filterList.createEmptyFilterParams(); |
|
306 |
params.setParam("stats", ((RasterDataStore)layer.getDataStore()).getStatistics()); |
|
307 |
params.setParam("remove", new Boolean(false)); |
|
308 |
params.setParam("renderBands", layer.getRender().getRenderColorInterpretation().buildRenderBands()); |
|
309 |
params.setParam("stretchs", null);//coge el LinearStretchParams por defecto |
|
310 |
enhancementManager.addFilter(params); |
|
311 |
} |
|
312 |
} |
|
313 |
} |
|
314 |
|
|
315 |
public int[] getRenderBands() { |
|
316 |
return new int[]{bandR, bandG, bandB}; |
|
317 |
} |
|
318 |
|
|
319 |
public RasterFilterList getFilterList() throws FilterTypeException { |
|
320 |
/*RasterManager rManager = RasterLocator.getManager(); |
|
321 |
try { |
|
322 |
RasterFilterList filterList = layer.getRender().getFilterList(); |
|
323 |
if(filterList != null) |
|
324 |
filterList.createFilterListFromStrings((ArrayList<String>)filters); |
|
325 |
else { |
|
326 |
filterList = rManager.createEmptyFilterList(Buffer.TYPE_BYTE); |
|
327 |
} |
|
328 |
|
|
329 |
return filterList; |
|
330 |
} catch (NullPointerException e) { |
|
331 |
return null; |
|
332 |
}*/ |
|
333 |
return null; |
|
334 |
} |
|
335 |
|
|
336 |
public ColorTable getColorTable() throws FilterTypeException { |
|
337 |
return layer.getRender().getColorTable(); |
|
338 |
} |
|
339 |
|
|
340 |
public List<String> getFilterArguments() { |
|
341 |
return filters; |
|
342 |
} |
|
343 |
|
|
344 |
String nameClass = null; |
|
345 |
/** |
|
346 |
* Asigna el nombre de la clase que se ha leido desde el proyecto |
|
347 |
* @param nameClass |
|
348 |
*/ |
|
349 |
public void setNameClass(String nameClass) { |
|
350 |
this.nameClass = nameClass; |
|
351 |
} |
|
352 |
} |
|
0 | 353 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.24/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.java | ||
---|---|---|
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.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.Point; |
|
27 |
import java.awt.Rectangle; |
|
28 |
import java.awt.geom.AffineTransform; |
|
29 |
import java.awt.geom.NoninvertibleTransformException; |
|
30 |
import java.awt.geom.Point2D; |
|
31 |
import java.awt.geom.Rectangle2D; |
|
32 |
import java.awt.image.BufferedImage; |
|
33 |
import java.io.File; |
|
34 |
import java.io.IOException; |
|
35 |
import java.net.URI; |
|
36 |
import java.util.ArrayList; |
|
37 |
import java.util.HashMap; |
|
38 |
import java.util.List; |
|
39 |
import java.util.Set; |
|
40 |
|
|
41 |
import org.cresques.cts.IProjection; |
|
42 |
|
|
43 |
import org.gvsig.compat.print.PrintAttributes; |
|
44 |
import org.gvsig.fmap.crs.CRSFactory; |
|
45 |
import org.gvsig.fmap.dal.DataStore; |
|
46 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
47 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
|
48 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
49 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
50 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
Also available in: Unified diff