Revision 9524 branches/piloto3d/libraries/libFMap/src/com/iver/cit/gvsig/fmap/ViewPort.java
ViewPort.java | ||
---|---|---|
97 | 97 |
private double dist3pixel; |
98 | 98 |
private double scale; |
99 | 99 |
private Rectangle2D cliprect; |
100 |
private boolean adjustableExtent=true; |
|
100 | 101 |
|
101 | 102 |
/** |
102 | 103 |
* Crea un nuevo ViewPort. |
... | ... | |
109 | 110 |
} |
110 | 111 |
|
111 | 112 |
/** |
113 |
* Sets the adjustable option, so the extent is automatically adjusted to view aspect. |
|
114 |
* |
|
115 |
* @param boolean Adjustable. |
|
116 |
*/ |
|
117 |
public void setAdjustable(boolean adjustable) { |
|
118 |
adjustableExtent = adjustable; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
112 | 122 |
* A?ade un ViewPortListener al extentListener. |
113 | 123 |
* |
114 | 124 |
* @param arg0 ViewPortListener. |
... | ... | |
116 | 126 |
* @return True si ha sido a?adida correctamente. |
117 | 127 |
*/ |
118 | 128 |
public boolean addViewPortListener(ViewPortListener arg0) { |
119 |
return listeners.add(arg0); |
|
129 |
if (!listeners.contains(arg0)) |
|
130 |
return listeners.add(arg0); |
|
131 |
return false; |
|
120 | 132 |
} |
121 | 133 |
|
134 |
|
|
122 | 135 |
/** |
123 | 136 |
* Borra el ViewPortListener que se pasa como par?metro delos |
124 | 137 |
* extentListener. |
... | ... | |
443 | 456 |
|
444 | 457 |
adjustedExtent = new Rectangle2D.Double(); |
445 | 458 |
|
446 |
if (escalaX < escalaY) { |
|
459 |
if (adjustableExtent) { |
|
460 |
if (escalaX < escalaY) { |
|
461 |
scale = escalaX; |
|
462 |
newHeight = imageSize.getHeight() / scale; |
|
463 |
adjustedExtent.setRect(xCenter - (extent.getWidth() / 2.0), |
|
464 |
yCenter - (newHeight / 2.0), extent.getWidth(), newHeight); |
|
465 |
} else { |
|
466 |
scale = escalaY; |
|
467 |
newWidth = imageSize.getWidth() / scale; |
|
468 |
adjustedExtent.setRect(xCenter - (newWidth / 2.0), |
|
469 |
yCenter - (extent.getHeight() / 2.0), newWidth, |
|
470 |
extent.getHeight()); |
|
471 |
} |
|
472 |
escalado.setToScale(scale, -scale); |
|
473 |
} |
|
474 |
else { // adjusted is same as extent |
|
447 | 475 |
scale = escalaX; |
448 |
newHeight = imageSize.getHeight() / scale; |
|
449 |
adjustedExtent.setRect(xCenter - (extent.getWidth() / 2.0), |
|
450 |
yCenter - (newHeight / 2.0), extent.getWidth(), newHeight); |
|
451 |
} else { |
|
452 |
scale = escalaY; |
|
453 |
newWidth = imageSize.getWidth() / scale; |
|
454 |
adjustedExtent.setRect(xCenter - (newWidth / 2.0), |
|
455 |
yCenter - (extent.getHeight() / 2.0), newWidth, |
|
456 |
extent.getHeight()); |
|
476 |
adjustedExtent.setFrame(extent); |
|
477 |
escalado.setToScale(escalaX, -escalaY); |
|
457 | 478 |
} |
458 | 479 |
|
459 | 480 |
translacion.setToTranslation(-getAdjustedExtent().getX(), |
460 | 481 |
-getAdjustedExtent().getY() - getAdjustedExtent().getHeight()); |
461 |
escalado.setToScale(scale, -scale); |
|
462 | 482 |
|
463 | 483 |
AffineTransform offsetTrans = new AffineTransform(); |
464 | 484 |
offsetTrans.setToTranslation(offset.getX(), offset.getY()); |
... | ... | |
540 | 560 |
} |
541 | 561 |
|
542 | 562 |
/** |
543 |
* Devuelve la unidad de medida. |
|
563 |
* Devuelve la unidad de medida en la que queremos realizar nuestras mediciones y |
|
564 |
* en la que se nos mostrar? toda la informaci?n. |
|
544 | 565 |
* |
545 | 566 |
* @return Returns the distanceUnits. |
546 | 567 |
*/ |
... | ... | |
549 | 570 |
} |
550 | 571 |
|
551 | 572 |
/** |
552 |
* Inserta la unidad de medida. |
|
573 |
* Inserta la unidad de medida en la que queremos realizar nuestras mediciones y |
|
574 |
* en la que se nos mostrar? toda la informaci?n. |
|
553 | 575 |
* |
554 | 576 |
* @param distanceUnits The distanceUnits to set. |
555 | 577 |
*/ |
... | ... | |
558 | 580 |
} |
559 | 581 |
|
560 | 582 |
/** |
561 |
* Devuelve la unidad de medida del mapa. |
|
583 |
* Devuelve la unidad de medida del mapa, es la unidad de medida en la que est? la cartogr?fia que cargamos, |
|
584 |
* normalmente en metros. |
|
562 | 585 |
* |
563 | 586 |
* @return Returns the mapUnits. |
564 | 587 |
*/ |
... | ... | |
567 | 590 |
} |
568 | 591 |
|
569 | 592 |
/** |
570 |
* Inserta la unidad de medida del mapa. |
|
593 |
* Inserta la unidad de medida del mapa, es la unidad de medida en la que est? la cartogr?fia que cargamos, |
|
594 |
* normalmente en metros. |
|
571 | 595 |
* |
572 | 596 |
* @param mapUnits The mapUnits to set. |
573 | 597 |
*/ |
... | ... | |
804 | 828 |
if (xml.contains("backColor")) { |
805 | 829 |
vp.setBackColor(StringUtilities.string2Color(xml.getStringProperty( |
806 | 830 |
"backColor"))); |
831 |
}else { |
|
832 |
vp.setBackColor(Color.white); |
|
807 | 833 |
} |
808 | 834 |
|
809 | 835 |
if (xml.contains("clipX")) { |
Also available in: Unified diff