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