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

Method mouseReleased

ij/src/main/java/ij/gui/ImageCanvas.java:1640–1690  ·  view source on GitHub ↗
(MouseEvent e)

Source from the content-addressed store, hash-verified

1638 }
1639
1640 @AstroImageJ(reason = "Update x/yClicked", modified = true)
1641 public void mouseReleased(MouseEvent e) {
1642 xClicked = e.getX();
1643 yClicked = e.getY();
1644
1645 if (pressTimer!=null) {
1646 pressTimer.cancel();
1647 pressTimer = null;
1648 }
1649
1650 int ox = offScreenX(e.getX());
1651 int oy = offScreenY(e.getY());
1652 Overlay overlay = imp.getOverlay();
1653 if ((overlay!=null||showAllOverlay!=null) && ox==mousePressedX && oy==mousePressedY) {
1654 boolean cmdDown = IJ.isMacOSX() && e.isMetaDown();
1655 Roi roi = imp.getRoi();
1656 if (roi!=null && roi.getBounds().width==0)
1657 roi=null;
1658 if ((e.isAltDown()||e.isControlDown()||cmdDown) && roi==null) {
1659 if (activateOverlayRoi(ox, oy))
1660 return;
1661 } else if ((System.currentTimeMillis()-mousePressedTime)>250L && !drawingTool()) { // long press
1662 if (activateOverlayRoi(ox,oy))
1663 return;
1664 }
1665
1666 }
1667
1668 PlugInTool tool = Toolbar.getPlugInTool();
1669 if (tool!=null) {
1670 tool.mouseReleased(imp, e);
1671 if (e.isConsumed()) return;
1672 }
1673 flags = e.getModifiers();
1674 flags &= ~InputEvent.BUTTON1_MASK; // make sure button 1 bit is not set
1675 flags &= ~InputEvent.BUTTON2_MASK; // make sure button 2 bit is not set
1676 flags &= ~InputEvent.BUTTON3_MASK; // make sure button 3 bit is not set
1677 Roi roi = imp.getRoi();
1678 if (roi != null) {
1679 Rectangle r = roi.getBounds();
1680 int type = roi.getType();
1681 if ((r.width==0 || r.height==0)
1682 && !(type==Roi.POLYGON||type==Roi.POLYLINE||type==Roi.ANGLE||type==Roi.LINE)
1683 && !(roi instanceof TextRoi)
1684 && roi.getState()==roi.CONSTRUCTING
1685 && type!=roi.POINT)
1686 imp.deleteRoi();
1687 else
1688 roi.handleMouseUp(e.getX(), e.getY());
1689 }
1690 }
1691
1692 private boolean activateOverlayRoi(int ox, int oy) {
1693 int currentImage = -1;

Callers 1

mouseReleasedMethod · 0.95

Calls 15

offScreenXMethod · 0.95
offScreenYMethod · 0.95
isMacOSXMethod · 0.95
getBoundsMethod · 0.95
activateOverlayRoiMethod · 0.95
drawingToolMethod · 0.95
getPlugInToolMethod · 0.95
mouseReleasedMethod · 0.95
getTypeMethod · 0.95
getStateMethod · 0.95
handleMouseUpMethod · 0.95
isAltDownMethod · 0.80

Tested by

no test coverage detected