<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ojwiki.soldin.de/index.php?action=history&amp;feed=atom&amp;title=Converting_a_CursorTool_to_a_PlugIn</id>
	<title>Converting a CursorTool to a PlugIn - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ojwiki.soldin.de/index.php?action=history&amp;feed=atom&amp;title=Converting_a_CursorTool_to_a_PlugIn"/>
	<link rel="alternate" type="text/html" href="https://ojwiki.soldin.de/index.php?title=Converting_a_CursorTool_to_a_PlugIn&amp;action=history"/>
	<updated>2026-04-20T14:18:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://ojwiki.soldin.de/index.php?title=Converting_a_CursorTool_to_a_PlugIn&amp;diff=326&amp;oldid=prev</id>
		<title>Mentaer: Created page with &#039;This is a useful class. It wraps a CursorTool with a PlugIn interface. For example, you can use it to convert the InfoTool into a PlugIn which you can then add to the right-click…&#039;</title>
		<link rel="alternate" type="text/html" href="https://ojwiki.soldin.de/index.php?title=Converting_a_CursorTool_to_a_PlugIn&amp;diff=326&amp;oldid=prev"/>
		<updated>2009-10-18T21:47:54Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;This is a useful class. It wraps a CursorTool with a PlugIn interface. For example, you can use it to convert the InfoTool into a PlugIn which you can then add to the right-click…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a useful class. It wraps a CursorTool with a PlugIn interface. For example, you can use it to convert the InfoTool into a PlugIn which you can then add to the right-click menu on the map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package com.vividsolutions.jcs.jump;&lt;br /&gt;
&lt;br /&gt;
import java.awt.Point;&lt;br /&gt;
import java.awt.event.MouseEvent;&lt;br /&gt;
&lt;br /&gt;
import com.vividsolutions.jts.util.Assert;&lt;br /&gt;
import com.vividsolutions.jump.workbench.plugin.PlugInContext;&lt;br /&gt;
import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;&lt;br /&gt;
import com.vividsolutions.jump.workbench.ui.LayerViewPanel;&lt;br /&gt;
import com.vividsolutions.jump.workbench.ui.cursortool.CursorTool;&lt;br /&gt;
&lt;br /&gt;
public class FUTURE_CursorToolToPlugInAdapter extends AbstractPlugIn {&lt;br /&gt;
    private CursorTool tool;&lt;br /&gt;
&lt;br /&gt;
    public FUTURE_CursorToolToPlugInAdapter(CursorTool tool) {&lt;br /&gt;
        this.tool = tool;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public boolean execute(PlugInContext context) throws Exception {&lt;br /&gt;
        Assert.isTrue(context.getLayerViewPanel() != null);&lt;br /&gt;
        Assert.isTrue(p(context) != null);&lt;br /&gt;
        tool.activate(context.getLayerViewPanel());&lt;br /&gt;
        try {&lt;br /&gt;
            doClick(tool, p(context).x, p(context).y, context.getLayerViewPanel());&lt;br /&gt;
        }&lt;br /&gt;
        finally {&lt;br /&gt;
            tool.deactivate();&lt;br /&gt;
        }&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void doClick(CursorTool tool, int x, int y, LayerViewPanel panel) {&lt;br /&gt;
        tool.mousePressed(createEvent(x, y, panel));&lt;br /&gt;
        tool.mouseReleased(createEvent(x, y, panel));&lt;br /&gt;
        tool.mouseClicked(createEvent(x, y, panel));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public String getName() {&lt;br /&gt;
        return tool.getName();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private static MouseEvent createEvent(int x, int y, LayerViewPanel panel) {&lt;br /&gt;
        return new MouseEvent(panel, 0, 0, MouseEvent.BUTTON1_MASK, &lt;br /&gt;
                x, y, 1, false, MouseEvent.BUTTON1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private Point p(PlugInContext context) {&lt;br /&gt;
        return context.getLayerViewPanel().getLastClickedPoint();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mentaer</name></author>
	</entry>
</feed>