Revision 38008

View differences:

tags/v2_0_0_Build_2045/libraries/libProjection/src-test/org/cresques/cts/AllTests.java
1
package org.cresques.cts;
2

  
3
import junit.framework.Test;
4
import junit.framework.TestSuite;
5

  
6
public class AllTests {
7

  
8
	public static Test suite() {
9
		TestSuite suite = new TestSuite("Test for org.cresques.cts");
10
		//$JUnit-BEGIN$
11

  
12
		//$JUnit-END$
13
		return suite;
14
	}
15

  
16
}
0 17

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text.properties
1
#Translations for language [es]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceptar
4
Aplicar=Aplicar
5
Block_Size_=Tama\u00f1o de bloque\:
6
Cancelar=Cancelar
7
Compression_=Compresi\u00f3n\:
8
datum=Datum
9
Generate_Tfw_=Generar Tfw\:
10
Interleave_=Entrelazado\:
11
Photometric_=Fotom\u00e9trica\:
12
Progressive_=Progresivo\:
13
projection=Proyecci\u00f3n
14
reference_system=Sistema de Referencia
15
zone=Huso
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_en.properties
1
#Translations for language [en]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Accept
4
Aplicar=Apply
5
Block_Size_=Block Size\:
6
Cancelar=Cancel
7
Compression_=Compression\:
8
datum=Datum
9
Generate_Tfw_=Generate Tfw\:
10
Interleave_=Interleave\:
11
Photometric_=Photometric\:
12
Progressive_=Progressive\:
13
projection=Projection
14
reference_system=Reference System
15
zone=Zone
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_gl.properties
1
#Translations for language [gl]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceptar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancelar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_ca.properties
1
#Translations for language [ca]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Acceptar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancel\u00b7lar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=Projecci\u00f3
14
reference_system=Sistema de refer\u00e8ncia
15
zone=
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_pt.properties
1
#Translations for language [pt]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceitar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancelar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_cs.properties
1
#Translations for language [cs]
2
#Mon Nov 06 09:04:31 CET 2006
3
Aceptar=Budi\u017e
4
Aplicar=Pou\u017e\u00edt
5
Block_Size_=
6
Cancelar=Zru\u0161it
7
Compression_=
8
datum=Datum
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=Projekce
14
reference_system=Prostorov\u00fd referen\u010dn\u00ed syst\u00e9m
15
zone=Z\u00f3na
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_fr.properties
1
#Translations for language [fr]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Accepter
4
Aplicar=Appliquer
5
Block_Size_=
6
Cancelar=Annuler
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_de.properties
1
#Translations for language [de]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=OK
4
Aplicar=Anwenden
5
Block_Size_=
6
Cancelar=Abbrechen
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_eu.properties
1
#Translations for language [eu]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Ados
4
Aplicar=Aplikatu
5
Block_Size_=
6
Cancelar=Utzi
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/config/org/cresques/resources/i18n/text_it.properties
1
#Translations for language [it]
2
#Tue Nov 07 12:30:01 CET 2006
3
Aceptar=Accetta
4
Aplicar=Applica
5
Block_Size_=Dimensioni blocco\:
6
Cancelar=Cancella
7
Compression_=Compressione
8
datum=Datum
9
Generate_Tfw_=Genera Tfw\:
10
Interleave_=Interlacciato\:
11
Photometric_=Fotometrica\:
12
Progressive_=Progressivo\:
13
projection=Proiezione
14
reference_system=Sistema di riferimento
15
zone=Fuso
0 16

  
tags/v2_0_0_Build_2045/libraries/libProjection/resources-test/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
5

  
6
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
7
		<layout class="org.apache.log4j.PatternLayout">
8
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
9
		</layout>
10
	</appender>
11

  
12
	<category name="org.gvsig.tools">
13
		<priority value="DEBUG" />
14
	</category>
15
	<category name="org.cresques">
16
		<priority value="DEBUG" /> 
17
	</category>
18
	<category name="org.gvsig.fmap.crs">
19
		<priority value="DEBUG" /> 
20
	</category>
21

  
22
	<root>
23
		<priority value="INFO" />
24
		<appender-ref ref="CONSOLE" />
25
	</root>
26
</log4j:configuration>
tags/v2_0_0_Build_2045/libraries/libProjection/src/org/cresques/CRSFactoryNotRegisteredException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}   {Create a base Locator implementation}
26
 */
27
package org.cresques;
28

  
29
import org.gvsig.tools.exception.BaseRuntimeException;
30

  
31
/**
32
 * Exception for errors related to the initialization of a Library.
33
 * 
34
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
35
 */
