Revision 1074 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/dialogs/FConfigLayoutDialog.java

View differences:

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

  
9
import java.awt.Dimension;
10
import java.text.NumberFormat;
11

  
12
import javax.swing.JPanel;
13

  
14 7
import com.iver.andami.PluginServices;
15
import com.iver.andami.Utilities;
16 8
import com.iver.andami.ui.mdiManager.View;
17 9
import com.iver.andami.ui.mdiManager.ViewInfo;
10

  
18 11
import com.iver.cit.gvsig.gui.layout.Attributes;
19 12
import com.iver.cit.gvsig.gui.layout.Layout;
20 13
import com.iver.cit.gvsig.gui.layout.Size;
21 14

  
15
import java.awt.Dimension;
22 16

  
17
import java.text.NumberFormat;
18

  
19
import javax.swing.JPanel;
20

  
21

  
23 22
/**
24 23
 * Clase para configurar el Layout.
25
 * 
24
 *
26 25
 * @author Vicente Caballero Navarro
27
 *
28 26
 */
29 27
public class FConfigLayoutDialog extends JPanel implements View {
30 28
	private javax.swing.JLabel lTamPag = null;
......
50 48
	private javax.swing.JComboBox cbResolucion = null;
51 49
	private javax.swing.JButton bAceptar = null;
52 50
	private javax.swing.JButton bCancelar = null;
53
	private Layout m_layout=null;
51
	private Layout m_layout = null;
54 52
	private javax.swing.JCheckBox chbHorizontal = null;
55 53
	private javax.swing.JCheckBox chbVertical = null;
56
	private int unit=2;
57
	private int type=0;
58
	private boolean isLand=true;
59
	private boolean margin=false;
60
	private int resolution=1;
61
	private double der=2.54;
62
	private double izq=2.54;
63
	private double sup=2.54;
64
	private double inf=2.54;
54
	private int unit = 2;
55
	private int type = 0;
56
	private boolean isLand = true;
57
	private boolean margin = false;
58
	private int resolution = 1;
59
	private double der = 2.54;
60
	private double izq = 2.54;
61
	private double sup = 2.54;
62
	private double inf = 2.54;
65 63
	private NumberFormat nf = NumberFormat.getInstance();
66
	
64

  
67 65
	/**
68 66
	 * This is the default constructor
67
	 *
68
	 * @param layout Referencia al Layout.
69 69
	 */
70 70
	public FConfigLayoutDialog(Layout layout) {
71 71
		super();
72
		m_layout=layout;
72
		m_layout = layout;
73 73
		initialize();
74 74
	}
75

  
75 76
	/**
76 77
	 * This method initializes this
77
	 * 
78
	 * @return void
79 78
	 */
80 79
	private void initialize() {
81 80
		nf.setMaximumFractionDigits(2);
82 81
		this.setLayout(null);
83
		type=m_layout.getAtributes().getType();
84
		unit=m_layout.getAtributes().getSelTypeUnit();
85
		isLand=m_layout.getAtributes().isLandSpace();
86
		sup=m_layout.getAtributes().m_area[0];
87
		inf=m_layout.getAtributes().m_area[1];
88
		izq=m_layout.getAtributes().m_area[2];
89
		der=m_layout.getAtributes().m_area[3];
90
			this.add(getLTamPag(), null);
91
			this.add(getCbTipoFolio(), null);
92
			this.add(getLDistancia(), null);
93
			this.add(getCbUnidades(), null);
94
			this.add(getLAnchura(), null);
95
			this.add(getLAltura(), null);
96
			this.add(getTAncho(), null);
97
			this.add(getTAlto(), null);
98
			this.add(getLOrientacion(), null);
99
			this.add(getLMargenes(), null);
100
			this.add(getChbMargenes(), null);
101
			this.add(getLSuperior(), null);
102
			this.add(getTSuperior(), null);
103
			this.add(getLIzquierdo(), null);
104
			this.add(getTIzquierdo(), null);
105
			this.add(getLInferior(), null);
106
			this.add(getTInferior(), null);
107
			this.add(getLDerecho(), null);
108
			this.add(getTDerecho(), null);
109
			this.add(getLResolucion(), null);
110
			this.add(getCbResolucion(), null);
111
			this.add(getBAceptar(), null);
112
			this.add(getBCancelar(), null);
113
			this.add(getChbHorizontal(), null);
114
			this.add(getChbVertical(), null);
115
			this.setPreferredSize(new Dimension(371, 300));
116
			
82
		type = m_layout.getAtributes().getType();
83
		unit = m_layout.getAtributes().getSelTypeUnit();
84
		isLand = m_layout.getAtributes().isLandSpace();
85
		sup = m_layout.getAtributes().m_area[0];
86
		inf = m_layout.getAtributes().m_area[1];
87
		izq = m_layout.getAtributes().m_area[2];
88
		der = m_layout.getAtributes().m_area[3];
89
		this.add(getLTamPag(), null);
90
		this.add(getCbTipoFolio(), null);
91
		this.add(getLDistancia(), null);
92
		this.add(getCbUnidades(), null);
93
		this.add(getLAnchura(), null);
94
		this.add(getLAltura(), null);
95
		this.add(getTAncho(), null);
96
		this.add(getTAlto(), null);
97
		this.add(getLOrientacion(), null);
98
		this.add(getLMargenes(), null);
99
		this.add(getChbMargenes(), null);
100
		this.add(getLSuperior(), null);
101
		this.add(getTSuperior(), null);
102
		this.add(getLIzquierdo(), null);
103
		this.add(getTIzquierdo(), null);
104
		this.add(getLInferior(), null);
105
		this.add(getTInferior(), null);
106
		this.add(getLDerecho(), null);
107
		this.add(getTDerecho(), null);
108
		this.add(getLResolucion(), null);
109
		this.add(getCbResolucion(), null);
110
		this.add(getBAceptar(), null);
111
		this.add(getBCancelar(), null);
112
		this.add(getChbHorizontal(), null);
113
		this.add(getChbVertical(), null);
114
		this.setPreferredSize(new Dimension(371, 300));
117 115
	}
118
	
116

  
119 117
	/**
120 118
	 * This method initializes lTamPag
121
	 * 
119
	 *
122 120
	 * @return javax.swing.JLabel
123 121
	 */
124 122
	private javax.swing.JLabel getLTamPag() {
125
		if(lTamPag == null) {
123
		if (lTamPag == null) {
126 124
			lTamPag = new javax.swing.JLabel();
127 125
			lTamPag.setSize(134, 20);
128
			lTamPag.setText(PluginServices.getText(this,"tamano_pagina")+":");
126
			lTamPag.setText(PluginServices.getText(this, "tamano_pagina") +
127
				":");
129 128
			lTamPag.setLocation(25, 15);
130 129
		}
130

  
131 131
		return lTamPag;
132 132
	}
133

  
133 134
	/**
134 135
	 * This method initializes cbTipoFolio
135
	 * 
136
	 *
136 137
	 * @return javax.swing.JComboBox
137 138
	 */
138 139
	private javax.swing.JComboBox getCbTipoFolio() {
139
		if(cbTipoFolio == null) {
140
		if (cbTipoFolio == null) {
140 141
			cbTipoFolio = new javax.swing.JComboBox();
141 142
			cbTipoFolio.setSize(175, 20);
142
			cbTipoFolio.setPreferredSize(new java.awt.Dimension(130,20));
143
			cbTipoFolio.setPreferredSize(new java.awt.Dimension(130, 20));
143 144
			cbTipoFolio.setLocation(175, 15);
144
			cbTipoFolio.addItem(PluginServices.getText(this,"Igual_que_la_impresora"));
145
			cbTipoFolio.addItem(PluginServices.getText(this,"A4"));
146
			cbTipoFolio.addItem(PluginServices.getText(this,"A3"));
147
			cbTipoFolio.addItem(PluginServices.getText(this,"A2"));
148
			cbTipoFolio.addItem(PluginServices.getText(this,"A1"));
149
			cbTipoFolio.addItem(PluginServices.getText(this,"A0"));
150
			cbTipoFolio.addItem(PluginServices.getText(this,"Personalizado"));
151
			
152
			cbTipoFolio.setSelectedIndex(m_layout.getAtributes().getType());		
153
			cbTipoFolio.addActionListener(new java.awt.event.ActionListener() { 
154
				public void actionPerformed(java.awt.event.ActionEvent e) {    
155
				type=cbTipoFolio.getSelectedIndex();
156
				Size size=m_layout.getAtributes().getSizeinUnits(isLand,type);
157
				getTAlto().setText(String.valueOf(nf.format(size.getAlto())));
158
				getTAncho().setText(String.valueOf(nf.format(size.getAncho())));
159
				setMargin(margin);
160
				}
161
			});
145
			cbTipoFolio.addItem(PluginServices.getText(this,
146
					"Igual_que_la_impresora"));
147
			cbTipoFolio.addItem(PluginServices.getText(this, "A4"));
148
			cbTipoFolio.addItem(PluginServices.getText(this, "A3"));
149
			cbTipoFolio.addItem(PluginServices.getText(this, "A2"));
150
			cbTipoFolio.addItem(PluginServices.getText(this, "A1"));
151
			cbTipoFolio.addItem(PluginServices.getText(this, "A0"));
152
			cbTipoFolio.addItem(PluginServices.getText(this, "Personalizado"));
153

  
154
			cbTipoFolio.setSelectedIndex(m_layout.getAtributes().getType());
155
			cbTipoFolio.addActionListener(new java.awt.event.ActionListener() {
156
					public void actionPerformed(java.awt.event.ActionEvent e) {
157
						type = cbTipoFolio.getSelectedIndex();
158

  
159
						Size size = m_layout.getAtributes().getSizeinUnits(isLand,
160
								type);
161
						getTAlto().setText(String.valueOf(nf.format(
162
									size.getAlto())));
163
						getTAncho().setText(String.valueOf(nf.format(
164
									size.getAncho())));
165
						setMargin(margin);
166
					}
167
				});
162 168
		}
169

  
163 170
		return cbTipoFolio;
164 171
	}
172

  
165 173
	/**
166 174
	 * This method initializes lDistancia
167
	 * 
175
	 *
168 176
	 * @return javax.swing.JLabel
169 177
	 */
170 178
	private javax.swing.JLabel getLDistancia() {
171
		if(lDistancia == null) {
179
		if (lDistancia == null) {
172 180
			lDistancia = new javax.swing.JLabel();
173 181
			lDistancia.setSize(137, 19);
174
			lDistancia.setText(PluginServices.getText(this,"distance_units"));
182
			lDistancia.setText(PluginServices.getText(this, "distance_units"));
175 183
			lDistancia.setLocation(25, 40);
176 184
		}
185

  
177 186
		return lDistancia;
178 187
	}
188

  
179 189
	/**
180 190
	 * This method initializes cbUnidades
181
	 * 
191
	 *
182 192
	 * @return javax.swing.JComboBox
183 193
	 */
184 194
	private javax.swing.JComboBox getCbUnidades() {
185
		if(cbUnidades == null) {
195
		if (cbUnidades == null) {
186 196
			cbUnidades = new javax.swing.JComboBox(Attributes.NAMES);
187 197
			cbUnidades.setSize(175, 20);
188 198
			cbUnidades.setLocation(175, 40);
189
			cbUnidades.setSelectedIndex(m_layout.getAtributes().getSelTypeUnit());		
190
			cbUnidades.addActionListener(new java.awt.event.ActionListener() { 
191
				public void actionPerformed(java.awt.event.ActionEvent e) {    
192
					unit=cbUnidades.getSelectedIndex();
193
					m_layout.getAtributes().setUnit(unit);
194
					Size size=m_layout.getAtributes().getSizeinUnits(isLand,type);
195
					getTAlto().setText(String.valueOf(nf.format(size.getAncho())));
196
					getTAncho().setText(String.valueOf(nf.format(size.getAlto())));
197
					setMargin(margin);
198
				}
199
			});
200
		
199
			cbUnidades.setSelectedIndex(m_layout.getAtributes().getSelTypeUnit());
200
			cbUnidades.addActionListener(new java.awt.event.ActionListener() {
201
					public void actionPerformed(java.awt.event.ActionEvent e) {
202
						unit = cbUnidades.getSelectedIndex();
203
						m_layout.getAtributes().setUnit(unit);
204

  
205
						Size size = m_layout.getAtributes().getSizeinUnits(isLand,
206
								type);
207
						getTAlto().setText(String.valueOf(nf.format(
208
									size.getAncho())));
209
						getTAncho().setText(String.valueOf(nf.format(
210
									size.getAlto())));
211
						setMargin(margin);
212
					}
213
				});
201 214
		}
215

  
202 216
		return cbUnidades;
203 217
	}
218

  
204 219
	/**
205 220
	 * This method initializes lAnchura
206
	 * 
221
	 *
207 222
	 * @return javax.swing.JLabel
208 223
	 */
209 224
	private javax.swing.JLabel getLAnchura() {
210
		if(lAnchura == null) {
225
		if (lAnchura == null) {
211 226
			lAnchura = new javax.swing.JLabel();
212 227
			lAnchura.setSize(81, 21);
213
			lAnchura.setText(PluginServices.getText(this,"anchura"));
228
			lAnchura.setText(PluginServices.getText(this, "anchura"));
214 229
			lAnchura.setLocation(25, 65);
215 230
		}
231

  
216 232
		return lAnchura;
217 233
	}
234

  
218 235
	/**
219 236
	 * This method initializes lAltura
220
	 * 
237
	 *
221 238
	 * @return javax.swing.JLabel
222 239
	 */
223 240
	private javax.swing.JLabel getLAltura() {
224
		if(lAltura == null) {
241
		if (lAltura == null) {
225 242
			lAltura = new javax.swing.JLabel();
226 243
			lAltura.setSize(90, 21);
227
			lAltura.setText(PluginServices.getText(this,"altura"));
244
			lAltura.setText(PluginServices.getText(this, "altura"));
228 245
			lAltura.setLocation(180, 65);
229 246
		}
247

  
230 248
		return lAltura;
231 249
	}
250

  
232 251
	/**
233 252
	 * This method initializes tAncho
234
	 * 
253
	 *
235 254
	 * @return javax.swing.JTextField
236 255
	 */
237 256
	private javax.swing.JTextField getTAncho() {
238
		if(tAncho == null) {
257
		if (tAncho == null) {
239 258
			tAncho = new javax.swing.JTextField();
240 259
			tAncho.setSize(60, 20);
241 260
			tAncho.setLocation(110, 65);
242
			Size size=m_layout.getAtributes().getSizeinUnits(isLand,type);
243
			String s=String.valueOf(nf.format(size.getAncho()));
261

  
262
			Size size = m_layout.getAtributes().getSizeinUnits(isLand, type);
263
			String s = String.valueOf(nf.format(size.getAncho()));
244 264
			tAncho.setText(s);
245 265
		}
266

  
246 267
		return tAncho;
247 268
	}
269

  
248 270
	/**
249 271
	 * This method initializes tAlto
250
	 * 
272
	 *
251 273
	 * @return javax.swing.JTextField
252 274
	 */
253 275
	private javax.swing.JTextField getTAlto() {
254
		if(tAlto == null) {
276
		if (tAlto == null) {
255 277
			tAlto = new javax.swing.JTextField();
256 278
			tAlto.setSize(60, 20);
257 279
			tAlto.setLocation(280, 65);
258
			Size size=m_layout.getAtributes().getSizeinUnits(isLand,type);
259
			String s=String.valueOf(nf.format(size.getAlto()));
280

  
281
			Size size = m_layout.getAtributes().getSizeinUnits(isLand, type);
282
			String s = String.valueOf(nf.format(size.getAlto()));
260 283
			tAlto.setText(s);
261 284
		}
285

  
262 286
		return tAlto;
263 287
	}
288

  
264 289
	/**
265 290
	 * This method initializes lOrientacion
266
	 * 
291
	 *
267 292
	 * @return javax.swing.JLabel
268 293
	 */
269 294
	private javax.swing.JLabel getLOrientacion() {
270
		if(lOrientacion == null) {
295
		if (lOrientacion == null) {
271 296
			lOrientacion = new javax.swing.JLabel();
272 297
			lOrientacion.setSize(102, 38);
273
			lOrientacion.setText(PluginServices.getText(this,"orientacion"));
298
			lOrientacion.setText(PluginServices.getText(this, "orientacion"));
274 299
			lOrientacion.setLocation(25, 100);
275 300
		}
301

  
276 302
		return lOrientacion;
277 303
	}
304

  
278 305
	/**
279 306
	 * This method initializes lMargenes
280
	 * 
307
	 *
281 308
	 * @return javax.swing.JLabel
282 309
	 */
283 310
	private javax.swing.JLabel getLMargenes() {
284
		if(lMargenes == null) {
311
		if (lMargenes == null) {
285 312
			lMargenes = new javax.swing.JLabel();
286 313
			lMargenes.setSize(95, 20);
287
			lMargenes.setText(PluginServices.getText(this,"margenes"));
314
			lMargenes.setText(PluginServices.getText(this, "margenes"));
288 315
			lMargenes.setLocation(25, 145);
289 316
		}
317

  
290 318
		return lMargenes;
291 319
	}
292
	private void setMargin(boolean b){
293
		margin=b;
294
		if (b){
295
			getTSuperior().setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(sup))));
296
			getTIzquierdo().setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(izq))));
297
			getTInferior().setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(inf))));
298
			getTDerecho().setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(der))));
320

  
321
	/**
322
	 * Inserta si se dibuja los margenes sobre el Layout o no.
323
	 *
324
	 * @param b True si se tiene que dibujar los margenes.
325
	 */
326
	private void setMargin(boolean b) {
327
		margin = b;
328

  
329
		if (b) {
330
			getTSuperior().setText(String.valueOf(nf.format(
331
						m_layout.getAtributes().toUnits(sup))));
332
			getTIzquierdo().setText(String.valueOf(nf.format(
333
						m_layout.getAtributes().toUnits(izq))));
334
			getTInferior().setText(String.valueOf(nf.format(
335
						m_layout.getAtributes().toUnits(inf))));
336
			getTDerecho().setText(String.valueOf(nf.format(
337
						m_layout.getAtributes().toUnits(der))));
299 338
			getTSuperior().setEnabled(true);
300 339
			getTIzquierdo().setEnabled(true);
301 340
			getTInferior().setEnabled(true);
302 341
			getTDerecho().setEnabled(true);
303
		}else{
342
		} else {
304 343
			getTSuperior().setText("");
305 344
			getTIzquierdo().setText("");
306 345
			getTInferior().setText("");
......
310 349
			getTInferior().setEnabled(false);
311 350
			getTDerecho().setEnabled(false);
312 351
		}
313
				
314 352
	}
353

  
315 354
	/**
316 355
	 * This method initializes chbMargenes
317
	 * 
356
	 *
318 357
	 * @return javax.swing.JCheckBox
319 358
	 */
320 359
	private javax.swing.JCheckBox getChbMargenes() {
321
		if(chbMargenes == null) {
360
		if (chbMargenes == null) {
322 361
			chbMargenes = new javax.swing.JCheckBox();
323 362
			chbMargenes.setSize(230, 21);
324
			chbMargenes.setText(PluginServices.getText(this,"utilizar_margenes_impresora"));
363
			chbMargenes.setText(PluginServices.getText(this,
364
					"utilizar_margenes_impresora"));
325 365
			chbMargenes.setLocation(125, 145);
326 366
			chbMargenes.setSelected(m_layout.getAtributes().isMargin());
327
			setMargin(m_layout.getAtributes().isMargin());	
328
			chbMargenes.addActionListener(new java.awt.event.ActionListener() { 
329
			
330
			public void actionPerformed(java.awt.event.ActionEvent e) {    
331
					if (chbMargenes.isSelected()){
332
						margin=true;
333
					}else{
334
						margin=false;
367
			setMargin(m_layout.getAtributes().isMargin());
368
			chbMargenes.addActionListener(new java.awt.event.ActionListener() {
369
					public void actionPerformed(java.awt.event.ActionEvent e) {
370
						if (chbMargenes.isSelected()) {
371
							margin = true;
372
						} else {
373
							margin = false;
374
						}
375

  
376
						setMargin(margin);
335 377
					}
336
						setMargin(margin);						
337
					}
338
			});
378
				});
339 379
		}
380

  
340 381
		return chbMargenes;
341 382
	}
383

  
342 384
	/**
343 385
	 * This method initializes lSuperior
344
	 * 
386
	 *
345 387
	 * @return javax.swing.JLabel
346 388
	 */
347 389
	private javax.swing.JLabel getLSuperior() {
348
		if(lSuperior == null) {
390
		if (lSuperior == null) {
349 391
			lSuperior = new javax.swing.JLabel();
350 392
			lSuperior.setSize(81, 20);
351
			lSuperior.setText(PluginServices.getText(this,"Superior"));
393
			lSuperior.setText(PluginServices.getText(this, "Superior"));
352 394
			lSuperior.setLocation(25, 167);
353 395
		}
396

  
354 397
		return lSuperior;
355 398
	}
399

  
356 400
	/**
357 401
	 * This method initializes tSuperior
358
	 * 
402
	 *
359 403
	 * @return javax.swing.JTextField
360 404
	 */
361 405
	private javax.swing.JTextField getTSuperior() {
362
		if(tSuperior == null) {
406
		if (tSuperior == null) {
363 407
			tSuperior = new javax.swing.JTextField();
364 408
			tSuperior.setSize(60, 20);
365 409
			tSuperior.setLocation(110, 167);
366
			if (m_layout.getAtributes().isMargin()){
367
			tSuperior.setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(sup))));
410

  
411
			if (m_layout.getAtributes().isMargin()) {
412
				tSuperior.setText(String.valueOf(nf.format(
413
							m_layout.getAtributes().toUnits(sup))));
368 414
			}
369 415
		}
416

  
370 417
		return tSuperior;
371 418
	}
419

  
372 420
	/**
373 421
	 * This method initializes lIzquierdo
374
	 * 
422
	 *
375 423
	 * @return javax.swing.JLabel
376 424
	 */
377 425
	private javax.swing.JLabel getLIzquierdo() {
378
		if(lIzquierdo == null) {
426
		if (lIzquierdo == null) {
379 427
			lIzquierdo = new javax.swing.JLabel();
380 428
			lIzquierdo.setSize(88, 20);
381
			lIzquierdo.setText(PluginServices.getText(this,"Izquierdo"));
429
			lIzquierdo.setText(PluginServices.getText(this, "Izquierdo"));
382 430
			lIzquierdo.setLocation(180, 167);
383 431
		}
432

  
384 433
		return lIzquierdo;
385 434
	}
435

  
386 436
	/**
387 437
	 * This method initializes tIzquierdo
388
	 * 
438
	 *
389 439
	 * @return javax.swing.JTextField
390 440
	 */
391 441
	private javax.swing.JTextField getTIzquierdo() {
392
		if(tIzquierdo == null) {
442
		if (tIzquierdo == null) {
393 443
			tIzquierdo = new javax.swing.JTextField();
394 444
			tIzquierdo.setSize(60, 20);
395 445
			tIzquierdo.setLocation(280, 167);
396
			if (m_layout.getAtributes().isMargin()){
397
			tIzquierdo.setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(izq))));
446

  
447
			if (m_layout.getAtributes().isMargin()) {
448
				tIzquierdo.setText(String.valueOf(nf.format(
449
							m_layout.getAtributes().toUnits(izq))));
398 450
			}
399 451
		}
452

  
400 453
		return tIzquierdo;
401 454
	}
455

  
402 456
	/**
403 457
	 * This method initializes lInferior
404
	 * 
458
	 *
405 459
	 * @return javax.swing.JLabel
406 460
	 */
407 461
	private javax.swing.JLabel getLInferior() {
408
		if(lInferior == null) {
462
		if (lInferior == null) {
409 463
			lInferior = new javax.swing.JLabel();
410 464
			lInferior.setSize(81, 21);
411
			lInferior.setText(PluginServices.getText(this,"Inferior"));
465
			lInferior.setText(PluginServices.getText(this, "Inferior"));
412 466
			lInferior.setLocation(25, 190);
413 467
		}
468

  
414 469
		return lInferior;
415 470
	}
471

  
416 472
	/**
417 473
	 * This method initializes tInferior
418
	 * 
474
	 *
419 475
	 * @return javax.swing.JTextField
420 476
	 */
421 477
	private javax.swing.JTextField getTInferior() {
422
		if(tInferior == null) {
478
		if (tInferior == null) {
423 479
			tInferior = new javax.swing.JTextField();
424 480
			tInferior.setSize(60, 20);
425 481
			tInferior.setLocation(110, 190);
426
			if (m_layout.getAtributes().isMargin()){
427
			tInferior.setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(inf))));
482

  
483
			if (m_layout.getAtributes().isMargin()) {
484
				tInferior.setText(String.valueOf(nf.format(
485
							m_layout.getAtributes().toUnits(inf))));
428 486
			}
429 487
		}
488

  
430 489
		return tInferior;
431 490
	}
491

  
432 492
	/**
433 493
	 * This method initializes lDerecho
434
	 * 
494
	 *
435 495
	 * @return javax.swing.JLabel
436 496
	 */
437 497
	private javax.swing.JLabel getLDerecho() {
438
		if(lDerecho == null) {
498
		if (lDerecho == null) {
439 499
			lDerecho = new javax.swing.JLabel();
440 500
			lDerecho.setSize(87, 21);
441
			lDerecho.setText(PluginServices.getText(this,"Derecho"));
501
			lDerecho.setText(PluginServices.getText(this, "Derecho"));
442 502
			lDerecho.setLocation(180, 190);
443 503
		}
504

  
444 505
		return lDerecho;
445 506
	}
507

  
446 508
	/**
447 509
	 * This method initializes tDerecho
448
	 * 
510
	 *
449 511
	 * @return javax.swing.JTextField
450 512
	 */
451 513
	private javax.swing.JTextField getTDerecho() {
452
		if(tDerecho == null) {
514
		if (tDerecho == null) {
453 515
			tDerecho = new javax.swing.JTextField();
454 516
			tDerecho.setSize(60, 20);
455 517
			tDerecho.setLocation(280, 190);
456
			if (m_layout.getAtributes().isMargin()){
457
			tDerecho.setText(String.valueOf(nf.format(m_layout.getAtributes().toUnits(der))));
518

  
519
			if (m_layout.getAtributes().isMargin()) {
520
				tDerecho.setText(String.valueOf(nf.format(
521
							m_layout.getAtributes().toUnits(der))));
458 522
			}
459 523
		}
524

  
460 525
		return tDerecho;
461 526
	}
527

  
462 528
	/**
463 529
	 * This method initializes lResolucion
464
	 * 
530
	 *
465 531
	 * @return javax.swing.JLabel
466 532
	 */
467 533
	private javax.swing.JLabel getLResolucion() {
468
		if(lResolucion == null) {
534
		if (lResolucion == null) {
469 535
			lResolucion = new javax.swing.JLabel();
470 536
			lResolucion.setSize(164, 21);
471
			lResolucion.setText(PluginServices.getText(this,"resolucion_resultado"));
537
			lResolucion.setText(PluginServices.getText(this,
538
					"resolucion_resultado"));
472 539
			lResolucion.setLocation(25, 215);
473 540
		}
541

  
474 542
		return lResolucion;
475 543
	}
544

  
476 545
	/**
477 546
	 * This method initializes cbResolucion
478
	 * 
547
	 *
479 548
	 * @return javax.swing.JComboBox
480 549
	 */
481 550
	private javax.swing.JComboBox getCbResolucion() {
482
		if(cbResolucion == null) {
551
		if (cbResolucion == null) {
483 552
			cbResolucion = new javax.swing.JComboBox();
484 553
			cbResolucion.setSize(150, 20);
485 554
			cbResolucion.setLocation(195, 215);
486
			cbResolucion.addItem(PluginServices.getText(this,"alta"));
487
			cbResolucion.addItem(PluginServices.getText(this,"normal"));
488
			cbResolucion.addItem(PluginServices.getText(this,"baja"));
555
			cbResolucion.addItem(PluginServices.getText(this, "alta"));
556
			cbResolucion.addItem(PluginServices.getText(this, "normal"));
557
			cbResolucion.addItem(PluginServices.getText(this, "baja"));
489 558
			cbResolucion.setSelectedIndex(m_layout.getAtributes().getResolution());
490
			cbResolucion.addActionListener(new java.awt.event.ActionListener() { 
491
				public void actionPerformed(java.awt.event.ActionEvent e) {    
492
				resolution=cbResolucion.getSelectedIndex();
493
				}
494
			});
559
			cbResolucion.addActionListener(new java.awt.event.ActionListener() {
560
					public void actionPerformed(java.awt.event.ActionEvent e) {
561
						resolution = cbResolucion.getSelectedIndex();
562
					}
563
				});
495 564
		}
565

  
496 566
		return cbResolucion;
497 567
	}
568

  
498 569
	/**
499 570
	 * This method initializes bAceptar
500
	 * 
571
	 *
501 572
	 * @return javax.swing.JButton
502 573
	 */
503 574
	private javax.swing.JButton getBAceptar() {
504
		if(bAceptar == null) {
575
		if (bAceptar == null) {
505 576
			bAceptar = new javax.swing.JButton();
506 577
			bAceptar.setSize(84, 23);
507
			bAceptar.setText(PluginServices.getText(this,"Aceptar"));
578
			bAceptar.setText(PluginServices.getText(this, "Aceptar"));
508 579
			bAceptar.setLocation(130, 245);
509
			bAceptar.addActionListener(new java.awt.event.ActionListener() { 
510
				public void actionPerformed(java.awt.event.ActionEvent e) {    
511
					m_layout.getAtributes().setUnit(unit);
512
					if (isLand){
513
						m_layout.getAtributes().setIsLandScape(true);
514
					}else{
515
						m_layout.getAtributes().setIsLandScape(false);
580
			bAceptar.addActionListener(new java.awt.event.ActionListener() {
581
					public void actionPerformed(java.awt.event.ActionEvent e) {
582
						m_layout.getAtributes().setUnit(unit);
583

  
584
						if (isLand) {
585
							m_layout.getAtributes().setIsLandScape(true);
586
						} else {
587
							m_layout.getAtributes().setIsLandScape(false);
588
						}
589

  
590
						m_layout.getAtributes().setType(type);
591
						m_layout.getAtributes().setSizeinUnits(isLand);
592
						obtainArea();
593

  
594
						double[] area = { sup, inf, izq, der };
595

  
596
						if (type == Attributes.CUSTOM) {
597
							Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf(
598
										getTAncho().getText()).doubleValue(),
599
									Double.valueOf(getTAlto().getText())
600
										  .doubleValue());
601
						}
602

  
603
						m_layout.getAtributes().setSelectedOptions(type, unit,
604
							isLand, margin, resolution, area);
605
						m_layout.refresh();
606
						PluginServices.getMDIManager().closeView(FConfigLayoutDialog.this);
516 607
					}
517
					m_layout.getAtributes().setType(type);
518
					m_layout.getAtributes().setSizeinUnits(isLand);
519
					obtainArea();
520
					double[] area={sup,inf,izq,der};
521
					if (type==Attributes.CUSTOM){
522
						Attributes.CUSTOM_PAPER_SIZE=new Size(Double.valueOf(getTAncho().getText()).doubleValue(),Double.valueOf(getTAlto().getText()).doubleValue());
523
					}
524
					m_layout.getAtributes().setSelectedOptions(type,unit,isLand,margin,resolution,area);
525
					m_layout.refresh();
526
					PluginServices.getMDIManager().closeView(FConfigLayoutDialog.this);
527
				}
528
			});
608
				});
529 609
		}
610

  
530 611
		return bAceptar;
531 612
	}
613

  
532 614
	/**
533 615
	 * This method initializes bCancelar
534
	 * 
616
	 *
535 617
	 * @return javax.swing.JButton
536 618
	 */
537 619
	private javax.swing.JButton getBCancelar() {
538
		if(bCancelar == null) {
620
		if (bCancelar == null) {
539 621
			bCancelar = new javax.swing.JButton();
540 622
			bCancelar.setSize(85, 23);
541
			bCancelar.setText(PluginServices.getText(this,"Cancelar"));
623
			bCancelar.setText(PluginServices.getText(this, "Cancelar"));
542 624
			bCancelar.setLocation(245, 245);
543
			bCancelar.addActionListener(new java.awt.event.ActionListener() { 
544
				public void actionPerformed(java.awt.event.ActionEvent e) {    
545
					//setVisible(false);
546
					PluginServices.getMDIManager().closeView(FConfigLayoutDialog.this);
547
				}
548
			});
625
			bCancelar.addActionListener(new java.awt.event.ActionListener() {
626
					public void actionPerformed(java.awt.event.ActionEvent e) {
627
						//setVisible(false);
628
						PluginServices.getMDIManager().closeView(FConfigLayoutDialog.this);
629
					}
630
				});
549 631
		}
632

  
550 633
		return bCancelar;
551 634
	}
635

  
552 636
	/**
553 637
	 * This method initializes chbHorizontal
554
	 * 
638
	 *
555 639
	 * @return javax.swing.JCheckBox
556 640
	 */
557 641
	private javax.swing.JCheckBox getChbHorizontal() {
558
		if(chbHorizontal == null) {
642
		if (chbHorizontal == null) {
559 643
			chbHorizontal = new javax.swing.JCheckBox();
560 644
			chbHorizontal.setSize(99, 21);
561
			chbHorizontal.setText(PluginServices.getText(this,"horizontal"));
645
			chbHorizontal.setText(PluginServices.getText(this, "horizontal"));
562 646
			chbHorizontal.setLocation(130, 110);
563 647
			chbHorizontal.setSelected(isLand);
564
			chbHorizontal.addActionListener(new java.awt.event.ActionListener() { 
565
				public void actionPerformed(java.awt.event.ActionEvent e) {    
566
						isLand=true;
648
			chbHorizontal.addActionListener(new java.awt.event.ActionListener() {
649
					public void actionPerformed(java.awt.event.ActionEvent e) {
650
						isLand = true;
567 651
						getChbVertical().setSelected(false);
568
						
569
					if (chbHorizontal.isSelected()){
570
						
571
						double iz=izq;
572
						izq=inf;
573
						inf=der;
574
						der=sup;
575
						sup=iz;
576
						
577
						setMargin(margin);
578
					//}else{
579
						if (type==Attributes.CUSTOM){
580
							Attributes.CUSTOM_PAPER_SIZE=new Size(Double.valueOf(getTAlto().getText()).doubleValue(),Double.valueOf(getTAncho().getText()).doubleValue());
652

  
653
						if (chbHorizontal.isSelected()) {
654
							double iz = izq;
655
							izq = inf;
656
							inf = der;
657
							der = sup;
658
							sup = iz;
659

  
660
							setMargin(margin);
661

  
662
							//}else{
663
							if (type == Attributes.CUSTOM) {
664
								Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf(
665
											getTAlto().getText()).doubleValue(),
666
										Double.valueOf(getTAncho().getText())
667
											  .doubleValue());
668
							}
669

  
670
							Size size = m_layout.getAtributes().getSizeinUnits(isLand,
671
									type);
672
							getTAncho().setText(String.valueOf(nf.format(
673
										size.getAncho())));
674
							getTAlto().setText(String.valueOf(nf.format(
675
										size.getAlto())));
581 676
						}
582
						Size size =m_layout.getAtributes().getSizeinUnits(isLand,type);
583
						getTAncho().setText(String.valueOf(nf.format(size.getAncho())));
584
						getTAlto().setText(String.valueOf(nf.format(size.getAlto())));
677

  
678
						chbHorizontal.setSelected(true);
585 679
					}
586
					chbHorizontal.setSelected(true);
587
			}
588
			});
680
				});
589 681
		}
682

  
590 683
		return chbHorizontal;
591 684
	}
685

  
592 686
	/**
593 687
	 * This method initializes chbVertical
594
	 * 
688
	 *
595 689
	 * @return javax.swing.JCheckBox
596 690
	 */
597 691
	private javax.swing.JCheckBox getChbVertical() {
598
		if(chbVertical == null) {
692
		if (chbVertical == null) {
599 693
			chbVertical = new javax.swing.JCheckBox();
600 694
			chbVertical.setSize(94, 23);
601
			chbVertical.setText(PluginServices.getText(this,"vertical"));
695
			chbVertical.setText(PluginServices.getText(this, "vertical"));
602 696
			chbVertical.setLocation(245, 110);
603 697
			chbVertical.setSelected(!isLand);
604
			chbVertical.addActionListener(new java.awt.event.ActionListener() { 
605
				public void actionPerformed(java.awt.event.ActionEvent e) {    
606
					
607
						isLand=false;
698
			chbVertical.addActionListener(new java.awt.event.ActionListener() {
699
					public void actionPerformed(java.awt.event.ActionEvent e) {
700
						isLand = false;
608 701
						getChbHorizontal().setSelected(false);
609
						
610
						if (chbVertical.isSelected()){
611
						double in=inf;
612
						inf=izq;
613
						izq=sup;
614
						sup=der;
615
						der=in;
616
						
617
						setMargin(margin);
618
					//}else{
619
						if (type==Attributes.CUSTOM){
620
							Attributes.CUSTOM_PAPER_SIZE=new Size(Double.valueOf(getTAncho().getText()).doubleValue(),Double.valueOf(getTAlto().getText()).doubleValue());
702

  
703
						if (chbVertical.isSelected()) {
704
							double in = inf;
705
							inf = izq;
706
							izq = sup;
707
							sup = der;
708
							der = in;
709

  
710
							setMargin(margin);
711

  
712
							//}else{
713
							if (type == Attributes.CUSTOM) {
714
								Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf(
715
											getTAncho().getText()).doubleValue(),
716
										Double.valueOf(getTAlto().getText())
717
											  .doubleValue());
718
							}
719

  
720
							Size size = m_layout.getAtributes().getSizeinUnits(isLand,
721
									type);
722
							getTAncho().setText(String.valueOf(nf.format(
723
										size.getAncho())));
724
							getTAlto().setText(String.valueOf(nf.format(
725
										size.getAlto())));
621 726
						}
622
						Size size =m_layout.getAtributes().getSizeinUnits(isLand,type);
623
						getTAncho().setText(String.valueOf(nf.format(size.getAncho())));
624
						getTAlto().setText(String.valueOf(nf.format(size.getAlto())));
727

  
728
						chbVertical.setSelected(true);
625 729
					}
626
					chbVertical.setSelected(true);
627
				
628
				}
629
			});
730
				});
630 731
		}
732

  
631 733
		return chbVertical;
632 734
	}
735

  
633 736
	/* (non-Javadoc)
634 737
	 * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
635 738
	 */
636 739
	public ViewInfo getViewInfo() {
637
		ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
638
    		m_viewinfo.setWidth(371);
639
			m_viewinfo.setHeight(300);
640
    		m_viewinfo.setTitle(PluginServices.getText(this,"Preparar_pagina"));
740
		ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
741
		m_viewinfo.setWidth(371);
742
		m_viewinfo.setHeight(300);
743
		m_viewinfo.setTitle(PluginServices.getText(this, "Preparar_pagina"));
641 744

  
642 745
		return m_viewinfo;
643 746
	}
747

  
644 748
	/**
645 749
	 * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
646 750
	 */
647 751
	public void viewActivated() {
648 752
	}
649
	private void obtainArea(){
650
		String s=(getTSuperior().getText());
651
		s=s.replace(',','.');  
652
		if (s.length()==0){
653
			s="0";
753

  
754
	/**
755
	 * Obtiene el ?rea de los JtextField.
756
	 */
757
	private void obtainArea() {
758
		String s = (getTSuperior().getText());
759
		s = s.replace(',', '.');
760

  
761
		if (s.length() == 0) {
762
			s = "0";
654 763
		}
655
		sup=m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
656
		s=(getTIzquierdo().getText());
657
		s=s.replace(',','.');  
658
		if (s.length()==0){
659
			s="0";
764

  
765
		sup = m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
766
		s = (getTIzquierdo().getText());
767
		s = s.replace(',', '.');
768

  
769
		if (s.length() == 0) {
770
			s = "0";
660 771
		}
661
		izq=m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
662
		s=(getTInferior().getText());
663
		s=s.replace(',','.');  
664
		if (s.length()==0){
665
			s="0";
772

  
773
		izq = m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
774
		s = (getTInferior().getText());
775
		s = s.replace(',', '.');
776

  
777
		if (s.length() == 0) {
778
			s = "0";
666 779
		}
667
		inf=m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
668
		s=(getTDerecho().getText());
669
		s=s.replace(',','.');  
670
		if (s.length()==0){
671
			s="0";
780

  
781
		inf = m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
782
		s = (getTDerecho().getText());
783
		s = s.replace(',', '.');
784

  
785
		if (s.length() == 0) {
786
			s = "0";
672 787
		}
673
		der=m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
788

  
789
		der = m_layout.getAtributes().fromUnits(Double.valueOf(s).doubleValue());
674 790
	}
675
}  //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
791
}

Also available in: Unified diff