svn-document-layout / branches / usability_v2 / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / gui / dialogs / FBorderDialog.java @ 140
History | View | Annotate | Download (28.5 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.project.documents.layout.gui.dialogs; |
23 |
|
24 |
import java.awt.Color; |
25 |
import java.awt.geom.AffineTransform; |
26 |
import java.awt.geom.Point2D; |
27 |
import java.awt.geom.Rectangle2D; |
28 |
|
29 |
import javax.swing.ButtonGroup; |
30 |
import javax.swing.JPanel; |
31 |
|
32 |
import org.gvsig.andami.PluginServices; |
33 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
34 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
35 |
import org.gvsig.app.project.ProjectManager; |
36 |
import org.gvsig.app.project.documents.layout.DefaultLayoutManager; |
37 |
import org.gvsig.app.project.documents.layout.DefaultLayoutNotification; |
38 |
import org.gvsig.app.project.documents.layout.FLayoutGraphics; |
39 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
40 |
import org.gvsig.app.project.documents.layout.LayoutNotification; |
41 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphics; |
42 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
43 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog; |
44 |
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter; |
45 |
import org.gvsig.app.project.documents.layout.geometryadapters.RectangleAdapter; |
46 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
47 |
import org.gvsig.fmap.geom.Geometry; |
48 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
49 |
import org.gvsig.tools.observer.Observable; |
50 |
import org.gvsig.tools.observer.ObservableHelper; |
51 |
import org.gvsig.tools.observer.Observer; |
52 |
|
53 |
/**
|
54 |
* Di?logo con todas las opciones para crear un borde a los fframes.
|
55 |
*
|
56 |
* @author Vicente Caballero Navarro
|
57 |
*/
|
58 |
public class FBorderDialog extends JPanel implements IWindow, Observable { |
59 |
|
60 |
private static final long serialVersionUID = 8890787517445911425L; |
61 |
private javax.swing.JRadioButton rbSeleccionados = null; |
62 |
private javax.swing.JRadioButton rbTodos = null; |
63 |
private javax.swing.JRadioButton rbMargen = null; |
64 |
private javax.swing.JCheckBox chbAgrupar = null; |
65 |
private javax.swing.JPanel pPosicion = null; |
66 |
private javax.swing.JCheckBox chbIgualLados = null; |
67 |
private javax.swing.JLabel lunidades = null; |
68 |
private javax.swing.JTextField tTodosLados = null; |
69 |
private javax.swing.JLabel lSuperior = null; |
70 |
private javax.swing.JLabel lInferior = null; |
71 |
private javax.swing.JTextField tSuperior = null; |
72 |
private javax.swing.JTextField tInferior = null; |
73 |
private javax.swing.JLabel lIzquierda = null; |
74 |
private javax.swing.JLabel lDerecha = null; |
75 |
private javax.swing.JTextField tIzquierda = null; |
76 |
private javax.swing.JTextField tDerecha = null; |
77 |
private javax.swing.JLabel lUnidades = null; |
78 |
private javax.swing.JButton bAceptar = null; |
79 |
private javax.swing.JButton bCancelar = null; |
80 |
private LayoutPanel layout = null; |
81 |
private IFFrame[] selecList;// = new ArrayList(); |
82 |
private FFrameGraphics fframegraphics = null; |
83 |
private FLayoutGraphics flg = null; |
84 |
private String m_NameUnit = null; |
85 |
private javax.swing.JButton bConfigurar = null; |
86 |
private GeometryAdapter geometry = new RectangleAdapter(); |
87 |
private boolean isAccepted = false; |
88 |
private ISymbol symbol;
|
89 |
|
90 |
private LayoutManager layoutManager = null; |
91 |
private ObservableHelper observers;
|
92 |
|
93 |
/**
|
94 |
* This is the default constructor
|
95 |
*
|
96 |
* @param l
|
97 |
* Referencia al Layout.
|
98 |
*/
|
99 |
public FBorderDialog(LayoutPanel layoutPanel) {
|
100 |
super();
|
101 |
layout = layoutPanel; |
102 |
layoutManager = |
103 |
(LayoutManager) ProjectManager.getInstance().getDocumentManager(
|
104 |
DefaultLayoutManager.TYPENAME); |
105 |
observers = new ObservableHelper();
|
106 |
observers.addObserver(layoutPanel.getLayoutControl()); |
107 |
flg = new FLayoutGraphics(layout);
|
108 |
|
109 |
LayoutManager layoutManager =
|
110 |
(LayoutManager) ProjectManager.getInstance().getDocumentManager(
|
111 |
DefaultLayoutManager.TYPENAME); |
112 |
fframegraphics = |
113 |
(FFrameGraphics) layoutManager |
114 |
.createFrame(FFrameGraphics.PERSISTENCE_DEFINITION_NAME); |
115 |
|
116 |
fframegraphics.setColor(Color.black);
|
117 |
fframegraphics.update(Geometry.TYPES.SURFACE, layout |
118 |
.getLayoutControl().getAT()); |
119 |
|
120 |
initialize(); |
121 |
startFFrameGraphic(); |
122 |
} |
123 |
|
124 |
private void startFFrameGraphic() { |
125 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
126 |
double x = Double.parseDouble(getTIzquierda().getText().toString()); |
127 |
double y = Double.parseDouble(getTSuperior().getText().toString()); |
128 |
double w = Double.parseDouble(getTDerecha().getText().toString()); |
129 |
double h = Double.parseDouble(getTInferior().getText().toString()); |
130 |
|
131 |
Rectangle2D re = new Rectangle2D.Double(); |
132 |
|
133 |
if (getRbSeleccionados().isSelected()) {
|
134 |
if (selecList.length > 0) { |
135 |
re = getRectangle(selecList[0]);
|
136 |
|
137 |
} |
138 |
|
139 |
for (int i = 1; i < selecList.length; i++) { |
140 |
Rectangle2D rectaux = getRectangle(selecList[i]);
|
141 |
re.add(rectaux); |
142 |
} |
143 |
|
144 |
// crear un Rect?ngulo alrededor de los fframes seleccionados.
|
145 |
} else
|
146 |
if (getRbTodos().isSelected()) {
|
147 |
if (fframes.length > 0) { |
148 |
re = getRectangle(fframes[0]);
|
149 |
} |
150 |
|
151 |
for (int i = 1; i < fframes.length; i++) { |
152 |
Rectangle2D rectaux = getRectangle(fframes[i]);
|
153 |
re.add(rectaux); |
154 |
} |
155 |
|
156 |
// creaer un Rect?ngulo que incluya a todos los fframes.
|
157 |
} else
|
158 |
if (getRbMargen().isSelected()) {
|
159 |
// creaer un Rect?ngulo en los m?rgenes del Layout.
|
160 |
re.setRect(layout.getLayoutContext().getAttributes() |
161 |
.getArea()); |
162 |
} |
163 |
|
164 |
re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w, |
165 |
re.getHeight() + y + h); |
166 |
|
167 |
geometry = new RectangleAdapter();
|
168 |
geometry.addPoint(new Point2D.Double(re.getX(), re.getY())); |
169 |
geometry.addPoint(new Point2D.Double(re.getMaxX(), re.getMaxY())); |
170 |
geometry.end(); |
171 |
fframegraphics.setGeometryAdapter(geometry); |
172 |
} |
173 |
|
174 |
/**
|
175 |
* This method initializes this
|
176 |
*/
|
177 |
private void initialize() { |
178 |
selecList = layout.getLayoutContext().getSelectedFFrames(); |
179 |
this.setLayout(null); |
180 |
m_NameUnit = layout.getLayoutContext().getAttributes().getNameUnit(); |
181 |
this.add(getRbSeleccionados(), null); |
182 |
this.add(getRbTodos(), null); |
183 |
this.add(getRbMargen(), null); |
184 |
this.add(getChbAgrupar(), null); |
185 |
this.add(getPPosicion(), null); |
186 |
this.add(getBAceptar(), null); |
187 |
this.add(getBCancelar(), null); |
188 |
this.add(getBConfigurar(), null); |
189 |
this.setSize(371, 223); |
190 |
|
191 |
ButtonGroup group = new ButtonGroup(); |
192 |
group.add(getRbSeleccionados()); |
193 |
group.add(getRbTodos()); |
194 |
group.add(getRbMargen()); |
195 |
} |
196 |
|
197 |
/**
|
198 |
* This method initializes rbSeleccionados
|
199 |
*
|
200 |
* @return javax.swing.JRadioButton
|
201 |
*/
|
202 |
private javax.swing.JRadioButton getRbSeleccionados() {
|
203 |
if (rbSeleccionados == null) { |
204 |
rbSeleccionados = new javax.swing.JRadioButton();
|
205 |
rbSeleccionados.setBounds(10, 8, 416, 20); |
206 |
rbSeleccionados.setText(PluginServices.getText(this,
|
207 |
"colocar_alrededor_seleccionados"));
|
208 |
|
209 |
if (selecList.length == 0) { |
210 |
rbSeleccionados.setEnabled(false);
|
211 |
getRbTodos().setSelected(true);
|
212 |
} else {
|
213 |
rbSeleccionados.setSelected(true);
|
214 |
} |
215 |
} |
216 |
|
217 |
return rbSeleccionados;
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* This method initializes rbTodos
|
222 |
*
|
223 |
* @return javax.swing.JRadioButton
|
224 |
*/
|
225 |
private javax.swing.JRadioButton getRbTodos() {
|
226 |
if (rbTodos == null) { |
227 |
rbTodos = new javax.swing.JRadioButton();
|
228 |
rbTodos.setBounds(10, 29, 332, 20); |
229 |
rbTodos.setText(PluginServices.getText(this,
|
230 |
"colocar_alrededor_todos"));
|
231 |
} |
232 |
|
233 |
return rbTodos;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* This method initializes rbMargen
|
238 |
*
|
239 |
* @return javax.swing.JRadioButton
|
240 |
*/
|
241 |
private javax.swing.JRadioButton getRbMargen() {
|
242 |
if (rbMargen == null) { |
243 |
rbMargen = new javax.swing.JRadioButton();
|
244 |
rbMargen.setBounds(10, 51, 286, 20); |
245 |
rbMargen |
246 |
.setText(PluginServices.getText(this, "colocar_a_margenes")); |
247 |
} |
248 |
|
249 |
return rbMargen;
|
250 |
} |
251 |
|
252 |
/**
|
253 |
* This method initializes chbAgrupar
|
254 |
*
|
255 |
* @return javax.swing.JCheckBox
|
256 |
*/
|
257 |
private javax.swing.JCheckBox getChbAgrupar() {
|
258 |
if (chbAgrupar == null) { |
259 |
chbAgrupar = new javax.swing.JCheckBox();
|
260 |
chbAgrupar.setBounds(10, 70, 280, 20); |
261 |
chbAgrupar.setText(PluginServices.getText(this, "agrupar_linea")); |
262 |
} |
263 |
|
264 |
return chbAgrupar;
|
265 |
} |
266 |
|
267 |
/**
|
268 |
* This method initializes pPosicion
|
269 |
*
|
270 |
* @return javax.swing.JPanel
|
271 |
*/
|
272 |
private javax.swing.JPanel getPPosicion() {
|
273 |
if (pPosicion == null) { |
274 |
pPosicion = new javax.swing.JPanel();
|
275 |
pPosicion.setLayout(null);
|
276 |
pPosicion.add(getChbIgualLados(), null);
|
277 |
pPosicion.add(getLunidades(), null);
|
278 |
pPosicion.add(getTTodosLados(), null);
|
279 |
pPosicion.add(getLSuperior(), null);
|
280 |
pPosicion.add(getLInferior(), null);
|
281 |
pPosicion.add(getTSuperior(), null);
|
282 |
pPosicion.add(getTInferior(), null);
|
283 |
pPosicion.add(getLIzquierda(), null);
|
284 |
pPosicion.add(getLDerecha(), null);
|
285 |
pPosicion.add(getTIzquierda(), null);
|
286 |
pPosicion.add(getTDerecha(), null);
|
287 |
pPosicion.add(getLUnidades(), null);
|
288 |
pPosicion.setBounds(12, 92, 350, 97); |
289 |
pPosicion.setBorder(javax.swing.BorderFactory.createTitledBorder( |
290 |
null, PluginServices.getText(this, "posicion_linea"), |
291 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
292 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
293 |
} |
294 |
|
295 |
return pPosicion;
|
296 |
} |
297 |
|
298 |
/**
|
299 |
* This method initializes chbIgualLados
|
300 |
*
|
301 |
* @return javax.swing.JCheckBox
|
302 |
*/
|
303 |
private javax.swing.JCheckBox getChbIgualLados() {
|
304 |
if (chbIgualLados == null) { |
305 |
chbIgualLados = new javax.swing.JCheckBox();
|
306 |
chbIgualLados.setBounds(10, 16, 243, 21); |
307 |
chbIgualLados.setText(PluginServices.getText(this,
|
308 |
"igual_todos_lados"));
|
309 |
chbIgualLados.setSelected(true);
|
310 |
chbIgualLados |
311 |
.addActionListener(new java.awt.event.ActionListener() {
|
312 |
|
313 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
314 |
if (!chbIgualLados.isSelected()) {
|
315 |
getTTodosLados().setEnabled(false);
|
316 |
getTSuperior().setEnabled(true);
|
317 |
getTInferior().setEnabled(true);
|
318 |
getTIzquierda().setEnabled(true);
|
319 |
getTDerecha().setEnabled(true);
|
320 |
} else {
|
321 |
getTTodosLados().setEnabled(true);
|
322 |
getTSuperior().setEnabled(false);
|
323 |
getTInferior().setEnabled(false);
|
324 |
getTIzquierda().setEnabled(false);
|
325 |
getTDerecha().setEnabled(false);
|
326 |
getTSuperior().setText(tTodosLados.getText()); |
327 |
getTInferior().setText(tTodosLados.getText()); |
328 |
getTIzquierda().setText(tTodosLados.getText()); |
329 |
getTDerecha().setText(tTodosLados.getText()); |
330 |
} |
331 |
} |
332 |
}); |
333 |
} |
334 |
|
335 |
return chbIgualLados;
|
336 |
} |
337 |
|
338 |
/**
|
339 |
* This method initializes lunidades
|
340 |
*
|
341 |
* @return javax.swing.JLabel
|
342 |
*/
|
343 |
private javax.swing.JLabel getLunidades() {
|
344 |
if (lunidades == null) { |
345 |
lunidades = new javax.swing.JLabel();
|
346 |
lunidades.setBounds(264, 64, 78, 18); |
347 |
lunidades.setText(PluginServices.getText(this, m_NameUnit));
|
348 |
} |
349 |
|
350 |
return lunidades;
|
351 |
} |
352 |
|
353 |
/**
|
354 |
* This method initializes tTodosLados
|
355 |
*
|
356 |
* @return javax.swing.JTextField
|
357 |
*/
|
358 |
private javax.swing.JTextField getTTodosLados() {
|
359 |
if (tTodosLados == null) { |
360 |
tTodosLados = new javax.swing.JTextField();
|
361 |
tTodosLados.setBounds(267, 19, 48, 16); |
362 |
tTodosLados.setText("0.5");
|
363 |
tTodosLados.addCaretListener(new javax.swing.event.CaretListener() {
|
364 |
|
365 |
public void caretUpdate(javax.swing.event.CaretEvent e) { |
366 |
if (getChbIgualLados().isSelected()) {
|
367 |
getTSuperior().setText(tTodosLados.getText()); |
368 |
getTInferior().setText(tTodosLados.getText()); |
369 |
getTIzquierda().setText(tTodosLados.getText()); |
370 |
getTDerecha().setText(tTodosLados.getText()); |
371 |
} |
372 |
} |
373 |
}); |
374 |
} |
375 |
|
376 |
return tTodosLados;
|
377 |
} |
378 |
|
379 |
/**
|
380 |
* This method initializes lSuperior
|
381 |
*
|
382 |
* @return javax.swing.JLabel
|
383 |
*/
|
384 |
private javax.swing.JLabel getLSuperior() {
|
385 |
if (lSuperior == null) { |
386 |
lSuperior = new javax.swing.JLabel();
|
387 |
lSuperior.setBounds(10, 55, 62, 16); |
388 |
lSuperior.setText(PluginServices.getText(this, "Superior")); |
389 |
} |
390 |
|
391 |
return lSuperior;
|
392 |
} |
393 |
|
394 |
/**
|
395 |
* This method initializes lInferior
|
396 |
*
|
397 |
* @return javax.swing.JLabel
|
398 |
*/
|
399 |
private javax.swing.JLabel getLInferior() {
|
400 |
if (lInferior == null) { |
401 |
lInferior = new javax.swing.JLabel();
|
402 |
lInferior.setBounds(10, 72, 62, 16); |
403 |
lInferior.setText(PluginServices.getText(this, "Inferior")); |
404 |
} |
405 |
|
406 |
return lInferior;
|
407 |
} |
408 |
|
409 |
/**
|
410 |
* This method initializes tSuperior
|
411 |
*
|
412 |
* @return javax.swing.JTextField
|
413 |
*/
|
414 |
private javax.swing.JTextField getTSuperior() {
|
415 |
if (tSuperior == null) { |
416 |
tSuperior = new javax.swing.JTextField();
|
417 |
tSuperior.setBounds(78, 55, 48, 16); |
418 |
tSuperior.setText("0.5");
|
419 |
tSuperior.setEnabled(false);
|
420 |
} |
421 |
|
422 |
return tSuperior;
|
423 |
} |
424 |
|
425 |
/**
|
426 |
* This method initializes tInferior
|
427 |
*
|
428 |
* @return javax.swing.JTextField
|
429 |
*/
|
430 |
private javax.swing.JTextField getTInferior() {
|
431 |
if (tInferior == null) { |
432 |
tInferior = new javax.swing.JTextField();
|
433 |
tInferior.setBounds(78, 72, 48, 16); |
434 |
tInferior.setText("0.5");
|
435 |
tInferior.setEnabled(false);
|
436 |
} |
437 |
|
438 |
return tInferior;
|
439 |
} |
440 |
|
441 |
/**
|
442 |
* This method initializes lIzquierda
|
443 |
*
|
444 |
* @return javax.swing.JLabel
|
445 |
*/
|
446 |
private javax.swing.JLabel getLIzquierda() {
|
447 |
if (lIzquierda == null) { |
448 |
lIzquierda = new javax.swing.JLabel();
|
449 |
lIzquierda.setBounds(140, 55, 62, 16); |
450 |
lIzquierda.setText(PluginServices.getText(this, "Izquierda")); |
451 |
} |
452 |
|
453 |
return lIzquierda;
|
454 |
} |
455 |
|
456 |
/**
|
457 |
* This method initializes lDerecha
|
458 |
*
|
459 |
* @return javax.swing.JLabel
|
460 |
*/
|
461 |
private javax.swing.JLabel getLDerecha() {
|
462 |
if (lDerecha == null) { |
463 |
lDerecha = new javax.swing.JLabel();
|
464 |
lDerecha.setBounds(140, 72, 62, 16); |
465 |
lDerecha.setText(PluginServices.getText(this, "Derecha")); |
466 |
} |
467 |
|
468 |
return lDerecha;
|
469 |
} |
470 |
|
471 |
/**
|
472 |
* This method initializes tIzquierda
|
473 |
*
|
474 |
* @return javax.swing.JTextField
|
475 |
*/
|
476 |
private javax.swing.JTextField getTIzquierda() {
|
477 |
if (tIzquierda == null) { |
478 |
tIzquierda = new javax.swing.JTextField();
|
479 |
tIzquierda.setBounds(207, 55, 48, 16); |
480 |
tIzquierda.setText("0.5");
|
481 |
tIzquierda.setEnabled(false);
|
482 |
} |
483 |
|
484 |
return tIzquierda;
|
485 |
} |
486 |
|
487 |
/**
|
488 |
* This method initializes tDerecha
|
489 |
*
|
490 |
* @return javax.swing.JTextField
|
491 |
*/
|
492 |
private javax.swing.JTextField getTDerecha() {
|
493 |
if (tDerecha == null) { |
494 |
tDerecha = new javax.swing.JTextField();
|
495 |
tDerecha.setBounds(207, 72, 48, 16); |
496 |
tDerecha.setText("0.5");
|
497 |
tDerecha.setEnabled(false);
|
498 |
} |
499 |
|
500 |
return tDerecha;
|
501 |
} |
502 |
|
503 |
/**
|
504 |
* This method initializes lUnidades
|
505 |
*
|
506 |
* @return javax.swing.JLabel
|
507 |
*/
|
508 |
private javax.swing.JLabel getLUnidades() {
|
509 |
if (lUnidades == null) { |
510 |
lUnidades = new javax.swing.JLabel();
|
511 |
lUnidades.setBounds(207, 36, 134, 18); |
512 |
lUnidades.setText(PluginServices.getText(this, "map_units")); |
513 |
} |
514 |
|
515 |
return lUnidades;
|
516 |
} |
517 |
|
518 |
/**
|
519 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
520 |
*/
|
521 |
public WindowInfo getWindowInfo() {
|
522 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
523 |
m_viewinfo.setTitle(PluginServices.getText(this,
|
524 |
"ajustes_linea_grafica"));
|
525 |
|
526 |
return m_viewinfo;
|
527 |
} |
528 |
|
529 |
/**
|
530 |
* This method initializes bAceptar
|
531 |
*
|
532 |
* @return javax.swing.JButton
|
533 |
*/
|
534 |
private javax.swing.JButton getBAceptar() {
|
535 |
if (bAceptar == null) { |
536 |
bAceptar = new javax.swing.JButton();
|
537 |
bAceptar.setBounds(134, 193, 100, 20); |
538 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
539 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
540 |
|
541 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
542 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
543 |
double x =
|
544 |
Double
|
545 |
.parseDouble(getTIzquierda().getText().toString()); |
546 |
double y =
|
547 |
Double.parseDouble(getTSuperior().getText().toString());
|
548 |
double w =
|
549 |
Double.parseDouble(getTDerecha().getText().toString());
|
550 |
double h =
|
551 |
Double.parseDouble(getTInferior().getText().toString());
|
552 |
|
553 |
if (!getChbAgrupar().isSelected()) {
|
554 |
Rectangle2D re = new Rectangle2D.Double(); |
555 |
|
556 |
if (getRbSeleccionados().isSelected()) {
|
557 |
if (selecList.length > 0) { |
558 |
re = getRectangle(selecList[0]);
|
559 |
|
560 |
} |
561 |
|
562 |
for (int i = 1; i < selecList.length; i++) { |
563 |
Rectangle2D rectaux =
|
564 |
getRectangle(selecList[i]); |
565 |
re.add(rectaux); |
566 |
} |
567 |
|
568 |
// crear un Rect?ngulo alrededor de los fframes
|
569 |
// seleccionados.
|
570 |
} else
|
571 |
if (getRbTodos().isSelected()) {
|
572 |
if (fframes.length > 0) { |
573 |
re = getRectangle(fframes[0]);
|
574 |
} |
575 |
|
576 |
for (int i = 1; i < fframes.length; i++) { |
577 |
Rectangle2D rectaux =
|
578 |
getRectangle(fframes[i]); |
579 |
re.add(rectaux); |
580 |
} |
581 |
|
582 |
// creaer un Rect?ngulo que incluya a todos los
|
583 |
// fframes.
|
584 |
} else
|
585 |
if (getRbMargen().isSelected()) {
|
586 |
// creaer un Rect?ngulo en los m?rgenes del
|
587 |
// Layout.
|
588 |
re.setRect(layout.getLayoutContext() |
589 |
.getAttributes().getArea()); |
590 |
} |
591 |
|
592 |
re.setRect(re.getX() - x, re.getY() - y, re.getWidth() |
593 |
+ x + w, re.getHeight() + y + h); |
594 |
|
595 |
geometry = new RectangleAdapter();
|
596 |
geometry.addPoint(new Point2D.Double(re.getX(), re |
597 |
.getY())); |
598 |
geometry.addPoint(new Point2D.Double(re.getMaxX(), re |
599 |
.getMaxY())); |
600 |
geometry.end(); |
601 |
fframegraphics.setGeometryAdapter(geometry); |
602 |
fframegraphics.setBoundBox(re); |
603 |
if (symbol != null) { |
604 |
fframegraphics.setSymbol(symbol); |
605 |
} |
606 |
layout.getLayoutContext().addFFrame(fframegraphics, |
607 |
true, true); |
608 |
} else { // Agrupar |
609 |
|
610 |
Rectangle2D re = new Rectangle2D.Double(); |
611 |
if (getRbSeleccionados().isSelected()) {
|
612 |
if (selecList.length > 0) { |
613 |
re = getRectangle(selecList[0]);
|
614 |
} |
615 |
|
616 |
for (int i = 1; i < selecList.length; i++) { |
617 |
Rectangle2D rectaux =
|
618 |
getRectangle(selecList[i]); |
619 |
re.add(rectaux); |
620 |
} |
621 |
|
622 |
// crear un Rect?ngulo alrededor de los fframes
|
623 |
// seleccionados.
|
624 |
} else
|
625 |
if (getRbTodos().isSelected()) {
|
626 |
if (fframes.length > 0) { |
627 |
re = getRectangle(fframes[0]);
|
628 |
} |
629 |
|
630 |
for (int i = 1; i < fframes.length; i++) { |
631 |
Rectangle2D rectaux =
|
632 |
getRectangle(fframes[i]); |
633 |
fframes[i].setSelected(true);
|
634 |
re.add(rectaux); |
635 |
} |
636 |
|
637 |
// creaer un Rect?ngulo que incluya a todos los
|
638 |
// fframes.
|
639 |
} else
|
640 |
if (getRbMargen().isSelected()) {
|
641 |
// creaer un Rect?ngulo en los m?rgenes del
|
642 |
// Layout.
|
643 |
re.setRect(layout.getLayoutContext() |
644 |
.getAttributes().getArea()); |
645 |
} |
646 |
|
647 |
re.setRect(re.getX() - x, re.getY() - y, re.getWidth() |
648 |
+ x + w, re.getHeight() + y + h); |
649 |
|
650 |
geometry = new RectangleAdapter();
|
651 |
geometry.addPoint(new Point2D.Double(re.getX(), re |
652 |
.getY())); |
653 |
geometry.addPoint(new Point2D.Double(re.getMaxX(), re |
654 |
.getMaxY())); |
655 |
geometry.end(); |
656 |
fframegraphics.setGeometryAdapter(geometry); |
657 |
fframegraphics.setBoundBox(re); |
658 |
if (symbol != null) { |
659 |
fframegraphics.setSymbol(symbol); |
660 |
} |
661 |
layout |
662 |
.getLayoutContext() |
663 |
.getFrameCommandsRecord() |
664 |
.startComplex( |
665 |
PluginServices.getText(this,
|
666 |
"group_graphic_line"));
|
667 |
layout.getLayoutContext().addFFrame(fframegraphics, |
668 |
false, true); |
669 |
flg.grouping(); |
670 |
layout.getLayoutContext().getFrameCommandsRecord() |
671 |
.endComplex(); |
672 |
|
673 |
} |
674 |
|
675 |
PluginServices.getMDIManager().closeWindow( |
676 |
FBorderDialog.this); |
677 |
observers.notifyObservers(FBorderDialog.this, |
678 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED));
|
679 |
layout.getLayoutControl().repaint(); |
680 |
isAccepted = true;
|
681 |
} |
682 |
}); |
683 |
} |
684 |
|
685 |
return bAceptar;
|
686 |
} |
687 |
|
688 |
/**
|
689 |
* This method initializes bCancelar
|
690 |
*
|
691 |
* @return javax.swing.JButton
|
692 |
*/
|
693 |
private javax.swing.JButton getBCancelar() {
|
694 |
if (bCancelar == null) { |
695 |
bCancelar = new javax.swing.JButton();
|
696 |
bCancelar.setBounds(251, 193, 100, 20); |
697 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
698 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
699 |
|
700 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
701 |
PluginServices.getMDIManager().closeWindow( |
702 |
FBorderDialog.this); |
703 |
isAccepted = false;
|
704 |
} |
705 |
}); |
706 |
} |
707 |
|
708 |
return bCancelar;
|
709 |
} |
710 |
|
711 |
/**
|
712 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
713 |
*/
|
714 |
public void viewActivated() { |
715 |
} |
716 |
|
717 |
/**
|
718 |
* This method initializes bConfigurar
|
719 |
*
|
720 |
* @return javax.swing.JButton
|
721 |
*/
|
722 |
private javax.swing.JButton getBConfigurar() {
|
723 |
if (bConfigurar == null) { |
724 |
bConfigurar = new javax.swing.JButton();
|
725 |
bConfigurar.setBounds(17, 193, 100, 20); |
726 |
bConfigurar.setText(PluginServices.getText(this, "configurar")); |
727 |
bConfigurar.addActionListener(new java.awt.event.ActionListener() {
|
728 |
|
729 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
730 |
|
731 |
FFrameGraphicsDialog graphicsdialog = |
732 |
(FFrameGraphicsDialog) layoutManager |
733 |
.createFFrameDialog(fframegraphics, layout); |
734 |
|
735 |
PluginServices.getMDIManager().addWindow(graphicsdialog); |
736 |
symbol = (ISymbol) graphicsdialog.getSelectedObject(); |
737 |
} |
738 |
}); |
739 |
} |
740 |
|
741 |
return bConfigurar;
|
742 |
} |
743 |
|
744 |
private Rectangle2D getRectangle(IFFrame f) { |
745 |
Rectangle2D.Double re = new Rectangle2D.Double(); |
746 |
re.setRect(f.getBoundBox()); |
747 |
Point2D p1 = new Point2D.Double(); |
748 |
Point2D p2 = new Point2D.Double(); |
749 |
Point2D p3 = new Point2D.Double(); |
750 |
Point2D p4 = new Point2D.Double(); |
751 |
double rotation = (f).getRotation();
|
752 |
AffineTransform at = new AffineTransform(); |
753 |
at.rotate(Math.toRadians(rotation), re.x + (re.width / 2), re.y |
754 |
+ (re.height / 2));
|
755 |
at.transform(new Point2D.Double(re.getX(), re.getY()), p1); |
756 |
at.transform(new Point2D.Double(re.getMaxX(), re.getY()), p2); |
757 |
at.transform(new Point2D.Double(re.getMaxX(), re.getMaxY()), p3); |
758 |
at.transform(new Point2D.Double(re.getX(), re.getMaxY()), p4); |
759 |
if (p1.getX() < p4.getX()) {
|
760 |
re.x = p1.getX(); |
761 |
} else {
|
762 |
re.x = p4.getX(); |
763 |
} |
764 |
if (p1.getY() < p2.getY()) {
|
765 |
re.y = p1.getY(); |
766 |
} else {
|
767 |
re.y = p2.getY(); |
768 |
} |
769 |
if (p2.getX() > p3.getX()) {
|
770 |
re.width = p2.getX() - re.x; |
771 |
} else {
|
772 |
re.width = p3.getX() - re.x; |
773 |
} |
774 |
if (p4.getY() > p3.getY()) {
|
775 |
re.height = p4.getY() - re.y; |
776 |
} else {
|
777 |
re.height = p3.getY() - re.y; |
778 |
} |
779 |
return re;
|
780 |
} |
781 |
|
782 |
public boolean isAccepted() { |
783 |
return isAccepted;
|
784 |
} |
785 |
|
786 |
public Object getWindowProfile() { |
787 |
return WindowInfo.DIALOG_PROFILE;
|
788 |
} |
789 |
|
790 |
public void addObserver(Observer o) { |
791 |
observers.addObserver(o); |
792 |
} |
793 |
|
794 |
public void deleteObserver(Observer o) { |
795 |
observers.deleteObserver(o); |
796 |
} |
797 |
|
798 |
public void deleteObservers() { |
799 |
observers.deleteObservers(); |
800 |
} |
801 |
} |