Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanelTransformation.java @ 7570

History | View | Annotate | Download (4.2 KB)

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.JFrame;
12
import javax.swing.JLabel;
13
import javax.swing.JPanel;
14

    
15
import org.cresques.cts.IProjection;
16
import org.gvsig.crs.EpsgConnection;
17
import org.gvsig.crs.ICrs;
18
import org.gvsig.gui.beans.swing.JButton;
19

    
20
import com.iver.andami.PluginServices;
21
import com.iver.cit.gvsig.gui.FOpenDialog;
22
import com.iver.cit.gvsig.gui.dialogs.TRSelectionDialog;
23

    
24
/**
25
 * @author Jos? Luis G?mez y Miguel Garc?a
26
 */
27
public class ProjChooserPanelTransformation extends JPanel {
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 boolean okPressed = false;
36
        private String abrev;
37
        
38
        public EpsgConnection connect = null;
39

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

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

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

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

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

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

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

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