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

Method grow

ij/src/main/java/ij/gui/Roi.java:905–949  ·  view source on GitHub ↗
(int sx, int sy)

Source from the content-addressed store, hash-verified

903 }
904
905 protected void grow(int sx, int sy) {
906 if (clipboard!=null) return;
907 int xNew = ic.offScreenX2(sx);
908 int yNew = ic.offScreenY2(sy);
909 if (type==RECTANGLE) {
910 if (xNew < 0) xNew = 0;
911 if (yNew < 0) yNew = 0;
912 }
913 if (constrain) {
914 // constrain selection to be square
915 if (!center)
916 {growConstrained(xNew, yNew); return;}
917 int dx, dy, d;
918 dx = xNew - x;
919 dy = yNew - y;
920 if (dx<dy)
921 d = dx;
922 else
923 d = dy;
924 xNew = x + d;
925 yNew = y + d;
926 }
927 if (center) {
928 width = Math.abs(xNew - startX)*2;
929 height = Math.abs(yNew - startY)*2;
930 x = startX - width/2;
931 y = startY - height/2;
932 } else {
933 width = Math.abs(xNew - startX);
934 height = Math.abs(yNew - startY);
935 x = (xNew>=startX)?startX:startX - width;
936 y = (yNew>=startY)?startY:startY - height;
937 if (type==RECTANGLE) {
938 if ((x+width) > xMax) width = xMax-x;
939 if ((y+height) > yMax) height = yMax-y;
940 }
941 }
942 updateClipRect();
943 imp.draw(clipX, clipY, clipWidth, clipHeight);
944 oldX = x;
945 oldY = y;
946 oldWidth = width;
947 oldHeight = height;
948 bounds = null;
949 }
950
951 private void growConstrained(int xNew, int yNew) {
952 int dx = xNew - startX;

Callers 7

handleMouseDragMethod · 0.95
rankMethod · 0.45
drawPlotObjectMethod · 0.45
countPlotPointsInRectMethod · 0.45
filterFloatMethod · 0.45
resetOutOfRoiMethod · 0.45
mouseClickedMethod · 0.45

Calls 6

growConstrainedMethod · 0.95
updateClipRectMethod · 0.95
offScreenX2Method · 0.45
offScreenY2Method · 0.45
absMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected