Statistics
| Revision:

root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / cmd / CmdSaveRaster.java @ 2249

History | View | Annotate | Download (4.44 KB)

1
/*
2
 * Created on 21-jun-2005
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package org.cresques.ui.cmd;
48

    
49
import java.awt.event.MouseEvent;
50
import java.awt.geom.Point2D;
51

    
52
import org.cresques.cts.IProjection;
53
import org.cresques.px.PxLayerList;
54
import org.cresques.ui.CQCursor;
55
import org.cresques.ui.CQMapCanvas;
56
import org.cresques.ui.CQSaveRaster;
57
import org.cresques.ui.raster.DataInputSaveRaster;
58
import org.cresques.ui.raster.SaveRasterDialogPanel;
59
import org.cresques.ui.raster.SaveSetupPanel;
60

    
61

    
62
/**
63
 * Comando save raster.
64
 * Permite seleccionar una zona del canvas para que pueda ser guardado
65
 * a formato raster georeferenciado.
66
 * @see org.cresques.geo.cover.Coverage
67
 * @author "Nacho Brodin" <brodin_ign@gva.es>
68
 */
69
public class CmdSaveRaster extends Cmd {
70
        
71
        private Point2D                         ptIni = null;
72
        private CQSaveRaster                saveRaster = null;
73
        private IProjection                        prj = null;
74
        private PxLayerList                        layerList = null;
75
                
76
        /**
77
         * Construye un nuevo CmdInfo para el Canvas
78
         * @param canvas
79
         */
80
        public CmdSaveRaster(CQMapCanvas canvas) {
81
                super(canvas);
82
                eventsWanted = (LEFT | RIGHT | PRESS | RELEASE | DRAG);
83
                cursor = CQCursor.getCursor(CQCursor.INFO_CURSOR);
84
        }
85

    
86
        /**
87
         * 
88
         * @param saveRaster
89
         */
90
        public void setCQSaveRaster(CQSaveRaster saveRaster){
91
                System.out.println("setCQSaveRaster");
92
                this.saveRaster = saveRaster;
93
                
94
        }
95
        
96
        /**
97
         * 
98
         * @param prj
99
         */
100
        public void setProjection(IProjection prj){
101
                System.out.println("setProjection");
102
                this.prj = prj;
103
                
104
        }
105
        
106
        /**
107
         * 
108
         * @param layerList
109
         */
110
        public void setLayerList(PxLayerList layerList){
111
                System.out.println("setLayerList");
112
                this.layerList = layerList;
113
                
114
        }
115
        
116
        /**
117
         * Recibe los eventos del rat?n.
118
         */
119
        public void cmd(Point2D pt, int bt, int mouseEvent) {
120
                //System.out.println("Save Raster: Evento = "+ mouseEvent);
121
                if (mouseEvent == PRESS && bt == MouseEvent.BUTTON1) {
122
                        ptIni = pt;
123
                } else if (mouseEvent == RELEASE && bt == MouseEvent.BUTTON1) {
124
                        if (pt.getX() == ptIni.getX() || pt.getY() == ptIni.getY()) {
125
                                System.err.println("Ptos coincidentes");
126
                        }else{
127
                                double iniX, iniY, finX, finY;
128
                                if(pt.getX()>ptIni.getX()){
129
                                        iniX =  ptIni.getX();
130
                                        finX = pt.getX();
131
                                }else{
132
                                        finX =  ptIni.getX();
133
                                        iniX = pt.getX();
134
                                }
135
                                if(pt.getY()>ptIni.getY()){
136
                                        iniY =  ptIni.getY();
137
                                        finY = pt.getY();
138
                                }else{
139
                                        finY =  ptIni.getY();
140
                                        iniY = pt.getY();
141
                                }
142
                                
143
                                
144
                                saveRaster.setProjection(this.prj);
145
                                saveRaster.setLayerList(this.layerList);
146
                                DataInputSaveRaster dialog = ((SaveSetupPanel)(((SaveRasterDialogPanel)saveRaster.getContentPane()).getContentPanel())).getSaveParameters();
147
                                int indexPoint = String.valueOf(finX).indexOf('.');
148
                                dialog.getTinf_derX().setText(String.valueOf(finX).substring(0,indexPoint+2));
149
                                indexPoint = String.valueOf(finY).indexOf('.');
150
                                dialog.getTinf_derY().setText(String.valueOf(finY).substring(0,indexPoint+2));
151
                                indexPoint = String.valueOf(iniX).indexOf('.');
152
                                dialog.getTsup_izqX().setText(String.valueOf(iniX).substring(0,indexPoint+2));
153
                                indexPoint = String.valueOf(iniY).indexOf('.');
154
                                dialog.getTsup_izqY().setText(String.valueOf(iniY).substring(0,indexPoint+2));
155
                                saveRaster.show();
156
                                
157
                        }
158
                                
159
                } 
160
        }
161
}