svn-gvsig-desktop / tags / v1_1_Build_1007 / extensions / extRasterTools / src / org / gvsig / rasterTools / saveRaster / ui / listener / SaveRasterListener.java @ 12478
History | View | Annotate | Download (4.48 KB)
1 | 4547 | nacho | /* 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 org.gvsig.rasterTools.saveRaster.ui.listener; |
||
42 | |||
43 | |||
44 | import java.awt.geom.Point2D; |
||
45 | |||
46 | import org.gvsig.rasterTools.saveRaster.tools.SaveRasterListenerImpl; |
||
47 | import org.gvsig.rasterTools.saveRaster.ui.main.SaveRasterControlsPanel; |
||
48 | import org.gvsig.rasterTools.saveRaster.ui.main.SaveRasterDefaultPanel; |
||
49 | |||
50 | import com.iver.andami.PluginServices; |
||
51 | import com.iver.cit.gvsig.fmap.MapControl; |
||
52 | import com.iver.cit.gvsig.fmap.ViewPort; |
||
53 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
54 | import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
||
55 | import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
||
56 | 8765 | jjdelcerro | import com.iver.cit.gvsig.project.documents.view.gui.View; |
57 | 4547 | nacho | |
58 | |||
59 | /**
|
||
60 | * Extensi?n de la clase SaveRasterListenerImpl de FMap para poder llamar a m?todos
|
||
61 | * de andami o de gvSIG.
|
||
62 | *
|
||
63 | * @author Nacho Brodin <brodin_ign@gva.es>
|
||
64 | */
|
||
65 | public class SaveRasterListener extends SaveRasterListenerImpl { |
||
66 | |||
67 | FLyrRaster layer = null;
|
||
68 | |||
69 | public SaveRasterListener(MapControl mapCtrl) {
|
||
70 | super(mapCtrl);
|
||
71 | } |
||
72 | |||
73 | /**
|
||
74 | *
|
||
75 | * @param flyr
|
||
76 | */
|
||
77 | public void setRasterLayer(FLyrRaster flyr){ |
||
78 | layer = flyr; |
||
79 | } |
||
80 | |||
81 | public void rectangle(RectangleEvent event) { |
||
82 | super.rectangle(event);
|
||
83 | |||
84 | if (PluginServices.getMainFrame() != null) |
||
85 | PluginServices.getMainFrame().enableControls(); |
||
86 | |||
87 | FLayers layers = mapCtrl.getMapContext().getLayers(); |
||
88 | |||
89 | SaveRasterDefaultPanel saveRaster = new SaveRasterDefaultPanel(layers, mapCtrl);
|
||
90 | ViewPort vp = mapCtrl.getViewPort(); |
||
91 | Point2D ini = vp.fromMapPoint(rect.getMinX(), rect.getMinY());
|
||
92 | Point2D fin = vp.fromMapPoint(rect.getMaxX(), rect.getMaxY());
|
||
93 | if(Math.abs(fin.getY()-ini.getY())>10 && Math.abs(fin.getX()-ini.getX())>10){ |
||
94 | 6880 | cesar | saveRaster.setProjection(((View) PluginServices.getMDIManager().getActiveWindow()).getProjection());
|
95 | 4547 | nacho | |
96 | SaveRasterControlsPanel dialog = (SaveRasterControlsPanel)saveRaster.getContentPanel(); |
||
97 | dialog.getBProperties().setEnabled(false);
|
||
98 | dialog.setProjection(vp.getProjection()); |
||
99 | dialog.setWidthInPixelsGeodesicas((int)Math.abs(fin.getX()-ini.getX())); |
||
100 | dialog.setHeightInPixelsGeodesicas((int)Math.abs(fin.getY()-ini.getY())); |
||
101 | |||
102 | int dec = 2; |
||
103 | if(!vp.getProjection().isProjected())
|
||
104 | dec = 6;
|
||
105 | |||
106 | int indexPoint = String.valueOf(rect.getMaxX()).indexOf('.'); |
||
107 | try{
|
||
108 | dialog.getTInfDerX().setText(String.valueOf(rect.getMaxX()).substring(0,indexPoint + dec)); |
||
109 | }catch(IndexOutOfBoundsException ex){ |
||
110 | dialog.getTInfDerX().setText(String.valueOf(rect.getMaxX()));
|
||
111 | } |
||
112 | |||
113 | indexPoint = String.valueOf(rect.getMaxY()).indexOf('.'); |
||
114 | try{
|
||
115 | dialog.getTInfDerY().setText(String.valueOf(rect.getMinY()).substring(0,indexPoint + dec)); |
||
116 | }catch(IndexOutOfBoundsException ex){ |
||
117 | dialog.getTInfDerY().setText(String.valueOf(rect.getMinY()));
|
||
118 | } |
||
119 | |||
120 | indexPoint = String.valueOf(rect.getMinX()).indexOf('.'); |
||
121 | try{
|
||
122 | dialog.getTSupIzqX().setText(String.valueOf(rect.getMinX()).substring(0,indexPoint + dec)); |
||
123 | }catch(IndexOutOfBoundsException ex){ |
||
124 | dialog.getTSupIzqX().setText(String.valueOf(rect.getMinX()));
|
||
125 | } |
||
126 | |||
127 | indexPoint = String.valueOf(rect.getMinY()).indexOf('.'); |
||
128 | try{
|
||
129 | dialog.getTSupIzqY().setText(String.valueOf(rect.getMaxY()).substring(0,indexPoint + dec)); |
||
130 | }catch(IndexOutOfBoundsException ex){ |
||
131 | dialog.getTSupIzqY().setText(String.valueOf(rect.getMaxY()));
|
||
132 | } |
||
133 | |||
134 | 6880 | cesar | PluginServices.getMDIManager().addWindow(saveRaster); |
135 | 4547 | nacho | } |
136 | } |
||
137 | } |