Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Methods to write a Tool

gaghi wrote:
my plugin should be something like that:

public class Test extends SimpleTools{
   public Test{
   //leave here empty?
   }

  public void myMethod(){
  //do stuff
  }
}
Oh okay - you are making a Tool! A plug-in can actually do several things; the Tools (as you know) interact with the map, the IOp thing I talked about is how you add a new "operation" to perform when you right click on something.

So I think the way it works is this...
public Test() {
   super( MOUSE ); // ie say you are interested in MOUSE events
}

You can combine things like super( MOUSE | WHEEL ), the javadocs have the details ...

If you are intersted in MOUSE then you can start to fill in methods like ...
   protected void onMouseDoubleClicked( MapMouseEvent e );
   protected void onMousePressed( MapMouseEvent e );
   ...etc...
I think that when i press the button in the toolbar the plugin should start.
My plugin has just this class.
What the tool does depends on how you defined it in your XML (ie on the extensions tab of the MANIFEST.MF editor).

Here is the example of the Info Tool:
<extension-point id="infoDisplay" name="infoDisplay" schema="schema/infoDisplay.exsd"/>
   <extension
         point="net.refractions.udig.project.ui.tool">
         <modalTool
               categoryId="net.refractions.udig.tool.category.info"
               class="net.refractions.udig.tool.info.InfoTool"
               cursor="default"
               icon="icons/etool16/info_mode.gif"
               id="net.refractions.udig.tool.info.infoMode"
               name="%info.name"
               onToolbar="true"
               toolCursorId="infoCursor"
               tooltip="%info.tooltip">
            <cursor
                  hotspotY="5"
                  hotspotX="5"
                  image="icons/pointer/info_source.png"/>
         </modalTool>
There are a couple kinds of tools:
- modalTools; takes over the entire MapEditor when the user clicks on it, only one modalTool can be on at a time
- actionTool; does one thing when the user clicks on it
- backgroundTool; watches what is going on - is always active, used to track mouse lat / lon position for example
Are you using an IOp? I'm sorry..am i using what? i'm new to all this. i followed some tutorials, books; but i've still so much to learn.
Jody


Back to the top