@@ -0,0 +1,2883 @@
+//%0A// PanActivator.java%0A//%0A%0A/*%0AImageJ software for multidimensional image processing and analysis.%0A%0ACopyright (c) 2010, ImageJDev.org.%0AAll rights reserved.%0A%0ARedistribution and use in source and binary forms, with or without%0Amodification, are permitted provided that the following conditions are met:%0A    * Redistributions of source code must retain the above copyright%0A      notice, this list of conditions and the following disclaimer.%0A    * Redistributions in binary form must reproduce the above copyright%0A      notice, this list of conditions and the following disclaimer in the%0A      documentation and/or other materials provided with the distribution.%0A    * Neither the names of the ImageJDev.org developers nor the%0A      names of its contributors may be used to endorse or promote products%0A      derived from this software without specific prior written permission.%0A%0ATHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22%0AAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE%0AIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE%0AARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE%0ALIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR%0ACONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF%0ASUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS%0AINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN%0ACONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)%0AARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE%0APOSSIBILITY OF SUCH DAMAGE.%0A*/%0A%0Apackage imagej.core.tools.global;%0A%0Aimport imagej.display.event.key.KyPressedEvent;%0Aimport imagej.display.event.key.KyReleasedEvent;%0Aimport imagej.tool.AbstractTool;%0Aimport imagej.tool.ITool;%0Aimport imagej.tool.Tool;%0Aimport imagej.tool.ToolService;%0A%0A/**%0A * Tool for activating the pan tool in response to the space bar.%0A * %0A * @author Curtis Rueden%0A */%0A@Tool(name = %22Pan Activator%22, global = true)%0Apublic class PanActivator extends AbstractTool %7B%0A%0A%09/** Key used to activate pan tool. */%0A%09private static final char KEY = ' ';%0A%0A%09/** Previously active tool, from before pan key was held. */%0A%09private ITool priorTool;%0A%0A%09@Override%0A%09public void onKeyDown(final KyPressedEvent evt) %7B%0A%09%09if (evt.getCharacter() != KEY) return;%0A%09%09final ToolService toolService =%0A%09%09%09evt.getContext().getService(ToolService.class);%0A%09%09final ITool activeTool = toolService.getActiveTool();%0A%09%09final ITool panTool = toolService.getTool(%22Pan%22);%0A%09%09if (activeTool == panTool) return;%0A%09%09priorTool = activeTool;%0A%09%09toolService.setActiveTool(panTool);%0A%09%7D%0A%0A%09@Override%0A%09public void onKeyUp(final KyReleasedEvent evt) %7B%0A%09%09if (evt.getCharacter() != KEY) return;%0A%09%09final ToolService toolService =%0A%09%09%09evt.getContext().getService(ToolService.class);%0A%09%09toolService.setActiveTool(priorTool);%0A%09%7D%0A%0A%7D%0A

Enable pan tool when space is pressed.