Revision 7823

View differences:

trunk/libraries/libJCRS/src/org/gvsig/crs/ogr/GetTransepsg.java
7 7
import org.gvsig.crs.Query;
8 8

  
9 9
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel;
10
import org.gvsig.crs.gui.panels.ProjChooserPanelTransformation;
11 10

  
12 11
public class GetTransepsg {
13 12
	int parameter_code = 0;
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/CRSSelectionDialogPanel.java
3 3
import java.awt.event.ActionEvent;
4 4
import java.awt.event.ActionListener;
5 5

  
6
import javax.swing.JOptionPane;
6 7
import javax.swing.JPanel;
7 8
import javax.swing.ListSelectionModel;
8 9
import javax.swing.event.ListSelectionEvent;
......
75 76
    }	
76 77

  
77 78
	public void valueChanged(ListSelectionEvent e) {
79
		String[] not_soported = {"engineering", "vertical", "compound", "geocentric"};
80
		boolean soported = true;
78 81
		ListSelectionModel lsm = (ListSelectionModel)e.getSource();
79 82
        if (lsm.isSelectionEmpty()) {
80 83
        	vp.ep.selectedRowTable = -1;
......
85 88
        } 
86 89
        else {        	
87 90
        	vp.ep.selectedRowTable = lsm.getMinSelectionIndex();
88
        	vp.ep.setCodeCRS(Integer.parseInt((String)vp.ep.dtm.getValueAt(vp.ep.selectedRowTable,0)));
89
        	vp.ep.setWKT();
90
        	setCode(vp.ep.epsg_code);
91
        	vp.getButtonAccept().setEnabled(true);
92
        	vp.ep.getInfoCrs().setEnabled(true);  
91
        	String crs_kind = (String)vp.ep.dtm.getValueAt(vp.ep.selectedRowTable,2);
92
        	for (int i = 0; i < not_soported.length; i++) {
93
        		if (crs_kind.equals(not_soported[i])){
94
        			soported = false;
95
        		}
96
        	}
97
        	if (soported){
98
        		vp.ep.setCodeCRS(Integer.parseInt((String)vp.ep.dtm.getValueAt(vp.ep.selectedRowTable,0)));
99
            	vp.ep.setWKT();
100
            	setCode(vp.ep.epsg_code);
101
            	vp.getButtonAccept().setEnabled(true);
102
            	
103
        	}
104
        	else {
105
        		JOptionPane.showMessageDialog(this, "CRS no soportado.", "Warning...",
106
						JOptionPane.WARNING_MESSAGE);
107
        		vp.ep.setCodeCRS(-1);
108
        		setCode(0);
109
        		vp.getButtonAccept().setEnabled(false);
110
        	}
111
        	vp.ep.getInfoCrs().setEnabled(true);
112
        	  
93 113
        }
94 114
              
95 115
	}
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/dialog/TRSelectionDialog.java
24 24
	private static final long serialVersionUID = 1L;
25 25
	private boolean okPressed = false;
26 26
	private IProjection lastProj = null;
27
	boolean targetNad = false;
27 28

  
28 29
	/**
29 30
	 * 
......
41 42
		this.setBounds(0, 0, 600, 500);
42 43
		this.setLayout(new GridLayout(0,1));
43 44
		this.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
44
		//PluginServices.getMDIManager().addWindow(this);
45
		
45 46
				
46 47
	}
47 48
	
48 49
	public boolean isOkPressed() { return okPressed; }
49 50
	
51
	public void setTargetNad(boolean tarNad){
52
		targetNad = tarNad;
53
	}
54
	
55
	public boolean getTargetNad(){
56
		return targetNad;
57
	}
58
	
50 59
	/**
51 60
	 * @return
52 61
	 */
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/ProjChooserPanelTransformation.java
1
package org.gvsig.crs.gui.panels;
2

  
3
import java.awt.FlowLayout;
4
import java.awt.GridLayout;
5
import java.awt.event.ActionListener;
6
import java.awt.event.ComponentEvent;
7
import java.awt.event.ComponentListener;
8
import java.awt.event.WindowEvent;
9
import java.awt.event.WindowListener;
10

  
11
import javax.swing.JButton;
12
import javax.swing.JFrame;
13
import javax.swing.JLabel;
14
import javax.swing.JPanel;
15

  
16
import org.cresques.cts.IProjection;
17
import org.gvsig.crs.EpsgConnection;
18
import org.gvsig.crs.ICrs;
19

  
20

  
21
import com.iver.andami.PluginServices;
22
import com.iver.cit.gvsig.gui.FOpenDialog;
23
import org.gvsig.crs.gui.dialog.TRSelectionDialog;
24

  
25
/**
26
 * @author Jos? Luis G?mez y Miguel Garc?a
27
 */