36
public class CRSFactoryNotRegisteredException extends BaseRuntimeException {
37

  
38
	private static final long serialVersionUID = 7354573543115812224L;
39

  
40
	private static final String KEY = "_CRSFactoryNotRegisteredException";
41

  
42
    private static final String MESSAGE = "An instance of ICRSFactory has not " +
43
    		"been registered in the CRSFactory";
44

  
45
    public CRSFactoryNotRegisteredException() {
46
        super(MESSAGE, KEY, serialVersionUID);
47
    }
48
}
tags/v2_0_0_Build_2045/libraries/libProjection/src/org/cresques/ui/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/v2_0_0_Build_2045/libraries/libProjection/src/org/cresques/ui/package.html
1
<html>
2
	<body>User Interface: Clases para interface de usuario.
3
</body>
4
</html>
0 5

  
tags/v2_0_0_Build_2045/libraries/libProjection/src/org/cresques/ui/DefaultDialogPanel.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.ui;
25

  
26
import java.awt.FlowLayout;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.event.ComponentEvent;
30
import java.awt.event.ComponentListener;
31

  
32
import javax.swing.JButton;
33
import javax.swing.JPanel;
34

  
35
import org.cresques.Messages;
36

  
37

  
38
/**
39
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
40
 */
41
public class DefaultDialogPanel extends JPanel implements ComponentListener{
42
    final private static long serialVersionUID = -3370601314380922368L;
43
    protected JPanel contentPane = null;
44
    private JPanel tabPane = null;
45
    protected JPanel buttonPane = null;
46
    private JButton acceptButton = null;
47
    private JButton cancelButton = null;
48
    private int flag = 0;
49
    protected int cWidth = 0, difWidth = 0;
50
    protected int cHeight = 0, difHeight = 0;
51
	protected JPanel pButton = null;
52

  
53
    /**
54
     * Constructor
55
     * @param init
56
     */
57
    public DefaultDialogPanel(boolean init){
58
    	if(init)
59
    		initialize();
60
    }
61

  
62
    /**
63
     * Constructor
64
     */
65
    public DefaultDialogPanel() {
66
        super();
67
        this.initialize();
68
    }
69

  
70
    /**
71
     * This method initializes this
72
     *
73
     * @return void
74
     */
75
    public void initialize() {
76
        //setBounds(0,0,321,230);
77
        //javax.swing.BoxLayout(jContentPane, javax.swing.BoxLayout.Y_AXIS);
78
        //jContentPane.setLayout(new java.awt.GridLayout(2,1));
79
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
80
        gridBagConstraints11.gridx = 0;
81
        gridBagConstraints11.insets = new java.awt.Insets(4,0,0,0);
82
        gridBagConstraints11.gridy = 1;
83
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
84
        gridBagConstraints.insets = new java.awt.Insets(5,0,2,0);
85
        gridBagConstraints.gridy = 0;
86
        gridBagConstraints.gridx = 0;
87
        setLayout(new GridBagLayout());
88
        setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
89

  
90
        //jContentPane.setSize(30, 24);
91
        this.setPreferredSize(new java.awt.Dimension(320, 165));
92
        this.add(getTabPanel(), gridBagConstraints);
93
        this.add(getPButton(), gridBagConstraints11);
94
        this.addComponentListener(this);
95

  
96
    }
97

  
98
    /**
99
     * Obtiene el panel general
100
     * @return
101
     */
102
    protected JPanel getContentPanel() {
103
        if (contentPane == null) {
104
            contentPane = new JPanel();
105
            contentPane.setLayout(new GridBagLayout());
106
            contentPane.setBounds(6, 200, 310, 125);
107
            contentPane.setPreferredSize(new java.awt.Dimension(310, 100));
108
        }
109

  
110
        return contentPane;
111
    }
112

  
113
    public JPanel getTabPanel() {
114
        if (tabPane == null) {
115
            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
116
            gridBagConstraints2.insets = new java.awt.Insets(5,0,0,0);
117
            gridBagConstraints2.gridy = 0;
118
            gridBagConstraints2.gridx = 0;
119
            tabPane = new JPanel();
120
            tabPane.setLayout(new GridBagLayout());
121

  
122

  
123
            //tabPane.setBounds(6, 7, 309, 189);
124
            tabPane.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.RAISED));
125
            tabPane.add(getContentPanel(), gridBagConstraints2);
126
        }
127

  
128
        return tabPane;
129
    }
130

  
131
    /**
132
	 * This method initializes jPanel
133
	 *
134
	 * @return javax.swing.JPanel
135
	 */
