svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / saveraster / map / SaveRasterListener.java @ 11267
History | View | Annotate | Download (3.88 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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 |
package org.gvsig.rastertools.saveraster.map; |
20 |
|
21 |
|
22 |
import java.awt.geom.Point2D; |
23 |
|
24 |
import org.gvsig.rastertools.saveraster.ui.SaveRasterDialog; |
25 |
import org.gvsig.rastertools.saveraster.ui.SaveRasterPanel; |
26 |
|
27 |
import com.iver.andami.PluginServices; |
28 |
import com.iver.cit.gvsig.fmap.MapControl; |
29 |
import com.iver.cit.gvsig.fmap.ViewPort; |
30 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
31 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
32 |
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
33 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
34 |
|
35 |
|
36 |
/**
|
37 |
* Extensi?n de la clase SaveRasterListenerImpl de FMap para poder llamar a m?todos
|
38 |
* de andami o de gvSIG.
|
39 |
*
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
41 |
*/
|
42 |
public class SaveRasterListener extends SaveRasterListenerImpl { |
43 |
|
44 |
FLyrRaster layer = null;
|
45 |
|
46 |
public SaveRasterListener(MapControl mapCtrl) {
|
47 |
super(mapCtrl);
|
48 |
} |
49 |
|
50 |
/**
|
51 |
*
|
52 |
* @param flyr
|
53 |
*/
|
54 |
public void setRasterLayer(FLyrRaster flyr){ |
55 |
layer = flyr; |
56 |
} |
57 |
|
58 |
public void rectangle(RectangleEvent event) { |
59 |
super.rectangle(event);
|
60 |
|
61 |
if (PluginServices.getMainFrame() != null) |
62 |
PluginServices.getMainFrame().enableControls(); |
63 |
|
64 |
FLayers layers = mapCtrl.getMapContext().getLayers(); |
65 |
|
66 |
SaveRasterDialog saveRaster = new SaveRasterDialog(layers, mapCtrl);
|
67 |
ViewPort vp = mapCtrl.getViewPort(); |
68 |
Point2D ini = vp.fromMapPoint(rect.getMinX(), rect.getMinY());
|
69 |
Point2D fin = vp.fromMapPoint(rect.getMaxX(), rect.getMaxY());
|
70 |
if(Math.abs(fin.getY()-ini.getY())>10 && Math.abs(fin.getX()-ini.getX())>10){ |
71 |
SaveRasterPanel dialog = (SaveRasterPanel)saveRaster.getControlsPanel(); |
72 |
dialog.getBProperties().setEnabled(false);
|
73 |
dialog.setProjection(vp.getProjection()); |
74 |
dialog.setWidthInPixelsGeodesicas((int)Math.abs(fin.getX()-ini.getX())); |
75 |
dialog.setHeightInPixelsGeodesicas((int)Math.abs(fin.getY()-ini.getY())); |
76 |
|
77 |
int dec = 2; |
78 |
if(!vp.getProjection().isProjected())
|
79 |
dec = 6;
|
80 |
|
81 |
int indexPoint = String.valueOf(rect.getMaxX()).indexOf('.'); |
82 |
try{
|
83 |
dialog.getTInfDerX().setText(String.valueOf(rect.getMaxX()).substring(0,indexPoint + dec)); |
84 |
}catch(IndexOutOfBoundsException ex){ |
85 |
dialog.getTInfDerX().setText(String.valueOf(rect.getMaxX()));
|
86 |
} |
87 |
|
88 |
indexPoint = String.valueOf(rect.getMaxY()).indexOf('.'); |
89 |
try{
|
90 |
dialog.getTInfDerY().setText(String.valueOf(rect.getMinY()).substring(0,indexPoint + dec)); |
91 |
}catch(IndexOutOfBoundsException ex){ |
92 |
dialog.getTInfDerY().setText(String.valueOf(rect.getMinY()));
|
93 |
} |
94 |
|
95 |
indexPoint = String.valueOf(rect.getMinX()).indexOf('.'); |
96 |
try{
|
97 |
dialog.getTSupIzqX().setText(String.valueOf(rect.getMinX()).substring(0,indexPoint + dec)); |
98 |
}catch(IndexOutOfBoundsException ex){ |
99 |
dialog.getTSupIzqX().setText(String.valueOf(rect.getMinX()));
|
100 |
} |
101 |
|
102 |
indexPoint = String.valueOf(rect.getMinY()).indexOf('.'); |
103 |
try{
|
104 |
dialog.getTSupIzqY().setText(String.valueOf(rect.getMaxY()).substring(0,indexPoint + dec)); |
105 |
}catch(IndexOutOfBoundsException ex){ |
106 |
dialog.getTSupIzqY().setText(String.valueOf(rect.getMaxY()));
|
107 |
} |
108 |
|
109 |
PluginServices.getMDIManager().addWindow(saveRaster); |
110 |
} |
111 |
} |
112 |
} |