(int dir, Point mousePt)
| 1110 | } |
| 1111 | |
| 1112 | private void doZoom(int dir, Point mousePt) |
| 1113 | { |
| 1114 | int oldZoom = drawingArea.getTileSize(); |
| 1115 | int newZoom = dir < 0 ? (oldZoom / 2) : (oldZoom * 2); |
| 1116 | if (newZoom < 8) { newZoom = 8; } |
| 1117 | if (newZoom > 32) { newZoom = 32; } |
| 1118 | |
| 1119 | if (oldZoom != newZoom) |
| 1120 | { |
| 1121 | // preserve effective mouse position in viewport when changing zoom level |
| 1122 | double f = (double)newZoom / (double)oldZoom; |
| 1123 | Point pos = drawingAreaScroll.getViewport().getViewPosition(); |
| 1124 | int newX = (int)Math.round(mousePt.x * f - (mousePt.x - pos.x)); |
| 1125 | int newY = (int)Math.round(mousePt.y * f - (mousePt.y - pos.y)); |
| 1126 | drawingArea.selectTileSize(newZoom); |
| 1127 | drawingAreaScroll.validate(); |
| 1128 | drawingAreaScroll.getViewport().setViewPosition(new Point(newX, newY)); |
| 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | private void doZoom(int dir) |
| 1133 | { |
no test coverage detected