svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / FLayoutGraphics.java @ 9192
History | View | Annotate | Download (9.55 KB)
1 |
/*
|
---|---|
2 |
* Created on 27-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; |
46 |
|
47 |
import java.awt.geom.Rectangle2D; |
48 |
import java.util.ArrayList; |
49 |
|
50 |
import com.iver.andami.PluginServices; |
51 |
import com.iver.cit.gvsig.gui.layout.Layout; |
52 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
53 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGroup; |
54 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
55 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameNorth; |
56 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameOverView; |
57 |
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture; |
58 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar; |
59 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameTable; |
60 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
61 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
62 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
63 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
64 |
import com.iver.cit.gvsig.project.documents.layout.gui.dialogs.FAlignDialog; |
65 |
import com.iver.cit.gvsig.project.documents.layout.gui.dialogs.FBorderDialog; |
66 |
import com.iver.cit.gvsig.project.documents.layout.gui.dialogs.FPositionDialog; |
67 |
|
68 |
|
69 |
/**
|
70 |
* Operaciones realizadas sobre el conjunto de FFrames.
|
71 |
*
|
72 |
* @author Vicente Caballero Navarro
|
73 |
*/
|
74 |
public class FLayoutGraphics { |
75 |
private Layout layout;
|
76 |
private FAlignDialog m_alignLayout = null; |
77 |
private FBorderDialog borderdialog = null; |
78 |
private FPositionDialog positiondialog = null; |
79 |
|
80 |
/**
|
81 |
* Crea un nuevo FLayoutGraphics.
|
82 |
*
|
83 |
* @param l Referencia al Layout.
|
84 |
*/
|
85 |
public FLayoutGraphics(Layout l) {
|
86 |
layout = l; |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Transforma un FFrameLegend a FFrames de tipo FFrameSymbol y FFrameText.
|
91 |
*/
|
92 |
public void simplify() { |
93 |
layout.getEFS().startComplexCommand(); |
94 |
IFFrame[] fframes=layout.getFFrames();
|
95 |
for (int i = fframes.length - 1; i >= 0; i--) { |
96 |
IFFrame fframe = fframes[i]; |
97 |
|
98 |
if (fframe instanceof FFrameLegend) { |
99 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
100 |
((FFrameLegend) fframe).toFFrames(layout); |
101 |
} |
102 |
} |
103 |
} |
104 |
layout.getEFS().endComplexCommand(PluginServices.getText(this,"simplify")); |
105 |
layout.refresh(); |
106 |
} |
107 |
|
108 |
/**
|
109 |
* Agrupar en un FFrameGroup todos los FFrames seleccionados.
|
110 |
*/
|
111 |
public void grouping() { |
112 |
// Se debe controlar de alguna forma si hay varios seleccionados.
|
113 |
IFFrame fframegroup = new FFrameGroup();
|
114 |
IFFrame[] fframes=layout.getFFrames();
|
115 |
if (fframes.length > 1) { |
116 |
ArrayList selecList = new ArrayList(); |
117 |
|
118 |
for (int i = fframes.length - 1; i >= 0; i--) { |
119 |
IFFrame fframe = fframes[i]; |
120 |
|
121 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
122 |
selecList.add(fframe); |
123 |
layout.delFFrame(fframe); |
124 |
} |
125 |
} |
126 |
|
127 |
for (int i = selecList.size() - 1; i >= 0; i--) { |
128 |
((FFrameGroup) fframegroup).addFFrame((IFFrame) selecList.get(i)); |
129 |
} |
130 |
|
131 |
((FFrameGroup) fframegroup).setAt(layout.getAT()); |
132 |
|
133 |
Rectangle2D.Double rd = ((FFrameGroup) fframegroup).getRectangle(layout.getAT());
|
134 |
|
135 |
Rectangle2D.Double rd1 = FLayoutUtilities.toSheetRect(rd,
|
136 |
layout.getAT()); |
137 |
|
138 |
fframegroup.setBoundBox(rd1); |
139 |
fframegroup.setSelected(true);
|
140 |
layout.addFFrame(fframegroup, true,true); |
141 |
layout.refresh(); |
142 |
} |
143 |
} |
144 |
|
145 |
/**
|
146 |
* Desagrupar los FFrames que estan contenidos dentro del FFrameGroup en
|
147 |
* FFrames individuales.
|
148 |
*/
|
149 |
public void ungrouping() { |
150 |
layout.getEFS().startComplexCommand(); |
151 |
IFFrame[] fframes=layout.getFFrames();
|
152 |
for (int i = fframes.length - 1; i >= 0; i--) { |
153 |
IFFrame fframe = fframes[i]; |
154 |
|
155 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
156 |
if (fframe instanceof FFrameGroup) { |
157 |
FFrameGroup fframegroup = (FFrameGroup) fframe; |
158 |
ArrayList selecList = new ArrayList(); |
159 |
|
160 |
for (int j = fframegroup.getFFrames().length - 1; j >= 0; |
161 |
j--) { |
162 |
selecList.add(fframegroup.getFFrames()[j]); |
163 |
} |
164 |
|
165 |
for (int j = selecList.size() - 1; j >= 0; j--) { |
166 |
IFFrame frame=(IFFrame) selecList.get(j); |
167 |
frame.setRotation(frame.getRotation()+fframe.getRotation()); |
168 |
layout.addFFrame(frame, false,true); |
169 |
} |
170 |
layout.delFFrame(fframegroup); |
171 |
} |
172 |
} |
173 |
} |
174 |
layout.getEFS().endComplexCommand(PluginServices.getText(this,"ungroup")); |
175 |
layout.refresh(); |
176 |
} |
177 |
|
178 |
/**
|
179 |
* Abre el di?logo para alinear los FFrames.
|
180 |
*/
|
181 |
public void aligning() { |
182 |
m_alignLayout = new FAlignDialog(layout);
|
183 |
PluginServices.getMDIManager().addWindow(m_alignLayout); |
184 |
} |
185 |
/**
|
186 |
* Posiciona los FFrames seleccionados delante de los no seleccionados.
|
187 |
*/
|
188 |
public void before() { |
189 |
layout.getEFS().startComplexCommand(); |
190 |
IFFrame[] fframes=layout.getFFrames();
|
191 |
for (int i = fframes.length - 1; i >= 0; i--) { |
192 |
IFFrame fframe = fframes[i]; |
193 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
194 |
if (fframe instanceof FFrameGroup) { |
195 |
((FFrameGroup) fframe).setAt(layout.getAT()); |
196 |
} |
197 |
|
198 |
IFFrame fframeAux=fframe.cloneFFrame(layout); |
199 |
fframeAux.setLevel(layout.getNumBefore()); |
200 |
layout.getEFS().modifyFFrame(fframe,fframeAux); |
201 |
fframeAux.getBoundingBox(layout.getAT()); |
202 |
} |
203 |
} |
204 |
layout.getEFS().endComplexCommand(PluginServices.getText(this,"change_before")); |
205 |
layout.updateFFrames(); |
206 |
layout.refresh(); |
207 |
} |
208 |
|
209 |
/**
|
210 |
* Posiciona los FFrames seleccionados detr?s de los FFrames no
|
211 |
* seleccionados.
|
212 |
*/
|
213 |
public void behind() { |
214 |
layout.getEFS().startComplexCommand(); |
215 |
IFFrame[] fframes=layout.getFFrames();
|
216 |
for (int i = fframes.length - 1; i >= 0; i--) { |
217 |
IFFrame fframe = fframes[i]; |
218 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
219 |
if (fframe instanceof FFrameGroup) { |
220 |
((FFrameGroup) fframe).setAt(layout.getAT()); |
221 |
} |
222 |
|
223 |
IFFrame fframeAux=fframe.cloneFFrame(layout); |
224 |
fframeAux.setLevel(layout.getNumBehind()); |
225 |
layout.getEFS().modifyFFrame(fframe,fframeAux); |
226 |
fframeAux.getBoundingBox(layout.getAT()); |
227 |
} |
228 |
} |
229 |
layout.getEFS().endComplexCommand(PluginServices.getText(this,"change_behind")); |
230 |
layout.updateFFrames(); |
231 |
layout.refresh(); |
232 |
} |
233 |
|
234 |
/**
|
235 |
* Abre el di?logo adecuadao a las propiedades del FFrame seleccionado,
|
236 |
* ahora mismo solo se abre cuando hay un solo FFrame seleccionado.
|
237 |
*/
|
238 |
public void openFFrameDialog() { |
239 |
IFFrame[] selecList = layout.getFFrameSelected();
|
240 |
|
241 |
if (selecList.length == 1) { |
242 |
IFFrame frame=selecList[0];
|
243 |
int toolaux = layout.getTool();
|
244 |
layout.setTool(getType(frame)); |
245 |
IFFrame fframeAux=frame.cloneFFrame(layout); |
246 |
if (layout.openFFrameDialog(fframeAux)) {
|
247 |
if (fframeAux instanceof IFFrameUseFMap) |
248 |
((IFFrameUseFMap)fframeAux).refresh(); |
249 |
layout.getEFS().modifyFFrame(frame,fframeAux); |
250 |
fframeAux.getBoundingBox(layout.getAT()); |
251 |
layout.updateFFrames(); |
252 |
layout.setIsReSel(true);
|
253 |
} |
254 |
layout.setTool(toolaux); |
255 |
} |
256 |
} |
257 |
|
258 |
/**
|
259 |
* Devuelve un entero que representa el tipo de FFrame que se le pasa como
|
260 |
* par?metro.
|
261 |
*
|
262 |
* @param fframe FFrame que se pasa como par?metro, para saber de que tipo
|
263 |
* es.
|
264 |
*
|
265 |
* @return entero.
|
266 |
*/
|
267 |
private int getType(IFFrame fframe) { |
268 |
if (fframe instanceof FFrameOverView) { |
269 |
return Layout.RECTANGLEOVERVIEW;
|
270 |
} else if (fframe instanceof FFrameView) { |
271 |
return Layout.RECTANGLEVIEW;
|
272 |
} else if (fframe instanceof FFrameText) { |
273 |
return Layout.RECTANGLETEXT;
|
274 |
} else if (fframe instanceof FFrameScaleBar) { |
275 |
return Layout.RECTANGLESCALEBAR;
|
276 |
} else if (fframe instanceof FFrameNorth) { |
277 |
return Layout.RECTANGLENORTH;
|
278 |
} else if (fframe instanceof FFrameTable) { |
279 |
return Layout.RECTANGLEBOX;
|
280 |
} else if (fframe instanceof FFramePicture) { |
281 |
return Layout.RECTANGLEPICTURE;
|
282 |
} else if (fframe instanceof FFrameLegend) { |
283 |
return Layout.RECTANGLELEGEND;
|
284 |
} else if (fframe instanceof FFrameGraphics) { |
285 |
return Layout.GRAPHICS;
|
286 |
} else if (fframe instanceof FFrameGroup) { |
287 |
return Layout.RECTANGLEGROUP;
|
288 |
} |
289 |
|
290 |
return Layout.SELECT;
|
291 |
} |
292 |
|
293 |
/**
|
294 |
* Selecci?n de todos los FFrames del Layout.
|
295 |
*/
|
296 |
public void selecAll() { |
297 |
IFFrame[] fframes=layout.getFFrames();
|
298 |
for (int i = fframes.length - 1; i >= 0; i--) { |
299 |
IFFrame fframe =fframes[i]; |
300 |
fframe.setSelected(true);
|
301 |
} |
302 |
layout.refresh(); |
303 |
} |
304 |
|
305 |
/**
|
306 |
* Abre el di?logo para a?adir un borde a los fframes.
|
307 |
*/
|
308 |
public void border() { |
309 |
borderdialog = new FBorderDialog(layout);
|
310 |
PluginServices.getMDIManager().addWindow(borderdialog); |
311 |
} |
312 |
|
313 |
/**
|
314 |
* Abre el di?logo de cambio de posici?n y tama?o del FFrame.
|
315 |
*/
|
316 |
public void position() { |
317 |
|
318 |
IFFrame[] fframes=layout.getFFrameSelected();
|
319 |
if (fframes.length!=0){ |
320 |
for (int i=0;i<fframes.length;i++){ |
321 |
positiondialog = new FPositionDialog(layout,fframes[i]);
|
322 |
PluginServices.getMDIManager().addWindow(positiondialog); |
323 |
} |
324 |
} |
325 |
} |
326 |
} |