root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / gui / dialogs / EventsFAlign.java @ 24962
History | View | Annotate | Download (39.7 KB)
1 | 7304 | caballero | /*
|
---|---|---|---|
2 | * Created on 22-jul-2004
|
||
3 | *
|
||
4 | */
|
||
5 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
6 | *
|
||
7 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
8 | *
|
||
9 | * This program is free software; you can redistribute it and/or
|
||
10 | * modify it under the terms of the GNU General Public License
|
||
11 | * as published by the Free Software Foundation; either version 2
|
||
12 | * of the License, or (at your option) any later version.
|
||
13 | *
|
||
14 | * This program is distributed in the hope that it will be useful,
|
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
17 | * GNU General Public License for more details.
|
||
18 | *
|
||
19 | * You should have received a copy of the GNU General Public License
|
||
20 | * along with this program; if not, write to the Free Software
|
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
22 | *
|
||
23 | * For more information, contact:
|
||
24 | *
|
||
25 | * Generalitat Valenciana
|
||
26 | * Conselleria d'Infraestructures i Transport
|
||
27 | * Av. Blasco Ib??ez, 50
|
||
28 | * 46010 VALENCIA
|
||
29 | * SPAIN
|
||
30 | *
|
||
31 | * +34 963862235
|
||
32 | * gvsig@gva.es
|
||
33 | * www.gvsig.gva.es
|
||
34 | *
|
||
35 | * or
|
||
36 | *
|
||
37 | * IVER T.I. S.A
|
||
38 | * Salamanca 50
|
||
39 | * 46005 Valencia
|
||
40 | * Spain
|
||
41 | *
|
||
42 | * +34 963163400
|
||
43 | * dac@iver.es
|
||
44 | */
|
||
45 | package com.iver.cit.gvsig.project.documents.layout.gui.dialogs; |
||
46 | |||
47 | import java.awt.event.ActionEvent; |
||
48 | import java.awt.event.ActionListener; |
||
49 | 10838 | caballero | import java.awt.geom.Rectangle2D; |
50 | 7304 | caballero | import java.util.Iterator; |
51 | import java.util.TreeMap; |
||
52 | |||
53 | 12826 | jaume | import com.iver.andami.PluginServices; |
54 | 21299 | vcaballero | import com.iver.cit.gvsig.project.documents.layout.commands.FrameCommandsRecord; |
55 | 12826 | jaume | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
56 | import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
||
57 | 7304 | caballero | |
58 | 12826 | jaume | |
59 | 7304 | caballero | /**
|
60 | * Clase que hace de Listener de FAlignDialog.
|
||
61 | *
|
||
62 | * @author Vicente Caballero Navarro
|
||
63 | */
|
||
64 | public class EventsFAlign implements ActionListener { |
||
65 | 10891 | caballero | private Layout m_layout;
|
66 | private boolean inLayout = false; |
||
67 | 7304 | caballero | |
68 | 10891 | caballero | /**
|
69 | * Crea un nuevo FAlign.
|
||
70 | *
|
||
71 | * @param layout Referencia al Layout.
|
||
72 | */
|
||
73 | public EventsFAlign(Layout layout) {
|
||
74 | m_layout = layout; |
||
75 | } |
||
76 | 7304 | caballero | |
77 | 10891 | caballero | /**
|
78 | * Desplaza los fframes seleccionados a la izquierda del fframe m?s
|
||
79 | * occidental.
|
||
80 | */
|
||
81 | private void alignLeft() { |
||
82 | double xmin = Double.MAX_VALUE; |
||
83 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
84 | 7304 | caballero | |
85 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
86 | IFFrame fframe = fframes[i]; |
||
87 | 7304 | caballero | |
88 | 10891 | caballero | if (xmin > fframe.getBoundBox().getMinX()) {
|
89 | xmin = fframe.getBoundBox().getMinX(); |
||
90 | } |
||
91 | } |
||
92 | 7304 | caballero | |
93 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
94 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_left")); |
95 | 7304 | caballero | |
96 | 10891 | caballero | for (int i = fframes.length - 1; i >= 0; i--) { |
97 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
98 | 7304 | caballero | |
99 | 10891 | caballero | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
100 | .clone(); |
||
101 | r.x = xmin; |
||
102 | fframe.setBoundBox(r); |
||
103 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
104 | 10891 | caballero | } |
105 | 7304 | caballero | |
106 | 24962 | vcaballero | efs.endComplex(); |
107 | 10891 | caballero | } |
108 | 7304 | caballero | |
109 | 10891 | caballero | /**
|
110 | * Desplaza los fframes seleccionados a la izquierda del Layout.
|
||
111 | */
|
||
112 | private void alignLeftL() { |
||
113 | double xmin = 0; |
||
114 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
115 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
116 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this,"align_to_layout_left")); |
117 | 7304 | caballero | |
118 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
119 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
120 | 7304 | caballero | |
121 | 10891 | caballero | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
122 | .clone(); |
||
123 | r.x = xmin; |
||
124 | fframe.setBoundBox(r); |
||
125 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
126 | 10891 | caballero | } |
127 | 7304 | caballero | |
128 | 24962 | vcaballero | efs.endComplex(); |
129 | 10891 | caballero | } |
130 | 7304 | caballero | |
131 | 10891 | caballero | /**
|
132 | * Desplaza los fframes seleccionados al centro del fframe mas ancho de
|
||
133 | * forma horizontal.
|
||
134 | */
|
||
135 | private void alignCenterV() { |
||
136 | double xcenter = 0; |
||
137 | 11215 | bsanchez | double w = Double.NEGATIVE_INFINITY; |
138 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
139 | 7304 | caballero | |
140 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
141 | IFFrame fframe = fframes[i]; |
||
142 | 7304 | caballero | |
143 | 10891 | caballero | if (w < fframe.getBoundBox().getWidth()) {
|
144 | w = fframe.getBoundBox().getWidth(); |
||
145 | xcenter = fframe.getBoundBox().getCenterX(); |
||
146 | } |
||
147 | } |
||
148 | 7304 | caballero | |
149 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
150 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_center")); |
151 | 7304 | caballero | |
152 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
153 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
154 | 7304 | caballero | |
155 | 10891 | caballero | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
156 | .clone(); |
||
157 | r.x = xcenter - (fframe.getBoundBox().width / 2);
|
||
158 | fframe.setBoundBox(r); |
||
159 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
160 | 10891 | caballero | } |
161 | 7304 | caballero | |
162 | 24962 | vcaballero | efs.endComplex(); |
163 | 10891 | caballero | } |
164 | 7304 | caballero | |
165 | 10891 | caballero | /**
|
166 | * Desplaza los fframes seleccionados al centro del Layout horizontalmente.
|
||
167 | */
|
||
168 | private void alignCenterVL() { |
||
169 | double xcenter = 0; |
||
170 | 23069 | vcaballero | xcenter = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho() / 2;
|
171 | 7304 | caballero | |
172 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
173 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
174 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this,"align_to_layout_center")); |
175 | 7304 | caballero | |
176 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
177 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
178 | 7304 | caballero | |
179 | 10891 | caballero | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
180 | .clone(); |
||
181 | r.x = xcenter - (fframe.getBoundBox().width / 2);
|
||
182 | fframe.setBoundBox(r); |
||
183 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
184 | 10891 | caballero | } |
185 | 7304 | caballero | |
186 | 24962 | vcaballero | efs.endComplex(); |
187 | 10891 | caballero | } |
188 | 7304 | caballero | |
189 | 10891 | caballero | /**
|
190 | * Desplaza los fframes seleccionados a la parte derecha del fframe m?s
|
||
191 | * oriental.
|
||
192 | */
|
||
193 | private void alignRight() { |
||
194 | 11215 | bsanchez | double xmax = Double.NEGATIVE_INFINITY; |
195 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
196 | 7304 | caballero | |
197 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
198 | IFFrame fframe = fframes[i]; |
||
199 | 7304 | caballero | |
200 | 10891 | caballero | if (xmax < fframe.getBoundBox().getMaxX()) {
|
201 | xmax = fframe.getBoundBox().getMaxX(); |
||
202 | } |
||
203 | } |
||
204 | 7304 | caballero | |
205 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
206 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_right")); |
207 | 7304 | caballero | |
208 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
209 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
210 | 7304 | caballero | |
211 | 10891 | caballero | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
212 | .clone(); |
||
213 | r.x = xmax - fframes[i].getBoundBox().width; |
||
214 | fframe.setBoundBox(r); |
||
215 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
216 | 10891 | caballero | } |
217 | 7304 | caballero | |
218 | 24962 | vcaballero | efs.endComplex(); |
219 | 10891 | caballero | } |
220 | 7304 | caballero | |
221 | 10891 | caballero | /**
|
222 | * Desplaza los fframes seleccionados a la parte derecha del Layout.
|
||
223 | */
|
||
224 | private void alignRightL() { |
||
225 | double xmax = 0; |
||
226 | 23069 | vcaballero | xmax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho(); |
227 | 7304 | caballero | |
228 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
229 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
230 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_to_layout_right")); |
231 | 7304 | caballero | |
232 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
233 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
234 | 7304 | caballero | |
235 | 10891 | caballero | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
236 | .clone(); |
||
237 | r.x = xmax - fframes[i].getBoundBox().width; |
||
238 | fframe.setBoundBox(r); |
||
239 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
240 | 10891 | caballero | } |
241 | 7304 | caballero | |
242 | 24962 | vcaballero | efs.endComplex(); |
243 | 10891 | caballero | } |
244 | 7304 | caballero | |
245 | 10891 | caballero | /**
|
246 | * Desplaza los fframes seleccionados a la parte inferior del fframe m?s
|
||
247 | * hacia abajo.
|
||
248 | */
|
||
249 | private void alignDown() { |
||
250 | 11215 | bsanchez | double ymax = Double.NEGATIVE_INFINITY; |
251 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
252 | 7304 | caballero | |
253 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
254 | IFFrame fframe = fframes[i]; |
||
255 | 7304 | caballero | |
256 | 10891 | caballero | if (ymax < fframe.getBoundBox().getMaxY()) {
|
257 | ymax = fframe.getBoundBox().getMaxY(); |
||
258 | } |
||
259 | } |
||
260 | 7304 | caballero | |
261 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
262 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_down")); |
263 | 7304 | caballero | |
264 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
265 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
266 | 7304 | caballero | |
267 | 10891 | caballero | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
268 | .clone(); |
||
269 | r.y = ymax - fframe.getBoundBox().height; |
||
270 | fframe.setBoundBox(r); |
||
271 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
272 | 10891 | caballero | } |
273 | 7304 | caballero | |
274 | 24962 | vcaballero | efs.endComplex(); |
275 | 10891 | caballero | } |
276 | 7304 | caballero | |
277 | 10891 | caballero | /**
|
278 | * Desplaza los fframes seleccionados a la parte inferior del Layout.
|
||
279 | */
|
||
280 | private void alignDownL() { |
||
281 | double ymax = 0; |
||
282 | 23069 | vcaballero | ymax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto(); |
283 | 7304 | caballero | |
284 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
285 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
286 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_to_layout_down")); |
287 | 7304 | caballero | |
288 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
289 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
290 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
291 | .clone(); |
||
292 | r.y = ymax - fframe.getBoundBox().height; |
||
293 | fframe.setBoundBox(r); |
||
294 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
295 | 10891 | caballero | } |
296 | 7304 | caballero | |
297 | 24962 | vcaballero | efs.endComplex(); |
298 | 10891 | caballero | } |
299 | 7304 | caballero | |
300 | 10891 | caballero | /**
|
301 | * Desplaza los fframes seleccionados a la parte superior del fframe que
|
||
302 | * m?s arriba este colocado.
|
||
303 | */
|
||
304 | private void alignUp() { |
||
305 | double ymin = Double.MAX_VALUE; |
||
306 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
307 | 7304 | caballero | |
308 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
309 | IFFrame fframe = fframes[i]; |
||
310 | 7304 | caballero | |
311 | 10891 | caballero | if (ymin > fframe.getBoundBox().getMinY()) {
|
312 | ymin = fframe.getBoundBox().getMinY(); |
||
313 | } |
||
314 | } |
||
315 | 7304 | caballero | |
316 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
317 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_up")); |
318 | 7304 | caballero | |
319 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
320 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
321 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
322 | .clone(); |
||
323 | r.y = ymin; |
||
324 | fframe.setBoundBox(r); |
||
325 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
326 | 10891 | caballero | } |
327 | 7304 | caballero | |
328 | 24962 | vcaballero | efs.endComplex(); |
329 | 10891 | caballero | } |
330 | 7304 | caballero | |
331 | 10891 | caballero | /**
|
332 | * Desplaza los fframes seleccionados a la parte superior del Layout.
|
||
333 | */
|
||
334 | private void alignUpL() { |
||
335 | double ymin = 0; |
||
336 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
337 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
338 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_to_layout_up")); |
339 | 7304 | caballero | |
340 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
341 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
342 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
343 | .clone(); |
||
344 | r.y = ymin; |
||
345 | fframe.setBoundBox(r); |
||
346 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
347 | 10891 | caballero | } |
348 | 7304 | caballero | |
349 | 24962 | vcaballero | efs.endComplex(); |
350 | 10891 | caballero | } |
351 | 7304 | caballero | |
352 | 10891 | caballero | /**
|
353 | * Desplaza los fframes seleccionados al centro del fframe m?s alto
|
||
354 | * verticalmente.
|
||
355 | */
|
||
356 | private void alignCenterH() { |
||
357 | double ycenter = 0; |
||
358 | 11215 | bsanchez | double h = Double.NEGATIVE_INFINITY; |
359 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
360 | 7304 | caballero | |
361 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
362 | IFFrame fframe = fframes[i]; |
||
363 | 7304 | caballero | |
364 | 10891 | caballero | if (h < fframe.getBoundBox().getHeight()) {
|
365 | h = fframe.getBoundBox().getHeight(); |
||
366 | ycenter = fframe.getBoundBox().getCenterY(); |
||
367 | } |
||
368 | } |
||
369 | 7304 | caballero | |
370 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
371 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_vertical_center")); |
372 | 7304 | caballero | |
373 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
374 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
375 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
376 | .clone(); |
||
377 | r.y = ycenter - (fframe.getBoundBox().height / 2);
|
||
378 | fframe.setBoundBox(r); |
||
379 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
380 | 10891 | caballero | } |
381 | 7304 | caballero | |
382 | 24962 | vcaballero | efs.endComplex(); |
383 | 10891 | caballero | } |
384 | 7304 | caballero | |
385 | 10891 | caballero | /**
|
386 | * Desplaza los fframes seleccionados en el Layout al centro verticalmente.
|
||
387 | */
|
||
388 | private void alignCenterHL() { |
||
389 | double ycenter = 0; |
||
390 | 23069 | vcaballero | ycenter = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto() / 2;
|
391 | 7304 | caballero | |
392 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
393 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
394 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "align_to_layout_vertical_center")); |
395 | 7304 | caballero | |
396 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
397 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
398 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
399 | .clone(); |
||
400 | r.y = ycenter - (fframe.getBoundBox().height / 2);
|
||
401 | fframe.setBoundBox(r); |
||
402 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
403 | 10891 | caballero | } |
404 | 7304 | caballero | |
405 | 24962 | vcaballero | efs.endComplex(); |
406 | 10891 | caballero | } |
407 | 7304 | caballero | |
408 | 10891 | caballero | /**
|
409 | * Distribuye los fframes seleccionados de forma equidistante y vertical,
|
||
410 | * de izquierda a derecha.
|
||
411 | */
|
||
412 | private void distLeft() { |
||
413 | double xmin = Double.MAX_VALUE; |
||
414 | 11215 | bsanchez | double xmax = Double.NEGATIVE_INFINITY; |
415 | 10891 | caballero | int num = 0; |
416 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
417 | num = fframes.length; |
||
418 | 7304 | caballero | |
419 | 10891 | caballero | for (int i = 0; i < num; i++) { |
420 | IFFrame fframe = fframes[i]; |
||
421 | 7304 | caballero | |
422 | 10891 | caballero | if (xmin > fframe.getBoundBox().getMinX()) {
|
423 | xmin = fframe.getBoundBox().getMinX(); |
||
424 | } |
||
425 | 7304 | caballero | |
426 | 10891 | caballero | if (xmax < fframe.getBoundBox().getMaxX()) {
|
427 | xmax = fframe.getBoundBox().getMaxX(); |
||
428 | } |
||
429 | } |
||
430 | 7304 | caballero | |
431 | 10891 | caballero | double dif = xmax - xmin;
|
432 | double dist = dif / num;
|
||
433 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
434 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_left")); |
435 | 7304 | caballero | |
436 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
437 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
438 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
439 | .clone(); |
||
440 | r.x = xmin + (dist * i); |
||
441 | fframe.setBoundBox(r); |
||
442 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
443 | 10891 | caballero | } |
444 | 7304 | caballero | |
445 | 24962 | vcaballero | efs.endComplex(); |
446 | 10891 | caballero | } |
447 | 7304 | caballero | |
448 | 10891 | caballero | /**
|
449 | * Distribuye los fframes seleccionados en el Layout de forma equidistante
|
||
450 | * y vertical, de izquierda a derecha.
|
||
451 | */
|
||
452 | private void distLeftL() { |
||
453 | double xmin = 0; |
||
454 | double xmax = 0; |
||
455 | 23069 | vcaballero | xmax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho(); |
456 | 7304 | caballero | |
457 | 10891 | caballero | int num = 0; |
458 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
459 | num = fframes.length; |
||
460 | 7304 | caballero | |
461 | 10891 | caballero | double dif = xmax - xmin;
|
462 | double dist = dif / num;
|
||
463 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
464 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_to_layout_left")); |
465 | 7304 | caballero | |
466 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
467 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
468 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
469 | .clone(); |
||
470 | r.x = xmin + (dist * i); |
||
471 | fframe.setBoundBox(r); |
||
472 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
473 | 10891 | caballero | } |
474 | 7304 | caballero | |
475 | 24962 | vcaballero | efs.endComplex(); |
476 | 10891 | caballero | } |
477 | 7304 | caballero | |
478 | 10891 | caballero | /**
|
479 | * Distribuye los fframes seleccionados de forma equidistante y vertical,
|
||
480 | * de derecha a izquierda.
|
||
481 | */
|
||
482 | private void distRight() { |
||
483 | double xmin = Double.MAX_VALUE; |
||
484 | 11215 | bsanchez | double xmax = Double.NEGATIVE_INFINITY; |
485 | 10891 | caballero | int num = 0; |
486 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
487 | num = fframes.length; |
||
488 | 7304 | caballero | |
489 | 10891 | caballero | for (int i = 0; i < num; i++) { |
490 | IFFrame fframe = fframes[i]; |
||
491 | 7304 | caballero | |
492 | 10891 | caballero | if (xmin > fframe.getBoundBox().getMinX()) {
|
493 | xmin = fframe.getBoundBox().getMinX(); |
||
494 | } |
||
495 | 7304 | caballero | |
496 | 10891 | caballero | if (xmax < fframe.getBoundBox().getMaxX()) {
|
497 | xmax = fframe.getBoundBox().getMaxX(); |
||
498 | } |
||
499 | } |
||
500 | 7304 | caballero | |
501 | 10891 | caballero | double dif = xmax - xmin;
|
502 | double dist = dif / num;
|
||
503 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
504 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_right")); |
505 | 7304 | caballero | |
506 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
507 | IFFrame fframe = fframes[i]; |
||
508 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
509 | .clone(); |
||
510 | r.x = xmax - (dist * i) - fframe.getBoundBox().width; |
||
511 | fframe.setBoundBox(r); |
||
512 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
513 | 10891 | caballero | } |
514 | 7304 | caballero | |
515 | 24962 | vcaballero | efs.endComplex(); |
516 | 10891 | caballero | } |
517 | 7304 | caballero | |
518 | 10891 | caballero | /**
|
519 | * Distribuye los fframes seleccionados en el Layout de forma equidistante
|
||
520 | * y vertical, de derecha a izquierda.
|
||
521 | */
|
||
522 | private void distRightL() { |
||
523 | double xmin = 0; |
||
524 | double xmax = 0; |
||
525 | 23069 | vcaballero | xmax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho(); |
526 | 7304 | caballero | |
527 | 10891 | caballero | int num = 0; |
528 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
529 | num = fframes.length; |
||
530 | 7304 | caballero | |
531 | 10891 | caballero | double dif = xmax - xmin;
|
532 | double dist = dif / num;
|
||
533 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
534 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_to_layout_right")); |
535 | 7304 | caballero | |
536 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
537 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
538 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
539 | .clone(); |
||
540 | r.x = xmax - (dist * i) - fframe.getBoundBox().width; |
||
541 | fframe.setBoundBox(r); |
||
542 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
543 | 10891 | caballero | } |
544 | 7304 | caballero | |
545 | 24962 | vcaballero | efs.endComplex(); |
546 | 10891 | caballero | } |
547 | 7304 | caballero | |
548 | 10891 | caballero | /**
|
549 | * Distribuye los fframes seleccionados de forma equidistante y vertical,
|
||
550 | * desde arriba hacia abajo.
|
||
551 | */
|
||
552 | private void distUp() { |
||
553 | double ymin = Double.MAX_VALUE; |
||
554 | 11215 | bsanchez | double ymax = Double.NEGATIVE_INFINITY; |
555 | 10891 | caballero | int num = 0; |
556 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
557 | num = fframes.length; |
||
558 | 7304 | caballero | |
559 | 10891 | caballero | for (int i = 0; i < num; i++) { |
560 | IFFrame fframe = fframes[i]; |
||
561 | 7304 | caballero | |
562 | 10891 | caballero | if (ymin > fframe.getBoundBox().getMinY()) {
|
563 | ymin = fframe.getBoundBox().getMinY(); |
||
564 | } |
||
565 | 7304 | caballero | |
566 | 10891 | caballero | if (ymax < fframe.getBoundBox().getMaxY()) {
|
567 | ymax = fframe.getBoundBox().getMaxY(); |
||
568 | } |
||
569 | } |
||
570 | 7304 | caballero | |
571 | 10891 | caballero | double dif = ymax - ymin;
|
572 | double dist = dif / num;
|
||
573 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
574 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_up")); |
575 | 7304 | caballero | |
576 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
577 | IFFrame fframe = fframes[i]; |
||
578 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
579 | .clone(); |
||
580 | r.y = ymin + (dist * i); |
||
581 | fframe.setBoundBox(r); |
||
582 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
583 | 10891 | caballero | } |
584 | 7304 | caballero | |
585 | 24962 | vcaballero | efs.endComplex(); |
586 | 10891 | caballero | } |
587 | 7304 | caballero | |
588 | 10891 | caballero | /**
|
589 | * Distribuye los fframes seleccionados en el Layout de forma equidistante
|
||
590 | * y vertical, desde arriba hacia abajo.
|
||
591 | */
|
||
592 | private void distUpL() { |
||
593 | double ymin = 0; |
||
594 | double ymax = 0; |
||
595 | 23069 | vcaballero | ymax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto(); |
596 | 7304 | caballero | |
597 | 10891 | caballero | int num = 0; |
598 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
599 | 7304 | caballero | |
600 | 10891 | caballero | num = fframes.length; |
601 | 7304 | caballero | |
602 | 10891 | caballero | double dif = ymax - ymin;
|
603 | double dist = dif / num;
|
||
604 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
605 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_to_layout_up")); |
606 | 7304 | caballero | |
607 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
608 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
609 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
610 | .clone(); |
||
611 | r.y = ymin + (dist * i); |
||
612 | fframe.setBoundBox(r); |
||
613 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
614 | 10891 | caballero | } |
615 | 7304 | caballero | |
616 | 24962 | vcaballero | efs.endComplex(); |
617 | 10891 | caballero | } |
618 | 7304 | caballero | |
619 | 10891 | caballero | /**
|
620 | * Distribuye los fframes seleccionados de forma equidistante y vertical,
|
||
621 | * desde bajo hacia arriba.
|
||
622 | */
|
||
623 | private void distDown() { |
||
624 | double ymin = Double.MAX_VALUE; |
||
625 | 11215 | bsanchez | double ymax = Double.NEGATIVE_INFINITY; |
626 | 10891 | caballero | int num = 0; |
627 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
628 | num = fframes.length; |
||
629 | 7304 | caballero | |
630 | 10891 | caballero | for (int i = 0; i < num; i++) { |
631 | IFFrame fframe = fframes[i]; |
||
632 | 7304 | caballero | |
633 | 10891 | caballero | if (ymin > fframe.getBoundBox().getMinY()) {
|
634 | ymin = fframe.getBoundBox().getMinY(); |
||
635 | } |
||
636 | 7304 | caballero | |
637 | 10891 | caballero | if (ymax < fframe.getBoundBox().getMaxY()) {
|
638 | ymax = fframe.getBoundBox().getMaxY(); |
||
639 | } |
||
640 | } |
||
641 | 7304 | caballero | |
642 | 10891 | caballero | double dif = ymax - ymin;
|
643 | double dist = dif / num;
|
||
644 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
645 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_down")); |
646 | 7304 | caballero | |
647 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
648 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
649 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
650 | .clone(); |
||
651 | r.y = ymax - (dist * i) - fframe.getBoundBox().height; |
||
652 | fframe.setBoundBox(r); |
||
653 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
654 | 10891 | caballero | } |
655 | 7304 | caballero | |
656 | 24962 | vcaballero | efs.endComplex(); |
657 | 10891 | caballero | } |
658 | 7304 | caballero | |
659 | 10891 | caballero | /**
|
660 | * Distribuye los fframes seleccionados en el Layout de forma equidistante
|
||
661 | * y vertical, desde bajo hacia arriba.
|
||
662 | */
|
||
663 | private void distDownL() { |
||
664 | double ymin = 0; |
||
665 | double ymax = 0; |
||
666 | 23069 | vcaballero | ymax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto(); |
667 | 7304 | caballero | |
668 | 10891 | caballero | int num = 0; |
669 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
670 | 7304 | caballero | |
671 | 10891 | caballero | num = fframes.length; |
672 | 7304 | caballero | |
673 | 10891 | caballero | double dif = ymax - ymin;
|
674 | double dist = dif / num;
|
||
675 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
676 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_to_layout_down")); |
677 | 7304 | caballero | |
678 | 10891 | caballero | for (int i = fframes.length - 1; i >= 0; i--) { |
679 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
680 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
681 | .clone(); |
||
682 | r.y = ymax - (dist * i) - fframe.getBoundBox().height; |
||
683 | fframe.setBoundBox(r); |
||
684 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
685 | 10891 | caballero | } |
686 | 7304 | caballero | |
687 | 24962 | vcaballero | efs.endComplex(); |
688 | 10891 | caballero | } |
689 | 7304 | caballero | |
690 | 10891 | caballero | /**
|
691 | * Distribuye los fframes seleccionados de forma equidistante y vertical.
|
||
692 | */
|
||
693 | private void distCenterH() { |
||
694 | double xmin = Double.MAX_VALUE; |
||
695 | 11215 | bsanchez | double xmax = Double.NEGATIVE_INFINITY; |
696 | 10891 | caballero | int num = 0; |
697 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
698 | num = fframes.length; |
||
699 | 7304 | caballero | |
700 | 10891 | caballero | for (int i = 0; i < num; i++) { |
701 | IFFrame fframe = fframes[i]; |
||
702 | 7304 | caballero | |
703 | 10891 | caballero | if (xmin > fframe.getBoundBox().getMinX()) {
|
704 | xmin = fframe.getBoundBox().getMinX(); |
||
705 | } |
||
706 | 7304 | caballero | |
707 | 10891 | caballero | if (xmax < fframe.getBoundBox().getMaxX()) {
|
708 | xmax = fframe.getBoundBox().getMaxX(); |
||
709 | } |
||
710 | } |
||
711 | 7304 | caballero | |
712 | 10891 | caballero | double dif = xmax - xmin;
|
713 | double dist = dif / num;
|
||
714 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
715 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_vertical")); |
716 | 7304 | caballero | |
717 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
718 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
719 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
720 | .clone(); |
||
721 | r.x = (xmin + (((dist) * (i + 1)) - (dist / 2))) - |
||
722 | (fframe.getBoundBox().width / 2);
|
||
723 | fframe.setBoundBox(r); |
||
724 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
725 | 10891 | caballero | } |
726 | 7304 | caballero | |
727 | 24962 | vcaballero | efs.endComplex(); |
728 | 10891 | caballero | } |
729 | 7304 | caballero | |
730 | 10891 | caballero | /**
|
731 | * Distribuye los fframes seleccionados en el Layout de forma equidistante
|
||
732 | * y vertical.
|
||
733 | */
|
||
734 | private void distCenterHL() { |
||
735 | double xmin = 0; |
||
736 | double xmax = 0; |
||
737 | 23069 | vcaballero | xmax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho(); |
738 | 7304 | caballero | |
739 | 10891 | caballero | int num = 0; |
740 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
741 | num = fframes.length; |
||
742 | 7304 | caballero | |
743 | 10891 | caballero | double dif = xmax - xmin;
|
744 | double dist = dif / num;
|
||
745 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
746 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_to_layout_vertical")); |
747 | 7304 | caballero | |
748 | 10891 | caballero | for (int i = 0; i < fframes.length; i++) { |
749 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
750 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
751 | .clone(); |
||
752 | r.x = (xmin + (((dist) * (i + 1)) - (dist / 2))) - |
||
753 | (fframe.getBoundBox().width / 2);
|
||
754 | fframe.setBoundBox(r); |
||
755 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
756 | 10891 | caballero | } |
757 | 7304 | caballero | |
758 | 24962 | vcaballero | efs.endComplex(); |
759 | 10891 | caballero | } |
760 | 7304 | caballero | |
761 | 10891 | caballero | /**
|
762 | * Distribuye los fframes seleccionados de forma equidistante y horizontal.
|
||
763 | */
|
||
764 | private void distCenterV() { |
||
765 | double ymin = Double.MAX_VALUE; |
||
766 | 11215 | bsanchez | double ymax = Double.NEGATIVE_INFINITY; |
767 | 10891 | caballero | int num = 0; |
768 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
769 | num = fframes.length; |
||
770 | 7304 | caballero | |
771 | 10891 | caballero | for (int i = 0; i < num; i++) { |
772 | IFFrame fframe = fframes[i]; |
||
773 | 7304 | caballero | |
774 | 10891 | caballero | if (ymin > fframe.getBoundBox().getMinY()) {
|
775 | ymin = fframe.getBoundBox().getMinY(); |
||
776 | } |
||
777 | |||
778 | if (ymax < fframe.getBoundBox().getMaxY()) {
|
||
779 | ymax = fframe.getBoundBox().getMaxY(); |
||
780 | } |
||
781 | } |
||
782 | |||
783 | double dif = ymax - ymin;
|
||
784 | double dist = dif / num;
|
||
785 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
786 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_horizontal")); |
787 | 10891 | caballero | |
788 | for (int i = 0; i < fframes.length; i++) { |
||
789 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
790 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
791 | .clone(); |
||
792 | r.y = (ymin + (((dist) * (i + 1)) - (dist / 2))) - |
||
793 | (fframe.getBoundBox().height / 2);
|
||
794 | fframe.setBoundBox(r); |
||
795 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
796 | 10891 | caballero | } |
797 | |||
798 | 24962 | vcaballero | efs.endComplex(); |
799 | 10891 | caballero | } |
800 | |||
801 | /**
|
||
802 | * Distribuye los fframes seleccionados en el Layout de forma equidistante
|
||
803 | * y horizontal.
|
||
804 | */
|
||
805 | private void distCenterVL() { |
||
806 | double ymin = 0; |
||
807 | double ymax = 0; |
||
808 | 23069 | vcaballero | ymax = m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto(); |
809 | 10891 | caballero | |
810 | int num = 0; |
||
811 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
812 | num = fframes.length; |
||
813 | |||
814 | double dif = ymax - ymin;
|
||
815 | double dist = dif / num;
|
||
816 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
817 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "distributes_to_layout_horizontal")); |
818 | 10891 | caballero | |
819 | for (int i = 0; i < fframes.length; i++) { |
||
820 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
821 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
822 | .clone(); |
||
823 | r.y = (ymin + (((dist) * (i + 1)) - (dist / 2))) - |
||
824 | (fframe.getBoundBox().height / 2);
|
||
825 | fframe.setBoundBox(r); |
||
826 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
827 | 10891 | caballero | } |
828 | |||
829 | 24962 | vcaballero | efs.endComplex(); |
830 | 10891 | caballero | } |
831 | |||
832 | /**
|
||
833 | * Cambia la anchura de los fframes seleccionados por la anchura del m?s
|
||
834 | * ancho.
|
||
835 | */
|
||
836 | private void sizeWidth() { |
||
837 | 11215 | bsanchez | double wmax = Double.NEGATIVE_INFINITY; |
838 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
839 | |||
840 | for (int i = 0; i < fframes.length; i++) { |
||
841 | IFFrame fframe = fframes[i]; |
||
842 | |||
843 | if (wmax < fframe.getBoundBox().getWidth()) {
|
||
844 | wmax = fframe.getBoundBox().getWidth(); |
||
845 | } |
||
846 | } |
||
847 | |||
848 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
849 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "change_width")); |
850 | 10891 | caballero | |
851 | for (int i = 0; i < fframes.length; i++) { |
||
852 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
853 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
854 | .clone(); |
||
855 | r.width = wmax; |
||
856 | fframe.setBoundBox(r); |
||
857 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
858 | 10891 | caballero | } |
859 | |||
860 | 24962 | vcaballero | efs.endComplex(); |
861 | 10891 | caballero | } |
862 | |||
863 | /**
|
||
864 | * Cambia la altura de los fframes seleccionados por la altura del mas
|
||
865 | * alto.
|
||
866 | */
|
||
867 | private void sizeHeight() { |
||
868 | 11215 | bsanchez | double hmax = Double.NEGATIVE_INFINITY; |
869 | 10891 | caballero | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
870 | |||
871 | for (int i = 0; i < fframes.length; i++) { |
||
872 | IFFrame fframe = fframes[i]; |
||
873 | |||
874 | if (hmax < fframe.getBoundBox().getHeight()) {
|
||
875 | hmax = fframe.getBoundBox().getHeight(); |
||
876 | } |
||
877 | } |
||
878 | |||
879 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
880 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "change_height")); |
881 | 10891 | caballero | |
882 | for (int i = 0; i < fframes.length; i++) { |
||
883 | IFFrame fframe = fframes[i].cloneFFrame(m_layout); |
||
884 | Rectangle2D.Double r = (Rectangle2D.Double) fframe.getBoundBox() |
||
885 | .clone(); |
||
886 | r.height = hmax; |
||
887 | fframe.setBoundBox(r); |
||
888 | 21299 | vcaballero | efs.update(fframes[i], fframe); |
889 | 10891 | caballero | } |
890 | |||
891 | 24962 | vcaballero | efs.endComplex(); |
892 | 10891 | caballero | } |
893 | |||
894 | /**
|
||
895 | * Distribuye horizontalmente los fframes dejando como espacio entre ellos
|
||
896 | * la media de todos los espacios.
|
||
897 | */
|
||
898 | private void spaceRight() { |
||
899 | double total = 0; |
||
900 | double num = 0; |
||
901 | double xmin = Double.MAX_VALUE; |
||
902 | 11215 | bsanchez | double xmax = Double.NEGATIVE_INFINITY; |
903 | 10891 | caballero | |
904 | TreeMap treemap = new TreeMap(); |
||
905 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
906 | num = fframes.length; |
||
907 | |||
908 | for (int i = 0; i < num; i++) { |
||
909 | IFFrame fframe = fframes[i]; |
||
910 | treemap.put(new Double(fframe.getBoundBox().getMinX()), fframe); |
||
911 | } |
||
912 | |||
913 | Iterator j = treemap.keySet().iterator();
|
||
914 | |||
915 | if (j.hasNext()) {
|
||
916 | IFFrame fframeA = (IFFrame) treemap.get(j.next()); |
||
917 | IFFrame fframeS = null;
|
||
918 | xmin = fframeA.getBoundBox().x; |
||
919 | |||
920 | while (j.hasNext()) {
|
||
921 | fframeS = (IFFrame) treemap.get(j.next()); |
||
922 | total += (fframeS.getBoundBox().getMinX() - |
||
923 | fframeA.getBoundBox().getMaxX()); |
||
924 | fframeA = fframeS; |
||
925 | } |
||
926 | |||
927 | if (fframeS != null) { |
||
928 | xmax = fframeS.getBoundBox().getMaxX(); |
||
929 | } |
||
930 | } |
||
931 | |||
932 | if (inLayout) {
|
||
933 | total += (xmin + |
||
934 | 23069 | vcaballero | (m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho() - xmax)); |
935 | 10891 | caballero | num += 2;
|
936 | } |
||
937 | |||
938 | double dist = total / (num - 1); |
||
939 | Iterator k = treemap.keySet().iterator();
|
||
940 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
941 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "horizontal_space")); |
942 | 10891 | caballero | |
943 | if (k.hasNext()) {
|
||
944 | IFFrame fframe = (IFFrame) treemap.get(k.next()); |
||
945 | IFFrame fframeA = fframe.cloneFFrame(m_layout); |
||
946 | |||
947 | if (inLayout) {
|
||
948 | Rectangle2D.Double r = (Rectangle2D.Double) fframeA.getBoundBox() |
||
949 | .clone(); |
||
950 | r.x = dist; |
||
951 | fframeA.setBoundBox(r); |
||
952 | 21299 | vcaballero | efs.update(fframe, fframeA); |
953 | 10891 | caballero | } |
954 | |||
955 | while (k.hasNext()) {
|
||
956 | IFFrame fframeAux = (IFFrame) treemap.get(k.next()); |
||
957 | IFFrame fframeS = fframeAux.cloneFFrame(m_layout); |
||
958 | Rectangle2D.Double r = (Rectangle2D.Double) fframeS.getBoundBox() |
||
959 | .clone(); |
||
960 | r.x = fframeA.getBoundBox().getMaxX() + dist; |
||
961 | fframeS.setBoundBox(r); |
||
962 | 21299 | vcaballero | efs.update(fframeAux, fframeS); |
963 | 10891 | caballero | fframeA = fframeS; |
964 | } |
||
965 | } |
||
966 | |||
967 | 24962 | vcaballero | efs.endComplex(); |
968 | 10891 | caballero | } |
969 | |||
970 | /**
|
||
971 | * Distribuye verticalmente los fframes dejando como espacio entre ellos la
|
||
972 | * media de todos los espacios.
|
||
973 | */
|
||
974 | private void spaceDown() { |
||
975 | double total = 0; |
||
976 | double num = 0; |
||
977 | double ymin = Double.MAX_VALUE; |
||
978 | 11215 | bsanchez | double ymax = Double.NEGATIVE_INFINITY; |
979 | 10891 | caballero | |
980 | TreeMap treemap = new TreeMap(); |
||
981 | IFFrame[] fframes = m_layout.getLayoutContext().getFFrameSelected();
|
||
982 | num = fframes.length; |
||
983 | |||
984 | for (int i = 0; i < num; i++) { |
||
985 | IFFrame fframe = fframes[i]; |
||
986 | treemap.put(new Double(fframe.getBoundBox().getMinY()), fframe); |
||
987 | } |
||
988 | |||
989 | Iterator j = treemap.keySet().iterator();
|
||
990 | |||
991 | if (j.hasNext()) {
|
||
992 | IFFrame fframeA = (IFFrame) treemap.get(j.next()); |
||
993 | ymin = fframeA.getBoundBox().y; |
||
994 | |||
995 | IFFrame fframeS = null;
|
||
996 | |||
997 | while (j.hasNext()) {
|
||
998 | fframeS = (IFFrame) treemap.get(j.next()); |
||
999 | total += (fframeS.getBoundBox().getMinY() - |
||
1000 | fframeA.getBoundBox().getMaxY()); |
||
1001 | fframeA = fframeS; |
||
1002 | } |
||
1003 | |||
1004 | if (fframeS != null) { |
||
1005 | ymax = fframeS.getBoundBox().getMaxY(); |
||
1006 | } |
||
1007 | } |
||
1008 | |||
1009 | if (inLayout) {
|
||
1010 | total += (ymin + |
||
1011 | 23069 | vcaballero | (m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto() - ymax)); |
1012 | 10891 | caballero | num += 2;
|
1013 | } |
||
1014 | |||
1015 | double dist = total / (num - 1); |
||
1016 | Iterator k = treemap.keySet().iterator();
|
||
1017 | 21358 | vcaballero | FrameCommandsRecord efs = m_layout.getLayoutContext().getFrameCommandsRecord(); |
1018 | 24962 | vcaballero | efs.startComplex(PluginServices.getText(this, "vertical_space")); |
1019 | 10891 | caballero | |
1020 | if (k.hasNext()) {
|
||
1021 | IFFrame fframe = (IFFrame) treemap.get(k.next()); |
||
1022 | IFFrame fframeA = fframe.cloneFFrame(m_layout); |
||
1023 | |||
1024 | if (inLayout) {
|
||
1025 | Rectangle2D.Double r = (Rectangle2D.Double) fframeA.getBoundBox() |
||
1026 | .clone(); |
||
1027 | r.y = dist; |
||
1028 | fframeA.setBoundBox(r); |
||
1029 | 21299 | vcaballero | efs.update(fframe, fframeA); |
1030 | 10891 | caballero | } |
1031 | |||
1032 | while (k.hasNext()) {
|
||
1033 | IFFrame fframeAux = (IFFrame) treemap.get(k.next()); |
||
1034 | IFFrame fframeS = fframeAux.cloneFFrame(m_layout); |
||
1035 | Rectangle2D.Double r = (Rectangle2D.Double) fframeS.getBoundBox() |
||
1036 | .clone(); |
||
1037 | r.y = fframeA.getBoundBox().getMaxY() + dist; |
||
1038 | fframeS.setBoundBox(r); |
||
1039 | 21299 | vcaballero | efs.update(fframeAux, fframeS); |
1040 | 10891 | caballero | fframeA = fframeS; |
1041 | } |
||
1042 | } |
||
1043 | |||
1044 | 24962 | vcaballero | efs.endComplex(); |
1045 | 10891 | caballero | } |
1046 | |||
1047 | /**
|
||
1048 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||
1049 | */
|
||
1050 | public void actionPerformed(ActionEvent e) { |
||
1051 | m_layout.getLayoutContext().updateFFrames(); |
||
1052 | |||
1053 | if (!inLayout) {
|
||
1054 | if (e.getActionCommand() == "LEFT") { |
||
1055 | alignLeft(); |
||
1056 | } else if (e.getActionCommand() == "CENTERV") { |
||
1057 | alignCenterV(); |
||
1058 | } else if (e.getActionCommand() == "RIGHT") { |
||
1059 | alignRight(); |
||
1060 | } else if (e.getActionCommand() == "UP") { |
||
1061 | alignUp(); |
||
1062 | } else if (e.getActionCommand() == "CENTERH") { |
||
1063 | alignCenterH(); |
||
1064 | } else if (e.getActionCommand() == "DOWN") { |
||
1065 | alignDown(); |
||
1066 | } else if (e.getActionCommand() == "DISTUP") { |
||
1067 | distUp(); |
||
1068 | } else if (e.getActionCommand() == "DISTCENTERV") { |
||
1069 | distCenterV(); |
||
1070 | } else if (e.getActionCommand() == "DISTDOWN") { |
||
1071 | distDown(); |
||
1072 | } else if (e.getActionCommand() == "DISTLEFT") { |
||
1073 | distLeft(); |
||
1074 | } else if (e.getActionCommand() == "DISTCENTERH") { |
||
1075 | distCenterH(); |
||
1076 | } else if (e.getActionCommand() == "DISTRIGHT") { |
||
1077 | distRight(); |
||
1078 | } else if (e.getActionCommand() == "SIZECENTERV") { |
||
1079 | sizeWidth(); |
||
1080 | } else if (e.getActionCommand() == "SIZECENTERH") { |
||
1081 | sizeHeight(); |
||
1082 | } else if (e.getActionCommand() == "SIZEOTHER") { |
||
1083 | sizeWidth(); |
||
1084 | m_layout.getLayoutContext().updateFFrames(); |
||
1085 | sizeHeight(); |
||
1086 | } else if (e.getActionCommand() == "SPACERIGHT") { |
||
1087 | spaceRight(); |
||
1088 | } else if (e.getActionCommand() == "SPACEDOWN") { |
||
1089 | spaceDown(); |
||
1090 | } else if (e.getActionCommand() == "INLAYOUT") { |
||
1091 | inLayout = true;
|
||
1092 | } |
||
1093 | } else {
|
||
1094 | if (e.getActionCommand() == "LEFT") { |
||
1095 | alignLeftL(); |
||
1096 | } else if (e.getActionCommand() == "CENTERV") { |
||
1097 | alignCenterVL(); |
||
1098 | } else if (e.getActionCommand() == "RIGHT") { |
||
1099 | alignRightL(); |
||
1100 | } else if (e.getActionCommand() == "UP") { |
||
1101 | alignUpL(); |
||
1102 | } else if (e.getActionCommand() == "CENTERH") { |
||
1103 | alignCenterHL(); |
||
1104 | } else if (e.getActionCommand() == "DOWN") { |
||
1105 | alignDownL(); |
||
1106 | } else if (e.getActionCommand() == "DISTUP") { |
||
1107 | distUpL(); |
||
1108 | } else if (e.getActionCommand() == "DISTCENTERV") { |
||
1109 | distCenterVL(); |
||
1110 | } else if (e.getActionCommand() == "DISTDOWN") { |
||
1111 | distDownL(); |
||
1112 | } else if (e.getActionCommand() == "DISTLEFT") { |
||
1113 | distLeftL(); |
||
1114 | } else if (e.getActionCommand() == "DISTCENTERH") { |
||
1115 | distCenterHL(); |
||
1116 | } else if (e.getActionCommand() == "DISTRIGHT") { |
||
1117 | distRightL(); |
||
1118 | } else if (e.getActionCommand() == "SIZECENTERV") { |
||
1119 | sizeWidth(); |
||
1120 | } else if (e.getActionCommand() == "SIZECENTERH") { |
||
1121 | sizeHeight(); |
||
1122 | } else if (e.getActionCommand() == "SIZEOTHER") { |
||
1123 | sizeWidth(); |
||
1124 | m_layout.getLayoutContext().updateFFrames(); |
||
1125 | sizeHeight(); |
||
1126 | } else if (e.getActionCommand() == "SPACERIGHT") { |
||
1127 | spaceRight(); |
||
1128 | } else if (e.getActionCommand() == "SPACEDOWN") { |
||
1129 | spaceDown(); |
||
1130 | } else if (e.getActionCommand() == "INLAYOUT") { |
||
1131 | inLayout = false;
|
||
1132 | } |
||
1133 | } |
||
1134 | |||
1135 | m_layout.getLayoutContext().updateFFrames(); |
||
1136 | m_layout.getLayoutContext().callLayoutDrawListeners(); |
||
1137 | } |
||
1138 | 7304 | caballero | } |