28
public class ProjChooserPanelTransformation extends JPanel {
29
    
30
	private static final long serialVersionUID = 1L;
31
	
32
	private static IProjection curProj = null; //(IProjection) new CRSFactory().getCRS("EPSG:23030");
33
	private JLabel jLblProj = null;
34
	private JLabel jLblProjName = null;
35
	private JButton jBtnChangeProj = null;
36
	private boolean okPressed = false;
37
	private String abrev;
38
	
39
	public EpsgConnection connect = null;
40

  
41
	private ActionListener actionListener = null;
42
	
43
	/**
44
	 *
45
	 */
46
	public ProjChooserPanelTransformation(IProjection proj) {
47
		super();
48
		setCurProj(proj);
49
		initialize();
50
	}
51
	
52
	public ProjChooserPanelTransformation(){
53
		  connect = new EpsgConnection();
54
		  connect.setConnection();
55
	}
56

  
57
	/**
58
	 * This method initializes this
59
	 *
60
	 * @return void
61
	 */
62
	private void initialize() {
63
        this.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 0));
64
        setPreferredSize(new java.awt.Dimension(330,35));
65
        this.setSize(new java.awt.Dimension(330,23));
66
        this.add(getJLblProjName(), null);
67
        this.add(getJLblProj(), null);
68
        this.add(getJBtnChangeProj(), null);
69
        //cambiar cuando la parte de JLuis se ensamble
70
        if(!((ICrs)curProj).getAbrev().equals("EPSG:23030"))
71
        	jLblProj.setText(((ICrs)curProj).getCrsWkt().getName());
72
        else
73
        	jLblProj.setText("EPSG:23030");
74
		initBtnChangeProj();
75
	}
76

  
77
	private void initBtnChangeProj() {
78
		getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
79
			public void actionPerformed(java.awt.event.ActionEvent e) {
80
				okPressed = false;
81
				TRSelectionDialog csSelect = new TRSelectionDialog();
82
				csSelect.setProjection(curProj);
83
		        
84
				csSelect.setLayout(new GridLayout(0,1));
85
				
86
				PluginServices.getMDIManager().addWindow(csSelect);
87
		        abrev = curProj.getAbrev();
88

  
89
		        if (csSelect.getProjection() != curProj) {
90
		        	curProj = csSelect.getProjection();
91
		        	abrev = csSelect.getProjectionName();
92
		        	jLblProj.setText(abrev);
93
		        	FOpenDialog.setLastProjection(curProj);
94
		        	okPressed = true;
95
		        	if (actionListener != null) {
96
		        		actionListener.actionPerformed(e);
97
		        	}
98
		        }else
99
		        	jLblProj.setText(abrev);	
100
			}
101
		});
102
	}
103

  
104
	public JLabel getJLblProjName() {
105
		if (jLblProjName == null) {
106
	        jLblProjName = new JLabel("Proyeccion actual");
107
			jLblProjName.setText(PluginServices.getText(this,"__proyeccion_actual")); //$NON-NLS-1$
108
		}
109
		return jLblProjName;
110
	}
111

  
112
	public JLabel getJLblProj() {
113
		if (jLblProj == null) {
114
	        jLblProj = new JLabel();
115
			jLblProj.setText(curProj.getAbrev());
116
		}
117
		return jLblProj;
118
	}
119
	public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) {
120
		jBtnChangeProj.addActionListener(al);
121
	}
