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

Method isHandle

ij/src/main/java/ij/gui/Roi.java:1591–1616  ·  view source on GitHub ↗

Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.

(int sx, int sy)

Source from the content-addressed store, hash-verified

1589 /** Returns a handle number if the specified screen coordinates are
1590 inside or near a handle, otherwise returns -1. */
1591 public int isHandle(int sx, int sy) {
1592 if (clipboard!=null || ic==null) return -1;
1593 double mag = ic.getMagnification();
1594 int margin = IJ.getScreenSize().width>1280?5:3;
1595 int size = getHandleSize()+margin;
1596 int halfSize = size/2;
1597 double x = getXBase();
1598 double y = getYBase();
1599 double width = getFloatWidth();
1600 double height = getFloatHeight();
1601 int sx1 = screenXD(x) - halfSize;
1602 int sy1 = screenYD(y) - halfSize;
1603 int sx3 = screenXD(x+width) - halfSize;
1604 int sy3 = screenYD(y+height) - halfSize;
1605 int sx2 = sx1 + (sx3 - sx1)/2;
1606 int sy2 = sy1 + (sy3 - sy1)/2;
1607 if (sx>=sx1&&sx<=sx1+size&&sy>=sy1&&sy<=sy1+size) return 0;
1608 if (sx>=sx2&&sx<=sx2+size&&sy>=sy1&&sy<=sy1+size) return 1;
1609 if (sx>=sx3&&sx<=sx3+size&&sy>=sy1&&sy<=sy1+size) return 2;
1610 if (sx>=sx3&&sx<=sx3+size&&sy>=sy2&&sy<=sy2+size) return 3;
1611 if (sx>=sx3&&sx<=sx3+size&&sy>=sy3&&sy<=sy3+size) return 4;
1612 if (sx>=sx2&&sx<=sx2+size&&sy>=sy3&&sy<=sy3+size) return 5;
1613 if (sx>=sx1&&sx<=sx1+size&&sy>=sy3&&sy<=sy3+size) return 6;
1614 if (sx>=sx1&&sx<=sx1+size&&sy>=sy2&&sy<=sy2+size) return 7;
1615 return -1;
1616 }
1617
1618 protected void mouseDownInHandle(int handle, int sx, int sy) {
1619 state = MOVING_HANDLE;

Callers 5

mousePressedMethod · 0.95
setCursorMethod · 0.95
mousePressedMethod · 0.95
handleRoiMouseDownMethod · 0.95
setCursorMethod · 0.95

Calls 9

getScreenSizeMethod · 0.95
getHandleSizeMethod · 0.95
getXBaseMethod · 0.95
getYBaseMethod · 0.95
getFloatWidthMethod · 0.95
getFloatHeightMethod · 0.95
screenXDMethod · 0.95
screenYDMethod · 0.95
getMagnificationMethod · 0.45

Tested by

no test coverage detected