root / branches / gvSIG_03_SLD / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / FLayoutGraphics.java @ 2106
History | View | Annotate | Download (8.68 KB)
1 | 312 | fernando | /*
|
---|---|---|---|
2 | * Created on 27-jul-2004
|
||
3 | *
|
||
4 | */
|
||
5 | 1103 | fjp | /* 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 | 312 | fernando | package com.iver.cit.gvsig.gui.layout; |
46 | |||
47 | 596 | fernando | import com.iver.andami.PluginServices; |
48 | 1074 | vcaballero | |
49 | 312 | fernando | 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.FFrame; |
||
53 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
||
54 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameGroup; |
||
55 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
||
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 | 1074 | vcaballero | private Layout layout;
|
74 | private FAlignDialog m_alignLayout = null; |
||
75 | private FBorderDialog borderdialog = null; |
||
76 | private FPositionDialog positiondialog = null; |
||
77 | 312 | fernando | |
78 | 1074 | vcaballero | /**
|
79 | * Crea un nuevo FLayoutGraphics.
|
||
80 | *
|
||
81 | * @param l Referencia al Layout.
|
||
82 | */
|
||
83 | public FLayoutGraphics(Layout l) {
|
||
84 | layout = l; |
||
85 | } |
||
86 | 312 | fernando | |
87 | 1074 | vcaballero | /**
|
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 | 312 | fernando | |
94 | 1074 | vcaballero | if (fframe instanceof FFrameLegend) { |
95 | if (fframe.getSelected() != FFrame.NOSELECT) {
|
||
96 | ((FFrameLegend) fframe).toFFrames(layout); |
||
97 | } |
||
98 | } |
||
99 | } |
||
100 | |||
101 | 312 | fernando | layout.setStatus(Layout.DESACTUALIZADO); |
102 | layout.repaint(); |
||
103 | 1074 | vcaballero | } |
104 | 312 | fernando | |
105 | 1074 | vcaballero | /**
|
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 | 312 | fernando | |
113 | 1074 | vcaballero | if (layout.getFFrames().size() > 1) { |
114 | ArrayList selecList = new ArrayList(); |
||
115 | 312 | fernando | |
116 | 1074 | vcaballero | for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
117 | IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
||
118 | 312 | fernando | |
119 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
120 | selecList.add(fframe); |
||
121 | 312 | fernando | |
122 | 1074 | vcaballero | layout.getFFrames().remove(fframe); |
123 | } |
||
124 | } |
||
125 | 312 | fernando | |
126 | 1074 | vcaballero | for (int i = selecList.size() - 1; i >= 0; i--) { |
127 | ((FFrameGroup) fframegroup).addFFrame((IFFrame) selecList.get(i)); |
||
128 | } |
||
129 | 312 | fernando | |
130 | 1074 | vcaballero | ((FFrameGroup) fframegroup).setAt(layout.getAT()); |
131 | 312 | fernando | |
132 | 1074 | vcaballero | Rectangle2D.Double rd = ((FFrameGroup) fframegroup).getRectangle(layout.getAT());
|
133 | 312 | fernando | |
134 | 1074 | vcaballero | //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 | 312 | fernando | |
138 | 1074 | vcaballero | fframegroup.setBoundBox(rd1); |
139 | fframegroup.setSelected(true);
|
||
140 | layout.addFFrame(fframegroup, true);
|
||
141 | 312 | fernando | layout.setStatus(Layout.DESACTUALIZADO); |
142 | layout.repaint(); |
||
143 | 1074 | vcaballero | } |
144 | } |
||
145 | 312 | fernando | |
146 | 1074 | vcaballero | /**
|
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 | 312 | fernando | |
154 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
155 | if (fframe instanceof FFrameGroup) { |
||
156 | FFrameGroup fframegroup = (FFrameGroup) fframe; |
||
157 | ArrayList selecList = new ArrayList(); |
||
158 | 312 | fernando | |
159 | 1074 | vcaballero | for (int j = fframegroup.getFFrames().size() - 1; j >= 0; |
160 | j--) { |
||
161 | selecList.add(fframegroup.getFFrames().get(j)); |
||
162 | 312 | fernando | |
163 | 1074 | vcaballero | fframegroup.getFFrames().remove(j); |
164 | } |
||
165 | 312 | fernando | |
166 | 1074 | vcaballero | for (int j = selecList.size() - 1; j >= 0; j--) { |
167 | layout.addFFrame((IFFrame) selecList.get(j), false);
|
||
168 | } |
||
169 | 312 | fernando | |
170 | 1074 | vcaballero | if (fframegroup.getFFrames().isEmpty()) {
|
171 | layout.getFFrames().remove(fframegroup); |
||
172 | } |
||
173 | } |
||
174 | } |
||
175 | } |
||
176 | |||
177 | 312 | fernando | layout.setStatus(Layout.DESACTUALIZADO); |
178 | layout.repaint(); |
||
179 | 1074 | vcaballero | } |
180 | 312 | fernando | |
181 | 1074 | vcaballero | /**
|
182 | * Abre el di?logo para alinear los FFrames.
|
||
183 | */
|
||
184 | public void aligning() { |
||
185 | m_alignLayout = new FAlignDialog(layout);
|
||
186 | PluginServices.getMDIManager().addView(m_alignLayout); |
||
187 | } |
||
188 | 312 | fernando | |
189 | 1074 | vcaballero | /**
|
190 | * Posiciona los FFrames seleccionados delante de los no seleccionados.
|
||
191 | */
|
||
192 | public void before() { |
||
193 | ArrayList auxList = new ArrayList(); |
||
194 | int num = 0; |
||
195 | 312 | fernando | |
196 | 1074 | vcaballero | for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
197 | IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
||
198 | 312 | fernando | |
199 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
200 | auxList.add(fframe); |
||
201 | layout.getFFrames().remove(fframe); |
||
202 | num++; |
||
203 | } |
||
204 | } |
||
205 | 312 | fernando | |
206 | 1074 | vcaballero | for (int i = num - 1; i >= 0; i--) { |
207 | layout.getFFrames().add((IFFrame) auxList.get(i)); |
||
208 | } |
||
209 | 312 | fernando | |
210 | layout.setStatus(Layout.DESACTUALIZADO); |
||
211 | layout.repaint(); |
||
212 | 1074 | vcaballero | } |
213 | 312 | fernando | |
214 | 1074 | vcaballero | /**
|
215 | * Posiciona los FFrames seleccionados detr?s de los FFrames no
|
||
216 | * seleccionados.
|
||
217 | */
|
||
218 | public void behind() { |
||
219 | ArrayList auxList = new ArrayList(); |
||
220 | int num = 0; |
||
221 | 312 | fernando | |
222 | 1074 | vcaballero | for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
223 | IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
||
224 | 312 | fernando | |
225 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
226 | auxList.add(fframe); |
||
227 | layout.getFFrames().remove(fframe); |
||
228 | num++; |
||
229 | } |
||
230 | } |
||
231 | 312 | fernando | |
232 | 1074 | vcaballero | for (int i = 0; i < num; i++) { |
233 | layout.getFFrames().add(0, (IFFrame) auxList.get(i));
|
||
234 | } |
||
235 | 312 | fernando | |
236 | layout.setStatus(Layout.DESACTUALIZADO); |
||
237 | layout.repaint(); |
||
238 | 1074 | vcaballero | } |
239 | 312 | fernando | |
240 | 1074 | vcaballero | /**
|
241 | * Abre el di?logo adecuadao a las propiedades del FFrame seleccionado,
|
||
242 | * ahora mismo solo se abre cuando hay un solo FFrame seleccionado.
|
||
243 | */
|
||
244 | public void openFFrameDialog() { |
||
245 | ArrayList selecList = new ArrayList(); |
||
246 | 312 | fernando | |
247 | 1074 | vcaballero | for (int i = 0; i < layout.getFFrames().size(); i++) { |
248 | //Abrir el di?logo de cada uno de los fframe seleccionados o
|
||
249 | //uno que sea general como en arcView.
|
||
250 | if (((IFFrame) layout.getFFrames().get(i)).getSelected() != FFrame.NOSELECT) {
|
||
251 | selecList.add(layout.getFFrames().get(i)); |
||
252 | } |
||
253 | } |
||
254 | 312 | fernando | |
255 | 1074 | vcaballero | if (selecList.size() == 1) { |
256 | int toolaux = layout.getTool();
|
||
257 | layout.setTool(getType((IFFrame) selecList.get(0)));
|
||
258 | layout.openFFrameDialog(((IFFrame) selecList.get(0)));
|
||
259 | layout.setTool(toolaux); |
||
260 | } |
||
261 | } |
||
262 | 312 | fernando | |
263 | 1074 | vcaballero | /**
|
264 | * Devuelve un entero que representa el tipo de FFrame que se le pasa como
|
||
265 | * par?metro.
|
||
266 | *
|
||
267 | * @param fframe FFrame que se pasa como par?metro, para saber de que tipo
|
||
268 | * es.
|
||
269 | *
|
||
270 | * @return entero.
|
||
271 | */
|
||
272 | private int getType(IFFrame fframe) { |
||
273 | if (fframe instanceof FFrameView) { |
||
274 | return Layout.RECTANGLEVIEW;
|
||
275 | } else if (fframe instanceof FFrameText) { |
||
276 | return Layout.RECTANGLETEXT;
|
||
277 | } else if (fframe instanceof FFrameScaleBar) { |
||
278 | return Layout.RECTANGLESCALEBAR;
|
||
279 | } else if (fframe instanceof FFramePicture) { |
||
280 | return Layout.RECTANGLEPICTURE;
|
||
281 | } else if (fframe instanceof FFrameLegend) { |
||
282 | return Layout.RECTANGLELEGEND;
|
||
283 | } else if (fframe instanceof FFrameGraphics) { |
||
284 | return Layout.GRAPHICS;
|
||
285 | } |
||
286 | 312 | fernando | |
287 | 1074 | vcaballero | return Layout.SELECT;
|
288 | } |
||
289 | 312 | fernando | |
290 | 1074 | vcaballero | /**
|
291 | * Selecci?n de todos los FFrames del Layout.
|
||
292 | */
|
||
293 | public void selecAll() { |
||
294 | for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
||
295 | IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
||
296 | 312 | fernando | fframe.setSelected(true);
|
297 | 1074 | vcaballero | } |
298 | |||
299 | 312 | fernando | layout.setStatus(Layout.DESACTUALIZADO); |
300 | layout.repaint(); |
||
301 | 1074 | vcaballero | } |
302 | 312 | fernando | |
303 | 1074 | vcaballero | /**
|
304 | * Abre el di?logo para a?adir un borde a los fframes.
|
||
305 | */
|
||
306 | public void border() { |
||
307 | borderdialog = new FBorderDialog(layout);
|
||
308 | PluginServices.getMDIManager().addView(borderdialog); |
||
309 | } |
||
310 | |||
311 | /**
|
||
312 | * Abre el di?logo de cambio de posici?n y tama?o del FFrame.
|
||
313 | */
|
||
314 | public void position() { |
||
315 | 1210 | vcaballero | |
316 | IFFrame[] fframes=layout.getFFrameSelected();
|
||
317 | if (fframes.length!=0){ |
||
318 | for (int i=0;i<fframes.length;i++){ |
||
319 | positiondialog = new FPositionDialog(layout,fframes[i]);
|
||
320 | PluginServices.getMDIManager().addView(positiondialog); |
||
321 | } |
||
322 | } |
||
323 | 1074 | vcaballero | } |
324 | 312 | fernando | } |