Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFramePictureDialog.java @ 312

History | View | Annotate | Download (10.5 KB)

1
/*
2
 * Created on 02-jun-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
package com.iver.cit.gvsig.gui.layout.fframes.dialogs;
8

    
9
import java.awt.Graphics2D;
10
import java.awt.Image;
11
import java.awt.geom.Rectangle2D;
12
import java.awt.image.BufferedImage;
13

    
14
import javax.swing.ImageIcon;
15
import javax.swing.JPanel;
16

    
17
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
18
import com.iver.cit.gvsig.gui.layout.Layout;
19
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture;
20
import com.iver.mdiApp.App;
21
import com.iver.mdiApp.Utilities;
22
import com.iver.mdiApp.plugins.files.SelectedFile;
23
import com.iver.mdiApp.ui.MDIApplicationContextImpl;
24
import com.iver.mdiApp.ui.MDIManager.ViewInfo;
25

    
26

    
27

    
28
/**
29
 * Dialogo para a?adir una imagen al Layout.
30
 * 
31
 * @author Vicente Caballero Navarro
32
 *
33
 */
34
public class FFramePictureDialog extends JPanel implements IFFrameDialog {
35
    private javax.swing.JPanel jContentPane = null;
36
    private javax.swing.JLabel lFichero = null;
37
    private javax.swing.JTextField tFichero = null;
38
    private javax.swing.JButton bExaminar = null;
39
    private javax.swing.JLabel lVisualizacion = null;
40
    private javax.swing.JComboBox cbVisualizacion = null;
41
    private javax.swing.JLabel lCalidad = null;
42
    private javax.swing.JComboBox cbCalidad = null;
43
    private javax.swing.JButton bAceptar = null;
44
    private javax.swing.JButton bCancelar = null;
45
    private Rectangle2D rect = new Rectangle2D.Double();
46
    private SelectedFile selectedFile = null;
47
        private FFramePicture fframepicture=null;// = new FFramePicture();
48
    private String namefile=null;         
49
        private Layout m_layout=null;
50
        private boolean isAcepted=false;
51
        private ViewInfo m_viewinfo = null;
52
    /**
53
     * This is the default constructor
54
     */
55
    public FFramePictureDialog(Layout layout,FFramePicture fframe) {
56
        super();
57
        fframepicture=fframe;
58
                m_layout=layout;
59
        initialize();
60
    }
61

    
62
    /**
63
     * DOCUMENT ME!
64
     *
65
     * @param r DOCUMENT ME!
66
     */
67
    public void setRectangle(Rectangle2D r) {
68
        rect.setRect(r);
69
       // this.setVisible(true);
70
    }
71

    
72
    /**
73
     * This method initializes this
74
     */
75
    private void initialize() {
76
        this.setLayout(null);
77
        this.add(getJContentPane(), null);
78
        this.setSize(381, 127);
79
   }
80

    
81
    /**
82
     * This method initializes jContentPane
83
     *
84
     * @return javax.swing.JPanel
85
     */
86
    private javax.swing.JPanel getJContentPane() {
87
        if (jContentPane == null) {
88
            jContentPane = new javax.swing.JPanel();
89
            jContentPane.setLayout(null);
90
            jContentPane.add(getLFichero(), null);
91
            jContentPane.add(getLCalidad(), null);
92
            jContentPane.add(getCbCalidad(), null);
93
            jContentPane.add(getTFichero(), null);
94
            jContentPane.add(getBExaminar(), null);
95
            jContentPane.add(getLVisualizacion(), null);
96
            jContentPane.add(getCbVisualizacion(), null);
97
            jContentPane.add(getBAceptar(), null);
98
            jContentPane.add(getBCancelar(), null);
99
            jContentPane.setSize(385, 128);
100
            jContentPane.setLocation(0, 0);
101
        }
102

    
103
        return jContentPane;
104
    }
105

    
106
    /**
107
     * This method initializes lFichero
108
     *
109
     * @return javax.swing.JLabel
110
     */
111
    private javax.swing.JLabel getLFichero() {
112
        if (lFichero == null) {
113
            lFichero = new javax.swing.JLabel();
114
            lFichero.setSize(42, 20);
115
            lFichero.setText(Utilities.getMessage(this,"Fichero"));
116
            lFichero.setLocation(10, 9);
117
        }
118

    
119
        return lFichero;
120
    }
121

    
122
    /**
123
     * This method initializes tFichero
124
     *
125
     * @return javax.swing.JTextField
126
     */
127
    private javax.swing.JTextField getTFichero() {
128
        if (tFichero == null) {
129
            tFichero = new javax.swing.JTextField();
130
            tFichero.setBounds(62, 8, 200, 20);
131
            tFichero.setPreferredSize(new java.awt.Dimension(200, 20));
132
           
133
        }
134
                if (fframepicture.getPath()!=null)tFichero.setText(fframepicture.getPath());
135
        return tFichero;
136
    }
137

    
138
    /**
139
     * This method initializes bExaminar
140
     *
141
     * @return javax.swing.JButton
142
     */
143
    private javax.swing.JButton getBExaminar() {
144
        if (bExaminar == null) {
145
            bExaminar = new javax.swing.JButton();
146
            bExaminar.setSize(88, 23);
147
            bExaminar.setText(Utilities.getMessage(this,"Examinar"));
148
            bExaminar.setLocation(275, 6);
149
            bExaminar.setPreferredSize(new java.awt.Dimension(88,23));
150
            bExaminar.addActionListener(new java.awt.event.ActionListener() {
151
                              public void actionPerformed(java.awt.event.ActionEvent e) {
152
                                                
153
                                                String[] extensiones = { "jpeg", "gif", "png", "jpg" };
154
                        String[] descripciones = {
155
                            "Files JPEG", "Files GIF", "Files PNG", "Files JPG"
156
                        };
157

    
158
                        selectedFile = App.instance.getMDIContext().showFileChooser(null, extensiones, descripciones, Utilities.getMessage(this,"Abrir_Imagen"),
159
                                false,
160
                               MDIApplicationContextImpl.FILES_AND_DIRECTORIES);
161

    
162
                                        namefile=selectedFile.getFile().getName();
163
                                        getTFichero().setText(selectedFile.getFile().getAbsolutePath());
164
                    fframepicture.setPath(selectedFile.getFile().getAbsolutePath());    
165
                                                
166
                }
167
                });
168
        }
169

    
170
        return bExaminar;
171
    }
172

    
173
    /**
174
     * DOCUMENT ME!
175
     *
176
     * @param val DOCUMENT ME!
177
     */
178
    public void setText(String val) {
179
        getTFichero().setText(val);
180
    }
181

    
182
    /**
183
     * This method initializes lVisualizacion
184
     *
185
     * @return javax.swing.JLabel
186
     */
187
    private javax.swing.JLabel getLVisualizacion() {
188
        if (lVisualizacion == null) {
189
            lVisualizacion = new javax.swing.JLabel();
190
            lVisualizacion.setBounds(9, 62, 75, 20);
191
            lVisualizacion.setText(Utilities.getMessage(this,"visualizacion"));
192
        }
193

    
194
        return lVisualizacion;
195
    }
196

    
197
    /**
198
     * This method initializes cbVisualizacion
199
     *
200
     * @return javax.swing.JComboBox
201
     */
202
    private javax.swing.JComboBox getCbVisualizacion() {
203
        if (cbVisualizacion == null) {
204
            cbVisualizacion = new javax.swing.JComboBox();
205
            cbVisualizacion.setSize(245, 20);
206
            cbVisualizacion.addItem(Utilities.getMessage(this,"cuando_activo"));
207
                        cbVisualizacion.addItem(Utilities.getMessage(this,"siempre"));
208
                        cbVisualizacion.setSelectedIndex(fframepicture.getViewing());
209
            cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20));
210
            cbVisualizacion.setLocation(118, 62);
211
            cbVisualizacion.setEnabled(false);
212
        }