136
	private JPanel getPButton() {
137
		if (pButton == null) {
138
			FlowLayout flowLayout1 = new FlowLayout();
139
			flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
140
			flowLayout1.setHgap(0);
141
			flowLayout1.setVgap(0);
142
			pButton = new JPanel();
143
			pButton.setPreferredSize(new java.awt.Dimension(320,25));
144
			pButton.setLayout(flowLayout1);
145
			pButton.add(getButtonPanel(), null);
146
		}
147
		return pButton;
148
	}
149

  
150

  
151
    /**
152
     * Obtiene el panel que contiene los botones de Aceptar, Cancelar y Aplicar
153
     * @return
154
     */
155
    protected JPanel getButtonPanel() {
156
        if (buttonPane == null) {
157
            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
158
            gridBagConstraints3.gridx = 1;
159
            gridBagConstraints3.insets = new java.awt.Insets(0,3,0,3);
160
            gridBagConstraints3.gridy = 0;
161
            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
162
            gridBagConstraints1.insets = new java.awt.Insets(0,0,0,3);
163
            gridBagConstraints1.gridy = 0;
164
            gridBagConstraints1.gridx = 0;
165
            buttonPane = new JPanel();
166
            buttonPane.setLayout(new GridBagLayout());
167
            buttonPane.add(getAcceptButton(), gridBagConstraints1);
168
            buttonPane.add(getCancelButton(), gridBagConstraints3);
169
        }
170

  
171
        return buttonPane;
172
    }
173

  
174
    /**
175
     * This method initializes Accept button
176
     *
177
     * @return javax.swing.JButton
178
     */
179
    public JButton getAcceptButton() {
180
        if (acceptButton == null) {
181
            acceptButton = new JButton("Aceptar");
182
            acceptButton.setText(Messages.getText("Aceptar"));
183
        }
184

  
185
        return acceptButton;
186
    }
187

  
188
    /**
189
     * This method initializes Cancel Button
190
     *
191
     * @return javax.swing.JButton
192
     */
193
    public JButton getCancelButton() {
194
        if (cancelButton == null) {
195
            cancelButton = new JButton("Cancelar");
196
            cancelButton.setText(Messages.getText("Cancelar"));
197
        }
198

  
199
        return cancelButton;
200
    }
201

  
202

  
203

  
204
	public void componentHidden(ComponentEvent e) {
205
		// TODO Auto-generated method stub
206

  
207
	}
208

  
209
	public void componentMoved(ComponentEvent e) {
210
		// TODO Auto-generated method stub
211

  
212
	}
213

  
214
	public void componentResized(ComponentEvent e) {
215
		if(e.getSource() == this)
216
			this.resizeWindow();
217
	}
218

  
219
	public void resizeWindow(){
220
		if (flag == 0){
221
			cWidth = this.getSize().width;
222
			cHeight = this.getSize().height;
223
			flag++;
224
		}
225

  
226
		int nWidth = getWidth();
227
		int nHeight = getHeight();
228
		difWidth = nWidth - cWidth;
229
		difHeight = nHeight - cHeight;
230
		this.tabPane.setSize(this.tabPane.getSize().width + difWidth, this.tabPane.getSize().height + difHeight);
231
		this.tabPane.setLocation(this.tabPane.getLocation().x - difWidth/2, this.tabPane.getLocation().y - difHeight/2);
232

  
233
		this.contentPane.setSize(this.contentPane.getSize().width + difWidth, this.contentPane.getSize().height + difHeight);
234
		//this.pButton.setSize(this.getPButton().getWidth() + difWidth/2, 25);
235
		//this.buttonPane.setLocation(this.buttonPane.getLocation().x + difWidth/2, this.buttonPane.getLocation().y + difHeight/2);
236
		this.pButton.setLocation(this.pButton.getLocation().x + difWidth/2, this.pButton.getLocation().y + difHeight/2);
237

  
238
	}
239

  
240
	public void componentShown(ComponentEvent e) {
241
		// TODO Auto-generated method stub
242

  
243
	}
244

  
245

  
246
}  //  @jve:decl-index=0:visual-constraint="12,13"
0 247

  
tags/v2_0_0_Build_2045/libraries/libProjection/src/org/cresques/ui/cts/CSSelectionDialogPanel.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.ui.cts;
25

  
26
import javax.swing.JPanel;
27

  
28
import org.cresques.Messages;
29
import org.cresques.impl.cts.ProjectionPool;
30
import org.cresques.ui.DefaultDialogPanel;
31

  
32

  
33
/**
34
 * Dialogo para abrir fichero.
35
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
36
 */