122

  
123
	/**
124
	 * This method initializes jButton
125
	 *
126
	 * @return javax.swing.JButton
127
	 */
128
	public JButton getJBtnChangeProj() {
129
		if (jBtnChangeProj == null) {
130
			jBtnChangeProj = new JButton();
131
			jBtnChangeProj.setText("..."); //$NON-NLS-1$
132
		}
133
		return jBtnChangeProj;
134
	}
135
	/**
136
	 * @return Returns the curProj.
137
	 */
138
	public static IProjection getCurProj() {
139
		return curProj;
140
	}
141
	/**
142
	 * @param curProj The curProj to set.
143
	 */
144
	public void setCurProj(IProjection curProj) {
145
		this.curProj = curProj;
146
	}
147
	/**
148
	 * @return Returns the okPressed.
149
	 */
150
	public boolean isOkPressed() {
151
		return okPressed;
152
	}
153
	/**
154
	 * @param actionListener The actionListener to set.
155
	 */
156
	public void addActionListener(ActionListener actionListener) {
157
		this.actionListener = actionListener;
158
	}
159

  
160
}  //  @jve:decl-index=0:visual-constraint="10,10"
161

  
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationManualPanel.java
24 24
import com.iver.andami.PluginServices;
25 25
import com.iver.andami.ui.mdiManager.IWindow;
26 26
import com.iver.andami.ui.mdiManager.WindowInfo;
27
import org.gvsig.crs.gui.panels.ProjChooserPanelTransformation;
28 27

  
29 28
public class TransformationManualPanel extends JPanel{
30 29
	
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationEpsgPanel.java
35 35
import com.iver.andami.PluginServices;
36 36
import com.iver.andami.ui.mdiManager.IWindow;
37 37
import com.iver.andami.ui.mdiManager.WindowInfo;
38
import org.gvsig.crs.gui.panels.ProjChooserPanelTransformation;
39 38

  
40 39
public class TransformationEpsgPanel extends JPanel {
41 40

  
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/ProjChooserPanel.java
36 36
	private static boolean okPressed = false;
37 37
	private String abrev;
38 38
	boolean panel = false;
39
	boolean targetNad = false;
39 40
	
40 41
	public EpsgConnection connect = null;
41 42

  
......
104 105
				else {
105 106
					okPressed = false;
106 107
					trSelect = new TRSelectionDialog();
108
					
107 109
					trSelect.setProjection(curProj);
108 110
			        
109 111
					trSelect.setLayout(new GridLayout(0,1));
110 112
					
111 113
					PluginServices.getMDIManager().addWindow(trSelect);
114
					setTargetNad(trSelect.getTargetNad());
112 115
			        abrev = curProj.getAbrev();
113 116
			        
114 117
			        if (trSelect.getProjection() != curProj) {
......
124 127
			        	jLblProj.setText(abrev);
125 128
					
126 129
				}
127
				
128
		       /* IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
129
		    	View activeView = (com.iver.cit.gvsig.gui.View) activeWindow;
130
		        if(activeView.getMapControl() == null)*/
131
		        	
130
					        	
132 131
			}
133 132
		});
134 133
	}
......
164 163
		}
165 164
		return jBtnChangeProj;
166 165
	}
166
	
167
	public void setTargetNad(boolean tarNad){
168
		targetNad = tarNad;
169
	}
170
	
171
	public boolean getTargetNad(){
172
		return targetNad;
173
	}
174
	
167 175
	/**
168 176
	 * @return Returns the curProj.
169 177
	 */
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/EPSGpanel.java
47 47
	JLabel jLabel = null;
48 48
	JTextField crsTextFld = null;	
49 49
	
50
	
51
	
52 50
	String cadWKT = "";
53 51
	
54 52
	int transf = 0;
......
58 56
	int method_code = 0;
59 57
	int datum_code = 0;
60 58
	int projection_conv_code = 0;
61
	String crs_kind = null;
59
	public String crs_kind = null;
62 60
	int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, 
63 61
			9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659};
64 62
	boolean select = false;
65 63
	
