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

Method mousePressed

ij/src/main/java/ij/gui/Toolbar.java:1236–1328  ·  view source on GitHub ↗
(final MouseEvent e)

Source from the content-addressed store, hash-verified

1234 }
1235
1236 public void mousePressed(final MouseEvent e) {
1237 boolean disablePopup = false;
1238 int x = e.getX();
1239 if (inGap(x))
1240 return;
1241 final int newTool = toolID(x);
1242 if (newTool==getNumTools()-1) {
1243 showSwitchPopupMenu(e);
1244 return;
1245 }
1246 if (!isValidTool(newTool))
1247 return;
1248 if (menus[newTool]!=null && menus[newTool].getItemCount()>0) {
1249 menus[newTool].show(e.getComponent(), e.getX(), e.getY());
1250 return;
1251 }
1252 int flags = e.getModifiers();
1253 boolean isRightClick = e.isPopupTrigger()||(!IJ.isMacintosh()&&(flags&Event.META_MASK)!=0);
1254 boolean doubleClick = newTool==current && (System.currentTimeMillis()-mouseDownTime)<=DOUBLE_CLICK_THRESHOLD;
1255 mouseDownTime = System.currentTimeMillis();
1256 if (!doubleClick || isRightClick) {
1257 triggerPopupMenu(newTool, e, isRightClick, false);
1258 if (isRightClick) mouseDownTime = 0L;
1259 } else if(!isRightClick) { //double click
1260 if (isMacroTool(current)) {
1261 String name = names[current].endsWith(" ")?names[current]:names[current]+" ";
1262 tools[current].runMacroTool(name+"Options");
1263 return;
1264 }
1265 if (isPlugInTool(current)) {
1266 tools[current].showOptionsDialog();
1267 return;
1268 }
1269 ImagePlus imp = WindowManager.getCurrentImage();
1270 switch (current) {
1271 case RECTANGLE:
1272 if (rectType==ROUNDED_RECT_ROI)
1273 IJ.doCommand("Rounded Rect Tool...");
1274 else {
1275 disablePopup = true;
1276 IJ.doCommand("Roi Defaults...");
1277 }
1278 break;
1279 case OVAL:
1280 showBrushDialog();
1281 break;
1282 case MAGNIFIER:
1283 if (imp!=null) {
1284 ImageCanvas ic = imp.getCanvas();
1285 if (ic!=null) ic.unzoom();
1286 }
1287 break;
1288 case LINE: case POLYLINE: case FREELINE:
1289 if (current==LINE && arrowMode) {
1290 IJ.doCommand("Arrow Tool...");
1291 } else
1292 IJ.runPlugIn("ij.plugin.frame.LineWidthAdjuster", "");
1293 break;

Callers

nothing calls this directly

Calls 15

inGapMethod · 0.95
toolIDMethod · 0.95
getNumToolsMethod · 0.95
showSwitchPopupMenuMethod · 0.95
isValidToolMethod · 0.95
isMacintoshMethod · 0.95
triggerPopupMenuMethod · 0.95
isMacroToolMethod · 0.95
isPlugInToolMethod · 0.95
getCurrentImageMethod · 0.95
doCommandMethod · 0.95
showBrushDialogMethod · 0.95

Tested by

no test coverage detected