(int newTool, MouseEvent e, boolean isRightClick, boolean isLongPress)
| 1159 | } |
| 1160 | |
| 1161 | public void triggerPopupMenu(int newTool, MouseEvent e, boolean isRightClick, boolean isLongPress) { |
| 1162 | mpPrevious = current; |
| 1163 | if (isMacroTool(newTool)) { |
| 1164 | String name = names[newTool]; |
| 1165 | if (newTool==UNUSED || name.contains("Unused Tool")) |
| 1166 | return; |
| 1167 | if (name.indexOf("Action Tool")!=-1) { |
| 1168 | if (e.isPopupTrigger()||e.isMetaDown()) { |
| 1169 | name = name.endsWith(" ")?name:name+" "; |
| 1170 | tools[newTool].runMacroTool(name+"Options"); |
| 1171 | } else { |
| 1172 | //drawTool(newTool, true); |
| 1173 | //IJ.wait(50); |
| 1174 | drawTool(newTool, false); |
| 1175 | runMacroTool(newTool); |
| 1176 | } |
| 1177 | return; |
| 1178 | } else { |
| 1179 | name = name.endsWith(" ")?name:name+" "; |
| 1180 | tools[newTool].runMacroTool(name+"Selected"); |
| 1181 | } |
| 1182 | } |
| 1183 | if (!isLongPress) |
| 1184 | setTool2(newTool); |
| 1185 | int x = e.getX(); |
| 1186 | int y = e.getY(); |
| 1187 | if (current==RECTANGLE && isRightClick) { |
| 1188 | rectItem.setState(rectType==RECT_ROI); |
| 1189 | roundRectItem.setState(rectType==ROUNDED_RECT_ROI); |
| 1190 | rotatedRectItem.setState(rectType==ROTATED_RECT_ROI); |
| 1191 | if (IJ.isMacOSX()) IJ.wait(10); |
| 1192 | rectPopup.show(e.getComponent(),x,y); |
| 1193 | mouseDownTime = 0L; |
| 1194 | } |
| 1195 | if (current==OVAL && isRightClick) { |
| 1196 | ovalItem.setState(ovalType==OVAL_ROI); |
| 1197 | ellipseItem.setState(ovalType==ELLIPSE_ROI); |
| 1198 | brushItem.setState(ovalType==BRUSH_ROI); |
| 1199 | if (IJ.isMacOSX()) IJ.wait(10); |
| 1200 | ovalPopup.show(e.getComponent(),x,y); |
| 1201 | mouseDownTime = 0L; |
| 1202 | } |
| 1203 | if (current==POINT && isRightClick) { |
| 1204 | pointItem.setState(!multiPointMode); |
| 1205 | multiPointItem.setState(multiPointMode); |
| 1206 | if (IJ.isMacOSX()) IJ.wait(10); |
| 1207 | pointPopup.show(e.getComponent(),x,y); |
| 1208 | mouseDownTime = 0L; |
| 1209 | } |
| 1210 | if (isLine(current) && isRightClick) { |
| 1211 | straightLineItem.setState(lineType==LINE&&!arrowMode); |
| 1212 | polyLineItem.setState(lineType==POLYLINE); |
| 1213 | freeLineItem.setState(lineType==FREELINE); |
| 1214 | arrowItem.setState(lineType==LINE&&arrowMode); |
| 1215 | if (IJ.isMacOSX()) IJ.wait(10); |
| 1216 | linePopup.show(e.getComponent(),x,y); |
| 1217 | mouseDownTime = 0L; |
| 1218 | } |
no test coverage detected