66
	String[] soported_crs = {"projected","geographic 2D","geographic 3D"};
67
	String[] not_soported_crs = {"engineering", "vertical", "compound", "geocentric"};
64
	String[] soported_crs = {"projected","geographic 2D","geographic 3D", "engineering", "vertical", "compound", "geocentric"};
65
	String[] not_soported_crs = {};
68 66
	
69 67
	private JRadioButton codeRadioButton = null;
70 68
	private JRadioButton nameRadioButton = null;
71 69
	private JRadioButton areaRadioButton = null;
72 70
	private JPanel groupRadioButton = null;	
73 71
	
74
	final static String epsg = "EPSG";
75
	final static String usgs = "USGS";
76
	final static String esri = "ESRI";
77
	
78
	String[] selection = {epsg, usgs, esri, "Nuevo CRS"};
79
	
80 72
	boolean inAnApplet = true;
81 73
	
82 74
	public EpsgConnection connect = null;
......
120 112
	
121 113
	private void codeRadioButton_actionPerformed(ActionEvent e) {
122 114
		searchTextField.setText("");
115
		codeRadioButton.setSelected(true);
123 116
		nameRadioButton.setSelected(false);
124 117
		areaRadioButton.setSelected(false);
125 118
	}
......
140 133
	
141 134
	private void nameRadioButton_actionPerformed(ActionEvent e) {
142 135
		searchTextField.setText("");
136
		nameRadioButton.setSelected(true);
143 137
		codeRadioButton.setSelected(false);
144 138
		areaRadioButton.setSelected(false);
145 139
	}
......
159 153
	
160 154
	private void areaRadioButton_actionPerformed(ActionEvent e) {
161 155
		searchTextField.setText("");
156
		areaRadioButton.setSelected(true);
162 157
		codeRadioButton.setSelected(false);
163 158
		nameRadioButton.setSelected(false);
164 159
	}
......
337 332
			}
338 333
			int numr = dtm.getRowCount();
339 334
			if (not_valid){
340
				JOptionPane.showMessageDialog(this, "Algunos CRS no son v?lidos, no ser?n mostrados.", "Warning...",
335
				JOptionPane.showMessageDialog(this, "CRS no soportado.", "Warning...",
341 336
						JOptionPane.WARNING_MESSAGE);
342 337
				not_valid = false;
343 338
			}
......
346 341
					JOptionPane.WARNING_MESSAGE);
347 342
			}
348 343
			else{
349
				this.getJTable().setRowSelectionInterval(0,0);
350
				/*
351
				 * Aqui tengo que meter el codigo necesario para que se seleccione
352
				 * la primera fila ya que me he asegurado de que no esta vacia
353
				 * y tengo que seleccionar la primera fila.
354
				 */
344
				this.getJTable().setRowSelectionInterval(0,0);				
355 345
			}
356 346
		}		
357 347
	}	
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationNadgridsPanel.java
13 13
import javax.swing.JFileChooser;
14 14
import javax.swing.JLabel;
15 15
import javax.swing.JPanel;
16
import javax.swing.JRadioButton;
16 17
import javax.swing.JScrollPane;
17 18
import javax.swing.JTextArea;
18 19
import javax.swing.JTextField;
19 20

  
20 21
import org.cresques.cts.IProjection;
21 22
import org.cresques.ui.DefaultDialogPanel;
23
import org.gvsig.crs.CrsException;
22 24
import org.gvsig.crs.CrsFactory;
23 25
import org.gvsig.crs.ICrs;
24 26

  
......
30 32
	
31 33
	private static final long serialVersionUID = 1L;
32 34
	
35
	private JPanel groupRadioButton = null;
36
	private JLabel chooserLabel = null;
37
	private JRadioButton sourceRadioButton = null;
38
	private JRadioButton targetRadioButton = null;
39
	
33 40
	private IProjection firstProj;
34
	private String nad = "+nadgrids=sped2et.gsb";
41
	private String nad = null;
35 42
		
36 43
	private String cadWKT = "";
37 44
	private int codeEpsg;
......
47 54
	private JLabel wkt;
