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