MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / restoreRoi

Method restoreRoi

ij/src/main/java/ij/ImagePlus.java:2373–2395  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 1

runMethod · 0.80

Calls 10

getToolIdMethod · 0.95
drawMethod · 0.95
getPreviousRoiMethod · 0.95
getBoundsMethod · 0.95
isSmallerMethod · 0.95
cloneMethod · 0.95
cloneMethod · 0.65
notifyListenersMethod · 0.45
setImageMethod · 0.45
setLocationMethod · 0.45

Tested by

no test coverage detected