Revision 3235 trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/ZoomControlPanel.java
ZoomControlPanel.java | ||
---|---|---|
26 | 26 |
import com.iver.andami.PluginServices; |
27 | 27 |
import com.iver.cit.gvsig.fmap.DriverException; |
28 | 28 |
import com.iver.cit.gvsig.fmap.ViewPort; |
29 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
30 | 29 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
31 | 30 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
32 | 31 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
... | ... | |
130 | 129 |
* This method initilizes canvas |
131 | 130 |
* @return CanvasZone |
132 | 131 |
*/ |
133 |
private CanvasZone getCanvas(){
|
|
132 |
public CanvasZone getCanvas(){
|
|
134 | 133 |
if(canvas == null){ |
135 | 134 |
canvas = new CanvasZone(sX, sY, this); |
136 | 135 |
canvas.setVisible(false); |
... | ... | |
328 | 327 |
* repintar el contenido sobre el Graphics2D a partir del viewPort que se le pase |
329 | 328 |
* @author Nacho Brodin (brodin_ign@gva.es) |
330 | 329 |
*/ |
331 |
class CanvasZone extends Canvas implements MouseListener, MouseMotionListener{ |
|
330 |
public class CanvasZone extends Canvas implements MouseListener, MouseMotionListener{
|
|
332 | 331 |
private ZoomControlPanel zoomControl = null; |
333 | 332 |
private int ancho; |
334 | 333 |
private int alto; |
... | ... | |
369 | 368 |
*/ |
370 | 369 |
public void setViewPort(ViewPort vp){ |
371 | 370 |
this.viewPort = vp; |
372 |
this.initViewPort(); |
|
371 |
this.initViewPort(vp, this.centerPoint);
|
|
373 | 372 |
} |
374 | 373 |
|
375 | 374 |
/** |
... | ... | |
402 | 401 |
/** |
403 | 402 |
*Calculamos el viewPort para el zoom de la minimagen |
404 | 403 |
*/ |
405 |
public void initViewPort(){
|
|
406 |
if(centerPoint != null){
|
|
407 |
newViewPort = this.viewPort.cloneViewPort();
|
|
404 |
public ViewPort initViewPort(ViewPort vp, Point2D center){
|
|
405 |
if(center != null){ |
|
406 |
newViewPort = vp.cloneViewPort();
|
|
408 | 407 |
//Hallamos la relaci?n entre el pixel y las WC a partir de la imagen de la capa |
409 |
double relacionPixelWcWidth = ((viewPort.getExtent().getMaxX() - viewPort.getExtent().getMinX()) / initZoom)/ancho;
|
|
410 |
double relacionPixelWcHeight = ((viewPort.getExtent().getMaxY() - viewPort.getExtent().getMinY()) / initZoom)/alto;
|
|
408 |
double relacionPixelWcWidth = ((vp.getExtent().getMaxX() - vp.getExtent().getMinX()) / initZoom)/ancho;
|
|
409 |
double relacionPixelWcHeight = ((vp.getExtent().getMaxY() - vp.getExtent().getMinY()) / initZoom)/alto;
|
|
411 | 410 |
|
412 |
double wcOriginX = centerPoint.getX() - ((viewPort.getImageWidth()*relacionPixelWcWidth)/2);
|
|
413 |
double wcOriginY = centerPoint.getY() - ((viewPort.getImageHeight()*relacionPixelWcHeight)/2);
|
|
411 |
double wcOriginX = center.getX() - ((vp.getImageWidth()*relacionPixelWcWidth)/2);
|
|
412 |
double wcOriginY = center.getY() - ((vp.getImageHeight()*relacionPixelWcHeight)/2);
|
|
414 | 413 |
|
415 | 414 |
double wcDstMinX = wcOriginX; |
416 | 415 |
double wcDstMinY = wcOriginY; |
417 |
double wcDstMaxX = wcDstMinX + (viewPort.getImageWidth()*relacionPixelWcWidth);
|
|
418 |
double wcDstMaxY = wcDstMinY + (viewPort.getImageHeight()*relacionPixelWcHeight);
|
|
416 |
double wcDstMaxX = wcDstMinX + (vp.getImageWidth()*relacionPixelWcWidth);
|
|
417 |
double wcDstMaxY = wcDstMinY + (vp.getImageHeight()*relacionPixelWcHeight);
|
|
419 | 418 |
|
420 | 419 |
double wcDstWidth = wcDstMaxX - wcDstMinX; |
421 | 420 |
double wcDstHeight = wcDstMaxY - wcDstMinY; |
... | ... | |
425 | 424 |
newViewPort.setExtent(ext); |
426 | 425 |
newViewPort.setImageSize(new java.awt.Dimension(ancho, alto)); |
427 | 426 |
newViewPort.setScale(); |
427 |
return newViewPort; |
|
428 | 428 |
} |
429 |
return null; |
|
429 | 430 |
} |
430 | 431 |
|
431 | 432 |
/** |
... | ... | |
467 | 468 |
//dibujamos |
468 | 469 |
|
469 | 470 |
if(zoomControl.getDialog().isEnlarge()){ |
470 |
//System.out.println("-------->"+newViewPort.getExtent().getX()+" "+newViewPort.getExtent().getY()+" "+newViewPort.getExtent().getWidth()+" "+newViewPort.getExtent().getHeight()); |
|
471 | 471 |
flayers.draw(null, (Graphics2D) dbGraphics, newViewPort,new Cancellable() { |
472 | 472 |
public boolean isCanceled() { |
473 | 473 |
return false; |
Also available in: Unified diff