root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameTextDialog.java @ 7738
History | View | Annotate | Download (25 KB)
1 |
/*
|
---|---|
2 |
* Created on 22-jun-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs; |
46 |
|
47 |
import java.awt.Color; |
48 |
import java.awt.geom.Rectangle2D; |
49 |
|
50 |
import javax.swing.ImageIcon; |
51 |
import javax.swing.JButton; |
52 |
import javax.swing.JCheckBox; |
53 |
import javax.swing.JColorChooser; |
54 |
import javax.swing.JDialog; |
55 |
import javax.swing.JFrame; |
56 |
import javax.swing.JLabel; |
57 |
import javax.swing.JPanel; |
58 |
import javax.swing.JTextField; |
59 |
import javax.swing.JToggleButton; |
60 |
|
61 |
import com.iver.andami.PluginServices; |
62 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
63 |
import com.iver.cit.gvsig.AddLayer; |
64 |
import com.iver.cit.gvsig.gui.layout.Layout; |
65 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
66 |
import com.iver.cit.gvsig.gui.utils.FontChooser; |
67 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
68 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation; |
69 |
/**
|
70 |
* Dialogo para a?adir texto al Layout.
|
71 |
*
|
72 |
* @author Vicente Caballero Navarro
|
73 |
*/
|
74 |
public class FFrameTextDialog extends JPanel implements IFFrameDialog { |
75 |
public static final ImageIcon ileft = new ImageIcon(AddLayer.class.getClassLoader() |
76 |
.getResource("images/left.PNG")); //$NON-NLS-1$ |
77 |
public static final ImageIcon icenterV = new ImageIcon(AddLayer.class.getClassLoader() |
78 |
.getResource("images/centerV.PNG")); //$NON-NLS-1$ |
79 |
public static final ImageIcon iright = new ImageIcon(AddLayer.class.getClassLoader() |
80 |
.getResource("images/right.PNG")); //$NON-NLS-1$ |
81 |
private javax.swing.JPanel jContentPane = null; // @jve:visual-info decl-index=0 visual-constraint="593,10" |
82 |
private javax.swing.JScrollPane jScrollPane = null; |
83 |
private javax.swing.JTextArea taTexto = null; |
84 |
private javax.swing.JLabel lAlinear = null; |
85 |
private JToggleButton bIzquierda = null; |
86 |
private JToggleButton bCentro = null; |
87 |
private JToggleButton bDerecha = null; |
88 |
private javax.swing.JCheckBox chkEscalaVista = null; |
89 |
private javax.swing.JButton bAceptar = null; |
90 |
private javax.swing.JButton bCancelar = null; |
91 |
private Layout m_layout = null; |
92 |
private Rectangle2D rect = new Rectangle2D.Double(); |
93 |
private FFrameText fframetext = null; //new FFrameText(); |
94 |
private boolean isAcepted = false; |
95 |
private javax.swing.JButton bFuente = null; |
96 |
private Color textcolor = null; |
97 |
private Color frameColor =null; |
98 |
private Color titleColor =null; |
99 |
private JButton jButton = null; |
100 |
private JCheckBox chkSurroundingRectangle = null; |
101 |
private JTextField txtCellPadding = null; |
102 |
private JLabel jLabel = null; |
103 |
private JCheckBox chkFontSize = null; |
104 |
private JTextField txtFontSize = null; |
105 |
private JCheckBox chkTitle = null; |
106 |
private JTextField txtTitle = null; |
107 |
private JPanel jPanel = null; |
108 |
private JTextField txtTitleSize = null; |
109 |
private JLabel jLabel3 = null; |
110 |
private JLabel jLabel4; |
111 |
private JPanel jPanel1 = null; |
112 |
private JTextField txtFrameSize = null; |
113 |
private JLabel jLabel5 = null; |
114 |
private JLabel jLabel6 = null; |
115 |
private JLabel jLabel7 = null; |
116 |
private JButton jButton1 = null; |
117 |
private JButton jButton2 = null; |
118 |
private JPRotation pRotation = null; |
119 |
/**
|
120 |
* This is the default constructor
|
121 |
*
|
122 |
* @param layout Referencia al Layout.
|
123 |
* @param fframe Referencia al fframe de texto.
|
124 |
*/
|
125 |
public FFrameTextDialog(Layout layout, FFrameText fframe) {
|
126 |
super();
|
127 |
fframetext = fframe; |
128 |
m_layout = layout; |
129 |
textcolor = fframe.getTextColor(); |
130 |
frameColor = fframe.getFrameColor(); |
131 |
titleColor = fframe.getTitleColor(); |
132 |
initialize(); |
133 |
} |
134 |
|
135 |
/**
|
136 |
* This method initializes this
|
137 |
*/
|
138 |
private void initialize() { |
139 |
this.setLayout(null); |
140 |
this.add(getJContentPane(), null); |
141 |
this.setSize(419, 429); |
142 |
getPRotation().setRotation(fframetext.getRotation()); |
143 |
} |
144 |
|
145 |
/**
|
146 |
* Inserta el rect?ngulo a ocupar por el fframe de texto.
|
147 |
*
|
148 |
* @param r Rect?ngulo.
|
149 |
*/
|
150 |
public void setRectangle(Rectangle2D r) { |
151 |
rect.setRect(r); |
152 |
} |
153 |
|
154 |
/**
|
155 |
* This method initializes jContentPane
|
156 |
*
|
157 |
* @return javax.swing.JPanel
|
158 |
*/
|
159 |
private javax.swing.JPanel getJContentPane() {
|
160 |
if (jContentPane == null) { |
161 |
jLabel = new JLabel(); |
162 |
jContentPane = new javax.swing.JPanel();
|
163 |
jContentPane.setLayout(null);
|
164 |
jContentPane.add(getJScrollPane(), null);
|
165 |
jContentPane.add(getLAlinear(), null);
|
166 |
jContentPane.add(getBIzquierda(), null);
|
167 |
jContentPane.add(getBCentro(), null);
|
168 |
jContentPane.add(getBDerecha(), null);
|
169 |
|
170 |
//jContentPane.add(getJLabel1(), null);
|
171 |
//jContentPane.add(getJComboBox(), null);
|
172 |
//jContentPane.add(getJLabel2(), null);
|
173 |
jContentPane.add(getChkEscalaVista(), null);
|
174 |
jContentPane.add(getBAceptar(), null);
|
175 |
jContentPane.add(getBCancelar(), null);
|
176 |
jContentPane.add(getBFuente(), null);
|
177 |
jContentPane.setSize(412, 422); |
178 |
jContentPane.setLocation(3, 4); |
179 |
jContentPane.add(getJButton(), null);
|
180 |
// jaume
|
181 |
jLabel.setText(PluginServices.getText(this, "Milimetros")); |
182 |
jLabel.setSize(56, 16); |
183 |
jLabel.setLocation(215, 74); |
184 |
jContentPane.add(getJPanel1(), null);
|
185 |
jContentPane.add(getJPanel(), null);
|
186 |
jContentPane.add(getChkFontSize(), null);
|
187 |
jContentPane.add(getTxtFontSize(), null);
|
188 |
jContentPane.add(getPRotation(), null);
|
189 |
} |
190 |
|
191 |
return jContentPane;
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* This method initializes jScrollPane
|
196 |
*
|
197 |
* @return javax.swing.JScrollPane
|
198 |
*/
|
199 |
private javax.swing.JScrollPane getJScrollPane() {
|
200 |
if (jScrollPane == null) { |
201 |
jScrollPane = new javax.swing.JScrollPane();
|
202 |
jScrollPane.setViewportView(getTaTexto()); |
203 |
jScrollPane.setSize(261, 83); |
204 |
jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
205 |
jScrollPane.setLocation(5, 5); |
206 |
} |
207 |
|
208 |
return jScrollPane;
|
209 |
} |
210 |
|
211 |
/**
|
212 |
* This method initializes taTexto
|
213 |
*
|
214 |
* @return javax.swing.JTextArea
|
215 |
*/
|
216 |
private javax.swing.JTextArea getTaTexto() {
|
217 |
if (taTexto == null) { |
218 |
taTexto = new javax.swing.JTextArea();
|
219 |
|
220 |
for (int i = 0; i < fframetext.getText().size(); i++) { |
221 |
if (!((String) fframetext.getText().get(i)).equals("")) { //$NON-NLS-1$ |
222 |
taTexto.append((String) fframetext.getText().get(i));
|
223 |
} |
224 |
} |
225 |
} |
226 |
|
227 |
return taTexto;
|
228 |
} |
229 |
|
230 |
/**
|
231 |
* This method initializes lAlinear
|
232 |
*
|
233 |
* @return javax.swing.JLabel
|
234 |
*/
|
235 |
private javax.swing.JLabel getLAlinear() {
|
236 |
if (lAlinear == null) { |
237 |
lAlinear = new javax.swing.JLabel();
|
238 |
lAlinear.setSize(52, 27); |
239 |
lAlinear.setText(PluginServices.getText(this, "alinear")); //$NON-NLS-1$ |
240 |
lAlinear.setLocation(5, 98); |
241 |
} |
242 |
|
243 |
return lAlinear;
|
244 |
} |
245 |
|
246 |
/**
|
247 |
* This method initializes bIzquierda
|
248 |
*
|
249 |
* @return javax.swing.JButton
|
250 |
*/
|
251 |
private JToggleButton getBIzquierda() { |
252 |
if (bIzquierda == null) { |
253 |
bIzquierda = new JToggleButton(); |
254 |
bIzquierda.setSize(30, 27); |
255 |
bIzquierda.setPreferredSize(new java.awt.Dimension(28, 20)); |
256 |
bIzquierda.setLocation(60, 98); |
257 |
|
258 |
if (fframetext.getPos() == FFrameText.LEFT) {
|
259 |
bIzquierda.setSelected(true);
|
260 |
} |
261 |
|
262 |
bIzquierda.setIcon(ileft); |
263 |
bIzquierda.addActionListener(new java.awt.event.ActionListener() {
|
264 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
265 |
fframetext.setPos(FFrameText.LEFT); |
266 |
getBIzquierda().setSelected(true);
|
267 |
getBCentro().setSelected(false);
|
268 |
getBDerecha().setSelected(false);
|
269 |
} |
270 |
}); |
271 |
} |
272 |
|
273 |
return bIzquierda;
|
274 |
} |
275 |
|
276 |
/**
|
277 |
* This method initializes bCentro
|
278 |
*
|
279 |
* @return javax.swing.JButton
|
280 |
*/
|
281 |
private JToggleButton getBCentro() { |
282 |
if (bCentro == null) { |
283 |
bCentro = new JToggleButton(); |
284 |
bCentro.setSize(30, 27); |
285 |
bCentro.setPreferredSize(new java.awt.Dimension(28, 20)); |
286 |
bCentro.setLocation(93, 98); |
287 |
|
288 |
if (fframetext.getPos() == FFrameText.CENTER) {
|
289 |
bCentro.setSelected(true);
|
290 |
} |
291 |
|
292 |
bCentro.setIcon(icenterV); |
293 |
bCentro.addActionListener(new java.awt.event.ActionListener() {
|
294 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
295 |
fframetext.setPos(FFrameText.CENTER); |
296 |
getBIzquierda().setSelected(false);
|
297 |
getBCentro().setSelected(true);
|
298 |
getBDerecha().setSelected(false);
|
299 |
} |
300 |
}); |
301 |
} |
302 |
|
303 |
return bCentro;
|
304 |
} |
305 |
|
306 |
/**
|
307 |
* This method initializes bDerecha
|
308 |
*
|
309 |
* @return javax.swing.JButton
|
310 |
*/
|
311 |
private JToggleButton getBDerecha() { |
312 |
if (bDerecha == null) { |
313 |
bDerecha = new JToggleButton(); |
314 |
bDerecha.setSize(30, 27); |
315 |
bDerecha.setPreferredSize(new java.awt.Dimension(28, 20)); |
316 |
bDerecha.setLocation(126, 98); |
317 |
|
318 |
if (fframetext.getPos() == FFrameText.RIGTH) {
|
319 |
bDerecha.setSelected(true);
|
320 |
} |
321 |
|
322 |
bDerecha.setIcon(iright); |
323 |
bDerecha.addActionListener(new java.awt.event.ActionListener() {
|
324 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
325 |
fframetext.setPos(FFrameText.RIGTH); |
326 |
getBIzquierda().setSelected(false);
|
327 |
getBCentro().setSelected(false);
|
328 |
getBDerecha().setSelected(true);
|
329 |
} |
330 |
}); |
331 |
} |
332 |
|
333 |
return bDerecha;
|
334 |
} |
335 |
|
336 |
/**
|
337 |
* This method initializes chbEscalaVista
|
338 |
*
|
339 |
* @return javax.swing.JCheckBox
|
340 |
*/
|
341 |
private javax.swing.JCheckBox getChkEscalaVista() {
|
342 |
if (chkEscalaVista == null) { |
343 |
chkEscalaVista = new javax.swing.JCheckBox();
|
344 |
chkEscalaVista.setSize(280, 20); |
345 |
chkEscalaVista.setText( |
346 |
PluginServices.getText(this, "__redimensionar_texto_escala")); //$NON-NLS-1$ |
347 |
chkEscalaVista.setSelected(fframetext.isSizeFixed()); |
348 |
chkEscalaVista.setLocation(6, 153); |
349 |
chkEscalaVista.setEnabled(true);
|
350 |
} |
351 |
|
352 |
return chkEscalaVista;
|
353 |
} |
354 |
|
355 |
/**
|
356 |
* This method initializes bAceptar
|
357 |
*
|
358 |
* @return javax.swing.JButton
|
359 |
*/
|
360 |
private javax.swing.JButton getBAceptar() {
|
361 |
if (bAceptar == null) { |
362 |
bAceptar = new javax.swing.JButton();
|
363 |
bAceptar.setSize(79, 26); |
364 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); //$NON-NLS-1$ |
365 |
bAceptar.setLocation(39, 388); |
366 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
367 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
368 |
fframetext.setBoundBox(FLayoutUtilities.toSheetRect( |
369 |
rect, m_layout.getAT())); |
370 |
fframetext.getText().clear(); |
371 |
|
372 |
for (int i = 0; i < getTaTexto().getLineCount(); i++) { |
373 |
try {
|
374 |
String s = getTaTexto().getText(getTaTexto()
|
375 |
.getLineStartOffset(i), |
376 |
getTaTexto().getLineEndOffset(i) - |
377 |
getTaTexto().getLineStartOffset(i)); |
378 |
|
379 |
if (!s.equals("")) { //$NON-NLS-1$ |
380 |
fframetext.addText(s); |
381 |
} |
382 |
} catch (Exception ex) { |
383 |
} |
384 |
} |
385 |
fframetext.setTextColor(textcolor); |
386 |
fframetext.setSizeFixed(!getChkEscalaVista().isSelected()); |
387 |
|
388 |
// jaume
|
389 |
boolean b = getChkSurroundingRectangle().isSelected();
|
390 |
fframetext.setSurrounded(getChkSurroundingRectangle().isSelected()); |
391 |
|
392 |
if (b){
|
393 |
// Hay rect?ngulo
|
394 |
fframetext.setCellPadding(Double.parseDouble(getTxtCellPadding().getText())/100); |
395 |
double i;
|
396 |
try{
|
397 |
i = Double.parseDouble(getTxtFrameSize().getText());
|
398 |
} catch (Exception ex){ |
399 |
i = 0;
|
400 |
} |
401 |
if (i==0) i = 1; |
402 |
fframetext.setFrameBorderSize(i/100);
|
403 |
fframetext.setFrameColor(frameColor); |
404 |
} |
405 |
b=getChkFontSize().isSelected(); |
406 |
fframetext.setFixedFontSize(b); |
407 |
|
408 |
if (b){
|
409 |
// El tama?o de la fuente es fijo
|
410 |
int i;
|
411 |
try{
|
412 |
i = Integer.parseInt(getTxtFontSize().getText());
|
413 |
} catch (Exception ex){ |
414 |
i = 12;
|
415 |
} |
416 |
fframetext.setFontSize(i); |
417 |
} |
418 |
b=getChkTitle().isSelected(); |
419 |
fframetext.setHasTitle(b); |
420 |
if (b){
|
421 |
// Hay t?tulo
|
422 |
fframetext.setTitle(getTxtTitle().getText()); |
423 |
int i;
|
424 |
try{
|
425 |
i = Integer.parseInt(getTxtTitleSize().getText());
|
426 |
} catch (Exception ex){ |
427 |
i = 12;
|
428 |
} |
429 |
fframetext.setTitleSize(i); |
430 |
|
431 |
fframetext.setTitleColor(titleColor); |
432 |
} |
433 |
|
434 |
fframetext.setRotation(getPRotation().getRotation()); |
435 |
PluginServices.getMDIManager().closeWindow(FFrameTextDialog.this); |
436 |
m_layout.refresh(); |
437 |
isAcepted = true;
|
438 |
} |
439 |
}); |
440 |
} |
441 |
|
442 |
return bAceptar;
|
443 |
} |
444 |
|
445 |
/**
|
446 |
* This method initializes bCancelar
|
447 |
*
|
448 |
* @return javax.swing.JButton
|
449 |
*/
|
450 |
private javax.swing.JButton getBCancelar() {
|
451 |
if (bCancelar == null) { |
452 |
bCancelar = new javax.swing.JButton();
|
453 |
bCancelar.setSize(85, 26); |
454 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); //$NON-NLS-1$ |
455 |
bCancelar.setLocation(144, 388); |
456 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
457 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
458 |
PluginServices.getMDIManager().closeWindow(FFrameTextDialog.this); |
459 |
} |
460 |
}); |
461 |
} |
462 |
|
463 |
return bCancelar;
|
464 |
} |
465 |
|
466 |
/* (non-Javadoc)
|
467 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
468 |
*/
|
469 |
public WindowInfo getWindowInfo() {
|
470 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
471 |
|
472 |
//vi.setResizable(false);
|
473 |
m_viewinfo.setTitle(PluginServices.getText(this, "Propiedades_texto")); //$NON-NLS-1$ |
474 |
|
475 |
return m_viewinfo;
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
|
480 |
*/
|
481 |
public boolean getIsAcepted() { |
482 |
return isAcepted;
|
483 |
} |
484 |
|
485 |
/**
|
486 |
* This method initializes bFuente
|
487 |
*
|
488 |
* @return javax.swing.JButton
|
489 |
*/
|
490 |
private javax.swing.JButton getBFuente() {
|
491 |
if (bFuente == null) { |
492 |
bFuente = new javax.swing.JButton();
|
493 |
bFuente.setBounds(157, 98, 73, 27); |
494 |
bFuente.setText(PluginServices.getText(this, "fuente")); //$NON-NLS-1$ |
495 |
bFuente.addActionListener(new java.awt.event.ActionListener() {
|
496 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
497 |
fframetext.setFont(FontChooser.showDialog( |
498 |
PluginServices.getText(this, "__seleccion_de_fuente"), fframetext.getFont())); // fchoser=new FontChooser(); //$NON-NLS-1$ |
499 |
} |
500 |
}); |
501 |
} |
502 |
|
503 |
return bFuente;
|
504 |
} |
505 |
|
506 |
/**
|
507 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
508 |
*/
|
509 |
public void viewActivated() { |
510 |
} |
511 |
/**
|
512 |
* This method initializes jButton
|
513 |
*
|
514 |
* @return javax.swing.JButton
|
515 |
*/
|
516 |
private JButton getJButton() { |
517 |
if (jButton == null) { |
518 |
jButton = new JButton(); |
519 |
jButton.setForeground(Color.white);
|
520 |
jButton.setBackground(textcolor); |
521 |
jButton.setBounds(235, 98, 32, 27); |
522 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
523 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
524 |
JDialog dlg;
|
525 |
JColorChooser colorChooser;
|
526 |
colorChooser = new JColorChooser(); |
527 |
dlg = JColorChooser.createDialog((JFrame) null, |
528 |
PluginServices.getText(this, "Elegir_Color"), |
529 |
true, colorChooser, null, null); |
530 |
dlg.show(true);
|
531 |
|
532 |
textcolor = colorChooser.getColor(); |
533 |
|
534 |
//getJPanel1().setBackground(textcolor);
|
535 |
jButton.setBackground(textcolor); |
536 |
|
537 |
} |
538 |
}); |
539 |
} |
540 |
return jButton;
|
541 |
} |
542 |
/**
|
543 |
* This method initializes chbSurroundingRectangle
|
544 |
*
|
545 |
* @return javax.swing.JCheckBox
|
546 |
* @author jaume
|
547 |
*/
|
548 |
private JCheckBox getChkSurroundingRectangle() { |
549 |
if (chkSurroundingRectangle == null) { |
550 |
chkSurroundingRectangle = new JCheckBox(); |
551 |
chkSurroundingRectangle.setText(PluginServices.getText(this, "usar_marco")); |
552 |
chkSurroundingRectangle.setSelected(fframetext.isSurrounded()); |
553 |
chkSurroundingRectangle.setBounds(5, 20, 143, 19); |
554 |
chkSurroundingRectangle.addItemListener(new java.awt.event.ItemListener() {
|
555 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
556 |
getTxtCellPadding().setEnabled(getChkSurroundingRectangle().isSelected()); |
557 |
getTxtFrameSize().setEnabled(getChkSurroundingRectangle().isSelected()); |
558 |
} |
559 |
}); |
560 |
} |
561 |
return chkSurroundingRectangle;
|
562 |
} |
563 |
/**
|
564 |
* This method initializes txtCellPadding
|
565 |
*
|
566 |
* @author jaume
|
567 |
*
|
568 |
* @return javax.swing.JTextField
|
569 |
*/
|
570 |
private JTextField getTxtCellPadding() { |
571 |
if (txtCellPadding == null) { |
572 |
txtCellPadding = new JTextField(); |
573 |
txtCellPadding.setEnabled(fframetext.isSurrounded()); |
574 |
txtCellPadding.setText(fframetext.getCellPadding()*100+""); |
575 |
txtCellPadding.setSize(60, 20); |
576 |
txtCellPadding.setLocation(140, 74); |
577 |
txtCellPadding.addKeyListener(new java.awt.event.KeyAdapter() {
|
578 |
public void keyReleased(java.awt.event.KeyEvent e) { |
579 |
ensureInteger(txtCellPadding); |
580 |
} |
581 |
}); |
582 |
|
583 |
} |
584 |
return txtCellPadding;
|
585 |
} |
586 |
/**
|
587 |
* This method initializes chkFontSize
|
588 |
*
|
589 |
* @return javax.swing.JCheckBox
|
590 |
*/
|
591 |
private JCheckBox getChkFontSize() { |
592 |
if (chkFontSize == null) { |
593 |
chkFontSize = new JCheckBox(); |
594 |
chkFontSize.setBounds(6, 174, 143, 19); |
595 |
chkFontSize.setText(PluginServices.getText(this, "tamanyo_fuente")); |
596 |
chkFontSize.setSelected(fframetext.isFontSizeFixed()); |
597 |
chkFontSize.addItemListener(new java.awt.event.ItemListener() {
|
598 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
599 |
getTxtFontSize().setEnabled(getChkFontSize().isSelected()); |
600 |
} |
601 |
}); |
602 |
} |
603 |
return chkFontSize;
|
604 |
} |
605 |
/**
|
606 |
* This method initializes txtFontSize
|
607 |
*
|
608 |
* @return javax.swing.JTextField
|
609 |
*/
|
610 |
private JTextField getTxtFontSize() { |
611 |
if (txtFontSize == null) { |
612 |
txtFontSize = new JTextField(); |
613 |
txtFontSize.setBounds(153, 176, 64, 17); |
614 |
txtFontSize.setEnabled(fframetext.isFontSizeFixed()); |
615 |
if (txtFontSize.isEnabled()) txtFontSize.setText(fframetext.getFontSize()+""); |
616 |
txtFontSize.addKeyListener(new java.awt.event.KeyAdapter() {
|
617 |
public void keyReleased(java.awt.event.KeyEvent e) { |
618 |
ensureInteger(txtFontSize); |
619 |
} |
620 |
}); |
621 |
} |
622 |
return txtFontSize;
|
623 |
} |
624 |
/**
|
625 |
* This method initializes chkTitle2
|
626 |
*
|
627 |
* @return javax.swing.JCheckBox
|
628 |
*/
|
629 |
private JCheckBox getChkTitle() { |
630 |
if (chkTitle == null) { |
631 |
chkTitle = new JCheckBox(); |
632 |
chkTitle.setText(PluginServices.getText(this, "usar_titulo")); |
633 |
chkTitle.setSelected(fframetext.hasTitle()); |
634 |
chkTitle.setBounds(6, 17, 85, 19); |
635 |
chkTitle.addChangeListener(new javax.swing.event.ChangeListener() {
|
636 |
public void stateChanged(javax.swing.event.ChangeEvent e) { |
637 |
getTxtTitle().setEnabled(chkTitle.isSelected()); |
638 |
getTxtTitleSize().setEnabled(chkTitle.isSelected()); |
639 |
jLabel3.setEnabled(chkTitle.isSelected()); |
640 |
} |
641 |
}); |
642 |
} |
643 |
return chkTitle;
|
644 |
} |
645 |
/**
|
646 |
* This method initializes txtTitle
|
647 |
*
|
648 |
* @return javax.swing.JTextField
|
649 |
*/
|
650 |
private JTextField getTxtTitle() { |
651 |
if (txtTitle == null) { |
652 |
txtTitle = new JTextField(); |
653 |
txtTitle.setEnabled(fframetext.hasTitle()); |
654 |
if (fframetext.hasTitle())
|
655 |
txtTitle.setText(fframetext.getTitle()); |
656 |
txtTitle.setBounds(92, 17, 175, 20); |
657 |
} |
658 |
return txtTitle;
|
659 |
} |
660 |
/**
|
661 |
* This method initializes jPanel
|
662 |
*
|
663 |
* @return javax.swing.JPanel
|
664 |
*/
|
665 |
private JPanel getJPanel() { |
666 |
if (jPanel == null) { |
667 |
jPanel = new JPanel(); |
668 |
jLabel3 = new JLabel(); |
669 |
jPanel.setLayout(null);
|
670 |
jPanel.setBounds(4, 307, 273, 76); |
671 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
672 |
null, PluginServices.getText(this, "titulo_fframetext"), |
673 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
674 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
675 |
jLabel3.setBounds(9, 45, 109, 22); |
676 |
jLabel3.setText(PluginServices.getText(this, "tamanyo_fuente")); |
677 |
jLabel3.setEnabled(fframetext.hasTitle()); |
678 |
jPanel.add(getTxtTitleSize(), null);
|
679 |
jPanel.add(jLabel3, null);
|
680 |
jPanel.add(getChkTitle(), null);
|
681 |
jPanel.add(getTxtTitle(), null);
|
682 |
jLabel4 = new JLabel(); |
683 |
jLabel4.setBounds(190, 45, 40, 16); |
684 |
jPanel.add(jLabel4, null);
|
685 |
jLabel4.setText(PluginServices.getText(this, "pixeles")); |
686 |
jPanel.add(getJButton2(), null);
|
687 |
|
688 |
} |
689 |
return jPanel;
|
690 |
} |
691 |
/**
|
692 |
* This method initializes txtTitleSize
|
693 |
*
|
694 |
* @return javax.swing.JTextField
|
695 |
*/
|
696 |
private JTextField getTxtTitleSize() { |
697 |
if (txtTitleSize == null) { |
698 |
txtTitleSize = new JTextField(); |
699 |
txtTitleSize.setBounds(121, 45, 64, 20); |
700 |
txtTitleSize.setEnabled(fframetext.hasTitle()); |
701 |
int i = fframetext.getTitleSize();
|
702 |
if (i == 0 && !txtTitleSize.isEnabled()) i = 5; |
703 |
txtTitleSize.setText(i+"");
|
704 |
txtTitleSize.addKeyListener(new java.awt.event.KeyAdapter() {
|
705 |
public void keyReleased(java.awt.event.KeyEvent e) { |
706 |
ensureInteger(txtTitleSize); |
707 |
} |
708 |
}); |
709 |
} |
710 |
return txtTitleSize;
|
711 |
} |
712 |
|
713 |
/**
|
714 |
* Asegura cutremente que no se meten valores que no sean.
|
715 |
* El funcionamiento consiste en si el ?ltimo car?cter escrito
|
716 |
* no vale para formar un int entonces se elimina.
|
717 |
*
|
718 |
* enteros.
|
719 |
* @param tf
|
720 |
*/
|
721 |
private void ensureInteger(JTextField tf){ |
722 |
String s = tf.getText();
|
723 |
try {
|
724 |
Integer.parseInt(s);
|
725 |
} catch (Exception e){ |
726 |
if (s.length()!=0) |
727 |
tf.setText(s.substring(0, s.length()-1)); |
728 |
else tf.setText(""); |
729 |
} |
730 |
} |
731 |
/**
|
732 |
* This method initializes jPanel1
|
733 |
*
|
734 |
* @return javax.swing.JPanel
|
735 |
*/
|
736 |
private JPanel getJPanel1() { |
737 |
if (jPanel1 == null) { |
738 |
jPanel1 = new JPanel(); |
739 |
jLabel5 = new JLabel(); |
740 |
jLabel6 = new JLabel(); |
741 |
jLabel7 = new JLabel(); |
742 |
jPanel1.setLayout(null);
|
743 |
jPanel1.setBounds(4, 199, 273, 106); |
744 |
jPanel1.add(getTxtCellPadding(), null);
|
745 |
jPanel1.add(getChkSurroundingRectangle(), null);
|
746 |
jPanel1.add(jLabel, null);
|
747 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
748 |
null, PluginServices.getText(this, "marco"), |
749 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
750 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
751 |
jLabel5.setText(PluginServices.getText(this, "Milimetros")); |
752 |
jLabel5.setLocation(215, 46); |
753 |
jLabel5.setSize(56, 16); |
754 |
jLabel5.setPreferredSize(new java.awt.Dimension(40,16)); |
755 |
jLabel6.setBounds(35, 47, 100, 20); |
756 |
jLabel6.setText(PluginServices.getText(this, "tamanyo_borde")); |
757 |
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
758 |
jLabel7.setBounds(35, 73, 100, 20); |
759 |
jLabel7.setText(PluginServices.getText(this, "margenes")); |
760 |
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
761 |
jPanel1.add(getTxtFrameSize(), null);
|
762 |
jPanel1.add(jLabel6, null);
|
763 |
jPanel1.add(jLabel7, null);
|
764 |
jPanel1.add(jLabel5, null);
|
765 |
jPanel1.add(getJButton1(), null);
|
766 |
} |
767 |
return jPanel1;
|
768 |
} |
769 |
/**
|
770 |
* This method initializes txtFrameSize
|
771 |
*
|
772 |
* @return javax.swing.JTextField
|
773 |
*/
|
774 |
private JTextField getTxtFrameSize() { |
775 |
if (txtFrameSize == null) { |
776 |
txtFrameSize = new JTextField(); |
777 |
txtFrameSize.setEnabled(fframetext.isSurrounded()); |
778 |
//if (txtFrameSize.isEnabled()){
|
779 |
double i = fframetext.getFrameBorderSize()*100; |
780 |
if (i==0) i = 1; |
781 |
txtFrameSize.setText(i+"");
|
782 |
//}
|
783 |
txtFrameSize.setLocation(140, 47); |
784 |
txtFrameSize.setSize(60, 20); |
785 |
} |
786 |
return txtFrameSize;
|
787 |
} |
788 |
/**
|
789 |
* This method initializes jButton1
|
790 |
*
|
791 |
* @return javax.swing.JButton
|
792 |
*/
|
793 |
private JButton getJButton1() { |
794 |
if (jButton1 == null) { |
795 |
jButton1 = new JButton(); |
796 |
jButton1.setForeground(fframetext.getFrameColor()); |
797 |
jButton1.setBackground(fframetext.getFrameColor()); |
798 |
jButton1.setBounds(229, 12, 32, 27); |
799 |
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
800 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
801 |
// color del marco
|
802 |
JDialog dlg;
|
803 |
JColorChooser colorChooser;
|
804 |
colorChooser = new JColorChooser(); |
805 |
dlg = JColorChooser.createDialog((JFrame) null, |
806 |
PluginServices.getText(this, "Elegir_Color"), |
807 |
true, colorChooser, null, null); |
808 |
dlg.show(true);
|
809 |
|
810 |
frameColor = colorChooser.getColor(); |
811 |
|
812 |
//getJPanel1().setBackground(textcolor);
|
813 |
jButton1.setBackground(frameColor); |
814 |
} |
815 |
}); |
816 |
} |
817 |
return jButton1;
|
818 |
} |
819 |
/**
|
820 |
* This method initializes jButton2
|
821 |
*
|
822 |
* @return javax.swing.JButton
|
823 |
*/
|
824 |
private JButton getJButton2() { |
825 |
if (jButton2 == null) { |
826 |
jButton2 = new JButton(); |
827 |
jButton2.setForeground(fframetext.getTitleColor()); |
828 |
jButton2.setBackground(fframetext.getTitleColor()); |
829 |
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
830 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
831 |
// color del t?tulo
|
832 |
JDialog dlg;
|
833 |
JColorChooser colorChooser;
|
834 |
colorChooser = new JColorChooser(); |
835 |
dlg = JColorChooser.createDialog((JFrame) null, |
836 |
PluginServices.getText(this, "Elegir_Color"), |
837 |
true, colorChooser, null, null); |
838 |
dlg.show(true);
|
839 |
|
840 |
titleColor = colorChooser.getColor(); |
841 |
jButton2.setBackground(titleColor); |
842 |
} |
843 |
}); |
844 |
|
845 |
jButton2.setBounds(235, 40, 32, 27); |
846 |
} |
847 |
return jButton2;
|
848 |
} |
849 |
|
850 |
/**
|
851 |
* This method initializes pRotation
|
852 |
*
|
853 |
* @return javax.swing.JPanel
|
854 |
*/
|
855 |
private JPRotation getPRotation() {
|
856 |
if (pRotation == null) { |
857 |
pRotation = new JPRotation();
|
858 |
pRotation.setBounds(281, 13, 125, 131); |
859 |
} |
860 |
return pRotation;
|
861 |
} |
862 |
} // @jve:decl-index=0:visual-constraint="10,10"
|