213

    
214
        return cbVisualizacion;
215
    }
216

    
217
    /**
218
     * This method initializes lCalidad
219
     *
220
     * @return javax.swing.JLabel
221
     */
222
    private javax.swing.JLabel getLCalidad() {
223
        if (lCalidad == null) {
224
            lCalidad = new javax.swing.JLabel();
225
            lCalidad.setSize(42, 20);
226
            lCalidad.setText(Utilities.getMessage(this,"calidad"));
227
            lCalidad.setLocation(10, 35);
228
        }
229

    
230
        return lCalidad;
231
    }
232

    
233
    /**
234
     * This method initializes cbCalidad
235
     *
236
     * @return javax.swing.JComboBox
237
     */
238
    private javax.swing.JComboBox getCbCalidad() {
239
        if (cbCalidad == null) {
240
            cbCalidad = new javax.swing.JComboBox();
241
            cbCalidad.setSize(245, 20);
242
            cbCalidad.addItem(Utilities.getMessage(this,"presentacion"));
243
                        cbCalidad.addItem(Utilities.getMessage(this,"borrador"));
244
                        cbCalidad.setSelectedIndex(fframepicture.getQuality());
245
            cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20));
246
            cbCalidad.setLocation(118, 35);
247
        }
248

    
249
        return cbCalidad;
