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