37
public class CSSelectionDialogPanel extends DefaultDialogPanel {
38
    final private static long serialVersionUID = -3370601314380922368L;
39

  
40
    public CSSelectionDialogPanel() {
41
        super();
42
        init();
43
    }
44

  
45
    /**
46
     * This method initializes this
47
     *
48
     * @return void
49
     */
50
    private void init() {
51
        this.setBounds(0, 0, 350, 260);
52
    }
53

  
54
    public CSSelectionPanel getProjPanel() {
55
        return (CSSelectionPanel) getContentPanel();
56
    }
57

  
58
    protected JPanel getContentPanel() {
59
        if (contentPane == null) {
60
        	contentPane = new CSSelectionPanel(Messages.getText("reference_system"));
61
        	contentPane.setBounds(14, 12, 280, 163);
62

  
63
            ((CSSelectionPanel) contentPane).setProjection(new ProjectionPool().get("EPSG:32619"));
64
        }
65

  
66
        return contentPane;
67
    }
68
}
0 69

  
tags/v2_0_0_Build_2045/libraries/libProjection/src/org/cresques/ui/cts/CSSelectionPanel.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.ui.cts;
25

  
26
import javax.swing.JLabel;
27
import javax.swing.JPanel;
28

  
29
import org.cresques.Messages;
30
import org.cresques.cts.IProjection;
31
import org.cresques.ui.LoadableComboBox;
32

  
33

  
34
//import es.gva.cit.geoexplorer.ui.LoadableComboBox;
35

  
36
/**
37
 * Panel de edici?n de Sistemas de referencia
38
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
39
 */
