root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / dialogs / EventsFAlign.java @ 1074
History | View | Annotate | Download (23.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 22-jul-2004
|
3 |
*
|
4 |
*/
|
5 |
package com.iver.cit.gvsig.gui.layout.dialogs; |
6 |
|
7 |
import com.iver.cit.gvsig.gui.layout.Layout; |
8 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
9 |
|
10 |
import java.awt.event.ActionEvent; |
11 |
import java.awt.event.ActionListener; |
12 |
|
13 |
import java.util.Iterator; |
14 |
import java.util.TreeMap; |
15 |
|
16 |
|
17 |
/**
|
18 |
* Clase que hace de Listener de FAlignDialog.
|
19 |
*
|
20 |
* @author Vicente Caballero Navarro
|
21 |
*/
|
22 |
public class EventsFAlign implements ActionListener { |
23 |
private Layout m_layout;
|
24 |
private boolean inLayout = false; |
25 |
|
26 |
/**
|
27 |
* Crea un nuevo FAlign.
|
28 |
*
|
29 |
* @param layout Referencia al Layout.
|
30 |
*/
|
31 |
public EventsFAlign(Layout layout) {
|
32 |
m_layout = layout; |
33 |
} |
34 |
|
35 |
/**
|
36 |
* Desplaza los fframes seleccionados a la izquierda del fframe m?s
|
37 |
* occidental.
|
38 |
*/
|
39 |
private void alignLeft() { |
40 |
double xmin = Double.MAX_VALUE; |
41 |
|
42 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
43 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
44 |
|
45 |
if (fframe.getSelected() != 0) { |
46 |
if (xmin > fframe.getBoundBox().getMinX()) {
|
47 |
xmin = fframe.getBoundBox().getMinX(); |
48 |
} |
49 |
} |
50 |
} |
51 |
|
52 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
53 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
54 |
|
55 |
if (fframe.getSelected() != 0) { |
56 |
fframe.getBoundBox().x = xmin; |
57 |
} |
58 |
} |
59 |
} |
60 |
|
61 |
/**
|
62 |
* Desplaza los fframes seleccionados a la izquierda del Layout.
|
63 |
*/
|
64 |
private void alignLeftL() { |
65 |
double xmin = 0; |
66 |
|
67 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
68 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
69 |
|
70 |
if (fframe.getSelected() != 0) { |
71 |
fframe.getBoundBox().x = xmin; |
72 |
} |
73 |
} |
74 |
} |
75 |
|
76 |
/**
|
77 |
* Desplaza los fframes seleccionados al centro del fframe mas ancho de
|
78 |
* forma horizontal.
|
79 |
*/
|
80 |
private void alignCenterV() { |
81 |
double xcenter = 0; |
82 |
double w = Double.MIN_VALUE; |
83 |
|
84 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
85 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
86 |
|
87 |
if (fframe.getSelected() != 0) { |
88 |
if (w < fframe.getBoundBox().getWidth()) {
|
89 |
w = fframe.getBoundBox().getWidth(); |
90 |
xcenter = fframe.getBoundBox().getCenterX(); |
91 |
} |
92 |
} |
93 |
} |
94 |
|
95 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
96 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
97 |
|
98 |
if (fframe.getSelected() != 0) { |
99 |
fframe.getBoundBox().x = xcenter - |
100 |
(fframe.getBoundBox().width / 2);
|
101 |
} |
102 |
} |
103 |
} |
104 |
|
105 |
/**
|
106 |
* Desplaza los fframes seleccionados al centro del Layout horizontalmente.
|
107 |
*/
|
108 |
private void alignCenterVL() { |
109 |
double xcenter = 0; |
110 |
xcenter = m_layout.getAtributes().m_sizePaper.getAncho() / 2;
|
111 |
|
112 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
113 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
114 |
|
115 |
if (fframe.getSelected() != 0) { |
116 |
fframe.getBoundBox().x = xcenter - |
117 |
(fframe.getBoundBox().width / 2);
|
118 |
} |
119 |
} |
120 |
} |
121 |
|
122 |
/**
|
123 |
* Desplaza los fframes seleccionados a la parte derecha del fframe m?s
|
124 |
* oriental.
|
125 |
*/
|
126 |
private void alignRight() { |
127 |
double xmax = Double.MIN_VALUE; |
128 |
|
129 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
130 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
131 |
|
132 |
if (fframe.getSelected() != 0) { |
133 |
if (xmax < fframe.getBoundBox().getMaxX()) {
|
134 |
xmax = fframe.getBoundBox().getMaxX(); |
135 |
} |
136 |
} |
137 |
} |
138 |
|
139 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
140 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
141 |
|
142 |
if (fframe.getSelected() != 0) { |
143 |
fframe.getBoundBox().x = xmax - |
144 |
((IFFrame) m_layout.getFFrames().get(i)).getBoundBox().width; |
145 |
} |
146 |
} |
147 |
} |
148 |
|
149 |
/**
|
150 |
* Desplaza los fframes seleccionados a la parte derecha del Layout.
|
151 |
*/
|
152 |
private void alignRightL() { |
153 |
double xmax = 0; |
154 |
xmax = m_layout.getAtributes().m_sizePaper.getAncho(); |
155 |
|
156 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
157 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
158 |
|
159 |
if (fframe.getSelected() != 0) { |
160 |
fframe.getBoundBox().x = xmax - |
161 |
((IFFrame) m_layout.getFFrames().get(i)).getBoundBox().width; |
162 |
} |
163 |
} |
164 |
} |
165 |
|
166 |
/**
|
167 |
* Desplaza los fframes seleccionados a la parte inferior del fframe m?s
|
168 |
* hacia abajo.
|
169 |
*/
|
170 |
private void alignDown() { |
171 |
double ymax = Double.MIN_VALUE; |
172 |
|
173 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
174 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
175 |
|
176 |
if (fframe.getSelected() != 0) { |
177 |
if (ymax < fframe.getBoundBox().getMaxY()) {
|
178 |
ymax = fframe.getBoundBox().getMaxY(); |
179 |
} |
180 |
} |
181 |
} |
182 |
|
183 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
184 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
185 |
|
186 |
if (fframe.getSelected() != 0) { |
187 |
fframe.getBoundBox().y = ymax - fframe.getBoundBox().height; |
188 |
} |
189 |
} |
190 |
} |
191 |
|
192 |
/**
|
193 |
* Desplaza los fframes seleccionados a la parte inferior del Layout.
|
194 |
*/
|
195 |
private void alignDownL() { |
196 |
double ymax = 0; |
197 |
ymax = m_layout.getAtributes().m_sizePaper.getAlto(); |
198 |
|
199 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
200 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
201 |
|
202 |
if (fframe.getSelected() != 0) { |
203 |
fframe.getBoundBox().y = ymax - fframe.getBoundBox().height; |
204 |
} |
205 |
} |
206 |
} |
207 |
|
208 |
/**
|
209 |
* Desplaza los fframes seleccionados a la parte superior del fframe que
|
210 |
* m?s arriba este colocado.
|
211 |
*/
|
212 |
private void alignUp() { |
213 |
double ymin = Double.MAX_VALUE; |
214 |
|
215 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
216 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
217 |
|
218 |
if (fframe.getSelected() != 0) { |
219 |
if (ymin > fframe.getBoundBox().getMinY()) {
|
220 |
ymin = fframe.getBoundBox().getMinY(); |
221 |
} |
222 |
} |
223 |
} |
224 |
|
225 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
226 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
227 |
|
228 |
if (fframe.getSelected() != 0) { |
229 |
fframe.getBoundBox().y = ymin; |
230 |
} |
231 |
} |
232 |
} |
233 |
|
234 |
/**
|
235 |
* Desplaza los fframes seleccionados a la parte superior del Layout.
|
236 |
*/
|
237 |
private void alignUpL() { |
238 |
double ymin = 0; |
239 |
|
240 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
241 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
242 |
|
243 |
if (fframe.getSelected() != 0) { |
244 |
fframe.getBoundBox().y = ymin; |
245 |
} |
246 |
} |
247 |
} |
248 |
|
249 |
/**
|
250 |
* Desplaza los fframes seleccionados al centro del fframe m?s alto
|
251 |
* verticalmente.
|
252 |
*/
|
253 |
private void alignCenterH() { |
254 |
double ycenter = 0; |
255 |
double h = Double.MIN_VALUE; |
256 |
|
257 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
258 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
259 |
|
260 |
if (fframe.getSelected() != 0) { |
261 |
if (h < fframe.getBoundBox().getHeight()) {
|
262 |
h = fframe.getBoundBox().getHeight(); |
263 |
ycenter = fframe.getBoundBox().getCenterY(); |
264 |
} |
265 |
} |
266 |
} |
267 |
|
268 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
269 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
270 |
|
271 |
if (fframe.getSelected() != 0) { |
272 |
fframe.getBoundBox().y = ycenter - |
273 |
(fframe.getBoundBox().height / 2);
|
274 |
} |
275 |
} |
276 |
} |
277 |
|
278 |
/**
|
279 |
* Desplaza los fframes seleccionados en el Layout al centro verticalmente.
|
280 |
*/
|
281 |
private void alignCenterHL() { |
282 |
double ycenter = 0; |
283 |
ycenter = m_layout.getAtributes().m_sizePaper.getAlto() / 2;
|
284 |
|
285 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
286 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
287 |
|
288 |
if (fframe.getSelected() != 0) { |
289 |
fframe.getBoundBox().y = ycenter - |
290 |
(fframe.getBoundBox().height / 2);
|
291 |
} |
292 |
} |
293 |
} |
294 |
|
295 |
/**
|
296 |
* Distribuye los fframes seleccionados de forma equidistante y vertical,
|
297 |
* de izquierda a derecha.
|
298 |
*/
|
299 |
private void distLeft() { |
300 |
double xmin = Double.MAX_VALUE; |
301 |
double xmax = Double.MIN_VALUE; |
302 |
int num = 0; |
303 |
|
304 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
305 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
306 |
|
307 |
if (fframe.getSelected() != 0) { |
308 |
if (xmin > fframe.getBoundBox().getMinX()) {
|
309 |
xmin = fframe.getBoundBox().getMinX(); |
310 |
} |
311 |
|
312 |
if (xmax < fframe.getBoundBox().getMaxX()) {
|
313 |
xmax = fframe.getBoundBox().getMaxX(); |
314 |
} |
315 |
|
316 |
num++; |
317 |
} |
318 |
} |
319 |
|
320 |
double dif = xmax - xmin;
|
321 |
double dist = dif / num;
|
322 |
|
323 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
324 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
325 |
|
326 |
if (fframe.getSelected() != 0) { |
327 |
fframe.getBoundBox().x = xmin + (dist * i); |
328 |
} |
329 |
} |
330 |
} |
331 |
|
332 |
/**
|
333 |
* Distribuye los fframes seleccionados en el Layout de forma equidistante
|
334 |
* y vertical, de izquierda a derecha.
|
335 |
*/
|
336 |
private void distLeftL() { |
337 |
double xmin = 0; |
338 |
double xmax = 0; |
339 |
xmax = m_layout.getAtributes().m_sizePaper.getAncho(); |
340 |
|
341 |
int num = 0; |
342 |
|
343 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
344 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
345 |
|
346 |
if (fframe.getSelected() != 0) { |
347 |
num++; |
348 |
} |
349 |
} |
350 |
|
351 |
double dif = xmax - xmin;
|
352 |
double dist = dif / num;
|
353 |
|
354 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
355 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
356 |
|
357 |
if (fframe.getSelected() != 0) { |
358 |
fframe.getBoundBox().x = xmin + (dist * i); |
359 |
} |
360 |
} |
361 |
} |
362 |
|
363 |
/**
|
364 |
* Distribuye los fframes seleccionados de forma equidistante y vertical,
|
365 |
* de derecha a izquierda.
|
366 |
*/
|
367 |
private void distRight() { |
368 |
double xmin = Double.MAX_VALUE; |
369 |
double xmax = Double.MIN_VALUE; |
370 |
int num = 0; |
371 |
|
372 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
373 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
374 |
|
375 |
if (fframe.getSelected() != 0) { |
376 |
if (xmin > fframe.getBoundBox().getMinX()) {
|
377 |
xmin = fframe.getBoundBox().getMinX(); |
378 |
} |
379 |
|
380 |
if (xmax < fframe.getBoundBox().getMaxX()) {
|
381 |
xmax = fframe.getBoundBox().getMaxX(); |
382 |
} |
383 |
|
384 |
num++; |
385 |
} |
386 |
} |
387 |
|
388 |
double dif = xmax - xmin;
|
389 |
double dist = dif / num;
|
390 |
|
391 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
392 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
393 |
|
394 |
if (fframe.getSelected() != 0) { |
395 |
fframe.getBoundBox().x = xmax - (dist * i) - |
396 |
fframe.getBoundBox().width; |
397 |
} |
398 |
} |
399 |
} |
400 |
|
401 |
/**
|
402 |
* Distribuye los fframes seleccionados en el Layout de forma equidistante
|
403 |
* y vertical, de derecha a izquierda.
|
404 |
*/
|
405 |
private void distRightL() { |
406 |
double xmin = 0; |
407 |
double xmax = 0; |
408 |
xmax = m_layout.getAtributes().m_sizePaper.getAncho(); |
409 |
|
410 |
int num = 0; |
411 |
|
412 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
413 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
414 |
|
415 |
if (fframe.getSelected() != 0) { |
416 |
num++; |
417 |
} |
418 |
} |
419 |
|
420 |
double dif = xmax - xmin;
|
421 |
double dist = dif / num;
|
422 |
|
423 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
424 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
425 |
|
426 |
if (fframe.getSelected() != 0) { |
427 |
fframe.getBoundBox().x = xmax - (dist * i) - |
428 |
fframe.getBoundBox().width; |
429 |
} |
430 |
} |
431 |
} |
432 |
|
433 |
/**
|
434 |
* Distribuye los fframes seleccionados de forma equidistante y vertical,
|
435 |
* desde arriba hacia abajo.
|
436 |
*/
|
437 |
private void distUp() { |
438 |
double ymin = Double.MAX_VALUE; |
439 |
double ymax = Double.MIN_VALUE; |
440 |
int num = 0; |
441 |
|
442 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
443 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
444 |
|
445 |
if (fframe.getSelected() != 0) { |
446 |
if (ymin > fframe.getBoundBox().getMinY()) {
|
447 |
ymin = fframe.getBoundBox().getMinY(); |
448 |
} |
449 |
|
450 |
if (ymax < fframe.getBoundBox().getMaxY()) {
|
451 |
ymax = fframe.getBoundBox().getMaxY(); |
452 |
} |
453 |
|
454 |
num++; |
455 |
} |
456 |
} |
457 |
|
458 |
double dif = ymax - ymin;
|
459 |
double dist = dif / num;
|
460 |
|
461 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
462 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
463 |
|
464 |
if (fframe.getSelected() != 0) { |
465 |
fframe.getBoundBox().y = ymin + (dist * i); |
466 |
} |
467 |
} |
468 |
} |
469 |
|
470 |
/**
|
471 |
* Distribuye los fframes seleccionados en el Layout de forma equidistante
|
472 |
* y vertical, desde arriba hacia abajo.
|
473 |
*/
|
474 |
private void distUpL() { |
475 |
double ymin = 0; |
476 |
double ymax = 0; |
477 |
ymax = m_layout.getAtributes().m_sizePaper.getAlto(); |
478 |
|
479 |
int num = 0; |
480 |
|
481 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
482 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
483 |
|
484 |
if (fframe.getSelected() != 0) { |
485 |
num++; |
486 |
} |
487 |
} |
488 |
|
489 |
double dif = ymax - ymin;
|
490 |
double dist = dif / num;
|
491 |
|
492 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
493 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
494 |
|
495 |
if (fframe.getSelected() != 0) { |
496 |
fframe.getBoundBox().y = ymin + (dist * i); |
497 |
} |
498 |
} |
499 |
} |
500 |
|
501 |
/**
|
502 |
* Distribuye los fframes seleccionados de forma equidistante y vertical,
|
503 |
* desde bajo hacia arriba.
|
504 |
*/
|
505 |
private void distDown() { |
506 |
double ymin = Double.MAX_VALUE; |
507 |
double ymax = Double.MIN_VALUE; |
508 |
int num = 0; |
509 |
|
510 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
511 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
512 |
|
513 |
if (fframe.getSelected() != 0) { |
514 |
if (ymin > fframe.getBoundBox().getMinY()) {
|
515 |
ymin = fframe.getBoundBox().getMinY(); |
516 |
} |
517 |
|
518 |
if (ymax < fframe.getBoundBox().getMaxY()) {
|
519 |
ymax = fframe.getBoundBox().getMaxY(); |
520 |
} |
521 |
|
522 |
num++; |
523 |
} |
524 |
} |
525 |
|
526 |
double dif = ymax - ymin;
|
527 |
double dist = dif / num;
|
528 |
|
529 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
530 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
531 |
|
532 |
if (fframe.getSelected() != 0) { |
533 |
fframe.getBoundBox().y = ymax - (dist * i) - |
534 |
fframe.getBoundBox().height; |
535 |
} |
536 |
} |
537 |
} |
538 |
|
539 |
/**
|
540 |
* Distribuye los fframes seleccionados en el Layout de forma equidistante
|
541 |
* y vertical, desde bajo hacia arriba.
|
542 |
*/
|
543 |
private void distDownL() { |
544 |
double ymin = 0; |
545 |
double ymax = 0; |
546 |
ymax = m_layout.getAtributes().m_sizePaper.getAlto(); |
547 |
|
548 |
int num = 0; |
549 |
|
550 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
551 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
552 |
|
553 |
if (fframe.getSelected() != 0) { |
554 |
num++; |
555 |
} |
556 |
} |
557 |
|
558 |
double dif = ymax - ymin;
|
559 |
double dist = dif / num;
|
560 |
|
561 |
for (int i = m_layout.getFFrames().size() - 1; i >= 0; i--) { |
562 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
563 |
|
564 |
if (fframe.getSelected() != 0) { |
565 |
fframe.getBoundBox().y = ymax - (dist * i) - |
566 |
fframe.getBoundBox().height; |
567 |
} |
568 |
} |
569 |
} |
570 |
|
571 |
/**
|
572 |
* Distribuye los fframes seleccionados de forma equidistante y vertical.
|
573 |
*/
|
574 |
private void distCenterH() { |
575 |
double xmin = Double.MAX_VALUE; |
576 |
double xmax = Double.MIN_VALUE; |
577 |
int num = 0; |
578 |
|
579 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
580 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
581 |
|
582 |
if (fframe.getSelected() != 0) { |
583 |
if (xmin > fframe.getBoundBox().getMinX()) {
|
584 |
xmin = fframe.getBoundBox().getMinX(); |
585 |
} |
586 |
|
587 |
if (xmax < fframe.getBoundBox().getMaxX()) {
|
588 |
xmax = fframe.getBoundBox().getMaxX(); |
589 |
} |
590 |
|
591 |
num++; |
592 |
} |
593 |
} |
594 |
|
595 |
double dif = xmax - xmin;
|
596 |
double dist = dif / num;
|
597 |
|
598 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
599 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
600 |
|
601 |
if (fframe.getSelected() != 0) { |
602 |
fframe.getBoundBox().x = (xmin + |
603 |
(((dist) * (i + 1)) - (dist / 2))) - |
604 |
(fframe.getBoundBox().width / 2);
|
605 |
} |
606 |
} |
607 |
} |
608 |
|
609 |
/**
|
610 |
* Distribuye los fframes seleccionados en el Layout de forma equidistante
|
611 |
* y vertical.
|
612 |
*/
|
613 |
private void distCenterHL() { |
614 |
double xmin = 0; |
615 |
double xmax = 0; |
616 |
xmax = m_layout.getAtributes().m_sizePaper.getAncho(); |
617 |
|
618 |
int num = 0; |
619 |
|
620 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
621 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
622 |
|
623 |
if (fframe.getSelected() != 0) { |
624 |
num++; |
625 |
} |
626 |
} |
627 |
|
628 |
double dif = xmax - xmin;
|
629 |
double dist = dif / num;
|
630 |
|
631 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
632 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
633 |
|
634 |
if (fframe.getSelected() != 0) { |
635 |
fframe.getBoundBox().x = (xmin + |
636 |
(((dist) * (i + 1)) - (dist / 2))) - |
637 |
(fframe.getBoundBox().width / 2);
|
638 |
} |
639 |
} |
640 |
} |
641 |
|
642 |
/**
|
643 |
* Distribuye los fframes seleccionados de forma equidistante y horizontal.
|
644 |
*/
|
645 |
private void distCenterV() { |
646 |
double ymin = Double.MAX_VALUE; |
647 |
double ymax = Double.MIN_VALUE; |
648 |
int num = 0; |
649 |
|
650 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
651 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
652 |
|
653 |
if (fframe.getSelected() != 0) { |
654 |
if (ymin > fframe.getBoundBox().getMinY()) {
|
655 |
ymin = fframe.getBoundBox().getMinY(); |
656 |
} |
657 |
|
658 |
if (ymax < fframe.getBoundBox().getMaxY()) {
|
659 |
ymax = fframe.getBoundBox().getMaxY(); |
660 |
} |
661 |
|
662 |
num++; |
663 |
} |
664 |
} |
665 |
|
666 |
double dif = ymax - ymin;
|
667 |
double dist = dif / num;
|
668 |
|
669 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
670 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
671 |
|
672 |
if (fframe.getSelected() != 0) { |
673 |
fframe.getBoundBox().y = (ymin + |
674 |
(((dist) * (i + 1)) - (dist / 2))) - |
675 |
(fframe.getBoundBox().height / 2);
|
676 |
} |
677 |
} |
678 |
} |
679 |
|
680 |
/**
|
681 |
* Distribuye los fframes seleccionados en el Layout de forma equidistante
|
682 |
* y horizontal.
|
683 |
*/
|
684 |
private void distCenterVL() { |
685 |
double ymin = 0; |
686 |
double ymax = 0; |
687 |
ymax = m_layout.getAtributes().m_sizePaper.getAlto(); |
688 |
|
689 |
int num = 0; |
690 |
|
691 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
692 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
693 |
|
694 |
if (fframe.getSelected() != 0) { |
695 |
num++; |
696 |
} |
697 |
} |
698 |
|
699 |
double dif = ymax - ymin;
|
700 |
double dist = dif / num;
|
701 |
|
702 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
703 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
704 |
|
705 |
if (fframe.getSelected() != 0) { |
706 |
fframe.getBoundBox().y = (ymin + |
707 |
(((dist) * (i + 1)) - (dist / 2))) - |
708 |
(fframe.getBoundBox().height / 2);
|
709 |
} |
710 |
} |
711 |
} |
712 |
|
713 |
/**
|
714 |
* Cambia la anchura de los fframes seleccionados por la anchura del m?s
|
715 |
* ancho.
|
716 |
*/
|
717 |
private void sizeWidth() { |
718 |
double wmax = Double.MIN_VALUE; |
719 |
|
720 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
721 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
722 |
|
723 |
if (fframe.getSelected() != 0) { |
724 |
if (wmax < fframe.getBoundBox().getWidth()) {
|
725 |
wmax = fframe.getBoundBox().getWidth(); |
726 |
} |
727 |
} |
728 |
} |
729 |
|
730 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
731 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
732 |
|
733 |
if (fframe.getSelected() != 0) { |
734 |
fframe.getBoundBox().width = wmax; |
735 |
} |
736 |
} |
737 |
} |
738 |
|
739 |
/**
|
740 |
* Cambia la altura de los fframes seleccionados por la altura del mas
|
741 |
* alto.
|
742 |
*/
|
743 |
private void sizeHeight() { |
744 |
double hmax = Double.MIN_VALUE; |
745 |
|
746 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
747 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
748 |
|
749 |
if (fframe.getSelected() != 0) { |
750 |
if (hmax < fframe.getBoundBox().getHeight()) {
|
751 |
hmax = fframe.getBoundBox().getHeight(); |
752 |
} |
753 |
} |
754 |
} |
755 |
|
756 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
757 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
758 |
|
759 |
if (fframe.getSelected() != 0) { |
760 |
fframe.getBoundBox().height = hmax; |
761 |
} |
762 |
} |
763 |
} |
764 |
|
765 |
/**
|
766 |
* Distribuye horizontalmente los fframes dejando como espacio entre ellos
|
767 |
* la media de todos los espacios.
|
768 |
*/
|
769 |
private void spaceRight() { |
770 |
double total = 0; |
771 |
double num = 0; |
772 |
double xmin = Double.MAX_VALUE; |
773 |
double xmax = Double.MIN_VALUE; |
774 |
|
775 |
TreeMap treemap = new TreeMap(); |
776 |
|
777 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
778 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
779 |
|
780 |
if (fframe.getSelected() != 0) { |
781 |
treemap.put((Object) new Double(fframe.getBoundBox().getMinX()), |
782 |
(Object) fframe);
|
783 |
num++; |
784 |
} |
785 |
} |
786 |
|
787 |
Iterator j = treemap.keySet().iterator();
|
788 |
|
789 |
if (j.hasNext()) {
|
790 |
IFFrame fframeA = (IFFrame) treemap.get(j.next()); |
791 |
IFFrame fframeS = null;
|
792 |
xmin = fframeA.getBoundBox().x; |
793 |
|
794 |
while (j.hasNext()) {
|
795 |
fframeS = (IFFrame) treemap.get(j.next()); |
796 |
total += (fframeS.getBoundBox().getMinX() - |
797 |
fframeA.getBoundBox().getMaxX()); |
798 |
fframeA = fframeS; |
799 |
} |
800 |
|
801 |
if (fframeS != null) { |
802 |
xmax = fframeS.getBoundBox().getMaxX(); |
803 |
} |
804 |
} |
805 |
|
806 |
if (inLayout) {
|
807 |
total += (xmin + |
808 |
(m_layout.getAtributes().m_sizePaper.getAncho() - xmax)); |
809 |
num += 2;
|
810 |
} |
811 |
|
812 |
double dist = total / (num - 1); |
813 |
Iterator k = treemap.keySet().iterator();
|
814 |
|
815 |
if (k.hasNext()) {
|
816 |
IFFrame fframeA = (IFFrame) treemap.get(k.next()); |
817 |
|
818 |
if (inLayout) {
|
819 |
fframeA.getBoundBox().x = dist; |
820 |
} |
821 |
|
822 |
while (k.hasNext()) {
|
823 |
IFFrame fframeS = (IFFrame) treemap.get(k.next()); |
824 |
fframeS.getBoundBox().x = fframeA.getBoundBox().getMaxX() + |
825 |
dist; |
826 |
fframeA = fframeS; |
827 |
} |
828 |
} |
829 |
} |
830 |
|
831 |
/**
|
832 |
* Distribuye verticalmente los fframes dejando como espacio entre ellos la
|
833 |
* media de todos los espacios.
|
834 |
*/
|
835 |
private void spaceDown() { |
836 |
double total = 0; |
837 |
double num = 0; |
838 |
double ymin = Double.MAX_VALUE; |
839 |
double ymax = Double.MIN_VALUE; |
840 |
|
841 |
TreeMap treemap = new TreeMap(); |
842 |
|
843 |
for (int i = 0; i < m_layout.getFFrames().size(); i++) { |
844 |
IFFrame fframe = (IFFrame) m_layout.getFFrames().get(i); |
845 |
|
846 |
if (fframe.getSelected() != 0) { |
847 |
treemap.put((Object) new Double(fframe.getBoundBox().getMinY()), |
848 |
(Object) fframe);
|
849 |
num++; |
850 |
} |
851 |
} |
852 |
|
853 |
Iterator j = treemap.keySet().iterator();
|
854 |
|
855 |
if (j.hasNext()) {
|
856 |
IFFrame fframeA = (IFFrame) treemap.get(j.next()); |
857 |
ymin = fframeA.getBoundBox().y; |
858 |
|
859 |
IFFrame fframeS = null;
|
860 |
|
861 |
while (j.hasNext()) {
|
862 |
fframeS = (IFFrame) treemap.get(j.next()); |
863 |
total += (fframeS.getBoundBox().getMinY() - |
864 |
fframeA.getBoundBox().getMaxY()); |
865 |
fframeA = fframeS; |
866 |
} |
867 |
|
868 |
if (fframeS != null) { |
869 |
ymax = fframeS.getBoundBox().getMaxY(); |
870 |
} |
871 |
} |
872 |
|
873 |
if (inLayout) {
|
874 |
total += (ymin + |
875 |
(m_layout.getAtributes().m_sizePaper.getAlto() - ymax)); |
876 |
num += 2;
|
877 |
} |
878 |
|
879 |
double dist = total / (num - 1); |
880 |
Iterator k = treemap.keySet().iterator();
|
881 |
|
882 |
if (k.hasNext()) {
|
883 |
IFFrame fframeA = (IFFrame) treemap.get(k.next()); |
884 |
|
885 |
if (inLayout) {
|
886 |
fframeA.getBoundBox().y = dist; |
887 |
} |
888 |
|
889 |
while (k.hasNext()) {
|
890 |
IFFrame fframeS = (IFFrame) treemap.get(k.next()); |
891 |
fframeS.getBoundBox().y = fframeA.getBoundBox().getMaxY() + |
892 |
dist; |
893 |
fframeA = fframeS; |
894 |
} |
895 |
} |
896 |
} |
897 |
|
898 |
// class Listener implements ActionListener {
|
899 |
|
900 |
/**
|
901 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
902 |
*/
|
903 |
public void actionPerformed(ActionEvent e) { |
904 |
if (!inLayout) {
|
905 |
if (e.getActionCommand() == "LEFT") { |
906 |
alignLeft(); |
907 |
} else if (e.getActionCommand() == "CENTERV") { |
908 |
alignCenterV(); |
909 |
} else if (e.getActionCommand() == "RIGHT") { |
910 |
alignRight(); |
911 |
} else if (e.getActionCommand() == "UP") { |
912 |
alignUp(); |
913 |
} else if (e.getActionCommand() == "CENTERH") { |
914 |
alignCenterH(); |
915 |
} else if (e.getActionCommand() == "DOWN") { |
916 |
alignDown(); |
917 |
} else if (e.getActionCommand() == "DISTUP") { |
918 |
distUp(); |
919 |
} else if (e.getActionCommand() == "DISTCENTERV") { |
920 |
distCenterV(); |
921 |
} else if (e.getActionCommand() == "DISTDOWN") { |
922 |
distDown(); |
923 |
} else if (e.getActionCommand() == "DISTLEFT") { |
924 |
distLeft(); |
925 |
} else if (e.getActionCommand() == "DISTCENTERH") { |
926 |
distCenterH(); |
927 |
} else if (e.getActionCommand() == "DISTRIGHT") { |
928 |
distRight(); |
929 |
} else if (e.getActionCommand() == "SIZECENTERV") { |
930 |
sizeWidth(); |
931 |
} else if (e.getActionCommand() == "SIZECENTERH") { |
932 |
sizeHeight(); |
933 |
} else if (e.getActionCommand() == "SIZEOTHER") { |
934 |
sizeWidth(); |
935 |
sizeHeight(); |
936 |
} else if (e.getActionCommand() == "SPACERIGHT") { |
937 |
spaceRight(); |
938 |
} else if (e.getActionCommand() == "SPACEDOWN") { |
939 |
spaceDown(); |
940 |
} else if (e.getActionCommand() == "INLAYOUT") { |
941 |
inLayout = true;
|
942 |
} |
943 |
} else {
|
944 |
if (e.getActionCommand() == "LEFT") { |
945 |
alignLeftL(); |
946 |
} else if (e.getActionCommand() == "CENTERV") { |
947 |
alignCenterVL(); |
948 |
} else if (e.getActionCommand() == "RIGHT") { |
949 |
alignRightL(); |
950 |
} else if (e.getActionCommand() == "UP") { |
951 |
alignUpL(); |
952 |
} else if (e.getActionCommand() == "CENTERH") { |
953 |
alignCenterHL(); |
954 |
} else if (e.getActionCommand() == "DOWN") { |
955 |
alignDownL(); |
956 |
} else if (e.getActionCommand() == "DISTUP") { |
957 |
distUpL(); |
958 |
} else if (e.getActionCommand() == "DISTCENTERV") { |
959 |
distCenterVL(); |
960 |
} else if (e.getActionCommand() == "DISTDOWN") { |
961 |
distDownL(); |
962 |
} else if (e.getActionCommand() == "DISTLEFT") { |
963 |
distLeftL(); |
964 |
} else if (e.getActionCommand() == "DISTCENTERH") { |
965 |
distCenterHL(); |
966 |
} else if (e.getActionCommand() == "DISTRIGHT") { |
967 |
distRightL(); |
968 |
} else if (e.getActionCommand() == "SIZECENTERV") { |
969 |
sizeWidth(); |
970 |
} else if (e.getActionCommand() == "SIZECENTERH") { |
971 |
sizeHeight(); |
972 |
} else if (e.getActionCommand() == "SIZEOTHER") { |
973 |
sizeWidth(); |
974 |
sizeHeight(); |
975 |
} else if (e.getActionCommand() == "SPACERIGHT") { |
976 |
spaceRight(); |
977 |
} else if (e.getActionCommand() == "SPACEDOWN") { |
978 |
spaceDown(); |
979 |
} else if (e.getActionCommand() == "INLAYOUT") { |
980 |
inLayout = false;
|
981 |
} |
982 |
} |
983 |
|
984 |
m_layout.refresh(); |
985 |
} |
986 |
} |