root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / FLayoutGraphics.java @ 1074
History | View | Annotate | Download (7.36 KB)
1 |
/*
|
---|---|
2 |
* Created on 27-jul-2004
|
3 |
*
|
4 |
*/
|
5 |
package com.iver.cit.gvsig.gui.layout; |
6 |
|
7 |
import com.iver.andami.PluginServices; |
8 |
|
9 |
import com.iver.cit.gvsig.gui.layout.dialogs.FAlignDialog; |
10 |
import com.iver.cit.gvsig.gui.layout.dialogs.FBorderDialog; |
11 |
import com.iver.cit.gvsig.gui.layout.dialogs.FPositionDialog; |
12 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrame; |
13 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
14 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGroup; |
15 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
16 |
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture; |
17 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar; |
18 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
19 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
20 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
21 |
|
22 |
import java.awt.geom.Rectangle2D; |
23 |
|
24 |
import java.util.ArrayList; |
25 |
|
26 |
|
27 |
/**
|
28 |
* Operaciones realizadas sobre el conjunto de FFrames.
|
29 |
*
|
30 |
* @author Vicente Caballero Navarro
|
31 |
*/
|
32 |
public class FLayoutGraphics { |
33 |
private Layout layout;
|
34 |
private FAlignDialog m_alignLayout = null; |
35 |
private FBorderDialog borderdialog = null; |
36 |
private FPositionDialog positiondialog = null; |
37 |
|
38 |
/**
|
39 |
* Crea un nuevo FLayoutGraphics.
|
40 |
*
|
41 |
* @param l Referencia al Layout.
|
42 |
*/
|
43 |
public FLayoutGraphics(Layout l) {
|
44 |
layout = l; |
45 |
} |
46 |
|
47 |
/**
|
48 |
* Transforma un FFrameLegend a FFrames de tipo FFrameSymbol y FFrameText.
|
49 |
*/
|
50 |
public void simplify() { |
51 |
for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
52 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
53 |
|
54 |
if (fframe instanceof FFrameLegend) { |
55 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
56 |
((FFrameLegend) fframe).toFFrames(layout); |
57 |
} |
58 |
} |
59 |
} |
60 |
|
61 |
layout.setStatus(Layout.DESACTUALIZADO); |
62 |
layout.repaint(); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* Agrupar en un FFrameGroup todos los FFrames seleccionados.
|
67 |
*/
|
68 |
public void grouping() { |
69 |
//Rectangle2D rex = new Rectangle2D.Double();
|
70 |
// Se debe controlar de alguna forma si hay varios seleccionados.
|
71 |
IFFrame fframegroup = new FFrameGroup();
|
72 |
|
73 |
if (layout.getFFrames().size() > 1) { |
74 |
ArrayList selecList = new ArrayList(); |
75 |
|
76 |
for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
77 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
78 |
|
79 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
80 |
selecList.add(fframe); |
81 |
|
82 |
layout.getFFrames().remove(fframe); |
83 |
} |
84 |
} |
85 |
|
86 |
for (int i = selecList.size() - 1; i >= 0; i--) { |
87 |
((FFrameGroup) fframegroup).addFFrame((IFFrame) selecList.get(i)); |
88 |
} |
89 |
|
90 |
((FFrameGroup) fframegroup).setAt(layout.getAT()); |
91 |
|
92 |
Rectangle2D.Double rd = ((FFrameGroup) fframegroup).getRectangle(layout.getAT());
|
93 |
|
94 |
//Rectangle re=new Rectangle((int)rd.getMinX(),(int)rd.getMinY(),(int)rd.getWidth(),(int)rd.getHeight());
|
95 |
Rectangle2D.Double rd1 = FLayoutUtilities.toSheetRect(rd,
|
96 |
layout.getAT()); |
97 |
|
98 |
fframegroup.setBoundBox(rd1); |
99 |
fframegroup.setSelected(true);
|
100 |
layout.addFFrame(fframegroup, true);
|
101 |
layout.setStatus(Layout.DESACTUALIZADO); |
102 |
layout.repaint(); |
103 |
} |
104 |
} |
105 |
|
106 |
/**
|
107 |
* Desagrupar los FFrames que estan contenidos dentro del FFrameGroup en
|
108 |
* FFrames individuales.
|
109 |
*/
|
110 |
public void ungrouping() { |
111 |
for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
112 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
113 |
|
114 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
115 |
if (fframe instanceof FFrameGroup) { |
116 |
FFrameGroup fframegroup = (FFrameGroup) fframe; |
117 |
ArrayList selecList = new ArrayList(); |
118 |
|
119 |
for (int j = fframegroup.getFFrames().size() - 1; j >= 0; |
120 |
j--) { |
121 |
selecList.add(fframegroup.getFFrames().get(j)); |
122 |
|
123 |
fframegroup.getFFrames().remove(j); |
124 |
} |
125 |
|
126 |
for (int j = selecList.size() - 1; j >= 0; j--) { |
127 |
layout.addFFrame((IFFrame) selecList.get(j), false);
|
128 |
} |
129 |
|
130 |
if (fframegroup.getFFrames().isEmpty()) {
|
131 |
layout.getFFrames().remove(fframegroup); |
132 |
} |
133 |
} |
134 |
} |
135 |
} |
136 |
|
137 |
layout.setStatus(Layout.DESACTUALIZADO); |
138 |
layout.repaint(); |
139 |
} |
140 |
|
141 |
/**
|
142 |
* Abre el di?logo para alinear los FFrames.
|
143 |
*/
|
144 |
public void aligning() { |
145 |
m_alignLayout = new FAlignDialog(layout);
|
146 |
PluginServices.getMDIManager().addView(m_alignLayout); |
147 |
} |
148 |
|
149 |
/**
|
150 |
* Posiciona los FFrames seleccionados delante de los no seleccionados.
|
151 |
*/
|
152 |
public void before() { |
153 |
ArrayList auxList = new ArrayList(); |
154 |
int num = 0; |
155 |
|
156 |
for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
157 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
158 |
|
159 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
160 |
auxList.add(fframe); |
161 |
layout.getFFrames().remove(fframe); |
162 |
num++; |
163 |
} |
164 |
} |
165 |
|
166 |
for (int i = num - 1; i >= 0; i--) { |
167 |
layout.getFFrames().add((IFFrame) auxList.get(i)); |
168 |
} |
169 |
|
170 |
layout.setStatus(Layout.DESACTUALIZADO); |
171 |
layout.repaint(); |
172 |
} |
173 |
|
174 |
/**
|
175 |
* Posiciona los FFrames seleccionados detr?s de los FFrames no
|
176 |
* seleccionados.
|
177 |
*/
|
178 |
public void behind() { |
179 |
ArrayList auxList = new ArrayList(); |
180 |
int num = 0; |
181 |
|
182 |
for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
183 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
184 |
|
185 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
186 |
auxList.add(fframe); |
187 |
layout.getFFrames().remove(fframe); |
188 |
num++; |
189 |
} |
190 |
} |
191 |
|
192 |
for (int i = 0; i < num; i++) { |
193 |
layout.getFFrames().add(0, (IFFrame) auxList.get(i));
|
194 |
} |
195 |
|
196 |
layout.setStatus(Layout.DESACTUALIZADO); |
197 |
layout.repaint(); |
198 |
} |
199 |
|
200 |
/**
|
201 |
* Abre el di?logo adecuadao a las propiedades del FFrame seleccionado,
|
202 |
* ahora mismo solo se abre cuando hay un solo FFrame seleccionado.
|
203 |
*/
|
204 |
public void openFFrameDialog() { |
205 |
ArrayList selecList = new ArrayList(); |
206 |
|
207 |
for (int i = 0; i < layout.getFFrames().size(); i++) { |
208 |
//Abrir el di?logo de cada uno de los fframe seleccionados o
|
209 |
//uno que sea general como en arcView.
|
210 |
if (((IFFrame) layout.getFFrames().get(i)).getSelected() != FFrame.NOSELECT) {
|
211 |
selecList.add(layout.getFFrames().get(i)); |
212 |
} |
213 |
} |
214 |
|
215 |
if (selecList.size() == 1) { |
216 |
int toolaux = layout.getTool();
|
217 |
layout.setTool(getType((IFFrame) selecList.get(0)));
|
218 |
layout.openFFrameDialog(((IFFrame) selecList.get(0)));
|
219 |
layout.setTool(toolaux); |
220 |
} |
221 |
} |
222 |
|
223 |
/**
|
224 |
* Devuelve un entero que representa el tipo de FFrame que se le pasa como
|
225 |
* par?metro.
|
226 |
*
|
227 |
* @param fframe FFrame que se pasa como par?metro, para saber de que tipo
|
228 |
* es.
|
229 |
*
|
230 |
* @return entero.
|
231 |
*/
|
232 |
private int getType(IFFrame fframe) { |
233 |
if (fframe instanceof FFrameView) { |
234 |
return Layout.RECTANGLEVIEW;
|
235 |
} else if (fframe instanceof FFrameText) { |
236 |
return Layout.RECTANGLETEXT;
|
237 |
} else if (fframe instanceof FFrameScaleBar) { |
238 |
return Layout.RECTANGLESCALEBAR;
|
239 |
} else if (fframe instanceof FFramePicture) { |
240 |
return Layout.RECTANGLEPICTURE;
|
241 |
} else if (fframe instanceof FFrameLegend) { |
242 |
return Layout.RECTANGLELEGEND;
|
243 |
} else if (fframe instanceof FFrameGraphics) { |
244 |
return Layout.GRAPHICS;
|
245 |
} |
246 |
|
247 |
return Layout.SELECT;
|
248 |
} |
249 |
|
250 |
/**
|
251 |
* Selecci?n de todos los FFrames del Layout.
|
252 |
*/
|
253 |
public void selecAll() { |
254 |
for (int i = layout.getFFrames().size() - 1; i >= 0; i--) { |
255 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i); |
256 |
fframe.setSelected(true);
|
257 |
} |
258 |
|
259 |
layout.setStatus(Layout.DESACTUALIZADO); |
260 |
layout.repaint(); |
261 |
} |
262 |
|
263 |
/**
|
264 |
* Abre el di?logo para a?adir un borde a los fframes.
|
265 |
*/
|
266 |
public void border() { |
267 |
borderdialog = new FBorderDialog(layout);
|
268 |
PluginServices.getMDIManager().addView(borderdialog); |
269 |
} |
270 |
|
271 |
/**
|
272 |
* Abre el di?logo de cambio de posici?n y tama?o del FFrame.
|
273 |
*/
|
274 |
public void position() { |
275 |
positiondialog = new FPositionDialog(layout);
|
276 |
PluginServices.getMDIManager().addView(positiondialog); |
277 |
} |
278 |
} |