40
public class CSSelectionPanel extends JPanel {
41
    final private static long serialVersionUID = -3370601314380922368L;
42
    private LoadableComboBox datumComboBox = null;
43
    private LoadableComboBox projComboBox = null;
44
    private LoadableComboBox huseComboBox = null;
45
    private JLabel jLabel = null;
46
    private JLabel jLabel1 = null;
47
    private JLabel jLabel2 = null;
48
    private String tit;
49
    private CSSelectionModel model;
50

  
51
    /**
52
     * Constructor de la clase.
53
     */
54
    public CSSelectionPanel(String tit) {
55
        super();
56

  
57
        if (tit == null) {
58
            //tit = "Sistema de referencia";
59
            //TODO: add com.iver.andami.PluginServices to this project
60
            //change all the labels from fix text got from the internationalitation
61
            tit = Messages.getText("reference_system");
62
            if (tit == null) tit="Reference System";
63
        }
64

  
65
        this.tit = tit;
66
        setModel(new CSSelectionModel());
67
        initialize();
68
    }
69

  
70
    /**
71
     * Inicializa el panel.
72
     * @return javax.swing.JPanel
73
     */
74
    private void initialize() {
75
        setPreferredSize(new java.awt.Dimension(295, 170));
76
        setLayout(null);
77

  
78
        /*javax.swing.border.Border border = javax.swing.BorderFactory.createCompoundBorder(
79
        javax.swing. BorderFactory.createTitledBorder("Sistema de coordenadas"),
80
        javax.swing.BorderFactory.createEmptyBorder(5,5,5,5)); */
81
        setBorder(javax.swing.BorderFactory.createCompoundBorder(null,
82
                                                                 javax.swing.BorderFactory.createTitledBorder(null,
83
                                                                		 										Messages.getText("reference_system"),
84
                                                                                                              javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
85
                                                                                                              javax.swing.border.TitledBorder.DEFAULT_POSITION,
86
                                                                                                              null,
87
                                                                                                              null)));
88

  
89
        jLabel = new JLabel();
90
        jLabel.setBounds(15, 15, 77, 23);
91
        jLabel.setText(Messages.getText("datum") + ":");
92
        add(jLabel, null);
93
        add(getDatumComboBox(), null);
94

  
95
        jLabel1 = new JLabel();
96
        jLabel1.setBounds(15, 60, 77, 23);
97
        jLabel1.setText(Messages.getText("projection") + ":");
98
        add(jLabel1, null);
99
        add(getProjComboBox(), null);
100

  
101
        jLabel2 = new JLabel();
102
        jLabel2.setBounds(15, 105, 77, 23);
103
        jLabel2.setText(Messages.getText("zone") + ":");
104
        add(jLabel2, null);
105
        add(getHuseComboBox(), null);
106

  
107
        setHuseComboBoxEnabled(false);
108
    }
109

  
110
    public void setModel(CSSelectionModel model) {
111
        this.model = model;
112

  
113
        getHuseComboBox().loadData(model.getZoneList());
114
        getDatumComboBox().loadData(model.getDatumList());
115
        getProjComboBox().loadData(model.getProjectionList());
116
    }
117

  
118
    private void setHuseComboBoxEnabled(boolean enabled) {
119
        if (jLabel2 != null) {
120
            jLabel2.setEnabled(enabled);
121
        }
122

  
123
        getHuseComboBox().setEnabled(enabled);
124
    }
125

  
126
    private void setDatumComboBoxEnabled(boolean enabled) {
127
        if (jLabel != null) {
128
            jLabel.setEnabled(enabled);
129
        }
130

  
131
        getDatumComboBox().setEnabled(enabled);
132
    }
133

  
134
    public void setProjection(IProjection proj) {
135
        model.setProjection(proj);
136

  
137
        setDatumComboBoxEnabled(true);
138
        getDatumComboBox().setSelectedIndex(model.getSelectedDatum());
139
 
140
        getProjComboBox().removeAllItems();
141
        getProjComboBox().loadData(model.getProjectionList());
142

  
143
        model.setProjection(proj);
144
        getProjComboBox().setSelectedIndex(model.getSelectedProj());
145
        model.setProjection(proj);
146
        
147
        if (model.getSelectedZone() >= 0) {
148
            setHuseComboBoxEnabled(true);
149
            getHuseComboBox().removeAllItems();
150
            getHuseComboBox().loadData(model.getZoneList());
151

  
152
            model.setProjection(proj);
153
            getHuseComboBox().setSelectedIndex(model.getSelectedZone());
154
        } else {
155
            setHuseComboBoxEnabled(false);
156
            getHuseComboBox().setSelectedIndex(0);
157
        }
158
    }
159

  
160
    /**
161
     * Inicializa datumComboBox
162
     *
163
     * @return javax.swing.JComboBox
164
     */
165
    private LoadableComboBox getDatumComboBox() {
166
        if (datumComboBox == null) {
167
            datumComboBox = new LoadableComboBox();
168
            datumComboBox.setBounds(14, 35, 250, 23);
169

  
170
            //			((LoadableComboBox) datumComboBox).loadData(model.getDatumList());
171
            datumComboBox.addItemListener(new java.awt.event.ItemListener() {
172
                    public void itemStateChanged(java.awt.event.ItemEvent e) {
173
                        model.setSelectedDatum(e.getItem());
174
                        getProjComboBox().removeAllItems();
175
                        getProjComboBox().loadData(model.getProjectionList());
176
                    }
177
                });
178
        }
179

  
180
        return datumComboBox;
181
    }
182

  
183
    /**
184
     * Inicializa projComboBox
185
     *
186
     * @return javax.swing.JComboBox
187
     */
188
    private LoadableComboBox getProjComboBox() {
189
        if (projComboBox == null) {
190
            projComboBox = new LoadableComboBox();
191
            projComboBox.setBounds(14, 80, 250, 23);
192
            projComboBox.addItemListener(new java.awt.event.ItemListener() {
193
                    public void itemStateChanged(java.awt.event.ItemEvent e) {
194
                        model.setSelectedProj(e.getItem());
195

  
196
                        if (model.getSelectedProjType() == CSSelectionModel.TRANSVERSAL) {
197
                            setHuseComboBoxEnabled(true);
198
                            getHuseComboBox().removeAllItems();
199
                            getHuseComboBox().loadData(model.getZoneList());
200

  
201
                        } else {
202
                            setHuseComboBoxEnabled(false);
203
                        }
204

  
205
                       // if (model.getSelectedProjType() == CSSelectionModel.NONE) {
206
                       //     setDatumComboBoxEnabled(false);
207
                       // } else {
208
                       //     setDatumComboBoxEnabled(true);
209
                       // }
210
                    }
211
                });
212
        }
213

  
214
        return projComboBox;
215
    }
216

  
217
    /**
218
     * Inicializa usoComboBox
219
     *
220
     * @return javax.swing.JComboBox
221
     */
222
    private LoadableComboBox getHuseComboBox() {
223
        if (huseComboBox == null) {
224
            huseComboBox = new LoadableComboBox();
225
            huseComboBox.setBounds(14, 125, 250, 23);
226
            huseComboBox.addItemListener(new java.awt.event.ItemListener() {
227
                    public void itemStateChanged(java.awt.event.ItemEvent e) {
228
                        model.setSelectedZone(e.getItem());
229
                    }
230
                });
231
        }
232

  
233
        return huseComboBox;
234
    }
235

  
236
    /**
237
     * @return
238
     */
239
    public IProjection getProjection() {
240
        return model.getProjection();
241
    }
242
}
0 243

  
tags/v2_0_0_Build_2045/libraries/libProjection/src/org/cresques/ui/cts/CSSelectionModel.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.ui.cts;
25

  
26
import org.cresques.cts.IProjection;
27
import org.cresques.impl.cts.ProjectionPool;
28

  
29

  
30
/**
31
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
32
 */
