Java Code Examples for ij.gui.Toolbar#getToolId()
The following examples show how to use
ij.gui.Toolbar#getToolId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PointSelectionBehavior.java From SNT with GNU General Public License v3.0 | 5 votes |
@Override public void doProcess(final MouseEvent me) { if (me.isConsumed() || Toolbar.getToolId() != Toolbar.WAND) return; final int mouseEventID = me.getID(); /* * It's nice to still be able to zoom with the mouse wheel, so don't * consume this event. */ if (mouseEventID == MouseEvent.MOUSE_WHEEL) return; me.consume(); if (mouseEventID != MouseEvent.MOUSE_CLICKED) return; final Picker picker = univ.getPicker(); final Content c = picker.getPickedContent(me.getX(), me.getY()); if (null == c) return; final Point3d point = picker.getPickPointGeometry(c, me.getX(), me.getY()); final boolean mac = IJ.isMacintosh(); final boolean shift_key_down = (me.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0; final boolean joiner_modifier_down = mac ? ((me.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) : ((me.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { tracerPlugin.clickForTrace(point, joiner_modifier_down); } }); }
Example 2
Source File: DisplayCanvas.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
/** Sets the cursor based on the current tool and cursor location. */ @Override public void setCursor(final int sx, final int sy, final int ox, final int oy) { // copy of ImageCanvas.setCursor without the win==null xMouse = ox; yMouse = oy; final Roi roi = imp.getRoi(); /* * ImageWindow win = imp.getWindow(); if (win==null) return; */ if (IJ.spaceBarDown()) { setCursor(handCursor); return; } switch (Toolbar.getToolId()) { case Toolbar.MAGNIFIER: if (IJ.isMacintosh()) setCursor(defaultCursor); else setCursor(moveCursor); break; case Toolbar.HAND: setCursor(handCursor); break; case ProjectToolbar.SELECT: case ProjectToolbar.PENCIL: setCursor(defaultCursor); break; default: // selection tool if (roi != null && roi.getState() != Roi.CONSTRUCTING && roi.isHandle(sx, sy) >= 0) setCursor(handCursor); else if (Prefs.usePointerCursor || (roi != null && roi.getState() != Roi.CONSTRUCTING && roi.contains(ox, oy))) setCursor(defaultCursor); else setCursor(crosshairCursor); break; } }
Example 3
Source File: DisplayCanvas.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
@Override public void mouseMoved(final MouseEvent me) { super.flags = me.getModifiers(); final int tool = Toolbar.getToolId(); switch (tool) { case Toolbar.POLYLINE: case Toolbar.POLYGON: case Toolbar.ANGLE: super.mouseMoved(me); repaint(); return; } mouse_moved.dispatch(me); }
Example 4
Source File: ProjectToolbar.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
/** Set macro buttons for TrakEM2 in ImageJ's toolbar */ static synchronized public void setProjectToolbar() { if (null == instance) instance = new ProjectToolbar(); // check if macros are installed already MacroInstaller installer = new MacroInstaller(); boolean toolbar_present = false; try { java.awt.event.ActionListener[] al = ij.Menus.getMacrosMenu().getActionListeners(); MacroInstaller minst = null; for (int j=al.length -1; j>-1; j--) { if (al[j] instanceof MacroInstaller) { minst = (MacroInstaller)al[j]; break; } } if (null != minst) { java.lang.reflect.Field f_macroNames = MacroInstaller.class.getDeclaredField("macroNames"); f_macroNames.setAccessible(true); Object ob = f_macroNames.get(minst); if (null != ob) { String[] macroNames = (String[])ob; if (null == macroNames) return; if (macroNames.length > 3 && null != macroNames[0] && 0 == macroNames[0].indexOf("Select and Transform") && null != macroNames[1] && 0 == macroNames[1].indexOf("Freehand") && null != macroNames[2] && 0 == macroNames[2].indexOf("Pen") && null != macroNames[3] && 0 == macroNames[3].indexOf("Align") ) { toolbar_present = true; } } } } catch (Exception e) { // the above is not thread safe, will fail many times because the Display being show is also trying to set the toolbar Utils.log2("Can't check if toolbar is in place."); //IJError.print(e); // if it fails, toolbar_present still is false and thus will result in the macros being installed again. } // sort of a constructor: an embedded macro set if (!toolbar_present) { int tool = Toolbar.getToolId(); final StringBuilder sb_tools = new StringBuilder(); sb_tools.append("macro 'Select and Transform Tool-C000L2242L2363L3494L35b5L46c6L4797L48a8L49b9L5a6aL8acaL5b6bL9bdbL5c5cLacdcLbdcd' {\ncall('ini.trakem2.utils.ProjectToolbar.toolChanged', 'SELECT');\n}\n") .append("macro 'Freehand Tool-C000Lb0c0La1d1L92e2L83f3L74f4L65e5L56d6L47c7L38b8L29a9L2a2aL4a9aL1b2bL5b8bL1c1cL6c7cL0d1dL5d6dL0e0eL3e5eL0f3f' {\ncall('ini.trakem2.utils.ProjectToolbar.toolChanged', 'PENCIL');\n}\n") .append("macro 'Pen Tool-C000L8080L7191L7292L6363L8383La3a3L6464L8484Lb4b4L5555L8585Lb5b5L4646L8686Lc6c6L4747Lc7c7L3838Ld8d8L4949Lc9c9L4a4aLcacaL5b5bLbbbbL5c5cLbcbcL4dcdL5e5eLbebeL5fbf' {\ncall('ini.trakem2.utils.ProjectToolbar.toolChanged', 'PEN');\n}\n") .append("macro 'Brush Tool - C037La077Ld098L6859L4a2fL2f4fL3f99L5e9bL9b98L6888L5e8dL888c' {\ncall('ini.trakem2.utils.ProjectToolbar.toolChanged', 'BRUSH');\n}\n") ; installer.install(sb_tools.toString()); // another call to install erases the previous, so it needs all at the same time Toolbar.getInstance().setTool(tool); } }
Example 5
Source File: ProjectToolbar.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
static public int getToolId() { int tool = Toolbar.getToolId(); if (Toolbar.WAND == tool) return ProjectToolbar.WAND; return tool; }
Example 6
Source File: ProjectToolbar.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
public void mousePressed(MouseEvent me) { int ij_tool = Toolbar.getToolId(); Utils.log2("Tool: " + ij_tool); }