gvsig-3d / org.gvsig.netcdf3d / trunk / org.gvsig.netcdf3d / org.gvsig.netcdf3d.lib / org.gvsig.netcdf3d.lib.impl / src / main / java / org / gvsig / netcdf3d / lib / impl / DefaultNetCDFTiledImageLayer.java @ 727
History | View | Annotate | Download (7.3 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2016 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
|
24 |
package org.gvsig.netcdf3d.lib.impl; |
25 |
|
26 |
import gov.nasa.worldwind.WWObjectImpl; |
27 |
import gov.nasa.worldwind.avlist.AVKey; |
28 |
import gov.nasa.worldwind.layers.Layer; |
29 |
import gov.nasa.worldwind.layers.TiledImageLayer; |
30 |
import gov.nasa.worldwind.render.DrawContext; |
31 |
|
32 |
import java.awt.Point; |
33 |
import java.awt.event.ActionEvent; |
34 |
import java.awt.event.ActionListener; |
35 |
import java.beans.PropertyChangeEvent; |
36 |
|
37 |
import javax.swing.Timer; |
38 |
|
39 |
import org.gvsig.fmap.dal.raster.api.RasterQuery; |
40 |
import org.gvsig.fmap.mapcontext.raster.api.RasterLayer; |
41 |
import org.gvsig.netcdf3d.lib.api.NetCDFLoaderParameters; |
42 |
import org.gvsig.view3d.lib.api.View3DLocator; |
43 |
import org.gvsig.view3d.lib.api.View3DManager; |
44 |
import org.gvsig.view3d.lib.api.exception.FactoryNotRegisteredException; |
45 |
import org.gvsig.view3d.lib.api.exception.LoadException; |
46 |
import org.gvsig.view3d.lib.api.loader.Loader; |
47 |
import org.gvsig.view3d.lib.api.loader.LoaderFactory; |
48 |
import org.gvsig.view3d.lib.api.loader.RasterLoaderParameters; |
49 |
|
50 |
import org.slf4j.Logger; |
51 |
import org.slf4j.LoggerFactory; |
52 |
|
53 |
/**
|
54 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
55 |
*
|
56 |
*/
|
57 |
public class DefaultNetCDFTiledImageLayer extends WWObjectImpl implements Layer { |
58 |
|
59 |
private static final Logger LOG = LoggerFactory.getLogger(DefaultNetCDFTiledImageLayer.class); |
60 |
|
61 |
private NetCDFLoaderParameters parameters;
|
62 |
private TiledImageLayer rasterLayer;
|
63 |
private Timer timer; |
64 |
|
65 |
/**
|
66 |
*
|
67 |
* @param parameters
|
68 |
*/
|
69 |
public DefaultNetCDFTiledImageLayer(NetCDFLoaderParameters parameters) {
|
70 |
this.parameters = parameters;
|
71 |
|
72 |
// Create Raster tiled image layer
|
73 |
try {
|
74 |
this.createRaserTiledImageLayer();
|
75 |
} catch (FactoryNotRegisteredException | LoadException e) {
|
76 |
LOG.error("Can not create raster tiled image layer", e);
|
77 |
return;
|
78 |
} |
79 |
|
80 |
this.timer = new Timer((int)(this.parameters.getLapse() * 1000), new DefaultNetCDFTimerTask(this, parameters)); |
81 |
this.timer.start();
|
82 |
} |
83 |
|
84 |
private void createRaserTiledImageLayer() |
85 |
throws FactoryNotRegisteredException, LoadException {
|
86 |
View3DManager manager = View3DLocator.getManager(); |
87 |
LoaderFactory loaderFactory = null;
|
88 |
loaderFactory = manager.getLoaderFactory(RasterLoaderParameters.NAME); |
89 |
Loader rasterLoader = loaderFactory.createLoader(); |
90 |
this.rasterLayer = (TiledImageLayer) rasterLoader.load(parameters);
|
91 |
// this.rasterLayer.setForceLevelZeroLoads(true);
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* @param rasterQuery
|
96 |
*
|
97 |
*/
|
98 |
public void setBaseQuery(RasterQuery rasterQuery) { |
99 |
RasterLayer rasterLayer = |
100 |
(RasterLayer) this.rasterLayer.getValue(View3DManager.GVSIG_LAYER);
|
101 |
rasterLayer.setBaseQuery(rasterQuery); |
102 |
|
103 |
long timeMillis = System.currentTimeMillis(); |
104 |
this.setExpiryTime(timeMillis);
|
105 |
this.rasterLayer.setExpiryTime(timeMillis);
|
106 |
this.propertyChange(new PropertyChangeEvent(this, AVKey.LAYER, null, this)); |
107 |
} |
108 |
|
109 |
@Override
|
110 |
public void dispose() { |
111 |
this.parameters = null; |
112 |
this.timer.stop();
|
113 |
this.timer = null; |
114 |
this.rasterLayer.dispose();
|
115 |
} |
116 |
|
117 |
@Override
|
118 |
public String getRestorableState() { |
119 |
return this.rasterLayer.getRestorableState(); |
120 |
} |
121 |
|
122 |
@Override
|
123 |
public void restoreState(String stateInXml) { |
124 |
this.rasterLayer.restoreState(stateInXml);
|
125 |
} |
126 |
|
127 |
@Override
|
128 |
public boolean isEnabled() { |
129 |
return this.rasterLayer.isEnabled(); |
130 |
} |
131 |
|
132 |
@Override
|
133 |
public void setEnabled(boolean enabled) { |
134 |
this.rasterLayer.setEnabled(enabled);
|
135 |
} |
136 |
|
137 |
@Override
|
138 |
public String getName() { |
139 |
return this.rasterLayer.getName(); |
140 |
} |
141 |
|
142 |
@Override
|
143 |
public void setName(String name) { |
144 |
this.rasterLayer.setName(name);
|
145 |
} |
146 |
|
147 |
@Override
|
148 |
public double getOpacity() { |
149 |
return this.rasterLayer.getOpacity(); |
150 |
} |
151 |
|
152 |
@Override
|
153 |
public void setOpacity(double opacity) { |
154 |
this.rasterLayer.setOpacity(opacity);
|
155 |
} |
156 |
|
157 |
@Override
|
158 |
public boolean isPickEnabled() { |
159 |
return this.rasterLayer.isPickEnabled(); |
160 |
} |
161 |
|
162 |
@Override
|
163 |
public void setPickEnabled(boolean isPickable) { |
164 |
this.rasterLayer.setPickEnabled(isPickable);
|
165 |
} |
166 |
|
167 |
@Override
|
168 |
public void preRender(DrawContext dc) { |
169 |
this.rasterLayer.preRender(dc);
|
170 |
} |
171 |
|
172 |
@Override
|
173 |
public void render(DrawContext dc) { |
174 |
this.rasterLayer.render(dc);
|
175 |
} |
176 |
|
177 |
@Override
|
178 |
public void pick(DrawContext dc, Point pickPoint) { |
179 |
this.rasterLayer.pick(dc, pickPoint);
|
180 |
} |
181 |
|
182 |
@Override
|
183 |
public boolean isAtMaxResolution() { |
184 |
return this.rasterLayer.isAtMaxResolution(); |
185 |
} |
186 |
|
187 |
@Override
|
188 |
public boolean isMultiResolution() { |
189 |
return this.rasterLayer.isMultiResolution(); |
190 |
} |
191 |
|
192 |
@Override
|
193 |
public double getScale() { |
194 |
return this.rasterLayer.getScale(); |
195 |
} |
196 |
|
197 |
@Override
|
198 |
public boolean isNetworkRetrievalEnabled() { |
199 |
return this.rasterLayer.isNetworkRetrievalEnabled(); |
200 |
} |
201 |
|
202 |
@Override
|
203 |
public void setNetworkRetrievalEnabled(boolean networkRetrievalEnabled) { |
204 |
this.rasterLayer.setNetworkRetrievalEnabled(networkRetrievalEnabled);
|
205 |
} |
206 |
|
207 |
@Override
|
208 |
public void setExpiryTime(long expiryTime) { |
209 |
this.rasterLayer.setExpiryTime(expiryTime);
|
210 |
} |
211 |
|
212 |
@Override
|
213 |
public long getExpiryTime() { |
214 |
return this.rasterLayer.getExpiryTime(); |
215 |
} |
216 |
|
217 |
@Override
|
218 |
public double getMinActiveAltitude() { |
219 |
return this.rasterLayer.getMinActiveAltitude(); |
220 |
} |
221 |
|
222 |
@Override
|
223 |
public void setMinActiveAltitude(double minActiveAltitude) { |
224 |
this.rasterLayer.setMinActiveAltitude(minActiveAltitude);
|
225 |
} |
226 |
|
227 |
@Override
|
228 |
public double getMaxActiveAltitude() { |
229 |
return this.rasterLayer.getMaxActiveAltitude(); |
230 |
} |
231 |
|
232 |
@Override
|
233 |
public void setMaxActiveAltitude(double maxActiveAltitude) { |
234 |
this.rasterLayer.setMaxActiveAltitude(maxActiveAltitude);
|
235 |
} |
236 |
|
237 |
@Override
|
238 |
public boolean isLayerInView(DrawContext dc) { |
239 |
return this.rasterLayer.isLayerInView(dc); |
240 |
} |
241 |
|
242 |
@Override
|
243 |
public boolean isLayerActive(DrawContext dc) { |
244 |
return this.rasterLayer.isLayerActive(dc); |
245 |
} |
246 |
|
247 |
@Override
|
248 |
public Double getMaxEffectiveAltitude(Double radius) { |
249 |
return this.rasterLayer.getMaxEffectiveAltitude(radius); |
250 |
} |
251 |
|
252 |
@Override
|
253 |
public Double getMinEffectiveAltitude(Double radius) { |
254 |
return this.rasterLayer.getMaxEffectiveAltitude(radius); |
255 |
} |
256 |
|
257 |
} |