33
public class CSSelectionModel {
34
    public static int NONE = 0x01;
35
    public static int GEODETIC = 0x02;
36
    public static int TRANSVERSAL = 0x03;
37
    public String[] datumList = {
38
	    "WGS 84", "European 1950", "Datum 73",
39
	    "North American Datum 1927",
40
	    "North American Datum 1983",
41
	    "La Canoa",
42
	    "NTF (Paris)",
43
	    "ETRS 89",
44
	    "Moon (IAU 2000)",
45
	    "Mars (IAU 2000)",
46
	    "Campo_Inchauspe",
47
	    "RGF93"
48
    };
49
    /*private String[] projList = {
50
        "Geodesica",
51
        "(UTM) Universal Transversal Mercator",
52
        "Datum 73 / Modified Portuguese Grid",
53
        "WGS 84 / LCC Canada",
54
        "NAD83 / NRCan LCC Canada",
55
        "Lambert Etendu",
56
        "RGF93 / Lambert-93",
57
        "WGS 84 / Mercator",
58
        "Campo Inchauspe / Zonas 1-7"
59
    };*/
60
    private String[][] projList = {
61
        	{"Geodesica", "(UTM) Universal Transversal Mercator",
62
        		"LCC Canada", "Mercator"}, // WGS84
63
        	{"Geodesica", "(UTM) Universal Transversal Mercator"}, // ED50
64
        	{"Geodesica", "Modified Portuguese Grid"}, //Datum 73
65
        	{"Geodesica", "(UTM) Universal Transversal Mercator"}, // NAD27
66
        	{"Geodesica", "(UTM) Universal Transversal Mercator", "NRCan LCC Canada"}, // NAD83
67
        	{"Geodesica", "(UTM) Universal Transversal Mercator"}, // La Canoa
68
        	{"Geodesica", "Lambert Etendu"}, // NTF (Paris)
69
        	{"Geodesica", "(UTM) Universal Transversal Mercator"}, // ETRS89
70
        	{"Geodesica"}, // Moon
71
        	{"Geodesica"}, // Mars
72
        	{"Geodesica", "Zonas 1-7"}, // CampoInchauspe
73
        	{"Geodesica", "Lambert-93"} // RFG93
74
        };
75

  
76
    private int[][] projType = {
77
    	{GEODETIC, TRANSVERSAL, NONE, NONE},
78
    	{GEODETIC, TRANSVERSAL},
79
    	{GEODETIC, NONE},
80
    	{GEODETIC, TRANSVERSAL},
81
    	{GEODETIC, TRANSVERSAL, NONE},
82
    	{GEODETIC, TRANSVERSAL},
83
    	{GEODETIC, NONE},
84
    	{GEODETIC, TRANSVERSAL},
85
    	{GEODETIC},
86
    	{GEODETIC},
87
    	{GEODETIC, TRANSVERSAL},
88
    	{GEODETIC, NONE}
89
    };
90
    
91
    private int [][] zoneRange = {
92
    	{1,60},
93
    	{1,60},
94
    	{0,0},
95
    	{3,23},
96
    	{3,23},
97
    	{18,21},
98
    	{0,0},
99
    	{28,38},
100
    	{0,0},
101
    	{0,0},
102
    	{1,7},
103
    	{0,0}
104
    };
105
    private String[] zoneList = {  };
106
    private int selectedDatum = 0;
107
    private int selectedProj = 0;
108
    private int selectedZone = 0;
109

  
110
    /**
111
     *
112
     */
113
    public CSSelectionModel() {
114
        super();
115
        zoneList = new String[60];
116

  
117
        for (int i = 1; i <= 60; i++)
118
            zoneList[i - 1] = "Huso " + Integer.toString(i);
119
    }
120
    
121

  
122
    public String[] getDatumList() {
123
        return datumList;
124
    }
125

  
126
    public String[] getProjectionList() {
127
        return projList[getSelectedDatum()];
128
    }
129

  
130
    public String[] getZoneList() {
131
    	int [] r = zoneRange[getSelectedDatum()];
132
        return getZoneList(r[0],r[1]);
133
    }
134

  
135
    public String[] getZoneList(int from, int to) {
136
        zoneList = new String[to-from+1];
137

  
138
        for (int i = from; i <= to; i++)
139
        	zoneList[i - from] = "Huso " + Integer.toString(i);
140
        return zoneList;
141
    }
142
    public void setSelectedDatum(int opNr) {
143
        selectedDatum = opNr;
144
    }
145

  
146
    public void setSelectedDatum(Object item) {
147
        String[] list = datumList;
148

  
149
        for (int i = 0; i < list.length; i++)
150
            if (list[i].compareTo((String) item) == 0) {
151
                selectedDatum = i;
152
                break;
153
            }
154
    }
155

  
156
    public int getSelectedDatum() {
157
        return selectedDatum;
158
    }
159

  
160
    public void setSelectedProj(int opNr) {
161
        selectedProj = opNr;
162
    }
163

  
164
    public void setSelectedProj(Object item) {
165
        String[] list = projList[getSelectedDatum()];
166

  
167
        for (int i = 0; i < list.length; i++)
168
            if (list[i].compareTo((String) item) == 0) {
169
                selectedProj = i;
170
                break;
171
            }
172
    }
173

  
174
    public int getSelectedProj() {
175
        return selectedProj;
176
    }
177

  
178
    public int getSelectedProjType() {
179
        return projType[getSelectedDatum()][selectedProj];
180
    }
181

  
182
    public void setSelectedZone(int opNr) {
183
        selectedZone = opNr;
184
    }
185

  
186
    public void setSelectedZone(Object item) {
187
        String[] list = zoneList;
188

  
189
        for (int i = 0; i < list.length; i++)
190
            if (list[i].compareTo((String) item) == 0) {
191
                selectedZone = i;
192
                break;
193
            }
194
    }
195

  
196
    public int getSelectedZone() {
197
        return selectedZone;
198
    }
199

  
200
    public void setProjection(IProjection proj) {
201
    	if (proj!=null){
202
    		String key = proj.getAbrev();
203
    		// Para usos posteriores.
204
    		// String db = key.split(":")[0];
205
    		key = key.split(":")[1];
206

  
207
    		setSelectedProj(0);
208
    		setSelectedZone(-1);
209

  
210
    		if (key.endsWith("4326")) {
211
    			setSelectedDatum(0);
212
    		} else if (key.endsWith("4230")) {
213
    			setSelectedDatum(1);
214
    		} else if (key.endsWith("4274")) {
215
    			setSelectedDatum(2);
216
    		} else if (key.endsWith("4267")) {
217
    			setSelectedDatum(3);
218
    		} else if (key.endsWith("4269")) {
219
    			setSelectedDatum(4);
220
    		} else if (key.endsWith("4247")) {
221
    			setSelectedDatum(5);
222
    		} else if (key.endsWith("4807")) {
223
    			setSelectedDatum(6);
224
    		} else if (key.endsWith("4258")) {
225
    			setSelectedDatum(7);
226
    		} else if (key.endsWith("30100")) {
227
    			setSelectedDatum(8);
228
    		} else if (key.endsWith("49900")) {
229
    			setSelectedDatum(9);
230
    		} else if (key.endsWith("4221")) {
231
    			setSelectedDatum(10);
232
    		} else if (key.endsWith("4171")) {
233
    			setSelectedDatum(11);
234
    		} else if (key.startsWith("326")) {
235
    			setSelectedDatum(0);
236
    			setSelectedProj(1);
237
    			setSelectedZone("Huso "+ Integer.parseInt(key.substring(3)));            		
238
    		} else if (key.startsWith("230")) {
239
    			setSelectedDatum(1);
240
    			setSelectedProj(1);
241
    			setSelectedZone("Huso "+ Integer.parseInt(key.substring(3)));
242
    		} else if (key.startsWith("267")) {
243
    			setSelectedDatum(3);
244
    			setSelectedProj(1);
245
    			setSelectedZone("Huso "+ Integer.parseInt(key.substring(3)));
246
    		} else if (key.startsWith("269")) {
247
    			setSelectedDatum(4);
248
    			setSelectedProj(1);
249
    			setSelectedZone("Huso "+ Integer.parseInt(key.substring(3)));
250
    		} else if (key.startsWith("247")) {
251
    			setSelectedDatum(5);
252
    			setSelectedProj(1);
253
    			setSelectedZone("Huso "+ Integer.parseInt(key.substring(3)));
254
    		} else if (key.startsWith("258")) {
255
    			setSelectedDatum(7);
256
    			setSelectedProj(1);
257
    			setSelectedZone("Huso "+ Integer.parseInt(key.substring(3)));
258
    		} else if (key.startsWith("221")) {
259
    			setSelectedDatum(10);
260
    			setSelectedProj(1);
261
    			setSelectedZone("Huso "+ Integer.parseInt(key.substring(4)));
262
    		} else if (key.endsWith("27492")) { // Datum 73 / Modified Portuguese Grid
263
    			setSelectedDatum(2);
264
    			setSelectedProj(1);
265
    			setSelectedZone(-1);
266
    		} else if (key.endsWith("42101")) { // WGS 84 / LCC Canada
267
    			setSelectedDatum(0);
268
    			setSelectedProj(2);
269
    			setSelectedZone(-1);
270
    		} else if (key.endsWith("9804")) { // WGS 84 / Mercator
271
    			setSelectedDatum(0);
272
    			setSelectedProj(3);
273
    			setSelectedZone(-1);
274
    		} else if (key.endsWith("30100")) { // Moon
275
    			setSelectedDatum(8);
276
    			setSelectedProj(0);
277
    			setSelectedZone(-1);
278
    		} else if (key.endsWith("49900")) { // Mars
279
    			setSelectedDatum(9);
280
    			setSelectedProj(0);
281
    			setSelectedZone(-1);
282
    		} else if (key.endsWith("42304")) { // NAD83 /  / LCC Canada
283
    			setSelectedDatum(4);
284
    			setSelectedProj(2);
285
    			setSelectedZone(-1);
286
    		} else if (key.endsWith("27582")) { // NTFParis /  / Lambert Etendu
287
    			setSelectedDatum(6);
288
    			setSelectedProj(1);
289
    			setSelectedZone(-1);
290
    		} else if (key.equals("2154")) { // RGF93 /  / Lambert 93
291
    			setSelectedDatum(11);
292
    			setSelectedProj(1);
293
    			setSelectedZone(-1);         
294
    		} else  {
295
    			System.err.println("CAGADA EN EL PARSING DE LA PROYECCION: " + key);
296
    		}
297
    	} else {
298
    	    selectedDatum = 0;
299
    	    selectedProj = 0;
300
    	    selectedZone = 0;
301
    	}
302
    }
303

  
304
    public IProjection getProjection() {
305
        IProjection proj = null;
306
        String datum = "326";
307

  
308
        if (selectedDatum == 0) {
309
            datum = "326";
310
            if (selectedProj == 0)
311
                return new ProjectionPool().get("EPSG:4"+datum);
312
            else if (selectedProj == 1) {
313
                String zone = Integer.toString(selectedZone + 1);
314
                if (selectedZone < 9) zone = "0" + zone;
315
                return new ProjectionPool().get("EPSG:" + datum + zone);
316
            } else if (selectedProj == 2)
317
                return new ProjectionPool().get("EPSG:42101");
318
            else if (selectedProj == 3)
319
                return new ProjectionPool().get("EPSG:9804");
320
            
321
        } else if (selectedDatum == 1) {
322
            datum = "230";
323
            if (selectedProj == 0)
324
                return new ProjectionPool().get("EPSG:4"+datum);
325
            else if (selectedProj == 1) {
326
                String zone = Integer.toString(selectedZone + 1);
327
                if (selectedZone < 9) zone = "0" + zone;
328
                return new ProjectionPool().get("EPSG:" + datum + zone);
329
            } 
330
            
331
        } else if (selectedDatum == 2) { // Lisboa 73
332
            datum = "274";
333
            if (selectedProj == 0)
334
                return new ProjectionPool().get("EPSG:4"+datum);
335
            else if (selectedProj == 1)
336
                return new ProjectionPool().get("EPSG:"+datum+"92");
337
            
338
       } else if (selectedDatum == 3) {
339
            datum = "267";
340
            if (selectedProj == 0)
341
                return new ProjectionPool().get("EPSG:4"+datum);
342
            else if (selectedProj == 1) {
343
                String zone = Integer.toString(selectedZone + 3);
344
                if (selectedZone+3 <= 9) zone = "0" + zone;
345
                return new ProjectionPool().get("EPSG:" + datum + zone);
346
            }
347
            
348
        } else if (selectedDatum == 4) {
349
            datum = "269";
350
            if (selectedProj == 0)
351
                return new ProjectionPool().get("EPSG:4"+datum);
352
            else if (selectedProj == 1) {
353
                String zone = Integer.toString(selectedZone + 3);
354
                if (selectedZone+3 <= 9) zone = "0" + zone;
355
                return new ProjectionPool().get("EPSG:" + datum + zone);
356
            } else if (selectedProj == 2)
357
                return new ProjectionPool().get("EPSG:42304");
358
            
359
        } else if (selectedDatum == 5) {
360
            datum = "247";
361
            if (selectedProj == 0)
362
                return new ProjectionPool().get("EPSG:4"+datum);
363
            else if (selectedProj == 1) {
364
                String zone = Integer.toString(selectedZone + 18);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff