root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / CRSMainPanel.java @ 8304
History | View | Annotate | Download (6.87 KB)
1 |
package org.gvsig.crs.gui; |
---|---|
2 |
import java.awt.BorderLayout; |
3 |
import java.awt.CardLayout; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.FlowLayout; |
6 |
import java.awt.GridLayout; |
7 |
import java.awt.event.ActionEvent; |
8 |
|
9 |
import javax.swing.BorderFactory; |
10 |
import javax.swing.JButton; |
11 |
import javax.swing.JComboBox; |
12 |
import javax.swing.JLabel; |
13 |
import javax.swing.JPanel; |
14 |
|
15 |
import org.cresques.cts.IProjection; |
16 |
import org.gvsig.crs.ICrs; |
17 |
import org.gvsig.crs.gui.panels.CrsRecentsPanel; |
18 |
import org.gvsig.crs.gui.panels.EPSGpanel; |
19 |
import org.gvsig.crs.gui.panels.ESRIpanel; |
20 |
import org.gvsig.crs.gui.panels.IAU2000panel; |
21 |
|
22 |
import com.iver.andami.PluginServices; |
23 |
import com.iver.andami.ui.mdiManager.IWindow; |
24 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
25 |
|
26 |
public class CRSMainPanel extends JPanel implements IWindow { |
27 |
|
28 |
/**
|
29 |
*
|
30 |
*/
|
31 |
private static final long serialVersionUID = 1L; |
32 |
|
33 |
private JComboBox jComboOptions = null; |
34 |
private JPanel Combopanel = null; |
35 |
private JPanel USGSpanel = null; |
36 |
|
37 |
final String recientes = PluginServices.getText(this,"recientes"); |
38 |
final String epsg = PluginServices.getText(this,"EPSG"); |
39 |
final String usgs = PluginServices.getText(this,"USGS"); |
40 |
final String esri = PluginServices.getText(this,"ESRI"); |
41 |
final String iau2000 = PluginServices.getText(this,"IAU2000"); |
42 |
final String newCRS = PluginServices.getText(this,"nuevo_crs"); |
43 |
|
44 |
String[] selection = {recientes, epsg, usgs, esri, iau2000, newCRS}; |
45 |
|
46 |
boolean inAnApplet = true; |
47 |
public CrsRecentsPanel crsRecentsPanel = null; |
48 |
public EPSGpanel epsgPanel = null; |
49 |
public ESRIpanel esriPanel = null; |
50 |
public IAU2000panel iauPanel = null; |
51 |
|
52 |
private JPanel jPanelMain = null; |
53 |
|
54 |
private JPanel jPanelButtons; |
55 |
private JButton jButtonAccept; |
56 |
private JButton jButonCancel; |
57 |
|
58 |
String dataSource = ""; |
59 |
|
60 |
public CRSMainPanel() {
|
61 |
crsRecentsPanel = new CrsRecentsPanel();
|
62 |
epsgPanel = new EPSGpanel();
|
63 |
esriPanel = new ESRIpanel();
|
64 |
iauPanel = new IAU2000panel();
|
65 |
|
66 |
this.add(vista(), BorderLayout.NORTH); |
67 |
this.add(getJPanelButtons(), BorderLayout.SOUTH); |
68 |
|
69 |
setDataSource(selection[0]);
|
70 |
} |
71 |
|
72 |
public CRSMainPanel(int target) { |
73 |
crsRecentsPanel = new CrsRecentsPanel();
|
74 |
epsgPanel = new EPSGpanel();
|
75 |
esriPanel = new ESRIpanel();
|
76 |
iauPanel = new IAU2000panel();
|
77 |
|
78 |
setDataSource(selection[0]);
|
79 |
} |
80 |
|
81 |
public JPanel capa(){ |
82 |
JPanel p = new JPanel(); |
83 |
p.setPreferredSize(new Dimension(550, 320)); |
84 |
p.setLayout(new GridLayout(0,1)); |
85 |
p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
86 |
p.setBorder( |
87 |
BorderFactory.createCompoundBorder(
|
88 |
BorderFactory.createCompoundBorder(
|
89 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_capa")), |
90 |
BorderFactory.createEmptyBorder(1,1,1,1)), |
91 |
p.getBorder())); |
92 |
p.add(getCombopanel()); |
93 |
p.add(getJPanelMain()); |
94 |
return p;
|
95 |
} |
96 |
|
97 |
public JPanel vista(){ |
98 |
JPanel p = new JPanel(); |
99 |
p.setPreferredSize(new Dimension(550, 320)); |
100 |
p.setLayout(new GridLayout(0,1)); |
101 |
p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
102 |
p.setBorder( |
103 |
BorderFactory.createCompoundBorder(
|
104 |
BorderFactory.createCompoundBorder(
|
105 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_vista")), |
106 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
107 |
p.getBorder())); |
108 |
p.add(getCombopanel()); |
109 |
p.add(getJPanelMain()); |
110 |
return p;
|
111 |
} |
112 |
|
113 |
public JPanel getJPanelMain(){ |
114 |
if (jPanelMain == null){ |
115 |
jPanelMain = new JPanel(); |
116 |
jPanelMain.setLayout(new CardLayout()); |
117 |
jPanelMain.setPreferredSize(new Dimension(525, 230)); |
118 |
jPanelMain.add(recientes, crsRecentsPanel); |
119 |
jPanelMain.add(epsg, epsgPanel); |
120 |
jPanelMain.add(esri, esriPanel); |
121 |
jPanelMain.add(usgs, getJPanelUSGS()); |
122 |
jPanelMain.add(iau2000, iauPanel); |
123 |
} |
124 |
|
125 |
return jPanelMain;
|
126 |
} |
127 |
|
128 |
public JPanel getCombopanel(){ |
129 |
if (Combopanel == null){ |
130 |
Combopanel = new JPanel(); |
131 |
Combopanel.setPreferredSize(new Dimension(525,30)); |
132 |
Combopanel.add(getJLabelTipo()); |
133 |
Combopanel.add(getJComboOptions()); |
134 |
} |
135 |
|
136 |
return Combopanel;
|
137 |
} |
138 |
|
139 |
private JLabel getJLabelTipo(){ |
140 |
JLabel jLabelTipo = new JLabel(); |
141 |
jLabelTipo.setPreferredSize(new Dimension(50,25)); |
142 |
jLabelTipo.setText(PluginServices.getText(this,"Tipo")); |
143 |
return jLabelTipo;
|
144 |
} |
145 |
|
146 |
public JComboBox getJComboOptions(){ |
147 |
if (jComboOptions == null){ |
148 |
jComboOptions = new JComboBox(selection); |
149 |
jComboOptions.setPreferredSize(new Dimension(100,25)); |
150 |
jComboOptions.setEditable(false);
|
151 |
jComboOptions.setSelectedIndex(0);
|
152 |
} |
153 |
return jComboOptions;
|
154 |
} |
155 |
|
156 |
public JPanel getJPanelUSGS() { |
157 |
if (USGSpanel == null){ |
158 |
USGSpanel = new JPanel(); |
159 |
USGSpanel.setLayout(new GridLayout(3,4)); |
160 |
USGSpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
161 |
USGSpanel.setPreferredSize(new Dimension(525, 400)); |
162 |
} |
163 |
return USGSpanel;
|
164 |
} |
165 |
|
166 |
private JPanel getJPanelButtons() { |
167 |
if(jPanelButtons == null) { |
168 |
jPanelButtons = new JPanel(); |
169 |
jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
170 |
jPanelButtons.setPreferredSize(new Dimension(525,50)); |
171 |
jPanelButtons.add(getJButtonCancel(),null);
|
172 |
jPanelButtons.add(getJButtonAccept(),null);
|
173 |
} |
174 |
return jPanelButtons;
|
175 |
} |
176 |
|
177 |
public JButton getJButtonCancel() { |
178 |
if(jButonCancel == null) { |
179 |
jButonCancel = new JButton(); |
180 |
jButonCancel.setText(PluginServices.getText(this,"cancel")); |
181 |
jButonCancel.setPreferredSize(new Dimension(100,25)); |
182 |
jButonCancel.setMnemonic('C');
|
183 |
jButonCancel.setToolTipText("Cancel");
|
184 |
} |
185 |
return jButonCancel;
|
186 |
} |
187 |
|
188 |
public void cancelButton_actionPerformed(ActionEvent e) { |
189 |
PluginServices.getMDIManager().closeWindow(this);
|
190 |
} |
191 |
|
192 |
public JButton getJButtonAccept() { |
193 |
if(jButtonAccept == null) { |
194 |
jButtonAccept = new JButton(); |
195 |
jButtonAccept.setText(PluginServices.getText(this,"ok")); |
196 |
jButtonAccept.setPreferredSize(new Dimension(100,25)); |
197 |
jButtonAccept.setEnabled(false);
|
198 |
jButtonAccept.setMnemonic('A');
|
199 |
jButtonAccept.setToolTipText("Accept");
|
200 |
} |
201 |
return jButtonAccept;
|
202 |
} |
203 |
|
204 |
public ICrs getProjection() {
|
205 |
if (getDataSource().equals(PluginServices.getText(this,"EPSG"))){ |
206 |
return epsgPanel.getProjection();
|
207 |
} |
208 |
else if (getDataSource().equals(PluginServices.getText(this,"IAU2000"))) { |
209 |
return iauPanel.getProjection();
|
210 |
} |
211 |
else if (getDataSource().equals(PluginServices.getText(this,"recientes"))) { |
212 |
return crsRecentsPanel.getProjection();
|
213 |
} |
214 |
return null; |
215 |
} |
216 |
|
217 |
public void setProjection(IProjection crs) { |
218 |
//setCrs((ICrs) crs);
|
219 |
} |
220 |
|
221 |
public void setDataSource(String sour){ |
222 |
dataSource = sour; |
223 |
} |
224 |
|
225 |
public String getDataSource(){ |
226 |
return dataSource;
|
227 |
} |
228 |
|
229 |
public WindowInfo getWindowInfo() {
|
230 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
231 |
m_viewinfo.setTitle(PluginServices.getText(this, "seleccionar_crs")); |
232 |
return m_viewinfo;
|
233 |
} |
234 |
|
235 |
public EPSGpanel getEpsgPanel() {
|
236 |
return epsgPanel;
|
237 |
} |
238 |
|
239 |
|
240 |
|
241 |
public ESRIpanel getEsriPanel() {
|
242 |
return esriPanel;
|
243 |
} |
244 |
|
245 |
|
246 |
|
247 |
public IAU2000panel getIauPanel() {
|
248 |
return iauPanel;
|
249 |
} |
250 |
|
251 |
public CrsRecentsPanel getRecentsPanel() {
|
252 |
return crsRecentsPanel;
|
253 |
} |
254 |
|
255 |
} |