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