()
| 2371 | } |
| 2372 | |
| 2373 | public void restoreRoi() { |
| 2374 | if (Toolbar.getToolId()==Toolbar.POINT && PointRoi.savedPoints!=null) { |
| 2375 | roi = (Roi)PointRoi.savedPoints.clone(); |
| 2376 | draw(); |
| 2377 | roi.notifyListeners(RoiListener.MODIFIED); |
| 2378 | return; |
| 2379 | } |
| 2380 | Roi previousRoi = Roi.getPreviousRoi(); |
| 2381 | if (previousRoi!=null) { |
| 2382 | Roi pRoi = previousRoi; |
| 2383 | Rectangle r = pRoi.getBounds(); |
| 2384 | if (r.width<=width||r.height<=height||(r.x<width&&r.y<height)||isSmaller(pRoi)) { // will it (mostly) fit in this image? |
| 2385 | roi = (Roi)pRoi.clone(); |
| 2386 | roi.setImage(this); |
| 2387 | if (r.x>=width || r.y>=height || (r.x+r.width)<0 || (r.y+r.height)<0) // does it need to be moved? |
| 2388 | roi.setLocation((width-r.width)/2, (height-r.height)/2); |
| 2389 | else if (r.width==width && r.height==height) // is it the same size as the image |
| 2390 | roi.setLocation(0, 0); |
| 2391 | draw(); |
| 2392 | roi.notifyListeners(RoiListener.MODIFIED); |
| 2393 | } |
| 2394 | } |
| 2395 | } |
| 2396 | |
| 2397 | boolean isSmaller(Roi r) { |
| 2398 | ImageProcessor mask = r.getMask(); |
no test coverage detected