nip
Class Tool

java.lang.Object
  extended by nip.Tool
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public abstract class Tool
extends java.lang.Object
implements java.awt.event.ActionListener, javax.swing.event.MouseInputListener

The Tool class is an abstract class which, when extended, provides NIP with the information needed to communicate with a tool. It does nothing on its own; the methods here are merely a way for the tool to interact with a NIP instance. The classes which extend it must make all the calls necessary to actually manipulate the NIP images.

Author:
Jonathon Lundy June 2009

Constructor Summary
Tool()
           
 
Method Summary
abstract  void actionNameCalled(java.lang.String name)
          When a command in the Method menu is pressed in the NIP instance, this method is called, with the parameter corresponding to the name of the command clicked upon (this will be one of the Strings in the array returned by getEventNames).
 void actionPerformed(java.awt.event.ActionEvent e)
          When a Method menu command is chosen, this method gets the name of that command and passes that string to the actionNameCalled method.
abstract  java.lang.String[] getEventNames()
          This method returns an array of Strings which correspond to the names of commands that will appear in the NIP Methods menu.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent arg0)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent arg0)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tool

public Tool()
Method Detail

getEventNames

public abstract java.lang.String[] getEventNames()
This method returns an array of Strings which correspond to the names of commands that will appear in the NIP Methods menu. The names need not be related to method names, but should be as self-explanatory as possible. This method is most easily implemented as follows: return new String[] = {"Option 1", "Option 2", ...}; Note: To avoid errors, a method that wishes to display no methods in the Methods menu should return a new String[0]() instead of null.

Returns:
An array of String objects containing the names of commands.

actionNameCalled

public abstract void actionNameCalled(java.lang.String name)
When a command in the Method menu is pressed in the NIP instance, this method is called, with the parameter corresponding to the name of the command clicked upon (this will be one of the Strings in the array returned by getEventNames). The implementation of this class will determine how the tool should respond when a command is pressed. It can be implemented by a chain of if-else if branches, one corresponding to each possible command.

Parameters:
name -

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
When a Method menu command is chosen, this method gets the name of that command and passes that string to the actionNameCalled method. This works as is and should not be overridden unless there's a good reason to do so.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent arg0)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent arg0)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener