Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameOverViewDialog.java @ 9392

History | View | Annotate | Download (10.7 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs;
42

    
43
import java.awt.geom.Rectangle2D;
44

    
45
import javax.swing.JList;
46
import javax.swing.JPanel;
47

    
48
import com.iver.andami.PluginServices;
49
import com.iver.andami.ui.mdiManager.WindowInfo;
50
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities;
51
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameView;
52
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
53
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel;
54
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
55
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
56
import com.iver.cit.gvsig.project.documents.view.ProjectView;
57

    
58

    
59
/**
60
 * Di?logo para a?adir una localizador al Layout.
61
 *
62
 * @author Vicente Caballero Navarro
63
 */
64
public class FFrameOverViewDialog extends JPanel implements IFFrameDialog {
65
        private javax.swing.JPanel jContentPane = null;  //  @jve:decl-index=0:visual-constraint="37,10"
66
        private javax.swing.JLabel lVistas = null;
67
        private javax.swing.JScrollPane jScrollPane = null;
68
        private javax.swing.JList liVistas = null; //  @jve:visual-info  decl-index=0 visual-constraint="98,-3"
69
        private javax.swing.JButton bAceptar = null;
70
        private javax.swing.JButton bCancelar = null;
71
        private javax.swing.JLabel lCalidad = null;
72
        private javax.swing.JComboBox cbCalidad = null;
73
        private ProjectView m_projectView = null;
74
        private Rectangle2D rect = new Rectangle2D.Double();
75
        private FFrameView fframeview = null; //new FFrameView();
76
        private Layout m_layout = null;
77
        private boolean isAcepted = false;
78
        private JPRotation rotation = null;
79
        private FFrameView newFFrameView;
80

    
81
        /**
82
         * This is the default constructor
83
         *
84
         * @param layout Referencia al Layout.
85
         * @param fframe Referencia al fframe vista.
86
         */
87
        public FFrameOverViewDialog(Layout layout, FFrameView fframe) {
88
                super();
89
                fframeview = fframe;
90
                m_layout = layout;
91
                initialize();
92
        }
93

    
94
        /**
95
         * This method initializes this
96
         */
97
        private void initialize() {
98
                this.setLayout(null);
99
                this.add(getJContentPane(), null);
100
                this.setSize(463, 222);
101

    
102
                getPRotation().setRotation(fframeview.getRotation());
103
        }
104

    
105
        /**
106
         * Inserta el rect?ngulo que ocupar? el fframe vista.
107
         *
108
         * @param r Rect?ngulo.
109
         */
110
        public void setRectangle(Rectangle2D r) {
111
                rect.setRect(r);
112
        }
113

    
114
        /**
115
         * This method initializes jContentPane
116
         *
117
         * @return javax.swing.JPanel
118
         */
119
        private javax.swing.JPanel getJContentPane() {
120
                if (jContentPane == null) {
121
                        jContentPane = new javax.swing.JPanel();
122
                        jContentPane.setLayout(null);
123
                        jContentPane.add(getLVistas(), null);
124
                        jContentPane.add(getJScrollPane(), null);
125
                        jContentPane.add(getLCalidad(), null);
126
                        jContentPane.add(getCbCalidad(), null);
127
                        jContentPane.add(getbAceptar(), null);
128
                        jContentPane.add(getBCancelar(), null);
129
                        jContentPane.setSize(462, 184);
130
                        jContentPane.setPreferredSize(new java.awt.Dimension(60, 60));
131
                        jContentPane.setLocation(0, 0);
132
                        jContentPane.add(getPRotation(), null);
133
                }
134

    
135
                return jContentPane;
136
        }
137

    
138
        /**
139
         * This method initializes lVistas
140
         *
141
         * @return javax.swing.JLabel
142
         */
143
        private javax.swing.JLabel getLVistas() {
144
                if (lVistas == null) {
145
                        lVistas = new javax.swing.JLabel();
146
                        lVistas.setSize(85, 19);
147
                        lVistas.setText(PluginServices.getText(this, "Vista"));
148
                        lVistas.setLocation(10, 10);
149
                }
150

    
151
                return lVistas;
152
        }
153

    
154
        /**
155
         * This method initializes jScrollPane
156
         *
157
         * @return javax.swing.JScrollPane
158
         */
159
        private javax.swing.JScrollPane getJScrollPane() {
160
                if (jScrollPane == null) {
161
                        jScrollPane = new javax.swing.JScrollPane();
162
                        jScrollPane.setViewportView(getLiVistas());
163
                        jScrollPane.setBounds(99, 8, 224, 64);
164
                        jScrollPane.setPreferredSize(new java.awt.Dimension(250, 60));
165
                }
166

    
167
                return jScrollPane;
168
        }
169

    
170
        /**
171
         * This method initializes liVistas
172
         *
173
         * @return javax.swing.JList
174
         */
175
        private javax.swing.JList getLiVistas() {
176
                if (liVistas == null) {
177
                        ListViewModel listmodel = new ListViewModel();
178
                        listmodel.addViews();
179
                        liVistas = new javax.swing.JList();
180
                        liVistas.setModel(listmodel);
181
                        for (int i = 0; i < liVistas.getModel().getSize(); i++) {
182
                                if (fframeview.getMapContext() != null) {
183

    
184
                                        ProjectView pvaux= (ProjectView) liVistas.getModel()
185
                                                                                                                  .getElementAt(i);
186

    
187
                                        if (pvaux.getMapContext().equals(fframeview.getMapContext())) {
188
                                                liVistas.setSelectedIndex(i);
189
                                                m_projectView= (ProjectView) liVistas.getModel()
190
                                                  .getElementAt(i);
191
                                        }
192
                                }
193
                        }
194

    
195
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
196
                                        private int selectIndex=-1;
197
                                        public void valueChanged(
198
                                                javax.swing.event.ListSelectionEvent e) {
199
                                                int selectInt = ((JList)e.getSource()).getSelectedIndex();
200
                                                if (selectInt!=selectIndex){
201
                                                        selectIndex=selectInt;
202
                                                        if (selectIndex==-1)
203
                                                                return;
204
                                                m_projectView = (ProjectView) liVistas.getModel()
205
                                                                                                                          .getElementAt(selectInt);
206

    
207
//                                                fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
208
//                                                                rect, m_layout.getAT()));
209
//                                                fframeview.setView(m_projectView);
210
//
211
//                                                fframeview.setMapUnits(m_projectView.getMapContext()
212
//                                                                                                                        .getViewPort()
213
//                                                                                                                        .getMapUnits());
214
                                        }
215
                                        }
216
                                });
217
                }
218

    
219
                return liVistas;
220
        }
221

    
222
        /**
223
         * This method initializes jButton
224
         *
225
         * @return javax.swing.JButton
226
         */
227
        private javax.swing.JButton getbAceptar() {
228
                if (bAceptar == null) {
229
                        bAceptar = new javax.swing.JButton();
230
                        bAceptar.setSize(85, 26);
231
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
232
                        bAceptar.setLocation(59, 136);
233
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
234

    
235
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
236
                                                newFFrameView=(FFrameView)fframeview.cloneFFrame(m_layout);
237
                                                newFFrameView.setBoundBox(FLayoutUtilities.toSheetRect(
238
                                                                rect, m_layout.getLayoutControl().getAT()));
239
                                                newFFrameView.setRotation(getPRotation().getRotation());
240
                                                if (m_projectView != null) {
241
                                                        newFFrameView.setName(m_projectView.getName());
242

    
243
                                                        newFFrameView.setView(m_projectView);
244

    
245
                                                        newFFrameView.setQuality(getCbCalidad()
246
                                                                                                          .getSelectedIndex());
247
                                                        newFFrameView.setBoundBox(FLayoutUtilities.toSheetRect(
248
                                                                        rect, m_layout.getLayoutControl().getAT()));
249

    
250
                                                        /*        for (int i=0;i<m_layout.getFFrames().size();i++){
251
                                                           IFFrame fframe=(IFFrame)m_layout.getFFrames().get(i);
252
                                                           if (fframe instanceof FFrameScaleBar){
253
                                                                   if (((FFrameScaleBar)fframe).getFFrameView()==fframeview){
254
                                                                   if (getJComboBox().getSelectedIndex()!=0){
255
                                                                   ((FFrameScaleBar)fframe).setIsFixed(true);
256
                                                                   ((FFrameScaleBar)fframe).setScaleView(Long.parseLong(getJTextField().getText()));
257
                                                                   }else{
258
                                                                           ((FFrameScaleBar)fframe).setIsFixed(false);
259
                                                                   }
260

261
                                                                   }
262
                                                           }
263

264

265
                                                           }
266
                                                         */
267
                                                }
268

    
269
                                                isAcepted = true;
270

    
271
                                                //}else{
272
                                                //        isAcepted=false;
273
                                                //}
274
                                                PluginServices.getMDIManager().closeWindow(FFrameOverViewDialog.this);
275
                                                fframeview.refresh();
276
                                                //m_layout.refresh();
277
                                        }
278
                                });