250
    }
251

    
252
    /**
253
     * This method initializes bAceptar
254
     *
255
     * @return javax.swing.JButton
256
     */
257
    private javax.swing.JButton getBAceptar() {
258
        if (bAceptar == null) {
259
            bAceptar = new javax.swing.JButton();
260
            bAceptar.setSize(85, 26);
261
            bAceptar.setText(Utilities.getMessage(this,"Aceptar"));
262
            bAceptar.setLocation(70, 89);
263
            bAceptar.addActionListener(new java.awt.event.ActionListener() { 
264
                    public void actionPerformed(java.awt.event.ActionEvent e) {    
265
                                        try {
266
                                                Image image = new ImageIcon(getTFichero().getText()).getImage();
267
                                                BufferedImage bi = new BufferedImage((int) image.getWidth(null),
268
                                                        (int) image.getHeight(null), BufferedImage.TYPE_INT_RGB);
269
                                                Graphics2D biContext = bi.createGraphics();
270
                                                biContext.drawImage(image, 0, 0, null);
271
                                                fframepicture.setImage(bi);
272
                                                } catch (Exception ex) {
273
                                                        App.instance.getNm().addError("Excepci?n :",ex);
274
                                                }
275
                                                fframepicture.setViewing(getCbVisualizacion().getSelectedIndex());
276
                                                fframepicture.setQuality(getCbCalidad().getSelectedIndex());
277
                                                if (namefile!=null)fframepicture.setName(namefile);
278
                                        fframepicture.setBoundBox(FLayoutUtilities.toSheetRect(rect,m_layout.getAT()));
279
                                        App.instance.getMDIContext().closeView(FFramePictureDialog.this);
280
                                        m_layout.refresh();
281
                                        isAcepted=true;
282
                                }
283
            });
284
        }
285

    
286
        return bAceptar;
287
    }
288

    
289
    /**
290
     * This method initializes bCancelar
291
     *
292
     * @return javax.swing.JButton
293
     */
294
    private javax.swing.JButton getBCancelar() {
295
        if (bCancelar == null) {
296
            bCancelar = new javax.swing.JButton();
297
            bCancelar.setSize(85, 26);
298
            bCancelar.setText(Utilities.getMessage(this,"Cancelar"));
299
            bCancelar.setLocation(219, 89);
300
            bCancelar.addActionListener(new java.awt.event.ActionListener() { 
301
                    public void actionPerformed(java.awt.event.ActionEvent e) {    
302
                                        App.instance.getMDIContext().closeView(FFramePictureDialog.this);
303
                                }
304
            });
305
        }
306

    
307
        return bCancelar;
308
    }
309

    
310
        /* (non-Javadoc)
311
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
312
         */
313
        public ViewInfo getViewInfo() {
314
                if (m_viewinfo==null){
315
                    m_viewinfo=new ViewInfo();
316
                    m_viewinfo.setFeatures(ViewInfo.MODALDIALOG);
317
                    m_viewinfo.setTitle(Utilities.getMessage(this,"propiedades_marco_imagenes"));
318
                }
319
                return m_viewinfo;
320
                }
321

    
322
        /**
323
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
324
         */
325
        public boolean getIsAcepted() {
326
                return isAcepted;
327
        }
328

    
329
        /**
330
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
331
         */
332
        public void viewActivated() {
333
        }
334
}  //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
335
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"