Changeset 2602 in josm for trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
- Timestamp:
- 2009-12-10T16:34:13+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r2592 r2602 133 133 // To avoid issues when the user tries to zoom in on the image borders, this point is not calculated 134 134 // again if there was less than 1.5seconds since the last event. 135 System.out.println(e);136 135 if (e.getWhen() - lastTimeForMousePoint > 1500 || mousePointInImg == null) { 137 136 lastTimeForMousePoint = e.getWhen(); … … 535 534 536 535 private Rectangle calculateDrawImageRectangle(Rectangle visibleRect) { 537 Dimension size = getSize(); 536 return calculateDrawImageRectangle(visibleRect, new Rectangle(0, 0, getSize().width, getSize().height)); 537 } 538 539 /** 540 * calculateDrawImageRectangle 541 * 542 * @param imgRect the part of the image that should be drawn (in image coordinates) 543 * @param compRect the part of the component where the image should be drawn (in component coordinates) 544 * @return the part of compRect with the same width/height ratio as the image 545 */ 546 static Rectangle calculateDrawImageRectangle(Rectangle imgRect, Rectangle compRect) { 538 547 int x, y, w, h; 539 548 x = 0; 540 549 y = 0; 541 w = size.width;542 h = size.height;543 544 int wFact = w * visibleRect.height;545 int hFact = h * visibleRect.width;550 w = compRect.width; 551 h = compRect.height; 552 553 int wFact = w * imgRect.height; 554 int hFact = h * imgRect.width; 546 555 if (wFact != hFact) { 547 556 if (wFact > hFact) { 548 w = hFact / visibleRect.height;549 x = ( size.width - w) / 2;557 w = hFact / imgRect.height; 558 x = (compRect.width - w) / 2; 550 559 } else { 551 h = wFact / visibleRect.width;552 y = ( size.height - h) / 2;553 } 554 } 555 return new Rectangle(x ,y, w, h);560 h = wFact / imgRect.width; 561 y = (compRect.height - h) / 2; 562 } 563 } 564 return new Rectangle(x + compRect.x, y + compRect.y, w, h); 556 565 } 557 566
Note:
See TracChangeset
for help on using the changeset viewer.