svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFrameTextDialog.java @ 312
History | View | Annotate | Download (12.9 KB)
1 |
/*
|
---|---|
2 |
* Created on 22-jun-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
package com.iver.cit.gvsig.gui.layout.fframes.dialogs; |
8 |
|
9 |
import java.awt.geom.Rectangle2D; |
10 |
|
11 |
import javax.swing.ImageIcon; |
12 |
import javax.swing.JPanel; |
13 |
import javax.swing.JToggleButton; |
14 |
|
15 |
import com.iver.cit.gvsig.Abrir; |
16 |
import com.iver.cit.gvsig.gui.Dialogs.FontChooser; |
17 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
18 |
import com.iver.cit.gvsig.gui.layout.Layout; |
19 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
20 |
import com.iver.mdiApp.App; |
21 |
import com.iver.mdiApp.Utilities; |
22 |
import com.iver.mdiApp.ui.MDIManager.ViewInfo; |
23 |
|
24 |
/**
|
25 |
* Dialogo para a?adir texto al Layout.
|
26 |
*
|
27 |
* @author Vicente Caballero Navarro
|
28 |
*
|
29 |
*/
|
30 |
public class FFrameTextDialog extends JPanel implements IFFrameDialog { |
31 |
|
32 |
private javax.swing.JPanel jContentPane = null; // @jve:visual-info decl-index=0 visual-constraint="593,10" |
33 |
|
34 |
private javax.swing.JScrollPane jScrollPane = null; |
35 |
private javax.swing.JTextArea taTexto = null; |
36 |
private javax.swing.JLabel lAlinear = null; |
37 |
private JToggleButton bIzquierda = null; |
38 |
private JToggleButton bCentro = null; |
39 |
private JToggleButton bDerecha = null; |
40 |
private javax.swing.JLabel jLabel1 = null; |
41 |
private javax.swing.JComboBox jComboBox = null; |
42 |
private javax.swing.JLabel jLabel2 = null; |
43 |
private javax.swing.JLabel lRotacion = null; |
44 |
private javax.swing.JTextField tRotacion = null; |
45 |
private javax.swing.JLabel lGrados = null; |
46 |
private javax.swing.JCheckBox chbEscalaVista = null; |
47 |
private javax.swing.JButton bAceptar = null; |
48 |
private javax.swing.JButton bCancelar = null; |
49 |
private Layout m_layout=null; |
50 |
private Rectangle2D rect=new Rectangle2D.Double(); |
51 |
private FFrameText fframetext=null;//new FFrameText(); |
52 |
private boolean isAcepted=false; |
53 |
private javax.swing.JButton bFuente = null; |
54 |
private ViewInfo m_viewinfo = null; |
55 |
public static final ImageIcon ileft = new ImageIcon(Abrir.class.getClassLoader() |
56 |
.getResource("images/left.PNG"));
|
57 |
public static final ImageIcon icenterV = new ImageIcon(Abrir.class.getClassLoader() |
58 |
.getResource("images/centerV.PNG"));
|
59 |
public static final ImageIcon iright = new ImageIcon(Abrir.class.getClassLoader() |
60 |
.getResource("images/right.PNG"));
|
61 |
|
62 |
/**
|
63 |
* This is the default constructor
|
64 |
*/
|
65 |
public FFrameTextDialog(Layout layout,FFrameText fframe) {
|
66 |
super();
|
67 |
fframetext=fframe; |
68 |
m_layout=layout; |
69 |
initialize(); |
70 |
|
71 |
} |
72 |
/**
|
73 |
* This method initializes this
|
74 |
*
|
75 |
* @return void
|
76 |
*/
|
77 |
private void initialize() { |
78 |
this.setLayout(null); |
79 |
this.add(getJContentPane(), null); |
80 |
this.setSize(288, 218); |
81 |
} |
82 |
public void setRectangle(Rectangle2D r){ |
83 |
rect.setRect(r); |
84 |
} |
85 |
/**
|
86 |
* This method initializes jContentPane
|
87 |
*
|
88 |
* @return javax.swing.JPanel
|
89 |
*/
|
90 |
private javax.swing.JPanel getJContentPane() {
|
91 |
if (jContentPane == null) { |
92 |
jContentPane = new javax.swing.JPanel();
|
93 |
jContentPane.setLayout(null);
|
94 |
jContentPane.add(getJScrollPane(), null);
|
95 |
jContentPane.add(getLAlinear(), null);
|
96 |
jContentPane.add(getBIzquierda(), null);
|
97 |
jContentPane.add(getBCentro(), null);
|
98 |
jContentPane.add(getBDerecha(), null);
|
99 |
//jContentPane.add(getJLabel1(), null);
|
100 |
//jContentPane.add(getJComboBox(), null);
|
101 |
//jContentPane.add(getJLabel2(), null);
|
102 |
jContentPane.add(getLRotacion(), null);
|
103 |
jContentPane.add(getTRotacion(), null);
|
104 |
jContentPane.add(getLGrados(), null);
|
105 |
jContentPane.add(getChbEscalaVista(), null);
|
106 |
jContentPane.add(getBAceptar(), null);
|
107 |
jContentPane.add(getBCancelar(), null);
|
108 |
jContentPane.add(getBFuente(), null);
|
109 |
jContentPane.setSize(286, 227); |
110 |
jContentPane.setLocation(6, 4); |
111 |
} |
112 |
return jContentPane;
|
113 |
} |
114 |
/**
|
115 |
* This method initializes jScrollPane
|
116 |
*
|
117 |
* @return javax.swing.JScrollPane
|
118 |
*/
|
119 |
private javax.swing.JScrollPane getJScrollPane() {
|
120 |
if(jScrollPane == null) { |
121 |
jScrollPane = new javax.swing.JScrollPane();
|
122 |
jScrollPane.setViewportView(getTaTexto()); |
123 |
jScrollPane.setSize(261, 83); |
124 |
jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
125 |
jScrollPane.setLocation(5, 5); |
126 |
} |
127 |
return jScrollPane;
|
128 |
} |
129 |
/**
|
130 |
* This method initializes taTexto
|
131 |
*
|
132 |
* @return javax.swing.JTextArea
|
133 |
*/
|
134 |
private javax.swing.JTextArea getTaTexto() {
|
135 |
if(taTexto == null) { |
136 |
taTexto = new javax.swing.JTextArea();
|
137 |
for(int i=0;i<fframetext.getText().size();i++){ |
138 |
if (!((String)fframetext.getText().get(i)).equals("")){ |
139 |
taTexto.append((String)fframetext.getText().get(i));
|
140 |
} |
141 |
taTexto.setPreferredSize(new java.awt.Dimension(220,80)); |
142 |
} |
143 |
} |
144 |
return taTexto;
|
145 |
} |
146 |
/**
|
147 |
* This method initializes lAlinear
|
148 |
*
|
149 |
* @return javax.swing.JLabel
|
150 |
*/
|
151 |
private javax.swing.JLabel getLAlinear() {
|
152 |
if(lAlinear == null) { |
153 |
lAlinear = new javax.swing.JLabel();
|
154 |
lAlinear.setSize(74, 27); |
155 |
lAlinear.setText(Utilities.getMessage(this,"alinear")); |
156 |
lAlinear.setLocation(5, 98); |
157 |
} |
158 |
return lAlinear;
|
159 |
} |
160 |
/**
|
161 |
* This method initializes bIzquierda
|
162 |
*
|
163 |
* @return javax.swing.JButton
|
164 |
*/
|
165 |
private JToggleButton getBIzquierda() { |
166 |
if(bIzquierda == null) { |
167 |
bIzquierda = new JToggleButton(); |
168 |
bIzquierda.setSize(30, 27); |
169 |
bIzquierda.setPreferredSize(new java.awt.Dimension(28,20)); |
170 |
bIzquierda.setLocation(87, 98); |
171 |
if (fframetext.getPos()==FFrameText.LEFT){
|
172 |
bIzquierda.setSelected(true);
|
173 |
} |
174 |
bIzquierda.setIcon(ileft); |
175 |
bIzquierda.addActionListener(new java.awt.event.ActionListener() {
|
176 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
177 |
fframetext.setPos(FFrameText.LEFT); |
178 |
getBIzquierda().setSelected(true);
|
179 |
getBCentro().setSelected(false);
|
180 |
getBDerecha().setSelected(false);
|
181 |
} |
182 |
}); |
183 |
} |
184 |
return bIzquierda;
|
185 |
} |
186 |
/**
|
187 |
* This method initializes bCentro
|
188 |
*
|
189 |
* @return javax.swing.JButton
|
190 |
*/
|
191 |
private JToggleButton getBCentro() { |
192 |
if(bCentro == null) { |
193 |
bCentro = new JToggleButton(); |
194 |
bCentro.setSize(30, 27); |
195 |
bCentro.setPreferredSize(new java.awt.Dimension(28,20)); |
196 |
bCentro.setLocation(120, 98); |
197 |
if (fframetext.getPos()==FFrameText.CENTER){
|
198 |
bCentro.setSelected(true);
|
199 |
} |
200 |
bCentro.setIcon(icenterV); |
201 |
bCentro.addActionListener(new java.awt.event.ActionListener() {
|
202 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
203 |
fframetext.setPos(FFrameText.CENTER); |
204 |
getBIzquierda().setSelected(false);
|
205 |
getBCentro().setSelected(true);
|
206 |
getBDerecha().setSelected(false);
|
207 |
} |
208 |
}); |
209 |
} |
210 |
return bCentro;
|
211 |
} |
212 |
/**
|
213 |
* This method initializes bDerecha
|
214 |
*
|
215 |
* @return javax.swing.JButton
|
216 |
*/
|
217 |
private JToggleButton getBDerecha() { |
218 |
if(bDerecha == null) { |
219 |
bDerecha = new JToggleButton(); |
220 |
bDerecha.setSize(30, 27); |
221 |
bDerecha.setPreferredSize(new java.awt.Dimension(28,20)); |
222 |
bDerecha.setLocation(153, 98); |
223 |
if (fframetext.getPos()==FFrameText.RIGTH){
|
224 |
bDerecha.setSelected(true);
|
225 |
} |
226 |
bDerecha.setIcon(iright); |
227 |
bDerecha.addActionListener(new java.awt.event.ActionListener() {
|
228 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
229 |
fframetext.setPos(FFrameText.RIGTH); |
230 |
getBIzquierda().setSelected(false);
|
231 |
getBCentro().setSelected(false);
|
232 |
getBDerecha().setSelected(true);
|
233 |
} |
234 |
}); |
235 |
} |
236 |
return bDerecha;
|
237 |
} |
238 |
/**
|
239 |
* This method initializes jLabel1
|
240 |
*
|
241 |
* @return javax.swing.JLabel
|
242 |
*/
|
243 |
private javax.swing.JLabel getJLabel1() {
|
244 |
if(jLabel1 == null) { |
245 |
jLabel1 = new javax.swing.JLabel();
|
246 |
jLabel1.setSize(95, 16); |
247 |
jLabel1.setText("Espacio Vertical:");
|
248 |
jLabel1.setLocation(5, 140); |
249 |
} |
250 |
return jLabel1;
|
251 |
} |
252 |
/**
|
253 |
* This method initializes jComboBox
|
254 |
*
|
255 |
* @return javax.swing.JComboBox
|
256 |
*/
|
257 |
private javax.swing.JComboBox getJComboBox() {
|
258 |
if(jComboBox == null) { |
259 |
jComboBox = new javax.swing.JComboBox();
|
260 |
jComboBox.addItem("0");
|
261 |
jComboBox.addItem("1");
|
262 |
jComboBox.addItem("2");
|
263 |
//jComboBox.setSelectedIndex(fframetext.getSpace());
|
264 |
jComboBox.setSize(102, 20); |
265 |
jComboBox.setPreferredSize(new java.awt.Dimension(45,20)); |
266 |
jComboBox.setLocation(130, 140); |
267 |
jComboBox.addActionListener(new java.awt.event.ActionListener() {
|
268 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
269 |
//fframetext.setSpace(jComboBox.getSelectedIndex());
|
270 |
} |
271 |
}); |
272 |
} |
273 |
return jComboBox;
|
274 |
} |
275 |
/**
|
276 |
* This method initializes jLabel2
|
277 |
*
|
278 |
* @return javax.swing.JLabel
|
279 |
*/
|
280 |
private javax.swing.JLabel getJLabel2() {
|
281 |
if(jLabel2 == null) { |
282 |
jLabel2 = new javax.swing.JLabel();
|
283 |
jLabel2.setSize(34, 16); |
284 |
jLabel2.setText("l?neas");
|
285 |
jLabel2.setLocation(238, 141); |
286 |
} |
287 |
return jLabel2;
|
288 |
} |
289 |
/**
|
290 |
* This method initializes lRotacion
|
291 |
*
|
292 |
* @return javax.swing.JLabel
|
293 |
*/
|
294 |
private javax.swing.JLabel getLRotacion() {
|
295 |
if(lRotacion == null) { |
296 |
lRotacion = new javax.swing.JLabel();
|
297 |
lRotacion.setBounds(6, 131, 109, 16); |
298 |
lRotacion.setText(Utilities.getMessage(this,"angulo_rotacion")); |
299 |
} |
300 |
return lRotacion;
|
301 |
} |
302 |
/**
|
303 |
* This method initializes tRotacion
|
304 |
*
|
305 |
* @return javax.swing.JTextField
|
306 |
*/
|
307 |
private javax.swing.JTextField getTRotacion() {
|
308 |
if(tRotacion == null) { |
309 |
tRotacion = new javax.swing.JTextField();
|
310 |
tRotacion.setBounds(154, 128, 64, 20); |
311 |
tRotacion.setPreferredSize(new java.awt.Dimension(45,20)); |
312 |
tRotacion.setText(Double.toString(fframetext.getRotation()));
|
313 |
} |
314 |
return tRotacion;
|
315 |
} |
316 |
/**
|
317 |
* This method initializes lGrados
|
318 |
*
|
319 |
* @return javax.swing.JLabel
|
320 |
*/
|
321 |
private javax.swing.JLabel getLGrados() {
|
322 |
if(lGrados == null) { |
323 |
lGrados = new javax.swing.JLabel();
|
324 |
lGrados.setSize(40, 16); |
325 |
lGrados.setText(Utilities.getMessage(this,"grados")); |
326 |
lGrados.setLocation(226, 130); |
327 |
} |
328 |
return lGrados;
|
329 |
} |
330 |
/**
|
331 |
* This method initializes chbEscalaVista
|
332 |
*
|
333 |
* @return javax.swing.JCheckBox
|
334 |
*/
|
335 |
private javax.swing.JCheckBox getChbEscalaVista() {
|
336 |
if(chbEscalaVista == null) { |
337 |
chbEscalaVista = new javax.swing.JCheckBox();
|
338 |
chbEscalaVista.setSize(280, 24); |
339 |
chbEscalaVista.setText("Redimensionar el texto a escala con la vista. ");
|
340 |
chbEscalaVista.setSelected(fframetext.isSizeFixed()); |
341 |
chbEscalaVista.setLocation(6, 153); |
342 |
chbEscalaVista.setEnabled(false);
|
343 |
} |
344 |
return chbEscalaVista;
|
345 |
} |
346 |
/**
|
347 |
* This method initializes bAceptar
|
348 |
*
|
349 |
* @return javax.swing.JButton
|
350 |
*/
|
351 |
private javax.swing.JButton getBAceptar() {
|
352 |
if(bAceptar == null) { |
353 |
bAceptar = new javax.swing.JButton();
|
354 |
bAceptar.setSize(79, 26); |
355 |
bAceptar.setText(Utilities.getMessage(this,"Aceptar")); |
356 |
bAceptar.setLocation(46, 183); |
357 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
358 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
359 |
|
360 |
fframetext.setBoundBox(FLayoutUtilities.toSheetRect(rect,m_layout.getAT())); |
361 |
fframetext.getText().clear(); |
362 |
for (int i=0;i<getTaTexto().getLineCount();i++){ |
363 |
try{
|
364 |
String s=getTaTexto().getText(getTaTexto().getLineStartOffset(i),getTaTexto().getLineEndOffset(i)-getTaTexto().getLineStartOffset(i));
|
365 |
if (!s.equals("")){ |
366 |
fframetext.addText(s); |
367 |
} |
368 |
}catch(Exception ex){ |
369 |
} |
370 |
} |
371 |
|
372 |
fframetext.setSizeFixed(!getChbEscalaVista().isSelected()); |
373 |
fframetext.setRotation(Double.parseDouble(getTRotacion().getText()));
|
374 |
App.instance.getMDIContext().closeView(FFrameTextDialog.this); |
375 |
m_layout.refresh(); |
376 |
isAcepted=true;
|
377 |
} |
378 |
}); |
379 |
} |
380 |
return bAceptar;
|
381 |
} |
382 |
/**
|
383 |
* This method initializes bCancelar
|
384 |
*
|
385 |
* @return javax.swing.JButton
|
386 |
*/
|
387 |
private javax.swing.JButton getBCancelar() {
|
388 |
if(bCancelar == null) { |
389 |
bCancelar = new javax.swing.JButton();
|
390 |
bCancelar.setSize(85, 26); |
391 |
bCancelar.setText(Utilities.getMessage(this,"Cancelar")); |
392 |
bCancelar.setLocation(151, 183); |
393 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
394 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
395 |
App.instance.getMDIContext().closeView(FFrameTextDialog.this); |
396 |
} |
397 |
}); |
398 |
} |
399 |
return bCancelar;
|
400 |
} |
401 |
/* (non-Javadoc)
|
402 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
403 |
*/
|
404 |
public ViewInfo getViewInfo() {
|
405 |
if (m_viewinfo==null){ |
406 |
m_viewinfo=new ViewInfo();
|
407 |
m_viewinfo.setFeatures(ViewInfo.MODALDIALOG); |
408 |
//vi.setResizable(false);
|
409 |
m_viewinfo.setTitle(Utilities.getMessage(this,"Propiedades_texto")); |
410 |
} |
411 |
return m_viewinfo;
|
412 |
} |
413 |
/**
|
414 |
* @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
|
415 |
*/
|
416 |
public boolean getIsAcepted() { |
417 |
return isAcepted;
|
418 |
} |
419 |
/**
|
420 |
* This method initializes bFuente
|
421 |
*
|
422 |
* @return javax.swing.JButton
|
423 |
*/
|
424 |
private javax.swing.JButton getBFuente() {
|
425 |
if(bFuente == null) { |
426 |
bFuente = new javax.swing.JButton();
|
427 |
bFuente.setBounds(184, 98, 82, 27); |
428 |
bFuente.setText(Utilities.getMessage(this,"fuente")); |
429 |
bFuente.addActionListener(new java.awt.event.ActionListener() {
|
430 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
431 |
fframetext.setFont(FontChooser.showDialog("Selecci?n de fuente",fframetext.getFont()));// fchoser=new FontChooser(); |
432 |
} |
433 |
}); |
434 |
} |
435 |
return bFuente;
|
436 |
} /**
|
437 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
438 |
*/
|
439 |
public void viewActivated() { |
440 |
} |
441 |
} // @jve:visual-info decl-index=0 visual-constraint="62,25"
|