svn-gvsig-desktop / tags / Root_v061 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / toolListeners / SaveRasterListener.java @ 4812
History | View | Annotate | Download (4.03 KB)
1 | 2183 | fernando | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | package com.iver.cit.gvsig.gui.toolListeners; |
||
42 | |||
43 | 4494 | nacho | import java.awt.Point; |
44 | 4351 | nacho | import java.awt.geom.Point2D; |
45 | |||
46 | 4494 | nacho | import org.cresques.cts.IProjection; |
47 | 2183 | fernando | import org.cresques.ui.raster.DataInputSaveRaster; |
48 | import org.cresques.ui.raster.SaveRasterDialogPanel; |
||
49 | import org.cresques.ui.raster.SaveSetupPanel; |
||
50 | |||
51 | import com.iver.andami.PluginServices; |
||
52 | 4494 | nacho | import com.iver.cit.gvsig.fmap.FMap; |
53 | 2183 | fernando | import com.iver.cit.gvsig.fmap.MapControl; |
54 | import com.iver.cit.gvsig.fmap.ViewPort; |
||
55 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
56 | import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
||
57 | import com.iver.cit.gvsig.fmap.tools.SaveRasterListenerImpl; |
||
58 | 4351 | nacho | import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
59 | 2183 | fernando | import com.iver.cit.gvsig.gui.View; |
60 | import com.iver.cit.gvsig.gui.Panels.SaveRasterDialog; |
||
61 | |||
62 | |||
63 | /**
|
||
64 | * Extensi?n de la clase SaveRasterListenerImpl de FMap para poder llamar a m?todos
|
||
65 | * de andami o de gvSIG.
|
||
66 | *
|
||
67 | * @author Nacho Brodin <brodin_ign@gva.es>
|
||
68 | */
|
||
69 | public class SaveRasterListener extends SaveRasterListenerImpl { |
||
70 | |||
71 | FLyrRaster layer = null;
|
||
72 | |||
73 | public SaveRasterListener(MapControl mapCtrl) {
|
||
74 | super(mapCtrl);
|
||
75 | } |
||
76 | |||
77 | /**
|
||
78 | *
|
||
79 | * @param flyr
|
||
80 | */
|
||
81 | public void setRasterLayer(FLyrRaster flyr){ |
||
82 | layer = flyr; |
||
83 | } |
||
84 | |||
85 | public void rectangle(RectangleEvent event) { |
||
86 | super.rectangle(event);
|
||
87 | |||
88 | if (PluginServices.getMainFrame() != null) |
||
89 | PluginServices.getMainFrame().enableControls(); |
||
90 | |||
91 | FLayers layers = mapCtrl.getMapContext().getLayers(); |
||
92 | |||
93 | SaveRasterDialog saveRaster = new SaveRasterDialog(layers, mapCtrl);
|
||
94 | 4351 | nacho | |
95 | ViewPort vp = mapCtrl.getViewPort(); |
||
96 | Point2D ini = vp.fromMapPoint(rect.getMinX(), rect.getMinY());
|
||
97 | Point2D fin = vp.fromMapPoint(rect.getMaxX(), rect.getMaxY());
|
||
98 | 4494 | nacho | if(Math.abs(fin.getY()-ini.getY())>10 && Math.abs(fin.getX()-ini.getX())>10){ |
99 | 2183 | fernando | saveRaster.setProjection(((View) PluginServices.getMDIManager().getActiveView()).getProjection());
|
100 | 4494 | nacho | |
101 | 2183 | fernando | DataInputSaveRaster dialog = ((SaveSetupPanel)(((SaveRasterDialogPanel)saveRaster.getContentPane()).getContentPanel())).getSaveParameters(); |
102 | 4494 | nacho | dialog.setProjection(vp.getProjection()); |
103 | dialog.setWidthInPixelsGeodesicas((int)Math.abs(fin.getX()-ini.getX())); |
||
104 | dialog.setHeightInPixelsGeodesicas((int)Math.abs(fin.getY()-ini.getY())); |
||
105 | |||
106 | 2385 | igbrotru | int indexPoint = String.valueOf(rect.getMaxX()).indexOf('.'); |
107 | 2183 | fernando | dialog.getTinf_derX().setText(String.valueOf(rect.getMaxX()).substring(0,indexPoint+2)); |
108 | indexPoint = String.valueOf(rect.getMaxY()).indexOf('.'); |
||
109 | 2385 | igbrotru | dialog.getTinf_derY().setText(String.valueOf(rect.getMinY()).substring(0,indexPoint+2)); |
110 | 2183 | fernando | indexPoint = String.valueOf(rect.getMinX()).indexOf('.'); |
111 | dialog.getTsup_izqX().setText(String.valueOf(rect.getMinX()).substring(0,indexPoint+2)); |
||
112 | indexPoint = String.valueOf(rect.getMinY()).indexOf('.'); |
||
113 | 2385 | igbrotru | dialog.getTsup_izqY().setText(String.valueOf(rect.getMaxY()).substring(0,indexPoint+2)); |
114 | 4351 | nacho | |
115 | 2183 | fernando | PluginServices.getMDIManager().addView(saveRaster); |
116 | } |
||
117 | 4494 | nacho | |
118 | |||
119 | 2183 | fernando | } |
120 | } |