svn-gvsig-desktop / tags / v10_RC2c / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / panels / ZoomControlPanel.java @ 8745
History | View | Annotate | Download (31.5 KB)
1 | 5791 | nacho | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | */
|
||
19 | 5217 | nacho | package org.gvsig.georeferencing.gui.panels; |
20 | |||
21 | import java.awt.BorderLayout; |
||
22 | import java.awt.Color; |
||
23 | import java.awt.Component; |
||
24 | import java.awt.Cursor; |
||
25 | import java.awt.Graphics; |
||
26 | import java.awt.Graphics2D; |
||
27 | import java.awt.GridBagConstraints; |
||
28 | import java.awt.GridBagLayout; |
||
29 | import java.awt.Image; |
||
30 | import java.awt.Point; |
||
31 | import java.awt.Toolkit; |
||
32 | import java.awt.event.ActionEvent; |
||
33 | import java.awt.event.ActionListener; |
||
34 | import java.awt.event.MouseEvent; |
||
35 | import java.awt.event.MouseListener; |
||
36 | import java.awt.event.MouseMotionListener; |
||
37 | import java.awt.geom.Point2D; |
||
38 | import java.awt.geom.Rectangle2D; |
||
39 | import java.awt.image.BufferedImage; |
||
40 | |||
41 | import javax.swing.ImageIcon; |
||
42 | import javax.swing.JButton; |
||
43 | import javax.swing.JOptionPane; |
||
44 | import javax.swing.JPanel; |
||
45 | |||
46 | 5664 | nacho | import org.cresques.px.Extent; |
47 | 5818 | nacho | import org.gvsig.georeferencing.gui.dialog.GeoreferencingDialog; |
48 | 5697 | nacho | import org.gvsig.georeferencing.utils.GeoUtils; |
49 | 5217 | nacho | |
50 | import com.iver.andami.PluginServices; |
||
51 | import com.iver.cit.gvsig.fmap.DriverException; |
||
52 | import com.iver.cit.gvsig.fmap.ViewPort; |
||
53 | 5445 | nacho | import com.iver.cit.gvsig.fmap.layers.FLayer; |
54 | 5217 | nacho | import com.iver.cit.gvsig.fmap.layers.FLayers; |
55 | 5241 | nacho | import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
56 | import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
||
57 | 5217 | nacho | import com.iver.cit.gvsig.gui.View; |
58 | 5352 | nacho | import com.iver.utiles.swing.threads.Cancellable; |
59 | 5217 | nacho | |
60 | /**
|
||
61 | 6641 | caballero | * Panel que contiene los controles de zoom de la vista para
|
62 | 5217 | nacho | * afinar en la georreferenciaci?n.
|
63 | 6641 | caballero | *
|
64 | 5217 | nacho | * @author Nacho Brodin (brodin_ign@gva.es)
|
65 | *
|
||
66 | */
|
||
67 | public class ZoomControlPanel extends JPanel implements ActionListener{ |
||
68 | 6641 | caballero | |
69 | 5217 | nacho | //**********************Vars**********************************
|
70 | 5818 | nacho | public static final int WIDTH_MINIMG = 140; |
71 | public static final int HEIGHT_MINIMG = 140; |
||
72 | 5217 | nacho | private JPanel pImage = null; |
73 | private JPanel pControls = null; |
||
74 | private JButton bZoomMas = null; |
||
75 | 6641 | caballero | private JButton bZoomMenos = null; |
76 | 5217 | nacho | private CanvasZone canvas = null; |
77 | private ViewPort viewPort = null; |
||
78 | public FLyrPoints lyrPoints = null; |
||
79 | public FLyrGeoRaster lyrGeoRaster = null; |
||
80 | public GeoreferencingDialog dialog = null; |
||
81 | private boolean rightControl = false; |
||
82 | 5303 | nacho | /**
|
83 | * Estado de los botones cuando se ejecuta disableAllControls
|
||
84 | */
|
||
85 | 5550 | nacho | private boolean[] buttonsState = new boolean[2]; |
86 | 5303 | nacho | /**
|
87 | * DisableAllControls ha sido ejecutada si est? a true esta variabled
|
||
88 | */
|
||
89 | 5550 | nacho | private boolean disableAllControls = false; |
90 | /**
|
||
91 | * Factor multiplicador cuando hacemos zoom mas
|
||
92 | */
|
||
93 | private double zoomMas = 0.6; |
||
94 | /**
|
||
95 | * Factor multiplicador cuando hacemos zoom menos
|
||
96 | */
|
||
97 | private double zoomMenos = 1.8; |
||
98 | 5217 | nacho | //**********************End Vars******************************
|
99 | 6641 | caballero | |
100 | 5217 | nacho | //**********************Methods*******************************
|
101 | /**
|
||
102 | * This is the default constructor
|
||
103 | */
|
||
104 | public ZoomControlPanel(boolean rightControl, GeoreferencingDialog dialog) { |
||
105 | super();
|
||
106 | this.rightControl = rightControl;
|
||
107 | this.dialog = dialog;
|
||
108 | initialize(rightControl); |
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * This method initializes this
|
||
113 | 6641 | caballero | *
|
114 | 5217 | nacho | * @return void
|
115 | */
|
||
116 | private void initialize(boolean rightControl) { |
||
117 | 6641 | caballero | |
118 | 5217 | nacho | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
119 | if(rightControl)
|
||
120 | gridBagConstraints1.gridx = 1;
|
||
121 | else
|
||
122 | gridBagConstraints1.gridx = 0;
|
||
123 | gridBagConstraints1.gridy = 0;
|
||
124 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
||
125 | if(rightControl)
|
||
126 | gridBagConstraints.gridx = 0;
|
||
127 | else
|
||
128 | gridBagConstraints.gridx = 1;
|
||
129 | gridBagConstraints.gridy = 0;
|
||
130 | this.setLayout(new GridBagLayout()); |
||
131 | this.setPreferredSize(new java.awt.Dimension(175,142)); |
||
132 | this.setSize(new java.awt.Dimension(175,142)); |
||
133 | this.setLocation(new java.awt.Point(0,0)); |
||
134 | this.add(getPImage(), gridBagConstraints);
|
||
135 | this.add(getPControls(), gridBagConstraints1);
|
||
136 | //Desactivamos el control en la inicializaci?n
|
||
137 | this.setEnabled(false); |
||
138 | } |
||
139 | |||
140 | /**
|
||
141 | * Carga las capas de puntos y de raster georreferenciado
|
||
142 | *
|
||
143 | */
|
||
144 | public void loadLayer() throws InstantiationException{ |
||
145 | //Cargamos las capas
|
||
146 | this.lyrGeoRaster = dialog.getLyrGeoRaster();
|
||
147 | this.lyrPoints = dialog.getLyrPoints();
|
||
148 | 6641 | caballero | |
149 | 5217 | nacho | if(lyrGeoRaster == null || lyrPoints == null) |
150 | throw new InstantiationException("No se ha podido instanciar la capa de puntos o georreferenciada"); |
||
151 | 6641 | caballero | |
152 | 5217 | nacho | } |
153 | 6641 | caballero | |
154 | 5217 | nacho | /**
|
155 | *Llama a la funci?n de pintado del canvas con los par?metros que tenga en ese momento
|
||
156 | */
|
||
157 | public void draw(){ |
||
158 | if(!getDialog().isEnlarge())
|
||
159 | getCanvas().loadBuffer(); |
||
160 | 5370 | nacho | canvas.draw = true;
|
161 | 5217 | nacho | getCanvas().repaint(); |
162 | } |
||
163 | 6641 | caballero | |
164 | 5217 | nacho | /**
|
165 | * Manejo de los controles zoom m?s y zoom menos
|
||
166 | */
|
||
167 | public void actionPerformed(ActionEvent e) { |
||
168 | 5550 | nacho | double zoom = zoomMas;
|
169 | 6641 | caballero | |
170 | 5550 | nacho | if(e.getSource() == bZoomMas)
|
171 | canvas.calcZoom(zoomMas); |
||
172 | 6641 | caballero | |
173 | 5217 | nacho | if(e.getSource() == bZoomMenos){
|
174 | 5550 | nacho | canvas.calcZoom(zoomMenos); |
175 | zoom = zoomMenos; |
||
176 | 5217 | nacho | } |
177 | 6641 | caballero | |
178 | 5550 | nacho | canvas.draw = true;
|
179 | canvas.repaint(); |
||
180 | if(isRightControl())
|
||
181 | lyrPoints.getPoint(dialog.getSelectedPoint()).zoomLeft *= zoom; |
||
182 | else
|
||
183 | lyrPoints.getPoint(dialog.getSelectedPoint()).zoomRight *= zoom; |
||
184 | 6641 | caballero | |
185 | 5217 | nacho | } |
186 | 6641 | caballero | |
187 | 5217 | nacho | /**
|
188 | *Limpia el canvas
|
||
189 | */
|
||
190 | public void clear(){ |
||
191 | canvas.setCleanCanvas(true);
|
||
192 | canvas.repaint(); |
||
193 | } |
||
194 | 6641 | caballero | |
195 | 5303 | nacho | /**
|
196 | * Esta funci?n deshabilita todos los controles y guarda sus valores
|
||
197 | * de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
|
||
198 | * se vuelvan a quedar como estaba
|
||
199 | */
|
||
200 | public void disableAllControls(){ |
||
201 | if(!disableAllControls){
|
||
202 | disableAllControls = true;
|
||
203 | 6641 | caballero | |
204 | 5303 | nacho | //Salvamos los estados
|
205 | buttonsState[0] = getBZoomMas().isEnabled();
|
||
206 | buttonsState[1] = getBZoomMenos().isEnabled();
|
||
207 | 6641 | caballero | |
208 | 5303 | nacho | //Desactivamos controles
|
209 | getBZoomMas().setEnabled(false);
|
||
210 | getBZoomMenos().setEnabled(false);
|
||
211 | } |
||
212 | } |
||
213 | 6641 | caballero | |
214 | 5303 | nacho | /**
|
215 | 6641 | caballero | * Esta funci?n deja los controles como estaban al ejecutar la funci?n
|
216 | 5303 | nacho | * disableAllControls
|
217 | */
|
||
218 | public void restoreControlsValue(){ |
||
219 | if(disableAllControls){
|
||
220 | disableAllControls = false;
|
||
221 | getBZoomMas().setEnabled(buttonsState[0]);
|
||
222 | getBZoomMenos().setEnabled(buttonsState[1]);
|
||
223 | } |
||
224 | } |
||
225 | 5217 | nacho | //**********************End Methods***************************
|
226 | 6641 | caballero | |
227 | 5217 | nacho | //**********************Setters & Getters*********************
|
228 | /**
|
||
229 | * @param viewPort The viewPort to set.
|
||
230 | */
|
||
231 | 5550 | nacho | public void setViewPort(ViewPort viewPort, double zoom) { |
232 | 5217 | nacho | this.viewPort = viewPort;
|
233 | 5550 | nacho | getCanvas().setViewPort(this.viewPort, zoom);
|
234 | 5217 | nacho | } |
235 | 6641 | caballero | |
236 | 5217 | nacho | /**
|
237 | 6641 | caballero | * This method initializes jPanel
|
238 | *
|
||
239 | * @return javax.swing.JPanel
|
||
240 | 5217 | nacho | */
|
241 | private JPanel getPImage() { |
||
242 | if (pImage == null) { |
||
243 | pImage = new JPanel(); |
||
244 | BorderLayout borderLayout = new BorderLayout(); |
||
245 | pImage.setLayout(borderLayout); |
||
246 | pImage.setPreferredSize(new java.awt.Dimension(140,140)); |
||
247 | pImage.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); |
||
248 | pImage.add(getCanvas(), BorderLayout.CENTER);
|
||
249 | } |
||
250 | return pImage;
|
||
251 | } |
||
252 | |||
253 | /**
|
||
254 | * This method initilizes canvas
|
||
255 | * @return CanvasZone
|
||
256 | */
|
||
257 | public CanvasZone getCanvas(){
|
||
258 | if(canvas == null){ |
||
259 | 5818 | nacho | canvas = new CanvasZone(ZoomControlPanel.WIDTH_MINIMG, ZoomControlPanel.HEIGHT_MINIMG, this); |
260 | 5217 | nacho | canvas.setVisible(false);
|
261 | canvas.addMouseListener(canvas); |
||
262 | canvas.addMouseMotionListener(canvas); |
||
263 | } |
||
264 | return canvas;
|
||
265 | } |
||
266 | 6641 | caballero | |
267 | 5217 | nacho | /**
|
268 | 6641 | caballero | * This method initializes jPanel1
|
269 | *
|
||
270 | * @return javax.swing.JPanel
|
||
271 | 5217 | nacho | */
|
272 | private JPanel getPControls() { |
||
273 | if (pControls == null) { |
||
274 | GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
||
275 | gridBagConstraints3.gridx = 0;
|
||
276 | gridBagConstraints3.insets = new java.awt.Insets(5,0,0,0); |
||
277 | gridBagConstraints3.gridy = 1;
|
||
278 | GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
||
279 | gridBagConstraints2.gridx = 0;
|
||
280 | gridBagConstraints2.gridy = 0;
|
||
281 | pControls = new JPanel(); |
||
282 | pControls.setLayout(new GridBagLayout()); |
||
283 | pControls.setPreferredSize(new java.awt.Dimension(33,140)); |
||
284 | pControls.add(getBZoomMas(), gridBagConstraints2); |
||
285 | pControls.add(getBZoomMenos(), gridBagConstraints3); |
||
286 | } |
||
287 | return pControls;
|
||
288 | } |
||
289 | |||
290 | /**
|
||
291 | 6641 | caballero | * This method initializes jButton
|
292 | *
|
||
293 | * @return javax.swing.JButton
|
||
294 | 5217 | nacho | */
|
295 | 5303 | nacho | public JButton getBZoomMas() { |
296 | 5217 | nacho | if (bZoomMas == null) { |
297 | bZoomMas = new JButton(); |
||
298 | bZoomMas.setPreferredSize(new java.awt.Dimension(25,25)); |
||
299 | 7091 | nacho | try{
|
300 | bZoomMas.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/aumentar.png"))); |
||
301 | }catch(NullPointerException e){ |
||
302 | //Sin icono
|
||
303 | } |
||
304 | 5217 | nacho | bZoomMas.addActionListener(this);
|
305 | } |
||
306 | return bZoomMas;
|
||
307 | } |
||
308 | |||
309 | /**
|
||
310 | 6641 | caballero | * This method initializes jButton
|
311 | *
|
||
312 | * @return javax.swing.JButton
|
||
313 | 5217 | nacho | */
|
314 | 5303 | nacho | public JButton getBZoomMenos() { |
315 | 5217 | nacho | if (bZoomMenos == null) { |
316 | bZoomMenos = new JButton(); |
||
317 | bZoomMenos.setPreferredSize(new java.awt.Dimension(25,25)); |
||
318 | 7091 | nacho | try{
|
319 | bZoomMenos.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/disminuir.png"))); |
||
320 | }catch(NullPointerException e){ |
||
321 | //Sin icono
|
||
322 | } |
||
323 | 5217 | nacho | bZoomMenos.addActionListener(this);
|
324 | } |
||
325 | return bZoomMenos;
|
||
326 | } |
||
327 | 6641 | caballero | |
328 | 5217 | nacho | /**
|
329 | * Obtiene true si se trata de un control con los botones de zoom
|
||
330 | * a la derecha y false si los tiene a la izquierda.
|
||
331 | * @return Returns the rightControl.
|
||
332 | */
|
||
333 | public boolean isRightControl() { |
||
334 | return rightControl;
|
||
335 | } |
||
336 | 6641 | caballero | |
337 | 5217 | nacho | /**
|
338 | * Obtiene la capa de imagen georreferenciada.
|
||
339 | * @return Returns the lyrGeoRaster.
|
||
340 | */
|
||
341 | public FLyrGeoRaster getLyrGeoRaster() {
|
||
342 | return lyrGeoRaster;
|
||
343 | } |
||
344 | |||
345 | /**
|
||
346 | * Obtiene la capa de puntos.
|
||
347 | * @return Returns the lyrPoints.
|
||
348 | */
|
||
349 | public FLyrPoints getLyrPoints() {
|
||
350 | try{
|
||
351 | if(lyrPoints == null) |
||
352 | this.loadLayer();
|
||
353 | }catch(InstantiationException e){ |
||
354 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
||
355 | PluginServices.getText(this, "error_capa_puntos")); |
||
356 | } |
||
357 | return lyrPoints;
|
||
358 | } |
||
359 | 6641 | caballero | |
360 | 5217 | nacho | /**
|
361 | * @return Returns the dialog.
|
||
362 | */
|
||
363 | public GeoreferencingDialog getDialog() {
|
||
364 | try{
|
||
365 | if(dialog == null) |
||
366 | this.loadLayer();
|
||
367 | }catch(InstantiationException e){ |
||
368 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
||
369 | PluginServices.getText(this, "error_capa_puntos")); |
||
370 | } |
||
371 | return dialog;
|
||
372 | 6641 | caballero | } |
373 | |||
374 | 5217 | nacho | /**
|
375 | * Asigna el viewPort recalculado
|
||
376 | * @param vp ViewPort
|
||
377 | */
|
||
378 | public void setNewViewPort(ViewPort vp){ |
||
379 | canvas.setNewViewPort(vp); |
||
380 | } |
||
381 | 6641 | caballero | |
382 | 5217 | nacho | /**
|
383 | * Obtiene el viewPort recalculado
|
||
384 | * @return vp ViewPort
|
||
385 | */
|
||
386 | public ViewPort getNewViewPort(){
|
||
387 | return canvas.getNewViewPort();
|
||
388 | } |
||
389 | 6641 | caballero | |
390 | 5217 | nacho | /**
|
391 | * Asigna al canvas la propiedad de visibilidad a verdadero o falso.
|
||
392 | * @param visible true para mostrar el canvas y false para ocultarlo
|
||
393 | */
|
||
394 | public void setVisible(boolean visible){ |
||
395 | canvas.setVisible(visible); |
||
396 | 5370 | nacho | canvas.draw = true;
|
397 | 5217 | nacho | canvas.repaint(); |
398 | } |
||
399 | 6641 | caballero | |
400 | 5217 | nacho | /**
|
401 | * Asigna el punto sobre el que se centrar? el zoom de la minimagen
|
||
402 | * @param pto
|
||
403 | */
|
||
404 | public void setCenterPoint(Point2D pto){ |
||
405 | getCanvas().setCenterPoint(pto); |
||
406 | } |
||
407 | 6641 | caballero | |
408 | 5217 | nacho | /**
|
409 | * Recupera el n?mero de punto que se est? tratando
|
||
410 | * @param n
|
||
411 | */
|
||
412 | public int getNumberPoint(){ |
||
413 | try{
|
||
414 | if(getDialog().getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 0) |
||
415 | return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
||
416 | else
|
||
417 | return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
||
418 | }catch(NullPointerException exc){ |
||
419 | return -1; |
||
420 | } |
||
421 | } |
||
422 | 6641 | caballero | |
423 | 5217 | nacho | /**
|
424 | * Activa o desactiva este panel y todos los que lo componen
|
||
425 | * @param enabled variable booleana para la activaci?n y/o desactivaci?n
|
||
426 | */
|
||
427 | public void setEnabled(boolean enabled){ |
||
428 | this.getBZoomMas().setEnabled(enabled);
|
||
429 | this.getBZoomMenos().setEnabled(enabled);
|
||
430 | this.getCanvas().setEnableEvent(enabled);
|
||
431 | } |
||
432 | 6641 | caballero | |
433 | 5550 | nacho | /**
|
434 | * Obtiene el modificador de escala aplicado a zoom m?s
|
||
435 | * @return
|
||
436 | */
|
||
437 | public double getZoomMas() { |
||
438 | return zoomMas;
|
||
439 | } |
||
440 | |||
441 | /**
|
||
442 | * Obtiene el modificador de escala aplicado a zoom m?s
|
||
443 | * @return
|
||
444 | */
|
||
445 | public double getZoomMenos() { |
||
446 | return zoomMenos;
|
||
447 | } |
||
448 | 6641 | caballero | |
449 | 5217 | nacho | //**********************End Setters & Getters*****************
|
450 | /**
|
||
451 | * Control que representa la zona de dibujado de la ventana. Este se encarga de
|
||
452 | * repintar el contenido sobre el Graphics2D a partir del viewPort que se le pase
|
||
453 | * @author Nacho Brodin (brodin_ign@gva.es)
|
||
454 | */
|
||
455 | public class CanvasZone extends JPanel implements MouseListener, MouseMotionListener{ |
||
456 | 6641 | caballero | |
457 | 5217 | nacho | //**********************Params********************************
|
458 | /**
|
||
459 | * Zoom inicial de la miniimagen
|
||
460 | */
|
||
461 | private int initZoom = 20; |
||
462 | //**********************End Params****************************
|
||
463 | 6641 | caballero | |
464 | 5217 | nacho | //**********************Vars**********************************
|
465 | private ZoomControlPanel zoomControl = null; |
||
466 | private int ancho; |
||
467 | private int alto; |
||
468 | private FLayers flayers = null; |
||
469 | private ViewPort newViewPort = null; |
||
470 | private Point2D centerPoint = null; |
||
471 | private Image dobleBuffer = null; |
||
472 | private BufferedImage imgTmp = null; |
||
473 | private Graphics dbGraphics = null; |
||
474 | 6641 | caballero | |
475 | 5561 | nacho | /**
|
476 | * Variable que estar? a true cuando queremos limpiar el canvas y a false cuando queremos
|
||
477 | * dibujar las capas.
|
||
478 | */
|
||
479 | 5217 | nacho | private boolean cleanCanvas = false; |
480 | /**
|
||
481 | * Cuando el control est? desactivado necesitamos controlar con esta variable que
|
||
482 | 6641 | caballero | * aunque se pinche sobre el canvas no se capture el evento
|
483 | */
|
||
484 | 5217 | nacho | private boolean enableEvent = true; |
485 | 5563 | nacho | |
486 | private Point2D initCrux = null; |
||
487 | 5217 | nacho | /**
|
488 | 5563 | nacho | * Variable que esta a true si estamos arrastrando la cruz por el canvas.
|
489 | 5217 | nacho | */
|
490 | private boolean dragged = false; |
||
491 | 7091 | nacho | private Image redCursor = null; |
492 | |||
493 | private Image blueCursor = null; |
||
494 | 5370 | nacho | /**
|
495 | * Esta variable se usa para informar cuando debe recargarse el buffer de las miniimagenes. Si siempre
|
||
496 | * est? a true no para de llamar al draw de FLyers para que pinte sobre el minicanvas.
|
||
497 | */
|
||
498 | 6641 | caballero | public boolean draw = true; |
499 | 5561 | nacho | /**
|
500 | * Esta variable estar? a false si no queremos que no se pinte la capa de puntos rojos sobre
|
||
501 | * la miniimagenes
|
||
502 | */
|
||
503 | private boolean drawRedCrux = true; |
||
504 | /**
|
||
505 | * Esta variable estar? a false si no queremos que no se pinte la capa de puntos azules sobre
|
||
506 | * la miniimagenes
|
||
507 | */
|
||
508 | private boolean drawBlueCrux = true; |
||
509 | 6641 | caballero | |
510 | 5217 | nacho | //**********************End Vars******************************
|
511 | 6641 | caballero | |
512 | 5217 | nacho | //**********************Classes*******************************
|
513 | class CancellableClass implements Cancellable{ |
||
514 | private boolean cancel = false; |
||
515 | public void setCanceled(boolean canceled) { |
||
516 | this.cancel = canceled;
|
||
517 | } |
||
518 | 6641 | caballero | |
519 | 5217 | nacho | public boolean isCanceled() { |
520 | return this.cancel; |
||
521 | } |
||
522 | } |
||
523 | //**********************End Classes***************************
|
||
524 | 6641 | caballero | |
525 | 5217 | nacho | //**********************Methods*******************************
|
526 | /**
|
||
527 | 6641 | caballero | *
|
528 | 5217 | nacho | */
|
529 | public CanvasZone( int anc,int alt, ZoomControlPanel zc) { |
||
530 | zoomControl = zc; |
||
531 | ancho = anc; |
||
532 | alto = alt; |
||
533 | 7091 | nacho | |
534 | if(redCursor == null){ |
||
535 | try{
|
||
536 | redCursor = new ImageIcon(getClass().getClassLoader().getResource("images/icoRed.png")).getImage(); |
||
537 | }catch(NullPointerException e){ |
||
538 | //Sin icono
|
||
539 | } |
||
540 | } |
||
541 | |||
542 | if(blueCursor == null){ |
||
543 | try{
|
||
544 | 7868 | nacho | blueCursor = new ImageIcon(getClass().getClassLoader().getResource("images/icoBlue.png")).getImage(); |
545 | 7091 | nacho | }catch(NullPointerException e){ |
546 | //Sin icono
|
||
547 | } |
||
548 | } |
||
549 | 6641 | caballero | |
550 | this.setSize(ancho, alto);
|
||
551 | 5217 | nacho | this.setBackground(Color.WHITE); |
552 | 6641 | caballero | |
553 | 5217 | nacho | imgTmp = new BufferedImage(this.ancho, this.alto, BufferedImage.TYPE_INT_ARGB); |
554 | dobleBuffer = new BufferedImage(this.ancho, this.alto, BufferedImage.TYPE_INT_ARGB); |
||
555 | dbGraphics = dobleBuffer.getGraphics(); |
||
556 | } |
||
557 | 6641 | caballero | |
558 | 5217 | nacho | /**
|
559 | * Calcula el zoom dependiendo del factor de escala pasado por
|
||
560 | * par?metro.
|
||
561 | */
|
||
562 | public void calcZoom(double factor){ |
||
563 | Rectangle2D.Double r = new Rectangle2D.Double(); |
||
564 | double nuevoX = centerPoint.getX() -
|
||
565 | ((newViewPort.getExtent().getWidth() * factor) / 2.0);
|
||
566 | double nuevoY = centerPoint.getY() -
|
||
567 | ((newViewPort.getExtent().getHeight() * factor) / 2.0);
|
||
568 | r.x = nuevoX; |
||
569 | r.y = nuevoY; |
||
570 | r.width = newViewPort.getExtent().getWidth() * factor; |
||
571 | r.height = newViewPort.getExtent().getHeight() * factor; |
||
572 | newViewPort.setExtent(r); |
||
573 | 6641 | caballero | newViewPort.refreshExtent(); |
574 | 5217 | nacho | } |
575 | 6641 | caballero | |
576 | 5217 | nacho | /**
|
577 | 5550 | nacho | * Calculamos el viewPort para el zoom de la minimagen
|
578 | * @param vp ViewPort inicial
|
||
579 | * @param center Centro del ViewPort a calcular.
|
||
580 | * @param vpDest ViewPort de destino. Si este es null se crear? un nuevo ViewPort sino se asignar?n los cambios a este.
|
||
581 | * @return
|
||
582 | 5217 | nacho | */
|
583 | 5550 | nacho | public ViewPort initViewPort(ViewPort vp, Point2D center, ViewPort vpDest, double zoom){ |
584 | 6641 | caballero | if(center != null){ |
585 | 5217 | nacho | //Hallamos la relaci?n entre el pixel y las WC a partir de la imagen de la capa
|
586 | double relacionPixelWcWidth = ((vp.getExtent().getMaxX() - vp.getExtent().getMinX()) / initZoom) / ancho;
|
||
587 | double relacionPixelWcHeight = ((vp.getExtent().getMaxY() - vp.getExtent().getMinY()) / initZoom) / alto;
|
||
588 | 6641 | caballero | |
589 | 5217 | nacho | double wcOriginX = center.getX() - ((vp.getImageWidth() * relacionPixelWcWidth) / 2); |
590 | double wcOriginY = center.getY() - ((vp.getImageHeight() * relacionPixelWcHeight) / 2); |
||
591 | 6641 | caballero | |
592 | double wcDstMinX = wcOriginX;
|
||
593 | double wcDstMinY = wcOriginY;
|
||
594 | 5217 | nacho | double wcDstMaxX = wcDstMinX + (vp.getImageWidth()*relacionPixelWcWidth);
|
595 | double wcDstMaxY = wcDstMinY + (vp.getImageHeight()*relacionPixelWcHeight);
|
||
596 | 6641 | caballero | |
597 | 5217 | nacho | double wcDstWidth = wcDstMaxX - wcDstMinX;
|
598 | double wcDstHeight = wcDstMaxY - wcDstMinY;
|
||
599 | 6641 | caballero | |
600 | 5217 | nacho | Rectangle2D ext = new Rectangle2D.Double(wcDstMinX, wcDstMinY, wcDstWidth, wcDstHeight); |
601 | 6641 | caballero | |
602 | 5217 | nacho | if(vpDest == null){ |
603 | newViewPort = vp.cloneViewPort(); |
||
604 | newViewPort.setExtent(ext); |
||
605 | 6641 | caballero | newViewPort.setImageSize(new java.awt.Dimension(ancho, alto));
|
606 | newViewPort.refreshExtent(); |
||
607 | 5550 | nacho | if(zoom != 1 && zoom != 0) |
608 | 5697 | nacho | newViewPort = GeoUtils.calcZoom(newViewPort, zoom); |
609 | 5217 | nacho | return newViewPort;
|
610 | }else{
|
||
611 | vpDest.setExtent(ext); |
||
612 | 6641 | caballero | vpDest.refreshExtent(); |
613 | 5550 | nacho | if(zoom != 1 && zoom != 0) |
614 | 5697 | nacho | vpDest = GeoUtils.calcZoom(vpDest, zoom); |
615 | 5217 | nacho | return vpDest;
|
616 | } |
||
617 | 6641 | caballero | |
618 | 5217 | nacho | } |
619 | return null; |
||
620 | } |
||
621 | 6641 | caballero | |
622 | 5217 | nacho | /**
|
623 | * Dibuja sobre el graphics de la mini imagen la imagen
|
||
624 | * definida en el newViewPort.
|
||
625 | */
|
||
626 | 6641 | caballero | public void loadBuffer(){ |
627 | 5217 | nacho | Graphics2D gTmp = (Graphics2D)imgTmp.getGraphics(); |
628 | 6641 | caballero | |
629 | 5217 | nacho | dbGraphics.setColor( Color.WHITE );
|
630 | dbGraphics.fillRect( 0,0,ancho,alto ); |
||
631 | gTmp.setColor( Color.WHITE );
|
||
632 | gTmp.fillRect( 0,0,ancho,alto ); |
||
633 | 6641 | caballero | |
634 | try{
|
||
635 | if(newViewPort != null){ |
||
636 | 5217 | nacho | //Si no tenemos las capas las cargamos
|
637 | if(flayers == null){ |
||
638 | View theView = null; |
||
639 | try{
|
||
640 | 6880 | cesar | theView = (View)PluginServices.getMDIManager().getActiveWindow();
|
641 | 5217 | nacho | }catch(ClassCastException exc){ |
642 | return;
|
||
643 | } |
||
644 | flayers = theView.getMapControl().getMapContext().getLayers(); |
||
645 | } |
||
646 | 6641 | caballero | |
647 | 5217 | nacho | /*Dibujamos sobre las miniimagenes
|
648 | Forzamos un draw de las capas para dibujar la vista sobre el control de las miniimagenes.
|
||
649 | 6641 | caballero | Como la capa gr?fica est? en FMap esta no aparece en el dibujado de FLayers por los que
|
650 | 5217 | nacho | forzaremos el pintado tambi?n de la capa de puntos sobre nuestro control*/
|
651 | 6641 | caballero | |
652 | 5217 | nacho | Cancellable cancellable = new CancellableClass();
|
653 | if(zoomControl.getDialog().isEnlarge()){
|
||
654 | if(zoomControl.getNumberPoint() != -1){ |
||
655 | 6641 | caballero | draw(new BufferedImage(newViewPort.getImageWidth(), newViewPort.getImageHeight(), BufferedImage.TYPE_INT_ARGB), |
656 | (Graphics2D) dbGraphics,
|
||
657 | 5781 | nacho | newViewPort, |
658 | cancellable , |
||
659 | 6881 | cesar | flayers.getMapContext().getScaleView()); |
660 | 5561 | nacho | if(zoomControl.isRightControl()){
|
661 | if(drawRedCrux)
|
||
662 | zoomControl.getLyrPoints().drawPixelCrux((Graphics2D) dbGraphics, newViewPort, cancellable);
|
||
663 | }else{
|
||
664 | if(drawBlueCrux)
|
||
665 | zoomControl.getLyrPoints().drawMapCrux((Graphics2D) dbGraphics, newViewPort, cancellable);
|
||
666 | } |
||
667 | 6641 | caballero | |
668 | 5217 | nacho | } |
669 | } |
||
670 | 6641 | caballero | |
671 | draw(new BufferedImage(newViewPort.getImageWidth(), newViewPort.getImageHeight(), BufferedImage.TYPE_INT_ARGB), |
||
672 | gTmp, |
||
673 | newViewPort, |
||
674 | cancellable, |
||
675 | 6881 | cesar | flayers.getMapContext().getScaleView()); |
676 | 5561 | nacho | if(zoomControl.isRightControl()){
|
677 | if(drawRedCrux)
|
||
678 | zoomControl.getLyrPoints().drawPixelCrux(gTmp, newViewPort, cancellable); |
||
679 | }else{
|
||
680 | if(drawBlueCrux)
|
||
681 | zoomControl.getLyrPoints().drawMapCrux(gTmp, newViewPort, cancellable); |
||
682 | } |
||
683 | 5217 | nacho | } |
684 | }catch (DriverException e) {
|
||
685 | e.printStackTrace(); |
||
686 | } |
||
687 | } |
||
688 | 6641 | caballero | |
689 | 5217 | nacho | /**
|
690 | 5445 | nacho | * Esta funci?n es una copia de la de Flyers modificada para para dibujar sobre las miniimagenes. En
|
691 | * la miniimagen con los controles a la derecha solo dibujar? el raster a georreferenciar. En la miniimagen
|
||
692 | * con los controles a la izquierda dibujar? la cartograf?a de base.
|
||
693 | 6641 | caballero | * @param image
|
694 | 5445 | nacho | * @param g
|
695 | * @param viewPort
|
||
696 | * @param cancel
|
||
697 | * @param scale
|
||
698 | * @throws DriverException
|
||
699 | */
|
||
700 | public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
||
701 | 6641 | caballero | Cancellable cancel,double scale) throws DriverException { |
702 | 5445 | nacho | for(int i=0;i<flayers.getLayersCount();i++){ |
703 | if (cancel.isCanceled())
|
||
704 | 6641 | caballero | break;
|
705 | 5445 | nacho | FLayer lyr = flayers.getLayer(i); |
706 | 6641 | caballero | |
707 | 5445 | nacho | try{
|
708 | if(zoomControl.isRightControl()){
|
||
709 | if(lyr instanceof FLyrGeoRaster) |
||
710 | lyr.draw(image, g, viewPort, cancel,scale); |
||
711 | }else{
|
||
712 | if (lyr.isVisible()){
|
||
713 | if(!(lyr instanceof FLyrGeoRaster)) |
||
714 | lyr.draw(image, g, viewPort, cancel,scale); |
||
715 | } |
||
716 | } |
||
717 | 6641 | caballero | |
718 | 5445 | nacho | } catch (DriverException e){
|
719 | } |
||
720 | } |
||
721 | } |
||
722 | 6641 | caballero | |
723 | 5445 | nacho | /**
|
724 | 6641 | caballero | *
|
725 | 5217 | nacho | */
|
726 | public void update(Graphics g){ |
||
727 | 5370 | nacho | draw = true;
|
728 | 5217 | nacho | this.paint(g);
|
729 | } |
||
730 | 6641 | caballero | |
731 | 5217 | nacho | /**
|
732 | * Dibuja sobre el Graphics2D pasado el viewPort solicitado a
|
||
733 | * la lista de capas.
|
||
734 | * @param g
|
||
735 | */
|
||
736 | public void paint( Graphics g ) { |
||
737 | if(!cleanCanvas){
|
||
738 | 5370 | nacho | if(draw){
|
739 | loadBuffer(); |
||
740 | draw = false;
|
||
741 | } |
||
742 | 5217 | nacho | g.drawImage(dobleBuffer, 0, 0, null); |
743 | 5556 | nacho | this.invalidate();
|
744 | 5217 | nacho | AdjustGeorefPanel p = zoomControl.getDialog().getConectorPanel().getAdjustGeorefPanel(); |
745 | try{
|
||
746 | 5370 | nacho | if(!this.zoomControl.isRightControl()) |
747 | p.setLZoomLeft("1:"+((int)newViewPort.getScale())); |
||
748 | else
|
||
749 | p.setLZoomRight("1:"+((int)newViewPort.getScale())); |
||
750 | 5217 | nacho | }catch(NullPointerException exc){ |
751 | //No ponemos la escala
|
||
752 | } |
||
753 | }else{
|
||
754 | 5392 | nacho | dbGraphics.setColor( Color.WHITE );
|
755 | dbGraphics.fillRect( 0,0,ancho,alto ); |
||
756 | 5217 | nacho | g.setColor( Color.WHITE );
|
757 | 5370 | nacho | g.fillRect( 0,0,ancho,alto ); |
758 | cleanCanvas = false;
|
||
759 | 5217 | nacho | } |
760 | } |
||
761 | 6641 | caballero | |
762 | 5217 | nacho | /* (non-Javadoc)
|
763 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||
764 | */
|
||
765 | public void mouseClicked(MouseEvent ev) { |
||
766 | 6641 | caballero | |
767 | 5217 | nacho | } |
768 | 6641 | caballero | |
769 | 5217 | nacho | /**
|
770 | * Cuando el rat?n entra dentro del control fijamos el valor de las coordenadas
|
||
771 | * que tiene el punto seleccionado. De esta forma cuando salga del control podr?
|
||
772 | * volver a restaurarlo en caso de que no haya sido cambiado.
|
||
773 | */
|
||
774 | public void mouseEntered(MouseEvent arg0) { |
||
775 | if(isEnableEvent()){
|
||
776 | if(!zoomControl.rightControl)
|
||
777 | zoomControl.getDialog().getPointManager().setCurrentWC(); |
||
778 | else
|
||
779 | zoomControl.getDialog().getPointManager().setCurrentPixelCoord(); |
||
780 | } |
||
781 | } |
||
782 | 6641 | caballero | |
783 | 5217 | nacho | /**
|
784 | * Al sacar el rat?n de la zona de dibujado de la miniimagen restauramos los valores
|
||
785 | 6641 | caballero | * de los JTextField.
|
786 | *
|
||
787 | * Se actualizaran los correspondientes a las coordenadas del mundo real
|
||
788 | 5217 | nacho | * en el caso de que el control tenga botones a la izquierda.
|
789 | 6641 | caballero | *
|
790 | 5217 | nacho | * Se actualizaran los correspondientes a las coordenadas en pixels cuando se trata del control con
|
791 | * botones a la derecha.
|
||
792 | */
|
||
793 | public void mouseExited(MouseEvent arg0) { |
||
794 | if(isEnableEvent()){
|
||
795 | if(!zoomControl.rightControl)
|
||
796 | zoomControl.getDialog().getPointManager().replaceWC(); |
||
797 | else
|
||
798 | zoomControl.getDialog().getPointManager().replacePixelCoord(); |
||
799 | 5561 | nacho | drawRedCrux = drawBlueCrux = true;
|
800 | repaint(); |
||
801 | 5217 | nacho | } |
802 | } |
||
803 | 6641 | caballero | |
804 | 5217 | nacho | /**
|
805 | * Controla la actualizaci?n del valor de un punto en los JTextDialog. Cuando se mueve sobre
|
||
806 | * el panel con controles a la izquierda actualizamos las coordenadas del mapa. Cuando se mueve sobre
|
||
807 | 6641 | caballero | * el panel con controles a la derecha actualizamos las coordenadas de la imagen.
|
808 | 5217 | nacho | */
|
809 | public void mouseMoved(MouseEvent arg0) { |
||
810 | 6641 | caballero | if( isEnableEvent() &&
|
811 | 5217 | nacho | zoomControl.getLyrPoints() != null &&
|
812 | zoomControl.getLyrPoints().getCountPoints() > 0 &&
|
||
813 | this.newViewPort != null && |
||
814 | this.newViewPort.getExtent() != null){ |
||
815 | 6641 | caballero | |
816 | 5217 | nacho | double newWCPointX = this.newViewPort.getExtent().getMinX() + ((arg0.getX() * this.newViewPort.getExtent().getWidth()) / this.getWidth()); |
817 | int ptoSelectY = (int)(this.getHeight() - arg0.getY()); |
||
818 | double newWCPointY = this.newViewPort.getExtent().getMinY() + ((ptoSelectY * this.newViewPort.getExtent().getHeight()) / this.getHeight()); |
||
819 | if(!zoomControl.rightControl){
|
||
820 | zoomControl.getDialog().getPointManager().setTempWC(newWCPointX, newWCPointY); |
||
821 | }else{
|
||
822 | Point2D pixelImg = zoomControl.getLyrGeoRaster().world2Img(newWCPointX, newWCPointY);
|
||
823 | if(pixelImg != null) |
||
824 | zoomControl.getDialog().getPointManager().setTempPixelCoord(pixelImg.getX(), pixelImg.getY()); |
||
825 | 6641 | caballero | else
|
826 | 5217 | nacho | //Si pixelImg es null es que nos hemos salido de la imagen por lo que reponemos los valores originales hasta que vuelva a entrar.
|
827 | 6641 | caballero | zoomControl.getDialog().getPointManager().replacePixelCoord(); |
828 | |||
829 | 5217 | nacho | } |
830 | } |
||
831 | } |
||
832 | 6641 | caballero | |
833 | 5217 | nacho | /**
|
834 | * Al pulsar el rat?n sobre la minimagen permitimos que se pueda desplazar la cruz
|
||
835 | *
|
||
836 | */
|
||
837 | public void mousePressed(MouseEvent ev) { |
||
838 | int cte = 10; |
||
839 | if( (ev.getX() > ((getWidth() >> 1) - cte)) && (ev.getX() < ((getWidth() >> 1) + cte)) && |
||
840 | (ev.getY() > ((getHeight() >> 1) - cte)) && (ev.getY() < ((getHeight() >> 1) + cte))){ |
||
841 | this.dragged = true; |
||
842 | 6641 | caballero | |
843 | 5217 | nacho | try{
|
844 | 5561 | nacho | if(zoomControl.isRightControl()){
|
845 | drawRedCrux = false;
|
||
846 | 5217 | nacho | setCursor(Toolkit.getDefaultToolkit().createCustomCursor(redCursor, new Point(16, 16), "")); |
847 | 5561 | nacho | }else{
|
848 | drawBlueCrux = false;
|
||
849 | 5217 | nacho | setCursor(Toolkit.getDefaultToolkit().createCustomCursor(blueCursor, new Point(16, 16), "")); |
850 | 5561 | nacho | } |
851 | 6641 | caballero | |
852 | 5217 | nacho | zoomControl.loadLayer(); |
853 | initCrux = new Point2D.Double(); |
||
854 | initCrux.setLocation(this.getWidth() / 2, this.getHeight() / 2); |
||
855 | 5370 | nacho | draw = true;
|
856 | 5217 | nacho | repaint(); |
857 | }catch(InstantiationException e){ |
||
858 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
||
859 | PluginServices.getText(this, "error_capa_puntos")); |
||
860 | } |
||
861 | } |
||
862 | } |
||
863 | |||
864 | /* (non-Javadoc)
|
||
865 | * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
|
||
866 | */
|
||
867 | public void mouseReleased(MouseEvent ev) { |
||
868 | if(!dragged)
|
||
869 | return;
|
||
870 | dragged = false;
|
||
871 | View theView = null; |
||
872 | try{
|
||
873 | 6880 | cesar | theView = (View) PluginServices.getMDIManager().getActiveWindow();
|
874 | 5217 | nacho | }catch(ClassCastException exc){ |
875 | return;
|
||
876 | } |
||
877 | ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort(); |
||
878 | setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
||
879 | |||
880 | 6641 | caballero | Point2D point = newViewPort.toMapPoint(ev.getX(), ev.getY());
|
881 | 5217 | nacho | int nPoint = Integer.valueOf(zoomControl.getDialog().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue(); |
882 | |||
883 | FLyrPoints lp = zoomControl.getLyrPoints();//(FLyrPoints)lyr;
|
||
884 | 6641 | caballero | |
885 | 5217 | nacho | if(zoomControl.isRightControl()){ //Control de actualizaci?n de pixel de imagen |
886 | Point2D pixelImg = zoomControl.getLyrGeoRaster().world2Img(point);
|
||
887 | //Point2D pixelImg = zoomControl.getLyrGeoRaster().world2Img(newWCPointX, newWCPointY);
|
||
888 | 6641 | caballero | |
889 | 5217 | nacho | if(pixelImg == null){ |
890 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
||
891 | PluginServices.getText(this, "fuera_de_extent")); |
||
892 | return;
|
||
893 | } |
||
894 | 6641 | caballero | |
895 | zoomControl.getDialog().getPointManager().updateData( nPoint, pixelImg, null,
|
||
896 | 5674 | nacho | zoomControl.getDialog(), null);
|
897 | 5670 | nacho | setCenterPoint(point); |
898 | 5697 | nacho | newViewPort = GeoUtils.shiftExtent(lyrPoints.getCenterPoint(dialog.getSelectedPoint(), false), point, lyrPoints.getMiniExtent(dialog.getSelectedPoint(), false)); |
899 | 5670 | nacho | lyrPoints.setMiniExtent(nPoint - 1, point, newViewPort, false); |
900 | calcZoom(lyrPoints.getZoomLeft(dialog.getSelectedPoint())); |
||
901 | 5217 | nacho | zoomControl.getDialog().getPointManager().setCurrentPixelCoord(); |
902 | }else{ //Control de actualizaci?n de coordenadas del mundo |
||
903 | 5674 | nacho | zoomControl.getDialog().getPointManager().updateData( nPoint, null, point,
|
904 | zoomControl.getDialog(), null);
|
||
905 | 5670 | nacho | setCenterPoint(point); |
906 | 5697 | nacho | newViewPort = GeoUtils.shiftExtent(lyrPoints.getCenterPoint(dialog.getSelectedPoint(), true), point, lyrPoints.getMiniExtent(dialog.getSelectedPoint(), true)); |
907 | 5670 | nacho | lyrPoints.setMiniExtent(nPoint - 1, point, newViewPort, true); |
908 | calcZoom(lyrPoints.getZoomRight(dialog.getSelectedPoint())); |
||
909 | 5217 | nacho | zoomControl.getDialog().getPointManager().setCurrentWC(); |
910 | } |
||
911 | 5670 | nacho | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw(); |
912 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw(); |
||
913 | 6641 | caballero | |
914 | 5370 | nacho | draw = true;
|
915 | 5561 | nacho | drawRedCrux = drawBlueCrux = true;
|
916 | 5217 | nacho | repaint(); |
917 | theView.getMapControl().getMapContext().invalidate(); |
||
918 | } |
||
919 | 6641 | caballero | |
920 | 5217 | nacho | /* (non-Javadoc)
|
921 | * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
|
||
922 | */
|
||
923 | public void mouseDragged(MouseEvent ev) { |
||
924 | this.mouseMoved(ev);
|
||
925 | } |
||
926 | //**********************End Methods***************************
|
||
927 | |||
928 | //**********************Setters & Getters*********************
|
||
929 | /**
|
||
930 | * @param cleanCanvas The cleanCanvas to set.
|
||
931 | */
|
||
932 | public void setCleanCanvas(boolean cleanCanvas) { |
||
933 | this.cleanCanvas = cleanCanvas;
|
||
934 | } |
||
935 | 6641 | caballero | |
936 | 5217 | nacho | /**
|
937 | * Asigna el punto donde se centrar? la vista de la minimagen
|
||
938 | * @param pto Punto central.
|
||
939 | */
|
||
940 | public void setCenterPoint(Point2D pto){ |
||
941 | this.centerPoint = pto;
|
||
942 | } |
||
943 | 6641 | caballero | |
944 | 5217 | nacho | /**
|
945 | * Asigna el viewPort
|
||
946 | * @param vp ViewPort
|
||
947 | */
|
||
948 | 5550 | nacho | public void setViewPort(ViewPort vp, double zoom){ |
949 | this.initViewPort(vp, this.centerPoint, null, zoom); |
||
950 | 5217 | nacho | } |
951 | |||
952 | /**
|
||
953 | * Asigna el viewPort recalculado
|
||
954 | * @param vp ViewPort
|
||
955 | */
|
||
956 | public void setNewViewPort(ViewPort vp){ |
||
957 | this.newViewPort = vp;
|
||
958 | } |
||
959 | 6641 | caballero | |
960 | 5217 | nacho | /**
|
961 | * Obtiene el viewPort recalculado
|
||
962 | * @return vp ViewPort
|
||
963 | */
|
||
964 | public ViewPort getNewViewPort(){
|
||
965 | return this.newViewPort; |
||
966 | } |
||
967 | 6641 | caballero | |
968 | 5217 | nacho | /**
|
969 | * Obtiene el valor del desactivador de eventos sobre el canvas.
|
||
970 | * @return
|
||
971 | */
|
||
972 | public boolean isEnableEvent() { |
||
973 | return enableEvent;
|
||
974 | } |
||
975 | |||
976 | /**
|
||
977 | * Asigna el desactivador de eventos sobre el canvas
|
||
978 | * @param enableEvent
|
||
979 | */
|
||
980 | public void setEnableEvent(boolean enableEvent) { |
||
981 | this.enableEvent = enableEvent;
|
||
982 | } |
||
983 | 6641 | caballero | |
984 | 5217 | nacho | //**********************End Setters & Getters*****************
|
985 | 6641 | caballero | |
986 | 5217 | nacho | } |
987 | } |