279
                }
280

    
281
                return bAceptar;
282
        }
283

    
284
        /**
285
         * This method initializes bCancelar
286
         *
287
         * @return javax.swing.JButton
288
         */
289
        private javax.swing.JButton getBCancelar() {
290
                if (bCancelar == null) {
291
                        bCancelar = new javax.swing.JButton();
292
                        bCancelar.setSize(85, 26);
293
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
294
                        bCancelar.setLocation(199, 136);
295
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
296
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
297
                                                newFFrameView=null;
298
                                                PluginServices.getMDIManager().closeWindow(FFrameOverViewDialog.this);
299
                                        }
300
                                });
301
                }
302

    
303
                return bCancelar;
304
        }
305

    
306
        /**
307
         * This method initializes lCalidad
308
         *
309
         * @return javax.swing.JLabel
310
         */
311
        private javax.swing.JLabel getLCalidad() {
312
                if (lCalidad == null) {
313
                        lCalidad = new javax.swing.JLabel();
314
                        lCalidad.setSize(86, 16);
315
                        lCalidad.setText(PluginServices.getText(this, "calidad"));
316
                        lCalidad.setLocation(14, 112);
317
                }
318

    
319
                return lCalidad;
320
        }
321

    
322
        /**
323
         * This method initializes cbCalidad
324
         *
325
         * @return javax.swing.JComboBox
326
         */
327
        private javax.swing.JComboBox getCbCalidad() {
328
                if (cbCalidad == null) {
329
                        //String[] s={"Presentaci?n","Borrador"};
330
                        cbCalidad = new javax.swing.JComboBox();
331
                        cbCalidad.setSize(220, 20);
332
                        cbCalidad.addItem(PluginServices.getText(this, "presentacion"));
333
                        cbCalidad.addItem(PluginServices.getText(this, "borrador"));
334
                        cbCalidad.setSelectedIndex(fframeview.getQuality());
335
                        cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20));
336
                        cbCalidad.setLocation(104, 112);
337
                }
338

    
339
                return cbCalidad;
340
        }
341

    
342
        /* (non-Javadoc)
343
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
344
         */
345
        public WindowInfo getWindowInfo() {
346
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
347

    
348
                //vi.setResizable(false);
349
                m_viewinfo.setTitle(PluginServices.getText(this,
350
                                "propiedades_marco_localizador"));
351

    
352
                return m_viewinfo;
353
        }
354

    
355
        /**
356
         * @see com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
357
         */
358
        public boolean getIsAcepted() {
359
                return isAcepted;
360
        }
361

    
362
        /**
363
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
364
         */
365
        public void viewActivated() {
366
        }
367

    
368
        /**
369
         * This method initializes rotation
370
         *
371
         * @return javax.swing.JPanel
372
         */
373
        private JPRotation getPRotation() {
374
                if (rotation == null) {
375
                        rotation = new JPRotation();
376
                        rotation.setBounds(330, 30, 120, 130);
377
                }
378
                return rotation;
379
        }
380

    
381
        public IFFrame getFFrame() {
382
                return newFFrameView;
383
        }
384
}  //  @jve:decl-index=0:visual-constraint="10,10"