Zooms the focused rectangle. @param more show more @param quick context switch (no animation)
(final boolean more, final boolean quick)
| 183 | * @param quick context switch (no animation) |
| 184 | */ |
| 185 | private void zoom(final boolean more, final boolean quick) { |
| 186 | gui.updating = !quick; |
| 187 | zoomIn = more; |
| 188 | |
| 189 | // choose zooming rectangle |
| 190 | final int hist = gui.notify.hist; |
| 191 | if(more) { |
| 192 | rectHist[hist] = focused; |
| 193 | mainRect = rectHist[hist]; |
| 194 | } else { |
| 195 | mainRect = rectHist[hist + 1]; |
| 196 | } |
| 197 | if(mainRect == null) mainRect = new MapRect(0, 0, getWidth(), getHeight()); |
| 198 | |
| 199 | // reset data & start zooming |
| 200 | final BufferedImage tmpMap = zoomMap; |
| 201 | zoomMap = mainMap; |
| 202 | mainMap = tmpMap; |
| 203 | focused = null; |
| 204 | |
| 205 | // create new context nodes |
| 206 | refreshLayout(); |
| 207 | |
| 208 | // calculate zooming speed (slower for large zooming scales) |
| 209 | if(mainRect.w > 0 && mainRect.h > 0) { |
| 210 | zoomSpeed = (int) (StrictMath.log(64.0d * getWidth() / mainRect.w) + |
| 211 | StrictMath.log(64.0d * getHeight() / mainRect.h)); |
| 212 | } |
| 213 | |
| 214 | if(quick) { |
| 215 | gui.updating = false; |
| 216 | focus(); |
| 217 | repaint(); |
| 218 | } else { |
| 219 | zoomStep = ZOOMSIZE; |
| 220 | new Thread(() -> { |
| 221 | focused = null; |
| 222 | |
| 223 | // run zooming |
| 224 | while(zoomStep > 1) { |
| 225 | Performance.sleep(zoomSpeed); |
| 226 | --zoomStep; |
| 227 | repaint(); |
| 228 | } |
| 229 | // wait until current painting is finished |
| 230 | while(gui.painting) Performance.sleep(zoomSpeed); |
| 231 | |
| 232 | // remove old rectangle and repaint map |
| 233 | zoomStep = 0; |
| 234 | gui.updating = false; |
| 235 | focus(); |
| 236 | repaint(); |
| 237 | }).start(); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * Finds the rectangle at the cursor position. |
no test coverage detected