root / branches / gvSIG_03_SLD / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameView.java @ 2106
History | View | Annotate | Download (18.1 KB)
1 | 312 | fernando | /*
|
---|---|---|---|
2 | * Created on 20-feb-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.fframes; |
46 | |||
47 | 596 | fernando | import com.iver.andami.PluginServices; |
48 | 800 | vcaballero | import com.iver.andami.messages.NotificationManager; |
49 | 1056 | vcaballero | |
50 | 312 | fernando | import com.iver.cit.gvsig.ProjectExtension; |
51 | 962 | vcaballero | import com.iver.cit.gvsig.fmap.ColorEvent; |
52 | 800 | vcaballero | import com.iver.cit.gvsig.fmap.ExtentEvent; |
53 | 312 | fernando | import com.iver.cit.gvsig.fmap.FMap; |
54 | 362 | vcaballero | import com.iver.cit.gvsig.fmap.ViewPort; |
55 | 1056 | vcaballero | import com.iver.cit.gvsig.fmap.ViewPortListener; |
56 | 800 | vcaballero | import com.iver.cit.gvsig.fmap.layers.XMLException; |
57 | 312 | fernando | import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
58 | import com.iver.cit.gvsig.gui.layout.Layout; |
||
59 | 1222 | fernando | import com.iver.cit.gvsig.project.Project; |
60 | import com.iver.cit.gvsig.project.ProjectView; |
||
61 | 1056 | vcaballero | |
62 | 312 | fernando | import com.iver.utiles.XMLEntity; |
63 | |||
64 | 1056 | vcaballero | import org.apache.log4j.Logger; |
65 | 312 | fernando | |
66 | 1282 | fjp | import java.awt.Color; |
67 | 1056 | vcaballero | import java.awt.Dimension; |
68 | import java.awt.Graphics2D; |
||
69 | import java.awt.Rectangle; |
||
70 | import java.awt.geom.AffineTransform; |
||
71 | import java.awt.geom.Point2D; |
||
72 | import java.awt.geom.Rectangle2D; |
||
73 | import java.awt.image.BufferedImage; |
||
74 | |||
75 | import java.util.ArrayList; |
||
76 | |||
77 | |||
78 | 312 | fernando | /**
|
79 | * FFrame para introducir una vista en el Layout.
|
||
80 | *
|
||
81 | * @author Vicente Caballero Navarro
|
||
82 | */
|
||
83 | 962 | vcaballero | public class FFrameView extends FFrame implements ViewPortListener { |
84 | 649 | vcaballero | private static Logger logger = Logger.getLogger(FFrameView.class.getName()); |
85 | 726 | vcaballero | public static final int AUTOMATICO = 0; |
86 | public static final int CONSTANTE = 1; |
||
87 | public static final int MANUAL = 2; |
||
88 | public static final int PRESENTACION = 0; |
||
89 | public static final int BORRADOR = 1; |
||
90 | 649 | vcaballero | private int m_Mode; |
91 | private int m_typeScale = AUTOMATICO; |
||
92 | private int m_extension = 0; |
||
93 | private int m_quality = PRESENTACION; |
||
94 | private int m_viewing = 0; |
||
95 | private boolean m_bLinked = true; |
||
96 | private ProjectView view = null; |
||
97 | private FMap m_fmap = null; |
||
98 | private double m_Scale = 0; |
||
99 | private int m_mapUnits = 1; //Metros. |
||
100 | private int num = 0; |
||
101 | private BufferedImage m_image = null; |
||
102 | private AffineTransform at = null; |
||
103 | 1056 | vcaballero | private Project project = null; |
104 | |||
105 | 649 | vcaballero | /**
|
106 | * Creates a new FFrameView object.
|
||
107 | */
|
||
108 | public FFrameView() {
|
||
109 | } |
||
110 | 312 | fernando | |
111 | 649 | vcaballero | /**
|
112 | 1073 | vcaballero | * Devuelve una descripci?n del FFrameView.
|
113 | 649 | vcaballero | *
|
114 | 1073 | vcaballero | * @return Descripci?n.
|
115 | 649 | vcaballero | */
|
116 | public String toString() { |
||
117 | if (getView() == null) { |
||
118 | return "FFrameView " + num + ": " + "Vacio"; |
||
119 | } |
||
120 | 312 | fernando | |
121 | 649 | vcaballero | return "FFrameView " + num + ": " + getView().getName(); |
122 | } |
||
123 | 312 | fernando | |
124 | 649 | vcaballero | /**
|
125 | * Rellena la escala de la vista que contiene el fframe.
|
||
126 | *
|
||
127 | * @param d escala de la vista.
|
||
128 | */
|
||
129 | public void setScale(double d) { |
||
130 | m_Scale = d; |
||
131 | } |
||
132 | 362 | vcaballero | |
133 | 649 | vcaballero | /**
|
134 | 1073 | vcaballero | * Inserta el nuevo extent a la FFrameView.
|
135 | 649 | vcaballero | *
|
136 | 1073 | vcaballero | * @param r Rect?ngulo a ocupar por el FFrameView.
|
137 | 649 | vcaballero | */
|
138 | 726 | vcaballero | public void setNewExtent(Rectangle2D r) { |
139 | 649 | vcaballero | getFMap().getViewPort().setExtent(r); |
140 | 1513 | vcaballero | m_Scale = FLayoutUtilities.getScaleView(getFMap().getViewPort(), getBoundBox().width,getBoundingBox(null).width/getBoundBox().width);
|
141 | 649 | vcaballero | } |
142 | 362 | vcaballero | |
143 | 649 | vcaballero | /**
|
144 | * Devuelve el FMap de la vista o una clonaci?n de este si se utiliza una
|
||
145 | * escala fija.
|
||
146 | *
|
||
147 | * @return FMap.
|
||
148 | */
|
||
149 | public FMap getFMap() {
|
||
150 | return m_fmap;
|
||
151 | } |
||
152 | 312 | fernando | |
153 | 649 | vcaballero | /**
|
154 | * Rellena la calidad que se quiere aplicar.
|
||
155 | *
|
||
156 | * @param q entero que representa la calidad a aplicar.
|
||
157 | */
|
||
158 | public void setQuality(int q) { |
||
159 | m_quality = q; |
||
160 | } |
||
161 | 312 | fernando | |
162 | 649 | vcaballero | /**
|
163 | * Devuelve un entero que representa la calidad que est? seleccionada.
|
||
164 | *
|
||
165 | * @return tipo de calidad selccionada.
|
||
166 | */
|
||
167 | public int getQuality() { |
||
168 | return m_quality;
|
||
169 | } |
||
170 | 312 | fernando | |
171 | 649 | vcaballero | /**
|
172 | * Devuelve un entero que representa la forma en que se actualiza la vista.
|
||
173 | *
|
||
174 | * @return forma que se actualiza la vista.
|
||
175 | */
|
||
176 | public int getViewing() { |
||
177 | return m_viewing;
|
||
178 | } |
||
179 | 312 | fernando | |
180 | 649 | vcaballero | /**
|
181 | * Rellena la forma de actualizar la vista.
|
||
182 | *
|
||
183 | * @param v entero que representa la forma de actualizar la vista.
|
||
184 | */
|
||
185 | public void setViewing(int v) { |
||
186 | m_viewing = v; |
||
187 | } |
||
188 | 312 | fernando | |
189 | 1056 | vcaballero | /**
|
190 | 1073 | vcaballero | * Inserta el ProjectView de donde obtener las propiedades de la vista a
|
191 | * mostrar.
|
||
192 | 1056 | vcaballero | *
|
193 | 1073 | vcaballero | * @param v Modelo de la vista.
|
194 | 1056 | vcaballero | */
|
195 | 649 | vcaballero | public void setView(ProjectView v) { |
196 | 1056 | vcaballero | view = v; |
197 | |||
198 | ViewPort vp = new ViewPort(v.getMapContext().getViewPort()
|
||
199 | .getProjection()); |
||
200 | 1513 | vcaballero | vp.setImageSize(new Dimension((int)getBoundingBox(null).width,(int)getBoundingBox(null).height)); |
201 | 1056 | vcaballero | if (m_bLinked) {
|
202 | if (getTypeScale() == AUTOMATICO) {
|
||
203 | m_fmap = v.getMapContext().createNewFMap(v.getMapContext() |
||
204 | .getViewPort() |
||
205 | .cloneViewPort()); |
||
206 | 1513 | vcaballero | m_fmap.getViewPort().setImageSize(new Dimension((int)getBoundingBox(null).width,(int)getBoundingBox(null).height)); |
207 | 1333 | vcaballero | v.getMapContext().getViewPort().removeViewPortListener(this);
|
208 | 1201 | fernando | v.getMapContext().getViewPort().addViewPortListener(this);
|
209 | 1056 | vcaballero | } else if (getTypeScale() == CONSTANTE) { |
210 | vp.setExtent((Rectangle2D) v.getMapContext().getViewPort()
|
||
211 | .getExtent().clone()); |
||
212 | m_fmap = v.getMapContext().createNewFMap(vp); |
||
213 | 1201 | fernando | v.getMapContext().getViewPort().removeViewPortListener(this);
|
214 | 1056 | vcaballero | } else if (getTypeScale() == MANUAL) { |
215 | 800 | vcaballero | vp.setExtent(getNewExtent(getScale())); |
216 | 1056 | vcaballero | m_fmap = v.getMapContext().createNewFMap(vp); |
217 | 1201 | fernando | v.getMapContext().getViewPort().removeViewPortListener(this);
|
218 | 800 | vcaballero | } |
219 | 1056 | vcaballero | } else if (!m_bLinked) { |
220 | 800 | vcaballero | try {
|
221 | 1056 | vcaballero | if (getTypeScale() == AUTOMATICO) {
|
222 | m_fmap = v.getMapContext().cloneFMap(); //(v.getMapContext().getViewPort().cloneViewPort());
|
||
223 | m_fmap.setViewPort(v.getMapContext().getViewPort() |
||
224 | .cloneViewPort()); |
||
225 | 1333 | vcaballero | v.getMapContext().getViewPort().removeViewPortListener(this);
|
226 | 1201 | fernando | v.getMapContext().getViewPort().addViewPortListener(this);
|
227 | 1056 | vcaballero | } else if (getTypeScale() == CONSTANTE) { |
228 | vp.setExtent((Rectangle2D) v.getMapContext().getViewPort()
|
||
229 | .getExtent().clone()); |
||
230 | m_fmap = v.getMapContext().cloneFMap(); |
||
231 | m_fmap.setViewPort(vp); |
||
232 | 1201 | fernando | v.getMapContext().getViewPort().removeViewPortListener(this);
|
233 | 1056 | vcaballero | } else if (getTypeScale() == MANUAL) { |
234 | vp.setExtent(getNewExtent(getScale())); |
||
235 | m_fmap = v.getMapContext().cloneFMap(); |
||
236 | m_fmap.setViewPort(vp); |
||
237 | 1201 | fernando | v.getMapContext().getViewPort().removeViewPortListener(this);
|
238 | 1056 | vcaballero | } |
239 | 800 | vcaballero | } catch (XMLException e1) {
|
240 | 1056 | vcaballero | NotificationManager.addError("Cuando se a?ade una vista al Layout",
|
241 | e1); |
||
242 | 800 | vcaballero | } |
243 | } |
||
244 | 1056 | vcaballero | |
245 | /*
|
||
246 | m_fmap = v.getMapContext();
|
||
247 | 800 | vcaballero | |
248 | 1056 | vcaballero | v.getMapContext().getViewPort();
|
249 | ViewPort vp = new ViewPort();
|
||
250 | vp.setExtent(v.getMapContext().getViewPort().getExtent());
|
||
251 | m_fmap = m_fmap.createNewFMap(vp);
|
||
252 | view = v;
|
||
253 | */
|
||
254 | 649 | vcaballero | } |
255 | 312 | fernando | |
256 | 649 | vcaballero | /**
|
257 | 1073 | vcaballero | * Devuelve el modelo de la vista.
|
258 | 649 | vcaballero | *
|
259 | 1073 | vcaballero | * @return Modelo de la vista.
|
260 | 649 | vcaballero | */
|
261 | public ProjectView getView() {
|
||
262 | return view;
|
||
263 | } |
||
264 | 312 | fernando | |
265 | 649 | vcaballero | /**
|
266 | * Devuelve un Rect?ngulo que representa el extent de la vista que se
|
||
267 | * requiere a partir de una escala.
|
||
268 | *
|
||
269 | 1073 | vcaballero | * @param scale Escala a mostrar.
|
270 | 649 | vcaballero | *
|
271 | * @return Rect?ngulo.
|
||
272 | */
|
||
273 | private Rectangle2D.Double getNewExtent(long scale) { |
||
274 | double hview = getBoundBox().getHeight();
|
||
275 | double wview = getBoundBox().getWidth();
|
||
276 | 1056 | vcaballero | double hextent = (scale * hview) / 100.0; |
277 | double wextent = (scale * wview) / 100.0; |
||
278 | 649 | vcaballero | double dif = hextent / m_fmap.getViewPort().getExtent().getHeight();
|
279 | double newx = m_fmap.getViewPort().getExtent().getCenterX() -
|
||
280 | ((m_fmap.getViewPort().getExtent().getWidth() * dif) / 2.0);
|
||
281 | double newy = m_fmap.getViewPort().getExtent().getCenterY() -
|
||
282 | ((m_fmap.getViewPort().getExtent().getHeight() * dif) / 2.0);
|
||
283 | 312 | fernando | |
284 | 649 | vcaballero | return new Rectangle2D.Double(newx, newy, wextent, hextent); |
285 | } |
||
286 | 312 | fernando | |
287 | 649 | vcaballero | /**
|
288 | * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
||
289 | * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
||
290 | * de dibujar.
|
||
291 | *
|
||
292 | 1073 | vcaballero | * @param g Graphics2D
|
293 | * @param at Transformada af?n.
|
||
294 | 649 | vcaballero | * @param rv rect?ngulo sobre el que hacer un clip.
|
295 | 1073 | vcaballero | * @param imgBase Imagen para acelerar el dibujado.
|
296 | 649 | vcaballero | *
|
297 | 1056 | vcaballero | * @throws com.iver.cit.gvsig.fmap.DriverException
|
298 | 649 | vcaballero | */
|
299 | public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
||
300 | 654 | fernando | BufferedImage imgBase) throws com.iver.cit.gvsig.fmap.DriverException { |
301 | 649 | vcaballero | Rectangle2D.Double r = getBoundingBox(at);
|
302 | 312 | fernando | |
303 | 649 | vcaballero | if (intersects(rv, r)) {
|
304 | if (getFMap() == null) { |
||
305 | drawEmpty(g); |
||
306 | } else {
|
||
307 | if (rv != null) { |
||
308 | // Dibujamos en pantalla
|
||
309 | Rectangle rclip = g.getClipBounds();
|
||
310 | g.clipRect((int) r.getMinX(), (int) r.getMinY(), |
||
311 | (int) r.getWidth(), (int) r.getHeight()); |
||
312 | |||
313 | if (getQuality() == PRESENTACION) {
|
||
314 | /* this.getFMap().setTransparent(true);
|
||
315 | this.getFMap().drawView((Graphics2D) g,
|
||
316 | new Rectangle((int) (r.x), (int) (r.y),
|
||
317 | (int) (r.width), (int) (r.height)),
|
||
318 | (Rectangle) rv, false, imgBase);
|
||
319 | */
|
||
320 | if (rv.intersects(r)) {
|
||
321 | this.getFMap().getViewPort().setOffset(new Point2D.Double( |
||
322 | r.x, r.y)); |
||
323 | this.getFMap().getViewPort().setImageSize(new Dimension( |
||
324 | (int) r.width, (int) r.height)); |
||
325 | |||
326 | try {
|
||
327 | 1282 | fjp | ViewPort viewPort = this.getFMap().getViewPort();
|
328 | Color theBackColor = viewPort.getBackColor();
|
||
329 | if (theBackColor != null) |
||
330 | { |
||
331 | g.setColor(theBackColor); |
||
332 | g.fillRect((int) r.x, (int) r.y, viewPort.getImageWidth(), viewPort.getImageHeight()); |
||
333 | } |
||
334 | |||
335 | 480 | fjp | this.getFMap().draw(imgBase, g);
|
336 | 654 | fernando | } catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
337 | 480 | fjp | // TODO Auto-generated catch block
|
338 | e.printStackTrace(); |
||
339 | } |
||
340 | 649 | vcaballero | } |
341 | 312 | fernando | |
342 | 649 | vcaballero | if (rclip != null) { |
343 | g.setClip(rclip.x, rclip.y, rclip.width, |
||
344 | 1282 | fjp | rclip.height); |
345 | } |
||
346 | 649 | vcaballero | } else {
|
347 | drawDraft(g); |
||
348 | 480 | fjp | } |
349 | 649 | vcaballero | } else {
|
350 | print(g, at); |
||
351 | } |
||
352 | } |
||
353 | } |
||
354 | } |
||
355 | 312 | fernando | |
356 | 649 | vcaballero | /**
|
357 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
||
358 | * java.awt.geom.AffineTransform)
|
||
359 | */
|
||
360 | public void print(Graphics2D g, AffineTransform at) { |
||
361 | Rectangle2D.Double r = getBoundingBox(at);
|
||
362 | 312 | fernando | |
363 | 649 | vcaballero | // Dibujamos en impresora
|
364 | Rectangle rclip = g.getClipBounds();
|
||
365 | g.clipRect((int) r.getMinX(), (int) r.getMinY(), (int) r.getWidth(), |
||
366 | (int) r.getHeight());
|
||
367 | this.getFMap().getViewPort().setOffset(new Point2D.Double(r.x, r.y)); |
||
368 | this.getFMap().getViewPort().setImageSize(new Dimension((int) r.width, |
||
369 | (int) r.height));
|
||
370 | 312 | fernando | |
371 | 649 | vcaballero | try {
|
372 | this.getFMap().print(g);
|
||
373 | 654 | fernando | } catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
374 | 1328 | fernando | NotificationManager.addError(e.getMessage(), e); |
375 | 649 | vcaballero | } |
376 | 312 | fernando | |
377 | 649 | vcaballero | g.setClip(rclip.x, rclip.y, rclip.width, rclip.height); |
378 | } |
||
379 | 312 | fernando | |
380 | 649 | vcaballero | /**
|
381 | * Rellena la unidad de medida en la que est? la vista.
|
||
382 | *
|
||
383 | * @param i entero que representa la unidad de medida de la vista.
|
||
384 | */
|
||
385 | public void setMapUnits(int i) { |
||
386 | m_mapUnits = i; |
||
387 | } |
||
388 | 312 | fernando | |
389 | 649 | vcaballero | /**
|
390 | * Obtiene la unidad de medida en la que est? la vista.
|
||
391 | *
|
||
392 | 1073 | vcaballero | * @return Unidad de medida.
|
393 | 649 | vcaballero | */
|
394 | public int getMapUnits() { |
||
395 | return m_mapUnits;
|
||
396 | } |
||
397 | 312 | fernando | |
398 | 649 | vcaballero | /**
|
399 | * Devuelve la escala seg?n el tipo de escala que se haya seleccionado al
|
||
400 | * a?adida la vista.
|
||
401 | *
|
||
402 | * @return escala.
|
||
403 | */
|
||
404 | public long getScale() { |
||
405 | /*if (m_bLinked){
|
||
406 | return getScaleView1(METROS);
|
||
407 | }
|
||
408 | */
|
||
409 | if (getTypeScale() == AUTOMATICO) {
|
||
410 | 1513 | vcaballero | return FLayoutUtilities.getScaleView(getFMap().getViewPort(), getBoundBox().width,getBoundingBox(null).width/getBoundBox().width); |
411 | 649 | vcaballero | } else if (getTypeScale() == CONSTANTE) { |
412 | 1073 | vcaballero | return (long) m_Scale; |
413 | 649 | vcaballero | } else if (getTypeScale() == MANUAL) { |
414 | return (long) m_Scale; |
||
415 | } |
||
416 | 312 | fernando | |
417 | 649 | vcaballero | return (long) m_Scale; |
418 | } |
||
419 | 312 | fernando | |
420 | 649 | vcaballero | /**
|
421 | * Seleccionar si la vista esta relacionada o no con la original.
|
||
422 | *
|
||
423 | * @param b true si est? ligada y false si no lo est?.
|
||
424 | */
|
||
425 | public void setLinked(boolean b) { |
||
426 | m_bLinked = b; |
||
427 | } |
||
428 | 312 | fernando | |
429 | 649 | vcaballero | /**
|
430 | 1073 | vcaballero | * Devuelve si est? ligada o no el FFrameView con la vista.
|
431 | 649 | vcaballero | *
|
432 | 1073 | vcaballero | * @return True si la vista est? ligada.
|
433 | 649 | vcaballero | */
|
434 | public boolean getLinked() { |
||
435 | return m_bLinked;
|
||
436 | } |
||
437 | 312 | fernando | |
438 | 649 | vcaballero | /**
|
439 | * Devuelve la opci?n seleccionada:Rellenar marco de la vista o recorte a
|
||
440 | * la vista.
|
||
441 | *
|
||
442 | * @return entero que representa la opci?n elegida.
|
||
443 | */
|
||
444 | public int getExtension() { |
||
445 | return m_extension;
|
||
446 | } |
||
447 | 362 | vcaballero | |
448 | 649 | vcaballero | /**
|
449 | * Devuelve el tipo de escala que est? seleccionada AUTOMATICO,CONSTANTE o
|
||
450 | * MANUAL.
|
||
451 | *
|
||
452 | * @return entero que representa el tipo seleccionado.
|
||
453 | */
|
||
454 | public int getTypeScale() { |
||
455 | return m_typeScale;
|
||
456 | } |
||
457 | 362 | vcaballero | |
458 | 649 | vcaballero | /**
|
459 | * Rellenar si se quiere:Rellenar marco de la vista o recorte a la vista.
|
||
460 | *
|
||
461 | * @param i entero que representa la opci?n elegida.
|
||
462 | */
|
||
463 | public void setExtension(int i) { |
||
464 | m_extension = i; |
||
465 | } |
||
466 | 312 | fernando | |
467 | 649 | vcaballero | /**
|
468 | * Rellenar el tipo de escala que se desea.
|
||
469 | *
|
||
470 | * @param i entero que representa el tipo de escala.
|
||
471 | */
|
||
472 | public void setTypeScale(int i) { |
||
473 | m_typeScale = i; |
||
474 | } |
||
475 | 312 | fernando | |
476 | 649 | vcaballero | /**
|
477 | 1830 | fernando | * @throws XMLException
|
478 | 649 | vcaballero | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
479 | */
|
||
480 | 1830 | fernando | public XMLEntity getXMLEntity() throws XMLException { |
481 | 649 | vcaballero | XMLEntity xml = new XMLEntity();
|
482 | 1094 | vcaballero | xml.putProperty("className",this.getClass().getName()); |
483 | 649 | vcaballero | xml.putProperty("m_name", m_name);
|
484 | xml.putProperty("x", getBoundBox().x);
|
||
485 | xml.putProperty("y", getBoundBox().y);
|
||
486 | xml.putProperty("w", getBoundBox().width);
|
||
487 | xml.putProperty("h", getBoundBox().height);
|
||
488 | xml.putProperty("m_Selected", m_Selected);
|
||
489 | xml.putProperty("type", Layout.RECTANGLEVIEW);
|
||
490 | xml.putProperty("m_Mode", m_Mode);
|
||
491 | xml.putProperty("m_typeScale", m_typeScale);
|
||
492 | xml.putProperty("m_extension", m_extension);
|
||
493 | xml.putProperty("m_quality", m_quality);
|
||
494 | xml.putProperty("m_viewing", m_viewing);
|
||
495 | xml.putProperty("m_bLinked", m_bLinked);
|
||
496 | xml.putProperty("m_mapUnits", m_mapUnits);
|
||
497 | xml.putProperty("m_Scale", m_Scale);
|
||
498 | 312 | fernando | |
499 | 649 | vcaballero | xml.putProperty("extentX", getFMap().getViewPort().getExtent().getX());
|
500 | xml.putProperty("extentY", getFMap().getViewPort().getExtent().getY());
|
||
501 | xml.putProperty("extentW",
|
||
502 | getFMap().getViewPort().getExtent().getWidth()); |
||
503 | xml.putProperty("extentH",
|
||
504 | getFMap().getViewPort().getExtent().getHeight()); |
||
505 | xml.putProperty("tag", getTag());
|
||
506 | 312 | fernando | |
507 | 649 | vcaballero | ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
508 | ArrayList views = pe.getProject().getViews();
|
||
509 | 312 | fernando | |
510 | 649 | vcaballero | boolean hasIndex = false; |
511 | 312 | fernando | |
512 | 649 | vcaballero | for (int i = 0; i < views.size(); i++) { |
513 | 800 | vcaballero | if (view == ((ProjectView) views.get(i))) {
|
514 | 649 | vcaballero | xml.putProperty("indice", i);
|
515 | hasIndex = true;
|
||
516 | } |
||
517 | } |
||
518 | 312 | fernando | |
519 | 649 | vcaballero | if (!hasIndex) {
|
520 | xml.putProperty("indice", -1); |
||
521 | } |
||
522 | 1056 | vcaballero | |
523 | 800 | vcaballero | xml.addChild(m_fmap.getXMLEntity()); |
524 | 1056 | vcaballero | |
525 | 649 | vcaballero | return xml;
|
526 | } |
||
527 | 398 | vcaballero | |
528 | 649 | vcaballero | /**
|
529 | 1073 | vcaballero | * Inserta la imagen para repintar el FFrameView.
|
530 | 649 | vcaballero | *
|
531 | 1073 | vcaballero | * @param bi Imagen para repintar.
|
532 | 649 | vcaballero | */
|
533 | public void setBufferedImage(BufferedImage bi) { |
||
534 | m_image = bi; |
||
535 | } |
||
536 | 398 | vcaballero | |
537 | 649 | vcaballero | /**
|
538 | 1073 | vcaballero | * Devuelve la imagen para repintar.
|
539 | 649 | vcaballero | *
|
540 | 1073 | vcaballero | * @return Imagen para repintar.
|
541 | 649 | vcaballero | */
|
542 | public BufferedImage getBufferedImage() { |
||
543 | return m_image;
|
||
544 | } |
||
545 | 398 | vcaballero | |
546 | 649 | vcaballero | /**
|
547 | 1073 | vcaballero | * Devuelve la MAtriz de transformaci?n utilizada por la FFrameView.
|
548 | 649 | vcaballero | *
|
549 | 1073 | vcaballero | * @return MAtriz de transformaci?n.
|
550 | 649 | vcaballero | */
|
551 | public AffineTransform getAt() { |
||
552 | return at;
|
||
553 | } |
||
554 | 398 | vcaballero | |
555 | 649 | vcaballero | /**
|
556 | 1073 | vcaballero | * Inserta la matriz de transformaci?n.
|
557 | 649 | vcaballero | *
|
558 | 1073 | vcaballero | * @param transform Matriz de transformaci?n.
|
559 | 649 | vcaballero | */
|
560 | public void setAt(AffineTransform transform) { |
||
561 | at = transform; |
||
562 | } |
||
563 | 1056 | vcaballero | |
564 | /**
|
||
565 | 1073 | vcaballero | * Inserta el proyecto.
|
566 | 1056 | vcaballero | *
|
567 | 1073 | vcaballero | * @param p Proyecto.
|
568 | 1056 | vcaballero | */
|
569 | public void setProject(Project p) { |
||
570 | project = p; |
||
571 | 686 | vcaballero | } |
572 | 1056 | vcaballero | |
573 | 649 | vcaballero | /**
|
574 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
||
575 | * com.iver.cit.gvsig.project.Project)
|
||
576 | */
|
||
577 | 686 | vcaballero | public void setXMLEntity(XMLEntity xml, Layout l) { |
578 | 649 | vcaballero | if (xml.getIntProperty("m_Selected") != 0) { |
579 | this.setSelected(true); |
||
580 | } else {
|
||
581 | this.setSelected(false); |
||
582 | } |
||
583 | 398 | vcaballero | |
584 | 649 | vcaballero | this.setName(xml.getStringProperty("m_name")); |
585 | this.setBoundBox(new Rectangle2D.Double(xml.getDoubleProperty("x"), |
||
586 | xml.getDoubleProperty("y"), xml.getDoubleProperty("w"), |
||
587 | xml.getDoubleProperty("h")));
|
||
588 | |||
589 | this.m_Mode = xml.getIntProperty("m_Mode"); |
||
590 | this.m_typeScale = xml.getIntProperty("m_typeScale"); |
||
591 | this.m_extension = xml.getIntProperty("m_extension"); |
||
592 | this.m_quality = xml.getIntProperty("m_quality"); |
||
593 | this.m_viewing = xml.getIntProperty("m_viewing"); |
||
594 | this.m_bLinked = xml.getBooleanProperty("m_bLinked"); |
||
595 | this.m_mapUnits = xml.getIntProperty("m_mapUnits"); |
||
596 | |||
597 | ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
||
598 | this.m_Scale = xml.getDoubleProperty("m_Scale"); |
||
599 | |||
600 | int indice = xml.getIntProperty("indice"); |
||
601 | |||
602 | if (indice != -1) { |
||
603 | 686 | vcaballero | ProjectView view = (ProjectView) project.getViews().get(indice); |
604 | 649 | vcaballero | this.m_fmap = view.getMapContext();
|
605 | this.setView((ProjectView) view);
|
||
606 | |||
607 | 800 | vcaballero | try {
|
608 | //this.m_fmap = view.getMapContext();
|
||
609 | 1056 | vcaballero | |
610 | /* this.getFMap().getViewPort().setExtent(new Rectangle2D.Double(
|
||
611 | xml.getDoubleProperty("extentX"),
|
||
612 | xml.getDoubleProperty("extentY"),
|
||
613 | xml.getDoubleProperty("extentW"),
|
||
614 | xml.getDoubleProperty("extentH")));
|
||
615 | */
|
||
616 | if (m_bLinked) {
|
||
617 | this.getFMap().getViewPort().setExtent(new Rectangle2D.Double( |
||
618 | xml.getDoubleProperty("extentX"),
|
||
619 | xml.getDoubleProperty("extentY"),
|
||
620 | xml.getDoubleProperty("extentW"),
|
||
621 | xml.getDoubleProperty("extentH")));
|
||
622 | } else if (!m_bLinked) { |
||
623 | this.m_fmap = FMap.createFromXML(xml.getChild(0)); |
||
624 | } |
||
625 | 800 | vcaballero | } catch (XMLException e) {
|
626 | 1056 | vcaballero | NotificationManager.addError("Pasando las propiedades del XMLEntity al objeto",
|
627 | e); |
||
628 | 800 | vcaballero | } |
629 | 649 | vcaballero | } |
630 | } |
||
631 | |||
632 | 398 | vcaballero | /**
|
633 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
||
634 | */
|
||
635 | public String getNameFFrame() { |
||
636 | 649 | vcaballero | return PluginServices.getText(this, "Vista") + num; |
637 | 398 | vcaballero | } |
638 | 800 | vcaballero | |
639 | /**
|
||
640 | * @see com.iver.cit.gvsig.fmap.ExtentListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
|
||
641 | */
|
||
642 | public void extentChanged(ExtentEvent e) { |
||
643 | 1056 | vcaballero | if (getTypeScale() == AUTOMATICO) {
|
644 | m_fmap.getViewPort().setExtent(e.getNewExtent()); |
||
645 | 800 | vcaballero | } |
646 | } |
||
647 | 962 | vcaballero | |
648 | /**
|
||
649 | * @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
|
||
650 | */
|
||
651 | public void backColorChanged(ColorEvent e) { |
||
652 | 1282 | fjp | m_fmap.getViewPort().setBackColor(e.getNewColor()); |
653 | 1333 | vcaballero | System.out.println("pasa por backColorChanged"); |
654 | 962 | vcaballero | } |
655 | 312 | fernando | } |