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

Method modifyRoi

ij/src/main/java/ij/gui/Roi.java:1664–1704  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1662 }
1663
1664 void modifyRoi() {
1665 if (previousRoi==null || previousRoi.modState==NO_MODS || imp==null)
1666 return;
1667 if (type==POINT || previousRoi.getType()==POINT) {
1668 if (type==POINT && previousRoi.getType()==POINT) {
1669 addPoint();
1670 } else if (isArea() && previousRoi.getType()==POINT && previousRoi.modState==SUBTRACT_FROM_ROI)
1671 subtractPoints();
1672 return;
1673 }
1674 Roi originalRoi = (Roi)previousRoi.clone();
1675 Roi previous = (Roi)previousRoi.clone();
1676 previous.modState = NO_MODS;
1677 ShapeRoi s1 = null;
1678 ShapeRoi s2 = null;
1679 if (previousRoi instanceof ShapeRoi)
1680 s1 = (ShapeRoi)previousRoi;
1681 else
1682 s1 = new ShapeRoi(previousRoi);
1683 if (this instanceof ShapeRoi)
1684 s2 = (ShapeRoi)this;
1685 else
1686 s2 = new ShapeRoi(this);
1687 if (previousRoi.modState==ADD_TO_ROI)
1688 s1.or(s2);
1689 else
1690 s1.not(s2);
1691 previousRoi.modState = NO_MODS;
1692 Roi roi2 = s1.trySimplify();
1693 if (roi2 == null) return;
1694 if (roi2!=null)
1695 roi2.copyAttributes(previousRoi);
1696 imp.setRoi(roi2);
1697 RoiManager rm = RoiManager.getRawInstance();
1698 if (rm!=null && rm.getCount()>0) {
1699 Roi[] rois = rm.getSelectedRoisAsArray();
1700 if (rois!=null && rois.length==1 && rois[0].equals(originalRoi))
1701 rm.runCommand("update");
1702 }
1703 setPreviousRoi(previous);
1704 }
1705
1706 void addPoint() {
1707 if (!(type==POINT && previousRoi.getType()==POINT)) {

Callers 5

handleMouseUpMethod · 0.95
updateMethod · 0.95
handleMouseUpMethod · 0.80
handleMouseUpMethod · 0.80
finishPolygonMethod · 0.80

Calls 15

addPointMethod · 0.95
isAreaMethod · 0.95
subtractPointsMethod · 0.95
orMethod · 0.95
notMethod · 0.95
trySimplifyMethod · 0.95
copyAttributesMethod · 0.95
getRawInstanceMethod · 0.95
getCountMethod · 0.95
runCommandMethod · 0.95
setPreviousRoiMethod · 0.95

Tested by

no test coverage detected