svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFramePictureDialog.java @ 596
History | View | Annotate | Download (10.7 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.Component; |
10 |
import java.awt.Graphics2D; |
11 |
import java.awt.Image; |
12 |
import java.awt.geom.Rectangle2D; |
13 |
import java.awt.image.BufferedImage; |
14 |
import java.io.File; |
15 |
|
16 |
import javax.swing.ImageIcon; |
17 |
import javax.swing.JFileChooser; |
18 |
import javax.swing.JPanel; |
19 |
|
20 |
import com.iver.andami.PluginServices; |
21 |
import com.iver.andami.messages.NotificationManager; |
22 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
23 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
24 |
import com.iver.cit.gvsig.gui.layout.Layout; |
25 |
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture; |
26 |
import com.iver.utiles.GenericFileFilter; |
27 |
|
28 |
|
29 |
|
30 |
/**
|
31 |
* Dialogo para a?adir una imagen al Layout.
|
32 |
*
|
33 |
* @author Vicente Caballero Navarro
|
34 |
*
|
35 |
*/
|
36 |
public class FFramePictureDialog extends JPanel implements IFFrameDialog { |
37 |
private javax.swing.JPanel jContentPane = null; |
38 |
private javax.swing.JLabel lFichero = null; |
39 |
private javax.swing.JTextField tFichero = null; |
40 |
private javax.swing.JButton bExaminar = null; |
41 |
private javax.swing.JLabel lVisualizacion = null; |
42 |
private javax.swing.JComboBox cbVisualizacion = null; |
43 |
private javax.swing.JLabel lCalidad = null; |
44 |
private javax.swing.JComboBox cbCalidad = null; |
45 |
private javax.swing.JButton bAceptar = null; |
46 |
private javax.swing.JButton bCancelar = null; |
47 |
private Rectangle2D rect = new Rectangle2D.Double(); |
48 |
private FFramePicture fframepicture=null;// = new FFramePicture(); |
49 |
private String namefile=null; |
50 |
private Layout m_layout=null; |
51 |
private boolean isAcepted=false; |
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(PluginServices.getText(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(PluginServices.getText(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 |
GenericFileFilter jpegFilter = new GenericFileFilter("jpeg", "Files JPEG"); |
153 |
GenericFileFilter jpgFilter = new GenericFileFilter("jpg", "Files JPG"); |
154 |
GenericFileFilter gifFilter = new GenericFileFilter("gif", "Files GIF"); |
155 |
GenericFileFilter pngFilter = new GenericFileFilter("png", "Files PNG"); |
156 |
|
157 |
JFileChooser jfc = new JFileChooser(); |
158 |
jfc.addChoosableFileFilter(jpegFilter); |
159 |
jfc.addChoosableFileFilter(jpgFilter); |
160 |
jfc.addChoosableFileFilter(gifFilter); |
161 |
jfc.addChoosableFileFilter(pngFilter); |
162 |
|
163 |
if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION){ |
164 |
File file = jfc.getSelectedFile();
|
165 |
namefile=file.getName(); |
166 |
getTFichero().setText(file.getAbsolutePath()); |
167 |
fframepicture.setPath(file.getAbsolutePath()); |
168 |
} |
169 |
} |
170 |
}); |
171 |
} |
172 |
|
173 |
return bExaminar;
|
174 |
} |
175 |
|
176 |
/**
|
177 |
* DOCUMENT ME!
|
178 |
*
|
179 |
* @param val DOCUMENT ME!
|
180 |
*/
|
181 |
public void setText(String val) { |
182 |
getTFichero().setText(val); |
183 |
} |
184 |
|
185 |
/**
|
186 |
* This method initializes lVisualizacion
|
187 |
*
|
188 |
* @return javax.swing.JLabel
|
189 |
*/
|
190 |
private javax.swing.JLabel getLVisualizacion() {
|
191 |
if (lVisualizacion == null) { |
192 |
lVisualizacion = new javax.swing.JLabel();
|
193 |
lVisualizacion.setBounds(9, 62, 75, 20); |
194 |
lVisualizacion.setText(PluginServices.getText(this,"visualizacion")); |
195 |
} |
196 |
|
197 |
return lVisualizacion;
|
198 |
} |
199 |
|
200 |
/**
|
201 |
* This method initializes cbVisualizacion
|
202 |
*
|
203 |
* @return javax.swing.JComboBox
|
204 |
*/
|
205 |
private javax.swing.JComboBox getCbVisualizacion() {
|
206 |
if (cbVisualizacion == null) { |
207 |
cbVisualizacion = new javax.swing.JComboBox();
|
208 |
cbVisualizacion.setSize(245, 20); |
209 |
cbVisualizacion.addItem(PluginServices.getText(this,"cuando_activo")); |
210 |
cbVisualizacion.addItem(PluginServices.getText(this,"siempre")); |
211 |
cbVisualizacion.setSelectedIndex(fframepicture.getViewing()); |
212 |
cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20)); |
213 |
cbVisualizacion.setLocation(118, 62); |
214 |
cbVisualizacion.setEnabled(false);
|
215 |
} |
216 |
|
217 |
return cbVisualizacion;
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* This method initializes lCalidad
|
222 |
*
|
223 |
* @return javax.swing.JLabel
|
224 |
*/
|
225 |
private javax.swing.JLabel getLCalidad() {
|
226 |
if (lCalidad == null) { |
227 |
lCalidad = new javax.swing.JLabel();
|
228 |
lCalidad.setSize(42, 20); |
229 |
lCalidad.setText(PluginServices.getText(this,"calidad")); |
230 |
lCalidad.setLocation(10, 35); |
231 |
} |
232 |
|
233 |
return lCalidad;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* This method initializes cbCalidad
|
238 |
*
|
239 |
* @return javax.swing.JComboBox
|
240 |
*/
|
241 |
private javax.swing.JComboBox getCbCalidad() {
|
242 |
if (cbCalidad == null) { |
243 |
cbCalidad = new javax.swing.JComboBox();
|
244 |
cbCalidad.setSize(245, 20); |
245 |
cbCalidad.addItem(PluginServices.getText(this,"presentacion")); |
246 |
cbCalidad.addItem(PluginServices.getText(this,"borrador")); |
247 |
cbCalidad.setSelectedIndex(fframepicture.getQuality()); |
248 |
cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20)); |
249 |
cbCalidad.setLocation(118, 35); |
250 |
} |
251 |
|
252 |
return cbCalidad;
|
253 |
} |
254 |
|
255 |
/**
|
256 |
* This method initializes bAceptar
|
257 |
*
|
258 |
* @return javax.swing.JButton
|
259 |
*/
|
260 |
private javax.swing.JButton getBAceptar() {
|
261 |
if (bAceptar == null) { |
262 |
bAceptar = new javax.swing.JButton();
|
263 |
bAceptar.setSize(85, 26); |
264 |
bAceptar.setText(PluginServices.getText(this,"Aceptar")); |
265 |
bAceptar.setLocation(70, 89); |
266 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
267 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
268 |
try {
|
269 |
Image image = new ImageIcon(getTFichero().getText()).getImage(); |
270 |
BufferedImage bi = new BufferedImage((int) image.getWidth(null), |
271 |
(int) image.getHeight(null), BufferedImage.TYPE_INT_RGB); |
272 |
Graphics2D biContext = bi.createGraphics();
|
273 |
biContext.drawImage(image, 0, 0, null); |
274 |
fframepicture.setImage(bi); |
275 |
} catch (Exception ex) { |
276 |
NotificationManager.addError("Excepci?n :",ex);
|
277 |
} |
278 |
fframepicture.setViewing(getCbVisualizacion().getSelectedIndex()); |
279 |
fframepicture.setQuality(getCbCalidad().getSelectedIndex()); |
280 |
if (namefile!=null)fframepicture.setName(namefile); |
281 |
fframepicture.setBoundBox(FLayoutUtilities.toSheetRect(rect,m_layout.getAT())); |
282 |
PluginServices.getMDIManager().closeView(FFramePictureDialog.this); |
283 |
m_layout.refresh(); |
284 |
isAcepted=true;
|
285 |
} |
286 |
}); |
287 |
} |
288 |
|
289 |
return bAceptar;
|
290 |
} |
291 |
|
292 |
/**
|
293 |
* This method initializes bCancelar
|
294 |
*
|
295 |
* @return javax.swing.JButton
|
296 |
*/
|
297 |
private javax.swing.JButton getBCancelar() {
|
298 |
if (bCancelar == null) { |
299 |
bCancelar = new javax.swing.JButton();
|
300 |
bCancelar.setSize(85, 26); |
301 |
bCancelar.setText(PluginServices.getText(this,"Cancelar")); |
302 |
bCancelar.setLocation(219, 89); |
303 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
304 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
305 |
PluginServices.getMDIManager().closeView(FFramePictureDialog.this); |
306 |
} |
307 |
}); |
308 |
} |
309 |
|
310 |
return bCancelar;
|
311 |
} |
312 |
|
313 |
/* (non-Javadoc)
|
314 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
315 |
*/
|
316 |
public ViewInfo getViewInfo() {
|
317 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
|
318 |
m_viewinfo.setTitle(PluginServices.getText(this,"propiedades_marco_imagenes")); |
319 |
|
320 |
return m_viewinfo;
|
321 |
} |
322 |
|
323 |
/**
|
324 |
* @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
|
325 |
*/
|
326 |
public boolean getIsAcepted() { |
327 |
return isAcepted;
|
328 |
} |
329 |
|
330 |
/**
|
331 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
332 |
*/
|
333 |
public void viewActivated() { |
334 |
} |
335 |
} // @jve:visual-info decl-index=0 visual-constraint="10,10"
|
336 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|