root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameView.java @ 9115
History | View | Annotate | Download (31.6 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 | 3680 | caballero | import java.awt.Color; |
48 | import java.awt.Dimension; |
||
49 | import java.awt.Graphics2D; |
||
50 | 5729 | caballero | import java.awt.Point; |
51 | 3680 | caballero | import java.awt.Rectangle; |
52 | import java.awt.geom.AffineTransform; |
||
53 | import java.awt.geom.Point2D; |
||
54 | import java.awt.geom.Rectangle2D; |
||
55 | import java.awt.image.BufferedImage; |
||
56 | import java.util.ArrayList; |
||
57 | |||
58 | 596 | fernando | import com.iver.andami.PluginServices; |
59 | 800 | vcaballero | import com.iver.andami.messages.NotificationManager; |
60 | 312 | fernando | import com.iver.cit.gvsig.ProjectExtension; |
61 | 962 | vcaballero | import com.iver.cit.gvsig.fmap.ColorEvent; |
62 | 2310 | vcaballero | import com.iver.cit.gvsig.fmap.DriverException; |
63 | 800 | vcaballero | import com.iver.cit.gvsig.fmap.ExtentEvent; |
64 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
65 | 5939 | jmvivo | import com.iver.cit.gvsig.fmap.ProjectionEvent; |
66 | 362 | vcaballero | import com.iver.cit.gvsig.fmap.ViewPort; |
67 | 1056 | vcaballero | import com.iver.cit.gvsig.fmap.ViewPortListener; |
68 | 2433 | caballero | import com.iver.cit.gvsig.fmap.layers.LegendListener; |
69 | 800 | vcaballero | import com.iver.cit.gvsig.fmap.layers.XMLException; |
70 | 2433 | caballero | import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent; |
71 | 312 | fernando | import com.iver.cit.gvsig.gui.layout.Layout; |
72 | 1222 | fernando | import com.iver.cit.gvsig.project.Project; |
73 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
74 | import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
||
75 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
||
76 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameLayoutDependence; |
||
77 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
||
78 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseProject; |
||
79 | import com.iver.cit.gvsig.project.documents.view.ProjectView; |
||
80 | 7379 | caballero | import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory; |
81 | 312 | fernando | import com.iver.utiles.XMLEntity; |
82 | |||
83 | 1056 | vcaballero | |
84 | 312 | fernando | /**
|
85 | * FFrame para introducir una vista en el Layout.
|
||
86 | *
|
||
87 | * @author Vicente Caballero Navarro
|
||
88 | */
|
||
89 | 3610 | caballero | public class FFrameView extends FFrame implements ViewPortListener, |
90 | 3680 | caballero | LegendListener, IFFrameUseProject, IFFrameLayoutDependence,IFFrameUseFMap { |
91 | 3610 | caballero | //private static Logger logger = Logger.getLogger(FFrameView.class.getName());
|
92 | public static final int PRESENTACION = 0; |
||
93 | public static final int BORRADOR = 1; |
||
94 | private int m_Mode; |
||
95 | private int m_typeScale = AUTOMATICO; |
||
96 | private int m_extension = 0; |
||
97 | private int m_quality = PRESENTACION; |
||
98 | private int m_viewing = 0; |
||
99 | private boolean m_bLinked = true; |
||
100 | private ProjectView view = null; |
||
101 | 6878 | cesar | private MapContext m_fmap = null; |
102 | 3610 | caballero | private double m_Scale = 0; |
103 | private int m_mapUnits = 1; //Metros. |
||
104 | 1056 | vcaballero | |
105 | 3610 | caballero | private BufferedImage m_image = null; |
106 | private AffineTransform at = null; |
||
107 | private Project project = null; |
||
108 | private Layout layout;
|
||
109 | 3680 | caballero | private double scaleAnt; |
110 | private boolean refresh=false; |
||
111 | 5729 | caballero | private Point origin; |
112 | private Point2D p1; |
||
113 | private Point2D p2; |
||
114 | /**
|
||
115 | 3610 | caballero | * Creates a new FFrameView object.
|
116 | */
|
||
117 | public FFrameView() {
|
||
118 | num++; |
||
119 | } |
||
120 | 312 | fernando | |
121 | 3610 | caballero | /**
|
122 | * Devuelve una descripci?n del FFrameView.
|
||
123 | *
|
||
124 | * @return Descripci?n.
|
||
125 | */
|
||
126 | public String toString() { |
||
127 | if (getView() == null) { |
||
128 | return "FFrameView " + num + ": " + "Vacio"; |
||
129 | } |
||
130 | 312 | fernando | |
131 | 3610 | caballero | return "FFrameView " + num + ": " + getView().getName(); |
132 | } |
||
133 | 362 | vcaballero | |
134 | 3610 | caballero | /**
|
135 | * Rellena la escala de la vista que contiene el fframe.
|
||
136 | *
|
||
137 | * @param d escala de la vista.
|
||
138 | */
|
||
139 | public void setScale(double d) { |
||
140 | m_Scale = d; |
||
141 | } |
||
142 | 362 | vcaballero | |
143 | 3610 | caballero | /**
|
144 | * Inserta el nuevo extent a la FFrameView.
|
||
145 | *
|
||
146 | * @param r Rect?ngulo a ocupar por el FFrameView.
|
||
147 | */
|
||
148 | public void setNewExtent(Rectangle2D r) { |
||
149 | 6881 | cesar | getMapContext().getViewPort().setExtent(r); |
150 | 6387 | jaume | refresh = true;
|
151 | 6881 | cesar | m_Scale = FLayoutUtilities.getScaleView(getMapContext().getViewPort(), |
152 | 3610 | caballero | getBoundBox().width, |
153 | getBoundingBox(null).width / getBoundBox().width);
|
||
154 | } |
||
155 | 312 | fernando | |
156 | 3610 | caballero | /**
|
157 | * Devuelve el FMap de la vista o una clonaci?n de este si se utiliza una
|
||
158 | * escala fija.
|
||
159 | *
|
||
160 | * @return FMap.
|
||
161 | */
|
||
162 | 6881 | cesar | public MapContext getMapContext() {
|
163 | 3680 | caballero | return m_fmap;
|
164 | 3610 | caballero | } |
165 | 312 | fernando | |
166 | 3610 | caballero | /**
|
167 | * Rellena la calidad que se quiere aplicar.
|
||
168 | *
|
||
169 | * @param q entero que representa la calidad a aplicar.
|
||
170 | */
|
||
171 | public void setQuality(int q) { |
||
172 | m_quality = q; |
||
173 | } |
||
174 | 312 | fernando | |
175 | 3610 | caballero | /**
|
176 | * Devuelve un entero que representa la calidad que est? seleccionada.
|
||
177 | *
|
||
178 | * @return tipo de calidad selccionada.
|
||
179 | */
|
||
180 | public int getQuality() { |
||
181 | return m_quality;
|
||
182 | } |
||
183 | 312 | fernando | |
184 | 3610 | caballero | /**
|
185 | * Devuelve un entero que representa la forma en que se actualiza la vista.
|
||
186 | *
|
||
187 | * @return forma que se actualiza la vista.
|
||
188 | */
|
||
189 | public int getViewing() { |
||
190 | return m_viewing;
|
||
191 | } |
||
192 | 312 | fernando | |
193 | 3610 | caballero | /**
|
194 | * Rellena la forma de actualizar la vista(cuando activo o siempre). De
|
||
195 | * momento esta opci?n esta deshabilitada.
|
||
196 | *
|
||
197 | * @param v entero que representa la forma de actualizar la vista.
|
||
198 | */
|
||
199 | public void setViewing(int v) { |
||
200 | m_viewing = v; |
||
201 | } |
||
202 | 1056 | vcaballero | |
203 | 3610 | caballero | /**
|
204 | * Inserta el ProjectView de donde obtener las propiedades de la vista a
|
||
205 | * mostrar.
|
||
206 | *
|
||
207 | * @param v Modelo de la vista.
|
||
208 | */
|
||
209 | public void setView(ProjectView v) { |
||
210 | 7669 | caballero | view=v; |
211 | 4497 | caballero | ViewPort vp =null;
|
212 | 6881 | cesar | if (getMapContext()!=null){ |
213 | vp=getMapContext().getViewPort(); |
||
214 | 4497 | caballero | }else{
|
215 | vp = v.getMapContext().getViewPort().cloneViewPort(); |
||
216 | } |
||
217 | 4453 | caballero | vp.setImageSize(new Dimension((int) getBoundingBox(null).width, |
218 | 3610 | caballero | (int) getBoundingBox(null).height)); |
219 | |||
220 | if (m_bLinked) {
|
||
221 | if (getTypeScale() == AUTOMATICO) {
|
||
222 | m_fmap = v.getMapContext().createNewFMap(v.getMapContext() |
||
223 | .getViewPort() |
||
224 | .cloneViewPort()); |
||
225 | m_fmap.getViewPort().setImageSize(new Dimension( |
||
226 | (int) getBoundingBox(null).width, |
||
227 | (int) getBoundingBox(null).height)); |
||
228 | v.getMapContext().getViewPort().addViewPortListener(this);
|
||
229 | v.getMapContext().addLayerListener(this);
|
||
230 | } else if (getTypeScale() == CONSTANTE) { |
||
231 | 8204 | caballero | m_fmap = v.getMapContext().createNewFMap(vp); |
232 | 7669 | caballero | vp.setExtent(getNewExtent(getScale())); |
233 | 3610 | caballero | v.getMapContext().getViewPort().removeViewPortListener(this);
|
234 | v.getMapContext().addLayerListener(this);
|
||
235 | } else if (getTypeScale() == MANUAL) { |
||
236 | m_fmap = v.getMapContext().createNewFMap(vp); |
||
237 | vp.setExtent(getNewExtent(getScale())); |
||
238 | v.getMapContext().getViewPort().removeViewPortListener(this);
|
||
239 | v.getMapContext().addLayerListener(this);
|
||
240 | } |
||
241 | } else if (!m_bLinked) { |
||
242 | try {
|
||
243 | if (getTypeScale() == AUTOMATICO) {
|
||
244 | m_fmap = v.getMapContext().cloneFMap(); //(v.getMapContext().getViewPort().cloneViewPort());
|
||
245 | m_fmap.setViewPort(v.getMapContext().getViewPort() |
||
246 | .cloneViewPort()); |
||
247 | m_fmap.getViewPort().setImageSize(new Dimension( |
||
248 | (int) getBoundingBox(null).width, |
||
249 | (int) getBoundingBox(null).height)); |
||
250 | v.getMapContext().getViewPort().addViewPortListener(this);
|
||
251 | } else if (getTypeScale() == CONSTANTE) { |
||
252 | 8795 | caballero | m_fmap = v.getMapContext().cloneFMap(); |
253 | 7669 | caballero | vp.setExtent(getNewExtent(getScale())); |
254 | 3610 | caballero | m_fmap.setViewPort(vp); |
255 | v.getMapContext().getViewPort().removeViewPortListener(this);
|
||
256 | } else if (getTypeScale() == MANUAL) { |
||
257 | m_fmap = v.getMapContext().cloneFMap(); |
||
258 | vp.setExtent(getNewExtent(getScale())); |
||
259 | m_fmap.setViewPort(vp); |
||
260 | v.getMapContext().getViewPort().removeViewPortListener(this);
|
||
261 | } |
||
262 | } catch (XMLException e1) {
|
||
263 | NotificationManager.addError("Cuando se a?ade una vista al Layout",
|
||
264 | e1); |
||
265 | } |
||
266 | } |
||
267 | } |
||
268 | 312 | fernando | |
269 | 3610 | caballero | /**
|
270 | * Devuelve el modelo de la vista.
|
||
271 | *
|
||
272 | * @return Modelo de la vista.
|
||
273 | */
|
||
274 | public ProjectView getView() {
|
||
275 | return view;
|
||
276 | } |
||
277 | 312 | fernando | |
278 | 3610 | caballero | /**
|
279 | * Devuelve un Rect?ngulo que representa el extent de la vista que se
|
||
280 | * requiere a partir de una escala.
|
||
281 | *
|
||
282 | * @param scale Escala a mostrar.
|
||
283 | *
|
||
284 | * @return Rect?ngulo.
|
||
285 | */
|
||
286 | private Rectangle2D.Double getNewExtent(long scale) { |
||
287 | double hview = getBoundBox().getHeight();
|
||
288 | double wview = getBoundBox().getWidth();
|
||
289 | double hextent = (scale * hview) / 100.0; |
||
290 | double wextent = (scale * wview) / 100.0; |
||
291 | 4453 | caballero | |
292 | 4972 | caballero | if (m_fmap.getViewPort().getExtent()==null) |
293 | return new Rectangle2D.Double(); |
||
294 | 3610 | caballero | double newx = m_fmap.getViewPort().getExtent().getCenterX() -
|
295 | (wextent / 2.0);
|
||
296 | double newy = m_fmap.getViewPort().getExtent().getCenterY() -
|
||
297 | (hextent / 2.0);
|
||
298 | 312 | fernando | |
299 | 3610 | caballero | return new Rectangle2D.Double(newx, newy, wextent, hextent); |
300 | } |
||
301 | 649 | vcaballero | |
302 | 3610 | caballero | /**
|
303 | 5777 | caballero | * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
304 | * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
||
305 | * de dibujar.
|
||
306 | *
|
||
307 | * @param g
|
||
308 | * Graphics2D
|
||
309 | * @param at
|
||
310 | * Transformada af?n.
|
||
311 | * @param rv
|
||
312 | * rect?ngulo sobre el que hacer un clip.
|
||
313 | * @param imgBase
|
||
314 | * Imagen para acelerar el dibujado.
|
||
315 | *
|
||
316 | * @throws com.iver.cit.gvsig.fmap.DriverException
|
||
317 | */
|
||
318 | public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
||
319 | BufferedImage imgBase)
|
||
320 | throws com.iver.cit.gvsig.fmap.DriverException {
|
||
321 | Rectangle2D.Double r = getBoundingBox(at);
|
||
322 | if (getRotation() != 0) |
||
323 | g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), r.y |
||
324 | + (r.height / 2));
|
||
325 | if (intersects(rv, r)) {
|
||
326 | 6881 | cesar | if (getMapContext() == null) { |
327 | 5777 | caballero | drawEmpty(g); |
328 | } else {
|
||
329 | if (rv != null) { |
||
330 | // Dibujamos en pantalla
|
||
331 | 6395 | caballero | Rectangle rclip = (Rectangle)g.getClipBounds().clone(); |
332 | 5777 | caballero | g.clipRect((int) r.getMinX(), (int) r.getMinY(), (int) r |
333 | .getWidth(), (int) r.getHeight());
|
||
334 | 312 | fernando | |
335 | 5777 | caballero | if (getQuality() == PRESENTACION) {
|
336 | if (rv.intersects(r)) {
|
||
337 | if (origin != null |
||
338 | && origin.equals(layout.getRectOrigin()) |
||
339 | && layout != null
|
||
340 | && layout.getAT().getScaleX() == scaleAnt |
||
341 | && m_image != null && !refresh) {
|
||
342 | g.translate(r.getX(), r.getY()); |
||
343 | g.drawImage(m_image, 0, 0, layout); |
||
344 | g.translate(-r.getX(), -r.getY()); |
||
345 | scaleAnt = layout.getAT().getScaleX(); |
||
346 | origin = (Point) layout.getRectOrigin().clone();
|
||
347 | } else {
|
||
348 | 6881 | cesar | ViewPort viewPort = this.getMapContext()
|
349 | 5777 | caballero | .getViewPort(); |
350 | Color theBackColor = viewPort.getBackColor();
|
||
351 | 312 | fernando | |
352 | 5777 | caballero | System.err.println("r : " + r); |
353 | if (r.getWidth() > layout.getWidth()
|
||
354 | || r.getHeight() > layout.getHeight()) { |
||
355 | 6881 | cesar | getMapContext().getViewPort().setOffset( |
356 | 5777 | caballero | new Point2D.Double(r.getX(), r |
357 | .getY())); |
||
358 | 6881 | cesar | getMapContext().getViewPort().setImageSize( |
359 | 5777 | caballero | new Dimension((int) r.getWidth(), |
360 | (int) r.getHeight()));
|
||
361 | 8791 | caballero | MapContext fmap = getMapContext().cloneToDraw(); |
362 | 5777 | caballero | ViewPort viewp = viewPort.cloneViewPort(); |
363 | viewp.setImageSize(new Dimension( |
||
364 | 6604 | caballero | layout.getWidth(), |
365 | layout.getHeight())); |
||
366 | Rectangle2D r1 = calculateExtent();
|
||
367 | 5777 | caballero | double width = layout.getAtributes()
|
368 | .getSizeInUnits().getAncho(); |
||
369 | double scale = FLayoutUtilities
|
||
370 | .getScaleView(viewp, width, r1 |
||
371 | .getWidth() |
||
372 | / width); |
||
373 | viewp.setExtent(r1); |
||
374 | 5729 | caballero | |
375 | 5777 | caballero | fmap.setViewPort(viewp); |
376 | g.translate(-r.getX(), -r.getY()); |
||
377 | 8449 | caballero | if (theBackColor != null) { |
378 | g.setColor(theBackColor); |
||
379 | g.fillRect((int) r.x, (int) r.y, viewp |
||
380 | .getImageWidth(), viewp |
||
381 | .getImageHeight()); |
||
382 | } |
||
383 | 5777 | caballero | fmap.draw(imgBase, g, scale); |
384 | g.translate(r.getX(), r.getY()); |
||
385 | 8791 | caballero | |
386 | 5777 | caballero | } else {
|
387 | 6881 | cesar | getMapContext().getViewPort().setOffset( |
388 | 5777 | caballero | new Point2D.Double(r.x, r.y)); |
389 | 6881 | cesar | getMapContext().getViewPort().setImageSize( |
390 | 5777 | caballero | new Dimension((int) r.width, |
391 | (int) r.height));
|
||
392 | m_image = new BufferedImage((int) r |
||
393 | .getWidth(), (int) r.getHeight(),
|
||
394 | BufferedImage.TYPE_INT_ARGB);
|
||
395 | Graphics2D gimg = (Graphics2D) m_image |
||
396 | .getGraphics(); |
||
397 | gimg.translate(-((int) r.getX()), -((int) r |
||
398 | .getY())); |
||
399 | 6881 | cesar | getMapContext().draw(m_image, gimg, getScale()); |
400 | 5777 | caballero | gimg.translate(((int) r.getX()), ((int) r |
401 | .getY())); |
||
402 | 8449 | caballero | if (theBackColor != null) { |
403 | g.setColor(theBackColor); |
||
404 | g.fillRect((int) r.x, (int) r.y, viewPort |
||
405 | .getImageWidth(), viewPort |
||
406 | .getImageHeight()); |
||
407 | } |
||
408 | 5777 | caballero | g.drawImage(m_image, (int) r.getX(),
|
409 | (int) r.getY(), layout);
|
||
410 | } |
||
411 | scaleAnt = layout.getAT().getScaleX(); |
||
412 | origin = (Point) layout.getRectOrigin().clone();
|
||
413 | refresh = false;
|
||
414 | } |
||
415 | } |
||
416 | if (rclip != null) { |
||
417 | g.setClip(rclip.x, rclip.y, rclip.width, |
||
418 | rclip.height); |
||
419 | } |
||
420 | 5729 | caballero | |
421 | 5777 | caballero | } else {
|
422 | drawDraft(g); |
||
423 | } |
||
424 | } else {
|
||
425 | printX(g, at); |
||
426 | } |
||
427 | } |
||
428 | } |
||
429 | if (getRotation() != 0) |
||
430 | g.rotate(Math.toRadians(-getRotation()), r.x + (r.width / 2), r.y |
||
431 | + (r.height / 2));
|
||
432 | 5729 | caballero | |
433 | 6881 | cesar | if (getMapContext() != null) { |
434 | setATMap((AffineTransform) getMapContext().getViewPort()
|
||
435 | 4779 | caballero | .getAffineTransform().clone()); |
436 | 312 | fernando | |
437 | 5777 | caballero | } |
438 | } |
||
439 | 6604 | caballero | private Rectangle2D calculateExtent() { |
440 | 5729 | caballero | Rectangle2D.Double r = new Rectangle2D.Double(); |
441 | 6718 | caballero | if (p1==null||p2==null) |
442 | return r;
|
||
443 | r.setFrameFromDiagonal(p1, p2); |
||
444 | 5729 | caballero | return r;
|
445 | } |
||
446 | 3610 | caballero | /**
|
447 | 4779 | caballero | * DOCUMENT ME!
|
448 | *
|
||
449 | * @param g
|
||
450 | * DOCUMENT ME!
|
||
451 | * @param at
|
||
452 | * DOCUMENT ME!
|
||
453 | *
|
||
454 | * @throws DriverException
|
||
455 | *
|
||
456 | 7304 | caballero | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
457 | 4779 | caballero | * java.awt.geom.AffineTransform)
|
458 | */
|
||
459 | 3610 | caballero | public void print(Graphics2D g, AffineTransform at) |
460 | throws DriverException {
|
||
461 | draw(g, at, null, null); |
||
462 | } |
||
463 | 312 | fernando | |
464 | 3610 | caballero | /**
|
465 | 5777 | caballero | * DOCUMENT ME!
|
466 | *
|
||
467 | * @param g
|
||
468 | * DOCUMENT ME!
|
||
469 | * @param at
|
||
470 | * DOCUMENT ME!
|
||
471 | */
|
||
472 | 3610 | caballero | private void printX(Graphics2D g, AffineTransform at) { |
473 | Rectangle2D.Double r = getBoundingBox(at);
|
||
474 | 312 | fernando | |
475 | 3610 | caballero | // Dibujamos en impresora
|
476 | Rectangle rclip = g.getClipBounds();
|
||
477 | g.clipRect((int) r.getMinX(), (int) r.getMinY(), (int) r.getWidth(), |
||
478 | (int) r.getHeight());
|
||
479 | 6881 | cesar | this.getMapContext().getViewPort().setOffset(new Point2D.Double(r.x, r.y)); |
480 | this.getMapContext().getViewPort().setImageSize(new Dimension((int) r.width, |
||
481 | 3610 | caballero | (int) r.height));
|
482 | 312 | fernando | |
483 | 3610 | caballero | try {
|
484 | 9010 | caballero | this.getMapContext().print(g, getScale(),layout.getAtributes().toPrintAttributes());
|
485 | 3610 | caballero | } catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
486 | NotificationManager.addError(e.getMessage(), e); |
||
487 | } |
||
488 | 362 | vcaballero | |
489 | 3610 | caballero | g.setClip(rclip.x, rclip.y, rclip.width, rclip.height); |
490 | } |
||
491 | 362 | vcaballero | |
492 | 3610 | caballero | /**
|
493 | * Rellena la unidad de medida en la que est? la vista.
|
||
494 | *
|
||
495 | * @param i entero que representa la unidad de medida de la vista.
|
||
496 | */
|
||
497 | public void setMapUnits(int i) { |
||
498 | m_mapUnits = i; |
||
499 | } |
||
500 | 312 | fernando | |
501 | 3610 | caballero | /**
|
502 | * Obtiene la unidad de medida en la que est? la vista.
|
||
503 | *
|
||
504 | * @return Unidad de medida.
|
||
505 | */
|
||
506 | public int getMapUnits() { |
||
507 | return m_mapUnits;
|
||
508 | } |
||
509 | 312 | fernando | |
510 | 3610 | caballero | /**
|
511 | * Devuelve la escala seg?n el tipo de escala que se haya seleccionado al
|
||
512 | * a?adida la vista.
|
||
513 | *
|
||
514 | * @return escala.
|
||
515 | */
|
||
516 | public long getScale() { |
||
517 | /*if (m_bLinked){
|
||
518 | return getScaleView1(METROS);
|
||
519 | }
|
||
520 | */
|
||
521 | 6881 | cesar | if (getMapContext()==null) |
522 | 4779 | caballero | return 0; |
523 | 3610 | caballero | if (getTypeScale() == AUTOMATICO) {
|
524 | 6881 | cesar | return FLayoutUtilities.getScaleView(getMapContext().getViewPort(),
|
525 | 3610 | caballero | getBoundBox().width, getBoundingBox(null).width);
|
526 | } else if (getTypeScale() == CONSTANTE) { |
||
527 | return (long) m_Scale; |
||
528 | } else if (getTypeScale() == MANUAL) { |
||
529 | return (long) m_Scale; |
||
530 | } |
||
531 | 312 | fernando | |
532 | 3610 | caballero | return (long) m_Scale; |
533 | } |
||
534 | 312 | fernando | |
535 | 3610 | caballero | /**
|
536 | * Seleccionar si la vista esta relacionada o no con la original.
|
||
537 | *
|
||
538 | * @param b true si est? ligada y false si no lo est?.
|
||
539 | */
|
||
540 | public void setLinked(boolean b) { |
||
541 | m_bLinked = b; |
||
542 | } |
||
543 | 312 | fernando | |
544 | 3610 | caballero | /**
|
545 | * Devuelve si est? ligada o no el FFrameView con la vista.
|
||
546 | *
|
||
547 | * @return True si la vista est? ligada.
|
||
548 | */
|
||
549 | public boolean getLinked() { |
||
550 | return m_bLinked;
|
||
551 | } |
||
552 | 312 | fernando | |
553 | 3610 | caballero | /**
|
554 | * Devuelve la opci?n seleccionada:Rellenar marco de la vista o recorte a
|
||
555 | * la vista.
|
||
556 | *
|
||
557 | * @return entero que representa la opci?n elegida.
|
||
558 | */
|
||
559 | public int getExtension() { |
||
560 | return m_extension;
|
||
561 | } |
||
562 | 398 | vcaballero | |
563 | 3610 | caballero | /**
|
564 | * Devuelve el tipo de escala que est? seleccionada AUTOMATICO,CONSTANTE o
|
||
565 | * MANUAL.
|
||
566 | *
|
||
567 | * @return entero que representa el tipo seleccionado.
|
||
568 | */
|
||
569 | public int getTypeScale() { |
||
570 | return m_typeScale;
|
||
571 | } |
||
572 | 398 | vcaballero | |
573 | 3610 | caballero | /**
|
574 | * Rellenar si se quiere:Rellenar marco de la vista o recorte a la vista.
|
||
575 | *
|
||
576 | * @param i entero que representa la opci?n elegida.
|
||
577 | */
|
||
578 | public void setExtension(int i) { |
||
579 | m_extension = i; |
||
580 | } |
||
581 | 398 | vcaballero | |
582 | 3610 | caballero | /**
|
583 | * Rellenar el tipo de escala que se desea.
|
||
584 | *
|
||
585 | * @param i entero que representa el tipo de escala.
|
||
586 | */
|
||
587 | public void setTypeScale(int i) { |
||
588 | m_typeScale = i; |
||
589 | } |
||
590 | 398 | vcaballero | |
591 | 3610 | caballero | /**
|
592 | * DOCUMENT ME!
|
||
593 | *
|
||
594 | * @return DOCUMENT ME!
|
||
595 | *
|
||
596 | * @throws SaveException
|
||
597 | *
|
||
598 | 7304 | caballero | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
|
599 | 3610 | caballero | */
|
600 | public XMLEntity getXMLEntity() throws SaveException { |
||
601 | XMLEntity xml = super.getXMLEntity();
|
||
602 | 1056 | vcaballero | |
603 | 3610 | caballero | try {
|
604 | xml.putProperty("type", Layout.RECTANGLEVIEW);
|
||
605 | xml.putProperty("m_Mode", m_Mode);
|
||
606 | xml.putProperty("m_typeScale", m_typeScale);
|
||
607 | xml.putProperty("m_extension", m_extension);
|
||
608 | xml.putProperty("m_quality", m_quality);
|
||
609 | xml.putProperty("m_viewing", m_viewing);
|
||
610 | xml.putProperty("m_bLinked", m_bLinked);
|
||
611 | xml.putProperty("m_mapUnits", m_mapUnits);
|
||
612 | xml.putProperty("m_Scale", m_Scale);
|
||
613 | 1056 | vcaballero | |
614 | 3610 | caballero | ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
615 | 7379 | caballero | ArrayList views = pe.getProject().getDocumentsByType(ProjectViewFactory.registerName);
|
616 | 2183 | fernando | |
617 | 3610 | caballero | boolean hasIndex = false; |
618 | 8204 | caballero | |
619 | |||
620 | 7743 | jmvivo | if (view != null) { |
621 | xml.putProperty("viewName",view.getName());
|
||
622 | for (int i = 0; i < views.size(); i++) { |
||
623 | if (view.getName().equals(((ProjectView) views.get(i)).getName())) {
|
||
624 | xml.putProperty("indice", i);
|
||
625 | hasIndex = true;
|
||
626 | break;
|
||
627 | } |
||
628 | } |
||
629 | 3610 | caballero | } |
630 | 2183 | fernando | |
631 | 3610 | caballero | if (!hasIndex) {
|
632 | xml.putProperty("indice", -1); |
||
633 | } |
||
634 | 2183 | fernando | |
635 | 6881 | cesar | if (getMapContext() != null && getMapContext().getViewPort().getExtent()!=null) { |
636 | 3610 | caballero | xml.putProperty("extentX",
|
637 | 6881 | cesar | getMapContext().getViewPort().getExtent().getX()); |
638 | 3610 | caballero | xml.putProperty("extentY",
|
639 | 6881 | cesar | getMapContext().getViewPort().getExtent().getY()); |
640 | 3610 | caballero | xml.putProperty("extentW",
|
641 | 6881 | cesar | getMapContext().getViewPort().getExtent().getWidth()); |
642 | 3610 | caballero | xml.putProperty("extentH",
|
643 | 6881 | cesar | getMapContext().getViewPort().getExtent().getHeight()); |
644 | 2183 | fernando | |
645 | 6881 | cesar | xml.addChild(getMapContext().getXMLEntity()); |
646 | 3610 | caballero | } |
647 | } catch (Exception e) { |
||
648 | throw new SaveException(e, this.getClass().getName()); |
||
649 | } |
||
650 | 2183 | fernando | |
651 | 3610 | caballero | return xml;
|
652 | } |
||
653 | 2183 | fernando | |
654 | 3610 | caballero | /**
|
655 | * Inserta la imagen para repintar el FFrameView.
|
||
656 | *
|
||
657 | * @param bi Imagen para repintar.
|
||
658 | */
|
||
659 | public void setBufferedImage(BufferedImage bi) { |
||
660 | m_image = bi; |
||
661 | } |
||
662 | 3103 | caballero | |
663 | 3610 | caballero | /**
|
664 | * Devuelve la imagen para repintar.
|
||
665 | *
|
||
666 | * @return Imagen para repintar.
|
||
667 | */
|
||
668 | public BufferedImage getBufferedImage() { |
||
669 | return m_image;
|
||
670 | } |
||
671 | 3103 | caballero | |
672 | 3610 | caballero | /**
|
673 | 4453 | caballero | * Devuelve la MAtriz de transformaci?n utilizada por la FFrameView.
|
674 | 3610 | caballero | *
|
675 | * @return MAtriz de transformaci?n.
|
||
676 | */
|
||
677 | 3680 | caballero | public AffineTransform getATMap() { |
678 | 3610 | caballero | return at;
|
679 | } |
||
680 | 3103 | caballero | |
681 | 3610 | caballero | /**
|
682 | * Inserta la matriz de transformaci?n.
|
||
683 | *
|
||
684 | * @param transform Matriz de transformaci?n.
|
||
685 | */
|
||
686 | 3680 | caballero | public void setATMap(AffineTransform transform) { |
687 | 3610 | caballero | at = transform; |
688 | } |
||
689 | /**
|
||
690 | * Inserta el proyecto.
|
||
691 | *
|
||
692 | * @param p Proyecto.
|
||
693 | */
|
||
694 | public void setProject(Project p) { |
||
695 | project = p; |
||
696 | } |
||
697 | 398 | vcaballero | |
698 | 3610 | caballero | /**
|
699 | 7304 | caballero | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
700 | 3610 | caballero | * com.iver.cit.gvsig.project.Project)
|
701 | */
|
||
702 | public void setXMLEntity03(XMLEntity xml, Layout l) { |
||
703 | if (xml.getIntProperty("m_Selected") != 0) { |
||
704 | this.setSelected(true); |
||
705 | } else {
|
||
706 | this.setSelected(false); |
||
707 | } |
||
708 | 649 | vcaballero | |
709 | 3610 | caballero | this.setName(xml.getStringProperty("m_name")); |
710 | this.setBoundBox(new Rectangle2D.Double(xml.getDoubleProperty("x"), |
||
711 | xml.getDoubleProperty("y"), xml.getDoubleProperty("w"), |
||
712 | xml.getDoubleProperty("h")));
|
||
713 | 649 | vcaballero | |
714 | 3610 | caballero | this.m_Mode = xml.getIntProperty("m_Mode"); |
715 | this.m_typeScale = xml.getIntProperty("m_typeScale"); |
||
716 | this.m_extension = xml.getIntProperty("m_extension"); |
||
717 | this.m_quality = xml.getIntProperty("m_quality"); |
||
718 | this.m_viewing = xml.getIntProperty("m_viewing"); |
||
719 | this.m_bLinked = xml.getBooleanProperty("m_bLinked"); |
||
720 | this.m_mapUnits = xml.getIntProperty("m_mapUnits"); |
||
721 | 649 | vcaballero | |
722 | 4453 | caballero | //ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
|
723 | 3610 | caballero | this.m_Scale = xml.getDoubleProperty("m_Scale"); |
724 | 649 | vcaballero | |
725 | 3610 | caballero | int indice = xml.getIntProperty("indice"); |
726 | 1056 | vcaballero | |
727 | 3610 | caballero | if (indice != -1) { |
728 | 7379 | caballero | ArrayList views = project.getDocumentsByType(ProjectViewFactory.registerName);
|
729 | 7304 | caballero | |
730 | ProjectView view = (ProjectView) views.get(indice); |
||
731 | 3610 | caballero | this.m_fmap = view.getMapContext();
|
732 | 6604 | caballero | this.setView(view);
|
733 | 3610 | caballero | |
734 | 3048 | fjp | try {
|
735 | 3610 | caballero | if (m_bLinked) {
|
736 | 6881 | cesar | this.getMapContext().getViewPort().setExtent(new Rectangle2D.Double( |
737 | 3610 | caballero | xml.getDoubleProperty("extentX"),
|
738 | xml.getDoubleProperty("extentY"),
|
||
739 | xml.getDoubleProperty("extentW"),
|
||
740 | xml.getDoubleProperty("extentH")));
|
||
741 | } else if (!m_bLinked) { |
||
742 | 6878 | cesar | this.m_fmap = MapContext.createFromXML03(xml.getChild(0)); |
743 | 3610 | caballero | } |
744 | } catch (XMLException e) {
|
||
745 | NotificationManager.addError("Pasando las propiedades del XMLEntity al objeto",
|
||
746 | e); |
||
747 | } |
||
748 | } |
||
749 | } |
||
750 | |||
751 | /**
|
||
752 | 7304 | caballero | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
753 | 3610 | caballero | */
|
754 | public String getNameFFrame() { |
||
755 | 5476 | caballero | return PluginServices.getText(this, "Vista")+ num; |
756 | 3610 | caballero | } |
757 | |||
758 | /**
|
||
759 | * @see com.iver.cit.gvsig.fmap.ExtentListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
|
||
760 | */
|
||
761 | public void extentChanged(ExtentEvent e) { |
||
762 | if (getTypeScale() == AUTOMATICO) {
|
||
763 | m_fmap.getViewPort().setExtent(e.getNewExtent()); |
||
764 | if (layout != null) { |
||
765 | layout.setStatus(Layout.DESACTUALIZADO); |
||
766 | } |
||
767 | 6395 | caballero | |
768 | 3610 | caballero | } |
769 | 6395 | caballero | refresh=true;
|
770 | 3610 | caballero | } |
771 | |||
772 | /**
|
||
773 | * @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
|
||
774 | */
|
||
775 | public void backColorChanged(ColorEvent e) { |
||
776 | if (getLinked()) {
|
||
777 | m_fmap.getViewPort().setBackColor(e.getNewColor()); |
||
778 | layout.setStatus(Layout.DESACTUALIZADO); |
||
779 | 4453 | caballero | |
780 | //setBufferedImage(null);
|
||
781 | 3610 | caballero | } |
782 | } |
||
783 | 6301 | caballero | |
784 | 5939 | jmvivo | /**
|
785 | * @see com.iver.cit.gvsig.fmap.ViewPortListener#projectionChanged(com.iver.cit.gvsig.fmap.ProjectionEvent)
|
||
786 | */
|
||
787 | public void projectionChanged(ProjectionEvent e) { |
||
788 | if (getTypeScale() == AUTOMATICO) {
|
||
789 | m_fmap.getViewPort().setProjection(e.getNewProjection()); |
||
790 | 3610 | caballero | |
791 | 5939 | jmvivo | if (layout != null) { |
792 | layout.setStatus(Layout.DESACTUALIZADO); |
||
793 | } |
||
794 | } |
||
795 | } |
||
796 | |||
797 | 3610 | caballero | /**
|
798 | * DOCUMENT ME!
|
||
799 | *
|
||
800 | * @param l DOCUMENT ME!
|
||
801 | */
|
||
802 | public void setLayout(Layout l) { |
||
803 | layout = l; |
||
804 | } |
||
805 | |||
806 | /**
|
||
807 | * DOCUMENT ME!
|
||
808 | *
|
||
809 | * @param e DOCUMENT ME!
|
||
810 | */
|
||
811 | public void legendChanged(LegendChangedEvent e) { |
||
812 | if (getLinked()) {
|
||
813 | layout.setStatus(Layout.DESACTUALIZADO); |
||
814 | 6301 | caballero | refresh=true;
|
815 | 4453 | caballero | //setBufferedImage(null);
|
816 | 3610 | caballero | } |
817 | } |
||
818 | |||
819 | /**
|
||
820 | * DOCUMENT ME!
|
||
821 | *
|
||
822 | * @param xml DOCUMENT ME!
|
||
823 | */
|
||
824 | public void setXMLEntity(XMLEntity xml) { |
||
825 | if (xml.getIntProperty("m_Selected") != 0) { |
||
826 | this.setSelected(true); |
||
827 | } else {
|
||
828 | this.setSelected(false); |
||
829 | } |
||
830 | |||
831 | this.setName(xml.getStringProperty("m_name")); |
||
832 | this.setBoundBox(new Rectangle2D.Double(xml.getDoubleProperty("x"), |
||
833 | xml.getDoubleProperty("y"), xml.getDoubleProperty("w"), |
||
834 | xml.getDoubleProperty("h")));
|
||
835 | |||
836 | this.m_Mode = xml.getIntProperty("m_Mode"); |
||
837 | this.m_typeScale = xml.getIntProperty("m_typeScale"); |
||
838 | this.m_extension = xml.getIntProperty("m_extension"); |
||
839 | this.m_quality = xml.getIntProperty("m_quality"); |
||
840 | this.m_viewing = xml.getIntProperty("m_viewing"); |
||
841 | this.m_bLinked = xml.getBooleanProperty("m_bLinked"); |
||
842 | this.m_mapUnits = xml.getIntProperty("m_mapUnits"); |
||
843 | setRotation(xml.getDoubleProperty("m_rotation"));
|
||
844 | 4453 | caballero | |
845 | 3610 | caballero | this.m_Scale = xml.getDoubleProperty("m_Scale"); |
846 | |||
847 | int indice = xml.getIntProperty("indice"); |
||
848 | 8204 | caballero | |
849 | 7743 | jmvivo | ProjectView view = null;
|
850 | 8204 | caballero | |
851 | 7743 | jmvivo | if (xml.contains("viewName")){ |
852 | view = (ProjectView)project.getProjectDocumentByName(xml.getStringProperty("viewName"),ProjectViewFactory.registerName);
|
||
853 | }else {
|
||
854 | if (indice != -1) { |
||
855 | try {
|
||
856 | ArrayList views = project.getDocumentsByType(ProjectViewFactory.registerName);
|
||
857 | 8204 | caballero | |
858 | 7743 | jmvivo | view = (ProjectView) views.get(indice); |
859 | } catch (IndexOutOfBoundsException e) { |
||
860 | NotificationManager.addError("No se ha encontrado la vista de indice "+ indice,
|
||
861 | e); |
||
862 | } |
||
863 | } |
||
864 | } |
||
865 | 3610 | caballero | |
866 | 8204 | caballero | |
867 | 7743 | jmvivo | if (view != null) { |
868 | this.setView(view);
|
||
869 | 8204 | caballero | |
870 | 7743 | jmvivo | try {
|
871 | if (xml.contains("extentX")) { |
||
872 | if (m_bLinked) {
|
||
873 | this.getMapContext().getViewPort().setExtent(new Rectangle2D.Double( |
||
874 | xml.getDoubleProperty("extentX"),
|
||
875 | xml.getDoubleProperty("extentY"),
|
||
876 | xml.getDoubleProperty("extentW"),
|
||
877 | xml.getDoubleProperty("extentH")));
|
||
878 | } else if (!m_bLinked) { |
||
879 | this.m_fmap = MapContext.createFromXML(xml.getChild(0)); |
||
880 | } |
||
881 | } |
||
882 | } catch (XMLException e) {
|
||
883 | NotificationManager.addError("Pasando las propiedades del XMLEntity al objeto",
|
||
884 | e); |
||
885 | } |
||
886 | 3610 | caballero | } else if (!m_bLinked) { |
887 | try {
|
||
888 | 6878 | cesar | this.m_fmap = MapContext.createFromXML(xml.getChild(0)); |
889 | 3048 | fjp | } catch (XMLException e) {
|
890 | e.printStackTrace(); |
||
891 | } |
||
892 | } |
||
893 | 3610 | caballero | } |
894 | 3048 | fjp | |
895 | 3610 | caballero | /**
|
896 | * DOCUMENT ME!
|
||
897 | *
|
||
898 | * @return DOCUMENT ME!
|
||
899 | */
|
||
900 | public Layout getLayout() {
|
||
901 | return layout;
|
||
902 | } |
||
903 | 3135 | caballero | |
904 | 3610 | caballero | /**
|
905 | * DOCUMENT ME!
|
||
906 | *
|
||
907 | * @param arg0 DOCUMENT ME!
|
||
908 | *
|
||
909 | * @return DOCUMENT ME!
|
||
910 | */
|
||
911 | public boolean compare(Object arg0) { |
||
912 | if (!(arg0 instanceof FFrameView)) { |
||
913 | return false; |
||
914 | } |
||
915 | 3183 | caballero | |
916 | 3610 | caballero | if (!this.getName().equals(((FFrameView) arg0).getName())) { |
917 | return false; |
||
918 | } |
||
919 | 3553 | caballero | |
920 | 6408 | caballero | if (Math.abs(this.getBoundBox().getWidth()-(((FFrameView) arg0).getBoundBox().getWidth()))>0.05) { |
921 | 3610 | caballero | return false; |
922 | } |
||
923 | 6408 | caballero | if (Math.abs(this.getBoundBox().getHeight()-(((FFrameView) arg0).getBoundBox().getHeight()))>0.05) { |
924 | return false; |
||
925 | } |
||
926 | 3610 | caballero | |
927 | if (!this.toString().equals(((FFrameView) arg0).toString())) { |
||
928 | return false; |
||
929 | } |
||
930 | |||
931 | 6881 | cesar | if (this.getMapContext()!=null && !this.getMapContext().equals(((FFrameView) arg0).getMapContext())) { |
932 | 3610 | caballero | return false; |
933 | } |
||
934 | |||
935 | return true; |
||
936 | } |
||
937 | |||
938 | /**
|
||
939 | * DOCUMENT ME!
|
||
940 | *
|
||
941 | * @param arg0 DOCUMENT ME!
|
||
942 | *
|
||
943 | * @return DOCUMENT ME!
|
||
944 | */
|
||
945 | public boolean equals(Object arg0) { |
||
946 | return this.compare(arg0); |
||
947 | } |
||
948 | 3680 | caballero | |
949 | public void refresh() { |
||
950 | 7669 | caballero | if (view!=null && (getTypeScale() == MANUAL || getTypeScale() == CONSTANTE )) |
951 | 6881 | cesar | getMapContext().getViewPort().setExtent(getNewExtent(getScale())); |
952 | 3680 | caballero | refresh=true;
|
953 | } |
||
954 | 4496 | caballero | |
955 | 5729 | caballero | public void fullExtent() throws DriverException { |
956 | 6881 | cesar | setNewExtent(getMapContext().getFullExtent()); |
957 | 4453 | caballero | } |
958 | 3680 | caballero | |
959 | 5729 | caballero | public void setPointsToZoom(Point2D px1, Point2D px2) { |
960 | p1=px1; |
||
961 | p2=px2; |
||
962 | } |
||
963 | 3680 | caballero | |
964 | 5729 | caballero | public void movePoints(Point2D px1, Point2D px2) { |
965 | double difX=-px2.getX()+px1.getX();
|
||
966 | double difY=-px2.getY()+px1.getY();
|
||
967 | 5873 | caballero | if (p1!=null) { |
968 | p1.setLocation(p1.getX()+difX,p1.getY()+difY); |
||
969 | p2.setLocation(p2.getX()+difX,p2.getY()+difY); |
||
970 | } |
||
971 | 4496 | caballero | } |
972 | 7669 | caballero | |
973 | public void cloneActions(IFFrame frame) { |
||
974 | 9115 | caballero | if (view ==null || view.getMapContext()==null) |
975 | return;
|
||
976 | 7669 | caballero | if (m_bLinked) {
|
977 | if (getTypeScale() == AUTOMATICO) {
|
||
978 | view.getMapContext().getViewPort().addViewPortListener(this);
|
||
979 | view.getMapContext().addLayerListener(this);
|
||
980 | } else if (getTypeScale() == CONSTANTE) { |
||
981 | view.getMapContext().getViewPort().removeViewPortListener(this);
|
||
982 | view.getMapContext().addLayerListener(this);
|
||
983 | } else if (getTypeScale() == MANUAL) { |
||
984 | view.getMapContext().getViewPort().removeViewPortListener(this);
|
||
985 | view.getMapContext().addLayerListener(this);
|
||
986 | } |
||
987 | } else if (!m_bLinked) { |
||
988 | if (getTypeScale() == AUTOMATICO) {
|
||
989 | view.getMapContext().getViewPort().addViewPortListener(this);
|
||
990 | } else if (getTypeScale() == CONSTANTE) { |
||
991 | view.getMapContext().getViewPort().removeViewPortListener(this);
|
||
992 | } else if (getTypeScale() == MANUAL) { |
||
993 | view.getMapContext().getViewPort().removeViewPortListener(this);
|
||
994 | } |
||
995 | } |
||
996 | ((FFrameView)frame).view.getMapContext().removeLayerListener((FFrameView)frame); |
||
997 | ((FFrameView)frame).view.getMapContext().getViewPort().removeViewPortListener((FFrameView)frame); |
||
998 | |||
999 | |||
1000 | } |
||
1001 | public void setBoundBox(Rectangle2D r) { |
||
1002 | |||
1003 | // if (getTypeScale()==CONSTANTE) {
|
||
1004 | // Rectangle2D extent=(Rectangle2D)view.getMapContext().getViewPort().getAdjustedExtent().clone();
|
||
1005 | // double dif=r.getWidth()/getBoundBox().getWidth();
|
||
1006 | // extent.setFrame(extent.getX(),extent.getY(),extent.getWidth()*dif,extent.getHeight()*dif);
|
||
1007 | // view.getMapContext().getViewPort().setExtent(extent);
|
||
1008 | // }
|
||
1009 | super.setBoundBox(r);
|
||
1010 | } |
||
1011 | 312 | fernando | } |