48 55
	private JTextArea info;
49 56
	private JScrollPane areaScrollPane;
57
	boolean targetNad = false;
50 58

  
51
	public TransformationNadgridsPanel() {		
59
	public TransformationNadgridsPanel() {
60
		nad = "+nadgrids=sped2et.gsb";
52 61
	}
53 62
		
54 63
	public JPanel getJPanel(){
55 64
		if (panel == null) {
56 65
			panel = new JPanel();
57
			panel.setLayout(new GridLayout(1,2));
66
			panel.setLayout(new GridLayout(1,4));
58 67
			panel.setLayout(new FlowLayout(FlowLayout.LEADING,5,10));
59 68
			panel.setPreferredSize(new Dimension(525, 110));
60 69
			panel.setBorder(
......
66 75
			panel.add(getLabel());
67 76
			panel.add(getScrollPanelArea());
68 77
			panel.add(getOpenPanel());
78
			panel.add(getJLabel());
79
			panel.add(getGroupRadioButton());
69 80
		}
70 81
		return panel;
71 82
	}
72 83
	
84
	private JPanel getGroupRadioButton() {
85
		if (groupRadioButton == null) {
86
			groupRadioButton = new JPanel();
87
			groupRadioButton.setLayout(new GridLayout(1,0));
88
			groupRadioButton.setPreferredSize(new Dimension(400,30));			
89
			groupRadioButton.add(getNadgridsSource());
90
			groupRadioButton.add(getNadgridsTarget());			
91
		}
92
		return groupRadioButton;
93
	}
94
	
95
	private JRadioButton getNadgridsSource() {
96
		if (sourceRadioButton == null) {
97
			sourceRadioButton = new JRadioButton();
98
			sourceRadioButton.setText(PluginServices.getText(this,"Aplicar a fuente"));//setText("By Code EPSG");
99
			sourceRadioButton.setSelected(true);
100
			sourceRadioButton.addActionListener(new java.awt.event.ActionListener() { 
101
				public void actionPerformed(java.awt.event.ActionEvent e) {    
102
					sourceRadioButton_actionPerformed(e);
103
				}
104
			});
105
		}
106
		return sourceRadioButton;
107
	}
108
	
109
	private void sourceRadioButton_actionPerformed(ActionEvent e) {		
110
		sourceRadioButton.setSelected(true);
111
		targetRadioButton.setSelected(false);
112
	}
113
	
114
	private JRadioButton getNadgridsTarget() {		
115
		if (targetRadioButton == null) {
116
			targetRadioButton = new JRadioButton();
117
			targetRadioButton.setText(PluginServices.getText(this,"Aplicar a destino"));//setText("By Code EPSG");
118
			targetRadioButton.setSelected(false);
119
			targetRadioButton.addActionListener(new java.awt.event.ActionListener() { 
120
				public void actionPerformed(java.awt.event.ActionEvent e) {    
121
					targetRadioButton_actionPerformed(e);
122
				}
123
			});
124
		}
125
		return targetRadioButton;
126
	}
127
	
128
	private void targetRadioButton_actionPerformed(ActionEvent e) {		
129
		targetRadioButton.setSelected(true);
130
		sourceRadioButton.setSelected(false);
131
	}
132
	
133
	private JLabel getJLabel(){
134
		chooserLabel = new JLabel();
135
		chooserLabel.setPreferredSize(new Dimension(400, 20));
136
		chooserLabel.setText(PluginServices.getText(this, "Seleccione donde quiere aplicar Nadgrids: "));
137
		return chooserLabel;
138
	}
139
	
73 140
	private JScrollPane getScrollPanelArea() {
74 141
		if(areaScrollPane == null) {
75 142
			areaScrollPane = new JScrollPane(getInfo());
......
172 239
    }
173 240
	
174 241
	public ICrs getProjection() {
175
		try {
176
			ICrs crs = new CrsFactory().getCRS(getCode(),
177
					getWKT(),nad);
178
			return crs;
179
		} catch (org.gvsig.crs.CrsException e) {
180
			e.printStackTrace();
242
		ICrs crs;
243
		if (sourceRadioButton.isSelected()){
244
			try {
245
				setNad(false);
246
				crs = new CrsFactory().getCRS(getCode(),
247
						getWKT(),nad);
248
				return crs;
249
			} catch (org.gvsig.crs.CrsException e) {
250
				e.printStackTrace();
251
			}
252
			return null;
181 253
		}
182
		return null;
254
		else {	
255
			setNad(true);
256
			try {
257
				crs = new CrsFactory().getCRS(getCode(),
258
						getWKT());
259
				return crs;
260
			} catch (CrsException e) {				
261
				e.printStackTrace();
262
			}
263
			return null;
264
		}		
183 265
	}
184 266
	
185 267
	public void setProjection(IProjection proj) {
186 268
		firstProj = proj;
187 269
	}
188 270
	
271
	public void setNad(boolean nadg){
272
		targetNad = nadg;		
273
	}
274
	
275
	public boolean getNad(){
276
		return targetNad;		
277
	}
278
	
189 279
	public void setCode(int cod){
190 280
		codeEpsg = cod;
191 281
	}
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/CRSLayerPanel.java
48 48
	public JButton before = null;
49 49
	private JPanel jPanelButton = null;
50 50
	
51
	boolean targetNad = false;	
51 52
	
52 53
	int crs_target = -1;
53 54
	String datum_target = "";
......
67 68
	TransformationNadgridsPanel nads = null;
68 69
	boolean nads_tr = false;
69 70
	
71
	boolean sin_tr = false;
72
	
70 73
	//Container contentPane = null;
71 74
	
72 75
	private JPanel Combopanel = null;
......
161 164
			options = new JComboBox(selection);
162 165
			options.setPreferredSize(new Dimension(150,25));	
163 166
			options.setEnabled(false);
164
			options.setEditable(false);
167
			options.setEditable(false);			
165 168
			options.setSelectedIndex(0);
166
			newSelection = (String) options.getSelectedItem();
167
			//options.addItemListener(this);			
169
			newSelection = (String) options.getSelectedItem();			
168 170
		}
169 171
		options.addActionListener(new ActionListener() {
170 172
			public void actionPerformed(ActionEvent e) {
......
250 252
		}
251 253
		else if (nads_tr) {
252 254
			setProjection(nads.getProjection());
255
			setTargetNad(nads.getNad());
253 256
			nads_tr = false;
254 257
		}
255 258
		else{
259
			sin_tr = true;
256 260
			setProjection(this.getProjection());
257
		}		
261
		}
262
		
258 263
		PluginServices.getMDIManager().closeWindow(this);
259 264
	}
260 265
	
......
324 329
		PluginServices.getMDIManager().closeWindow(this);
325 330
	}
326 331
	
332
	public void setTargetNad(boolean tarNad){
333
		targetNad = tarNad;
334
	}
335
	
336
	public boolean getTargetNad(){
337
		return targetNad;
338
	}
339
	
340
	/*
341
	 * revisar esta solucion
342
	 */
327 343
	public ICrs getProjection() {
328
		ICrs crs;
329
		try {
330
			if(CRSPanel.ep.getCodeCRS() == -1 || cancelYes == true){
331
				cancelYes = false;
332
				return (ICrs)crsfirst;
333
			}
334
			else {
335
				crs = new CrsFactory().getCRS(CRSPanel.ep.getCodeCRS(),CRSPanel.ep.getWKT());			
344
		if (sin_tr) {
345
			ICrs crs;
346
			try {
347
				crs = new CrsFactory().getCRS(CRSPanel.ep.getCodeCRS(),CRSPanel.ep.getWKT());
348
				sin_tr = false;
336 349
				return crs;
350
			} catch (CrsException e) {
351
				e.printStackTrace();
337 352
			}
338
			
339
		} catch (CrsException e) {
340
			e.printStackTrace();
341
		}
342
		return null;
353
			return null;
354
		}		
355
		return (ICrs) crsfirst;		
343 356
	}
344 357
	
345 358
	public void setProjection(IProjection proj) {

Also available in: Unified diff