Statistics
| Revision:

root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanel.java @ 7581

History | View | Annotate | Download (4.56 KB)

1
/*
2
 * Created on 30-ene-2005
3
 */
4
package org.gvsig.crs.gui.panels;
5

    
6
import java.awt.FlowLayout;
7
import java.awt.GridLayout;
8
import java.awt.event.ActionListener;
9

    
10
import org.gvsig.gui.beans.swing.JButton;
11
import javax.swing.JLabel;
12

    
13
import org.cresques.cts.IProjection;
14
import org.gvsig.crs.EpsgConnection;
15
import org.gvsig.crs.ICrs;
16
import org.gvsig.crs.gui.dialog.CSSelectionDialog;
17

    
18
import com.iver.andami.PluginServices;
19
import com.iver.andami.ui.mdiManager.IWindow;
20
import com.iver.cit.gvsig.gui.FOpenDialog;
21
import com.iver.cit.gvsig.gui.View;
22
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel;
23

    
24
/**
25
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
26
 */
27
public class ProjChooserPanel extends CRSSelectPanel {
28
    
29
        private static final long serialVersionUID = 1L;
30
        
31
        private static IProjection curProj = null; //(IProjection) new CRSFactory().getCRS("EPSG:23030");
32
        private JLabel jLblProj = null;
33
        private JLabel jLblProjName = null;
34
        private JButton jBtnChangeProj = null;
35
        private static boolean okPressed = false;
36
        private String abrev;
37
        
38
        public EpsgConnection connect = null;
39

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

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

    
73
        private void initBtnChangeProj() {
74
                getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
75
                        public void actionPerformed(java.awt.event.ActionEvent e) {
76
                                okPressed = false;
77
                                CSSelectionDialog csSelect = new CSSelectionDialog();
78
                                csSelect.setProjection(curProj);
79
                                
80
                                csSelect.setLayout(new GridLayout(0,1));
81

    
82
                        PluginServices.getMDIManager().addWindow(csSelect);
83
                        IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
84
                            View activeView = (com.iver.cit.gvsig.gui.View) activeWindow;
85
                        if(activeView.getMapControl() == null)
86
                                abrev = curProj.getAbrev();
87
                        else
88
                                abrev = activeView.getMapControl().getProjection().getAbrev();
89

    
90
                        if (csSelect.isOkPressed()) {
91
                                curProj = csSelect.getProjection();
92
                                if(activeView.getMapControl() == null)
93
                                        abrev = csSelect.getProjectionAbrev();
94
                                else 
95
                                        abrev = activeView.getMapControl().getProjection().getAbrev();
96
                                jLblProj.setText(curProj.getAbrev());
97
                                FOpenDialog.setLastProjection(curProj);
98
                                okPressed = true;
99
                                if (actionListener != null) {
100
                                        actionListener.actionPerformed(e);
101
                                }
102
                        }else
103
                                
104
                                jLblProj.setText(abrev);
105
                        }
106
                });
107
        }
108

    
109
        public JLabel getJLblProjName() {
110
                if (jLblProjName == null) {
111
                jLblProjName = new JLabel("Proyeccion actual");
112
                        jLblProjName.setText(PluginServices.getText(this,"__proyeccion_actual")); //$NON-NLS-1$
113
                }
114
                return jLblProjName;
115
        }
116

    
117
        public JLabel getJLblProj() {
118
                if (jLblProj == null) {
119
                jLblProj = new JLabel();
120
                        jLblProj.setText(curProj.getAbrev());
121
                }
122
                return jLblProj;
123
        }
124
        public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) {
125
                jBtnChangeProj.addActionListener(al);
126
        }
127

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