Revision 20125
trunk/libraries/lib3DMap/src/com/iver/ai2/gvsig3d/map3d/MapContext3D.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.Component; |
4 | 4 |
import java.awt.Dimension; |
5 |
import java.awt.Graphics2D; |
|
5 | 6 |
import java.awt.Point; |
7 |
import java.awt.Rectangle; |
|
8 |
import java.awt.geom.AffineTransform; |
|
6 | 9 |
import java.awt.geom.Rectangle2D; |
10 |
import java.awt.image.AffineTransformOp; |
|
11 |
import java.awt.image.BufferedImage; |
|
12 |
import java.awt.image.ImagingOpException; |
|
7 | 13 |
import java.io.File; |
14 |
import java.io.IOException; |
|
8 | 15 |
import java.util.ArrayList; |
9 | 16 |
|
17 |
import javax.imageio.ImageIO; |
|
18 |
import javax.media.opengl.GL; |
|
10 | 19 |
import javax.swing.JOptionPane; |
11 | 20 |
|
12 | 21 |
import org.cresques.cts.ICoordTrans; |
... | ... | |
19 | 28 |
import com.iver.ai2.gvsig3d.map3d.layers.FLayers3D; |
20 | 29 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
21 | 30 |
import com.iver.andami.PluginServices; |
31 |
import com.iver.andami.messages.NotificationManager; |
|
22 | 32 |
import com.iver.cit.gvsig.AddLayer; |
23 | 33 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
24 | 34 |
import com.iver.cit.gvsig.fmap.MapContext; |
... | ... | |
42 | 52 |
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
43 | 53 |
import com.iver.cit.gvsig.fmap.rendering.LegendListener; |
44 | 54 |
import com.iver.utiles.XMLEntity; |
55 |
import com.iver.utiles.swing.threads.Cancellable; |
|
45 | 56 |
|
46 | 57 |
import es.upv.ai2.osgvp.Node; |
47 | 58 |
import es.upv.ai2.osgvp.Vec3; |
... | ... | |
82 | 93 |
|
83 | 94 |
// private ViewPort3D vport; |
84 | 95 |
|
96 |
@Override |
|
97 |
public void draw(BufferedImage image, Graphics2D g, Cancellable cancel, |
|
98 |
double scale) throws ReadDriverException { |
|
99 |
// TODO Auto-generated method stub |
|
100 |
// super.draw(image, g, cancel, scale); |
|
101 |
String tempScreenshot = "c:/tempLayout.png"; |
|
102 |
m_canvas3d.getOSGViewer().takeScreenshot(tempScreenshot); |
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
// GL glContext = m_canvas3d.getGL(); |
|
107 |
// glContext. |
|
108 |
BufferedImage img = null; |
|
109 |
// Read from a file |
|
110 |
File file = new File(tempScreenshot); |
|
111 |
try { |
|
112 |
img = ImageIO.read(file); |
|
113 |
} catch (IOException e) { |
|
114 |
// TODO Auto-generated catch block |
|
115 |
e.printStackTrace(); |
|
116 |
} |
|
117 |
// Rectangle r = g.getClipBounds(); |
|
118 |
// double x = r.getMinX(); |
|
119 |
// double y = r.getMinY(); |
|
120 |
// double w = r.getWidth(); |
|
121 |
// double h = r.getHeight(); |
|
122 |
// |
|
123 |
// double scalex = w / img.getWidth(null); |
|
124 |
// double scaley = h / img.getHeight(null); |
|
125 |
// try { |
|
126 |
// AffineTransform xform = AffineTransform.getScaleInstance(scalex, |
|
127 |
// scaley); |
|
128 |
// AffineTransform xpos = AffineTransform.getTranslateInstance(x, y); |
|
129 |
// xpos.concatenate(xform); |
|
130 |
// g.drawRenderedImage(img, xpos); |
|
131 |
// } catch (ImagingOpException e) { |
|
132 |
// NotificationManager.addError("Dibujando FFramePicture", e); |
|
133 |
// } |
|
134 |
|
|
135 |
} |
|
136 |
|
|
137 |
// @Override |
|
138 |
// public void draw(BufferedImage image, Graphics2D g, double scale) |
|
139 |
// throws ReadDriverException { |
|
140 |
// // TODO Auto-generated method stub |
|
141 |
// super.draw(image, g, scale); |
|
142 |
// } |
|
143 |
|
|
144 |
// @Override |
|
145 |
// public void drawGraphics(BufferedImage image, Graphics2D g, |
|
146 |
// Cancellable cancel, double scale) throws ReadDriverException { |
|
147 |
// // TODO Auto-generated method stub |
|
148 |
// super.drawGraphics(image, g, cancel, scale); |
|
149 |
// } |
|
150 |
|
|
85 | 151 |
public MapContext3D(ViewPort vp) { |
86 | 152 |
super(vp); |
87 | 153 |
|
... | ... | |
267 | 333 |
legendLyr.addLegendListener((LegendListener) this); |
268 | 334 |
} |
269 | 335 |
layer.addLayerListener((LayerListener) this); |
270 |
|
|
336 |
|
|
271 | 337 |
// listener to manage the selection for the layers |
272 | 338 |
if (layer.getClass().equals(FLyrVect.class)) { |
273 | 339 |
FLyrVect lyr = (FLyrVect) layer; |
274 | 340 |
try { |
275 |
lyr.getRecordset().getSelectionSupport().addSelectionListener(this); |
|
341 |
lyr.getRecordset().getSelectionSupport().addSelectionListener( |
|
342 |
this); |
|
276 | 343 |
} catch (ReadDriverException e) { |
277 | 344 |
// TODO Auto-generated catch block |
278 | 345 |
e.printStackTrace(); |
... | ... | |
473 | 540 |
|
474 | 541 |
public void editionChanged(LayerEvent e) { |
475 | 542 |
// TODO Implement this method |
476 |
|
|
477 |
|
|
478 |
|
|
543 |
|
|
479 | 544 |
} |
480 | 545 |
|
481 | 546 |
public void refreshLayerInPlanet(Layer3DProps props, boolean bRemoveCache) { |
... | ... | |
919 | 984 |
|
920 | 985 |
Rectangle2D extent = new Rectangle2D.Double(minX, minY, width, |
921 | 986 |
height); |
922 |
if (cacheService.intersectsLayer(extent)) { // extent test |
|
923 |
// if (cacheService.intersectsLayer(extent)) { // extent test |
|
924 |
// System.out.println("Extent del evento del tilenum " |
|
925 |
// + tileNum + minX + " " + minY + " " + width + " " |
|
926 |
// + height); |
|
987 |
if (cacheService.intersectsLayer(extent)) { // extent test |
|
988 |
// if (cacheService.intersectsLayer(extent)) { // extent |
|
989 |
// test |
|
990 |
// System.out.println("Extent del evento del tilenum " |
|
991 |
// + tileNum + minX + " " + minY + " " + width + " " |
|
992 |
// + height); |
|
927 | 993 |
try { |
928 |
//tileFileName = cacheService.getTileAsFName(tileNum); |
|
929 |
tileFileName = cacheService.getTileAsFName(tileNum,extent); |
|
930 |
//System.err.println("tile num " + tileNum); |
|
931 |
//System.err.println("nombre fichero " + tileFileName); |
|
994 |
// tileFileName = cacheService.getTileAsFName(tileNum); |
|
995 |
tileFileName = cacheService.getTileAsFName(tileNum, |
|
996 |
extent); |
|
997 |
// System.err.println("tile num " + tileNum); |
|
998 |
// System.err.println("nombre fichero " + tileFileName); |
|
932 | 999 |
} catch (Exception e) { |
933 | 1000 |
return; |
934 | 1001 |
} |
... | ... | |
1008 | 1075 |
|
1009 | 1076 |
Rectangle2D extent = new Rectangle2D.Double(minX, minY, width, height); |
1010 | 1077 |
if (cacheService.intersectsLayer(extent)) { // extent test |
1011 |
// if (cacheService.intersectsLayer(extent)) { |
|
1012 |
// System.out.println("Extetn del evento " + minX + " " + minY + " "
|
|
1013 |
// + width + " " + height);
|
|
1078 |
// if (cacheService.intersectsLayer(extent)) {
|
|
1079 |
// System.out.println("Extetn del evento " + minX + " " + minY + " "
|
|
1080 |
// + width + " " + height);
|
|
1014 | 1081 |
try { |
1015 | 1082 |
// tileFileName = cacheService.getTileAsFName(tileNum,extent); |
1016 | 1083 |
tileFileName = cacheService.getTileAsFName(tileNum, extent); |
... | ... | |
1074 | 1141 |
TileNum tileNum = new TileNum(evt.getLevel(), tileIndices); |
1075 | 1142 |
|
1076 | 1143 |
String tileFileName; |
1077 |
double minX = evt.getMinX();
|
|
1144 |
double minX = evt.getMinX(); |
|
1078 | 1145 |
double minY = evt.getMinY(); |
1079 | 1146 |
double width = evt.getMaxX() - evt.getMinX(); |
1080 | 1147 |
double height = evt.getMaxY() - evt.getMinY(); |
1081 | 1148 |
|
1082 | 1149 |
Rectangle2D extent = new Rectangle2D.Double(minX, minY, width, height); |
1083 | 1150 |
if (cacheService.intersectsLayer(extent)) { // extent test |
1084 |
// if (cacheService.intersectsLayer(extent)) { |
|
1151 |
// if (cacheService.intersectsLayer(extent)) {
|
|
1085 | 1152 |
try { |
1086 |
tileFileName = cacheService.getTileAsFName(tileNum,extent);
|
|
1087 |
//tileFileName = cacheService.getTileAsFName(tileNum); |
|
1153 |
tileFileName = cacheService.getTileAsFName(tileNum, extent);
|
|
1154 |
// tileFileName = cacheService.getTileAsFName(tileNum);
|
|
1088 | 1155 |
// System.err.println("tile num " + tileNum); |
1089 | 1156 |
// System.err.println("nombre fichero " + tileFileName); |
1090 | 1157 |
} catch (Exception e) { |
... | ... | |
1200 | 1267 |
if (vp.getDirty()) { |
1201 | 1268 |
vp.setDirty(false); |
1202 | 1269 |
// extentAux = vport.getExtent(); |
1203 |
|
|
1204 |
//Comento el zoom pq no kiero q me lo haga y me cambie la vista cuando repinto |
|
1205 |
|
|
1206 |
//this.zoomToExtent(vp.getExtent()); |
|
1270 |
|
|
1271 |
// Comento el zoom pq no kiero q me lo haga y me cambie la vista |
|
1272 |
// cuando repinto |
|
1273 |
|
|
1274 |
// this.zoomToExtent(vp.getExtent()); |
|
1207 | 1275 |
// System.out.println("extend seleccionado: \n Centro: " |
1208 | 1276 |
// + extentAux.getCenterX() + "\n Alto: " + extentAux.getHeight() |
1209 | 1277 |
// + "\n Ancho: " + extentAux.getWidth()); |
... | ... | |
1216 | 1284 |
|
1217 | 1285 |
} |
1218 | 1286 |
FLayer[] selectedExtent = getLayers().getActives(); |
1219 |
|
|
1287 |
|
|
1220 | 1288 |
if (selectedExtent.length > 0) { |
1221 | 1289 |
for (int i = 0; i < selectedExtent.length; i++) { |
1222 | 1290 |
if (selectedExtent[0].isAvailable()) { |
1223 |
|
|
1291 |
|
|
1224 | 1292 |
FLayer lyr3D = selectedExtent[i]; |
1225 | 1293 |
Layer3DProps layer3DProps = Layer3DProps |
1226 |
.getLayer3DProps(lyr3D); |
|
1227 |
|
|
1294 |
.getLayer3DProps(lyr3D);
|
|
1295 |
|
|
1228 | 1296 |
int order = layer3DProps.getPlanetOrder(); |
1229 | 1297 |
// float opacity = layer3DProps.getOpacity(); |
1230 |
float opacity = (((FLyrDefault) lyr3D) |
|
1231 |
.getTransparency()) |
|
1298 |
float opacity = (((FLyrDefault) lyr3D).getTransparency()) |
|
1232 | 1299 |
/ (float) 255; |
1233 | 1300 |
// Notify the opacity to planet |
1234 | 1301 |
this.m_planet.setTextureOpacityLayer(order, opacity); |
1235 | 1302 |
} |
1236 | 1303 |
} |
1237 |
|
|
1304 |
|
|
1238 | 1305 |
} |
1239 | 1306 |
// super.invalidate(); |
1240 | 1307 |
|
... | ... | |
1250 | 1317 |
FLayer layer = (FLayer) layerList.get(iLayer); |
1251 | 1318 |
if (layer.getClass().equals(FLyrVect.class)) { |
1252 | 1319 |
FLyrVect lyr = (FLyrVect) layer; |
1253 |
|
|
1254 |
FBitSet selection = null; |
|
1255 |
try { |
|
1256 |
selection = lyr.getRecordset().getSelectionSupport().getSelection(); |
|
1257 |
} catch (ReadDriverException e1) { |
|
1258 |
// TODO Auto-generated catch block |
|
1259 |
e1.printStackTrace(); |
|
1260 |
} |
|
1261 |
|
|
1262 |
// if (!(selection.isEmpty())){ |
|
1263 |
if ((selection.cardinality() == 0) || (!(selection.isEmpty())) ){ |
|
1264 |
Layer3DProps props = Layer3DProps.getLayer3DProps(layer); |
|
1265 |
refreshLayerInPlanet(props, true); |
|
1266 |
} |
|
1320 |
|
|
1321 |
FBitSet selection = null; |
|
1322 |
try { |
|
1323 |
selection = lyr.getRecordset().getSelectionSupport() |
|
1324 |
.getSelection(); |
|
1325 |
} catch (ReadDriverException e1) { |
|
1326 |
// TODO Auto-generated catch block |
|
1327 |
e1.printStackTrace(); |
|
1328 |
} |
|
1329 |
|
|
1330 |
// if (!(selection.isEmpty())){ |
|
1331 |
if ((selection.cardinality() == 0) |
|
1332 |
|| (!(selection.isEmpty()))) { |
|
1333 |
Layer3DProps props = Layer3DProps |
|
1334 |
.getLayer3DProps(layer); |
|
1335 |
refreshLayerInPlanet(props, true); |
|
1336 |
} |
|
1267 | 1337 |
} |
1268 |
|
|
1338 |
|
|
1269 | 1339 |
} |
1270 | 1340 |
} |
1271 | 1341 |
m_canvas3d.repaint(); |
1272 |
|
|
1342 |
|
|
1273 | 1343 |
} |
1274 | 1344 |
} |
Also available in: Unified diff