svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / gui / Dialogs / GeoreferencingDialog.java @ 2854
History | View | Annotate | Download (7.93 KB)
1 | 2844 | nacho | package com.iver.cit.gvsig.gui.Dialogs; |
---|---|---|---|
2 | |||
3 | import java.awt.BorderLayout; |
||
4 | import java.awt.FlowLayout; |
||
5 | |||
6 | import javax.swing.JButton; |
||
7 | import javax.swing.JDialog; |
||
8 | import javax.swing.JFileChooser; |
||
9 | import javax.swing.JPanel; |
||
10 | import javax.swing.JTabbedPane; |
||
11 | import javax.swing.event.ChangeEvent; |
||
12 | import javax.swing.event.ChangeListener; |
||
13 | |||
14 | import org.cresques.cts.IProjection; |
||
15 | |||
16 | import com.iver.andami.PluginServices; |
||
17 | import com.iver.andami.ui.mdiManager.View; |
||
18 | import com.iver.andami.ui.mdiManager.ViewInfo; |
||
19 | 2854 | nacho | import com.iver.cit.gvsig.fmap.MapControl; |
20 | import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
||
21 | import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
||
22 | import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
||
23 | import com.iver.cit.gvsig.fmap.tools.Behavior.MoveBehavior; |
||
24 | import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
||
25 | import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
||
26 | 2844 | nacho | import com.iver.cit.gvsig.gui.Panels.SelectFilePanel; |
27 | import com.iver.cit.gvsig.gui.Panels.SelectPointsPanel; |
||
28 | 2854 | nacho | import com.iver.cit.gvsig.gui.toolListeners.GeorefPanListener; |
29 | import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener; |
||
30 | import com.iver.cit.gvsig.gui.toolListeners.ZoomInGeorefListener; |
||
31 | import com.iver.cit.gvsig.gui.toolListeners.ZoomInListener; |
||
32 | import com.iver.cit.gvsig.gui.toolListeners.ZoomOutGeorefListener; |
||
33 | 2844 | nacho | import com.iver.cit.gvsig.gui.wizards.WizardListener; |
34 | import com.iver.cit.gvsig.project.Project; |
||
35 | |||
36 | /**
|
||
37 | * Panel que contiene el Wizard de georeferenciaci?n con los tabs
|
||
38 | * interiores
|
||
39 | *
|
||
40 | * @author Nacho Brodin (brodin_ign@gva.es)
|
||
41 | */
|
||
42 | public class GeoreferencingDialog extends JPanel implements com.iver.andami.ui.mdiManager.View { |
||
43 | |||
44 | static private IProjection proj = Project.getProjection(); |
||
45 | private javax.swing.JTabbedPane tabPanel = null;; |
||
46 | private JFileChooser fileChooser; |
||
47 | private JPanel pBotones = null; |
||
48 | private JButton bProcesar = null; |
||
49 | private JButton bCancelar = null; |
||
50 | private WizardListener wizardListener = new DialogWizardListener(); |
||
51 | private JButton bSave = null; |
||
52 | 2854 | nacho | private static boolean loadTools = false; |
53 | 2844 | nacho | |
54 | /**
|
||
55 | * Constructor.
|
||
56 | */
|
||
57 | public GeoreferencingDialog() {
|
||
58 | initialize(); |
||
59 | |||
60 | } |
||
61 | |||
62 | /**
|
||
63 | * This method initializes this
|
||
64 | */
|
||
65 | private void initialize() { |
||
66 | this.setLayout(new BorderLayout()); |
||
67 | this.setPreferredSize(new java.awt.Dimension(400,315)); |
||
68 | this.setSize(new java.awt.Dimension(400,315)); |
||
69 | this.setLocation(new java.awt.Point(0,0)); |
||
70 | this.add(getTabPanel(), BorderLayout.CENTER); |
||
71 | this.add(getPBotones(), java.awt.BorderLayout.SOUTH);
|
||
72 | this.addTab(PluginServices.getText(this, "cargar_fichero"), new SelectFilePanel(this)); |
||
73 | this.addTab(PluginServices.getText(this, "seleccionar_puntos"), new SelectPointsPanel()); |
||
74 | |||
75 | 2854 | nacho | //Cargamos las herramientas la primera vez que abrimos la ventana
|
76 | if(!loadTools){
|
||
77 | GeoreferencingDialog.loadTools = true;
|
||
78 | com.iver.cit.gvsig.gui.View vista = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
||
79 | MapControl mapCtrl = vista.getMapControl(); |
||
80 | |||
81 | StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
||
82 | |||
83 | ZoomOutGeorefListener zogl = new ZoomOutGeorefListener(mapCtrl);
|
||
84 | mapCtrl.addMapTool("geoZoomOut", new Behavior[]{new PointBehavior(zogl), new MouseMovementBehavior(sbl)}); |
||
85 | |||
86 | ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(mapCtrl);
|
||
87 | ZoomInGeorefListener zigl = new ZoomInGeorefListener(mapCtrl);
|
||
88 | mapCtrl.addMapTool("geoZoomIn", new Behavior[]{new RectangleBehavior(zigl), |
||
89 | new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
||
90 | |||
91 | GeorefPanListener pl = new GeorefPanListener(mapCtrl);
|
||
92 | mapCtrl.addMapTool("geoPan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
||
93 | } |
||
94 | 2844 | nacho | } |
95 | |||
96 | /**
|
||
97 | * This method initializes tabPanel
|
||
98 | *
|
||
99 | * @return javax.swing.JTabbedPane
|
||
100 | */
|
||
101 | public javax.swing.JTabbedPane getTabPanel() {
|
||
102 | if (tabPanel == null) { |
||
103 | tabPanel = new javax.swing.JTabbedPane();
|
||
104 | tabPanel.setBounds(0, 0, 519, 352); |
||
105 | tabPanel.addChangeListener(new ChangeListener() { |
||
106 | public void stateChanged(ChangeEvent e) { |
||
107 | JTabbedPane tabs = (JTabbedPane) e.getSource(); |
||
108 | //getBProcesar().setEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
|
||
109 | } |
||
110 | }); |
||
111 | } |
||
112 | |||
113 | return tabPanel;
|
||
114 | } |
||
115 | |||
116 | /**
|
||
117 | * A?ade pesta?as al panel
|
||
118 | * @param title Nombre del tab
|
||
119 | * @param panel Panel que ir? en la pesta?a
|
||
120 | */
|
||
121 | public void addTab(String title, JPanel panel){ |
||
122 | getTabPanel().addTab(title, panel); |
||
123 | } |
||
124 | |||
125 | /**
|
||
126 | * Obtiene el panel que contiene la pesta?a seleccionada
|
||
127 | * @return Panel seleccionado
|
||
128 | */
|
||
129 | public JPanel getSelectedTab(){ |
||
130 | return (JPanel) getTabPanel().getSelectedComponent(); |
||
131 | } |
||
132 | |||
133 | public ViewInfo getViewInfo() {
|
||
134 | ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
||
135 | m_viewinfo.setTitle(PluginServices.getText(this,"cargar_sin_georef")); |
||
136 | return m_viewinfo;
|
||
137 | } |
||
138 | |||
139 | /**
|
||
140 | * This method initializes jPanel
|
||
141 | *
|
||
142 | * @return javax.swing.JPanel
|
||
143 | */
|
||
144 | private JPanel getPBotones() { |
||
145 | if (pBotones == null) { |
||
146 | FlowLayout flowLayout1 = new FlowLayout(); |
||
147 | pBotones = new JPanel(); |
||
148 | pBotones.setLayout(flowLayout1); |
||
149 | flowLayout1.setHgap(30);
|
||
150 | pBotones.add(getBProcesar(), null);
|
||
151 | pBotones.add(getBSave(), null);
|
||
152 | pBotones.add(getBCancelar(), null);
|
||
153 | } |
||
154 | return pBotones;
|
||
155 | } |
||
156 | |||
157 | /**
|
||
158 | * This method initializes bProcesar
|
||
159 | *
|
||
160 | * @return javax.swing.JButton
|
||
161 | */
|
||
162 | private JButton getBProcesar() { |
||
163 | if (bProcesar == null) { |
||
164 | bProcesar = new JButton(); |
||
165 | bProcesar.setText(PluginServices.getText(this,"procesar")); |
||
166 | bProcesar.setEnabled(false);
|
||
167 | bProcesar.addActionListener(new java.awt.event.ActionListener() {
|
||
168 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
169 | if (PluginServices.getMainFrame() == null) { |
||
170 | ((JDialog) (getParent().getParent().getParent()
|
||
171 | .getParent())).dispose(); |
||
172 | } else {
|
||
173 | PluginServices.getMDIManager().closeView((View) GeoreferencingDialog.this);
|
||
174 | } |
||
175 | } |
||
176 | }); |
||
177 | } |
||
178 | return bProcesar;
|
||
179 | } |
||
180 | /**
|
||
181 | * This method initializes bCancelar
|
||
182 | *
|
||
183 | * @return javax.swing.JButton
|
||
184 | */
|
||
185 | private JButton getBCancelar() { |
||
186 | if (bCancelar == null) { |
||
187 | bCancelar = new JButton(); |
||
188 | bCancelar.setText(PluginServices.getText(this,"cancelar")); |
||
189 | bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
||
190 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
191 | if (PluginServices.getMainFrame() != null) { |
||
192 | PluginServices.getMDIManager().closeView((View) GeoreferencingDialog.this);
|
||
193 | } else {
|
||
194 | ((JDialog) (getParent().getParent().getParent()
|
||
195 | .getParent())).dispose(); |
||
196 | } |
||
197 | } |
||
198 | }); |
||
199 | } |
||
200 | return bCancelar;
|
||
201 | } |
||
202 | |||
203 | public class DialogWizardListener implements WizardListener { |
||
204 | |||
205 | /**
|
||
206 | * @see com.iver.cit.gvsig.gui.wms.WizardListener#error(java.lang.Exception)
|
||
207 | */
|
||
208 | public void error(Exception e) { |
||
209 | } |
||
210 | |||
211 | /**
|
||
212 | * @see com.iver.cit.gvsig.gui.wms.WizardListener#wizardStateChanged(boolean)
|
||
213 | */
|
||
214 | public void wizardStateChanged(boolean finishable) { |
||
215 | getBProcesar().setEnabled(finishable); |
||
216 | } |
||
217 | |||
218 | } |
||
219 | public static IProjection getLastProjection() { |
||
220 | return proj;
|
||
221 | } |
||
222 | public static void setLastProjection(IProjection proj) { |
||
223 | GeoreferencingDialog.proj = proj; |
||
224 | } |
||
225 | |||
226 | /**
|
||
227 | * This method initializes jButton
|
||
228 | *
|
||
229 | * @return javax.swing.JButton
|
||
230 | */
|
||
231 | private JButton getBSave() { |
||
232 | if (bSave == null) { |
||
233 | bSave = new JButton(); |
||
234 | bSave.setText(PluginServices.getText(this,"guardar")); |
||
235 | bSave.setEnabled(false);
|
||
236 | } |
||
237 | return bSave;
|
||
238 | } |
||
239 | } // @jve:decl-index=0:visual-constraint="10,10"
|
||
240 | // @jve:visual-info decl-index=0 visual-constraint="10,10"
|
||
241 | // @jve:visual-info decl-index=0 visual-constraint="10,10" |