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