|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.esri.arcgis.controls.BaseCommand com.esri.arcgis.controls.BaseTool
public class BaseTool
This is a helper class for creating custom tools. It implements the ITool interface and
exteds the BaseCommand class.
It forces the user to implement the OnCreate method.
public class BaseTest extends BaseTool
{
public BaseTest() {
bitmapPath = "icons/identify.bmp";
cursorPath = "icons/identify.cur";
caption = "Identify";
category = "Commands";
message = "Identifies the geographic features or place you click on";
name = "CustomCommands_Identify";
toolTip = "Identify";
enabled = true;
}
Then this Base test can be used as a tool and added to the ToolBarBean. Here toolbar
is the ToolBarBean.
toolbar.addItem(new BaseTest(),0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly);
Field Summary | |
---|---|
protected String |
cursorPath
Specify the location of the cursor file for your tool. |
protected boolean |
deactivate
Activate or De-Activate the tool. |
protected boolean |
m_oncontextmenu
The context menu. |
Fields inherited from class com.esri.arcgis.controls.BaseCommand |
---|
bitmapPath, caption, category, enabled, helpFile, message, name, toolTip |
Constructor Summary | |
---|---|
BaseTool()
Creates a new instance of BaseTool |
Method Summary | |
---|---|
boolean |
deactivate()
Causes the tool to no longer be the active tool. |
int |
getCursor()
The mouse pointer for this tool. |
int |
getCursorFromLocation(String filename)
It return the cursor from the given file location. |
boolean |
onContextMenu(int param,
int param1)
Context menu event occured at the given xy location. |
void |
onDblClick()
Occurs when a mouse button is double clicked when this tool is active. |
void |
onKeyDown(int param,
int param1)
Occurs when a key on the keyboard is pressed when this tool is active. |
void |
onKeyUp(int param,
int param1)
Occurs when a key on the keyboard is released when this tool is active. |
void |
onMouseDown(int param,
int param1,
int param2,
int param3)
Occurs when a mouse button is pressed when this tool is active. |
void |
onMouseMove(int param,
int param1,
int param2,
int param3)
Occurs when the mouse is moved when this tool is active. |
void |
onMouseUp(int param,
int param1,
int param2,
int param3)
Occurs when a mouse button is released when this tool is active. |
void |
refresh(int param)
Occurs when a screen display in the application is refreshed. |
Methods inherited from class com.esri.arcgis.controls.BaseCommand |
---|
getBitmap, getCaption, getCategory, getHelpContextID, getHelpFile, getMessage, getName, getTooltip, isChecked, isEnabled, onClick, onCreate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String cursorPath
protected boolean deactivate
protected boolean m_oncontextmenu
Constructor Detail |
---|
public BaseTool()
Method Detail |
---|
public void onMouseDown(int param, int param1, int param2, int param3)
button specifies which mouse button is pressed. The button argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the mouse buttons are pressed. The values for button are as follows:
1 Left button
2 Right button
3 Left and Right buttons
4 Middle button
5 Left and Middle buttons
6 Right and Middle buttons
7 All buttons
Shift indicates whether the Shift key, Ctrl key, or Alt key is pressed when the mouse button is pressed. The Shift argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the keys are pressed. The values for Shift are as follows:
0 No key pressed
1 Shift key pressed
2 Ctrl key pressed
3 Shift and Ctrl keys pressed
4 Alt key pressed
5 Shift and Alt keys pressed
6 Ctrl and Atl keys pressed
7 Shift, Ctrl, and Alt keys pressed
X is the X coordinate, in device units, where the mouse button was pressed.
Y is the Y coordinate, in device units, where the mouse button was pressed.
When implementing ITool to create a custom tool, write the code that performs the action when the left mouse button is pressed when this tool is the active tool in the OnMouseDown method.
onMouseDown
in interface ITool
button
- The button (in)shift
- The shift (in)x
- The x (in)y
- The y (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void refresh(int param)
hDC is the handle to the display context which just got refreshed in the application.
When implementing ITool to create a custom tool, write the code in the Refresh method that performs some action when a screen display in the application is refreshed while this tool is the active tool. When the current screen display in the application is refreshed, the handle to the device context that is associated with that screen display is passed into the Refresh method as an argument.
refresh
in interface ITool
hdc
- The hdc (A COM typedef) (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void onDblClick()
When implementing ITool to create a custom tool, write the code that performs the action when a mouse button is double-clicked when this tool is the active tool in the OnDblClick method.
onDblClick
in interface ITool
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void onKeyUp(int param, int param1)
keyCode specifies which key on the keyboard was released.
Shift indicates whether the Shift key, Ctrl key, or Alt key was pressed when the mouse button was pressed. 0 for no keys pressed. 1 for Shift key pressed. 2 for Ctrl key pressed. 4 for Alt key pressed. If both the Shift key and the Ctrl key were pressed, Shift would be 3. If all three keys were pressed, Shift would be 7.
When implementing ITool to create a custom tool, write the code that performs the action when a key on the keyboard is released when this tool is the active tool in the OnKeyUp method.
onKeyUp
in interface ITool
keyCode
- The keyCode (in)shift
- The shift (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void onMouseMove(int param, int param1, int param2, int param3)
button specifies which mouse button was pressed while moving the mouse. The button argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the mouse buttons are pressed. The values for button are as follows:
1 Left button
2 Right button
3 Left and Right buttons
4 Middle button
5 Left and Middle buttons
6 Right and Middle buttons
7 All buttons
Shift indicates whether the Shift key, Ctrl key, or Alt key is pressed when the mouse is moved. The Shift argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the keys are pressed. The values for Shift are as follows:
0 No key pressed
1 Shift key pressed
2 Ctrl key pressed
3 Shift and Ctrl keys pressed
4 Alt key pressed
5 Shift and Alt keys pressed
6 Ctrl and Atl keys pressed
7 Shift, Ctrl, and Alt keys pressed
X is the X coordinate, in device units, of the mouse location.
Y is the Y coordinate, in device units, of the mouse location.
When implementing ITool to create a custom tool, write the code that performs the action when the mouse is moved when this tool is the active tool in the OnMouseMove method.
onMouseMove
in interface ITool
button
- The button (in)shift
- The shift (in)x
- The x (in)y
- The y (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void onMouseUp(int param, int param1, int param2, int param3)
button specifies which mouse button is released. The button argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the mouse buttons are pressed. The values for button are as follows:
1 Left button
2 Right button
3 Left and Right buttons
4 Middle button
5 Left and Middle buttons
6 Right and Middle buttons
7 All buttons
Shift indicates whether the Shift key, Ctrl key, or Alt key is pressed when the mouse button is released. The Shift argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the keys are pressed. The values for Shift are as follows:
0 No key pressed
1 Shift key pressed
2 Ctrl key pressed
3 Shift and Ctrl keys pressed
4 Alt key pressed
5 Shift and Alt keys pressed
6 Ctrl and Atl keys pressed
7 Shift, Ctrl, and Alt keys pressed
X is the X coordinate, in device units, where the mouse button was released.
Y is the Y coordinate, in device units, where the mouse button was released.
When implementing ITool to create a custom tool, write the code that performs the action when a mouse button is released when this tool is the active tool in the OnMouseUp method.
onMouseUp
in interface ITool
button
- The button (in)shift
- The shift (in)x
- The x (in)y
- The y (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public boolean deactivate()
When implementing ITool to create a custom tool, add some logic to the Deactivate method to specify whether this tool can be deactivated. If ITool_Deactivate is set to False, the default, you cannot interact with any other tools because this tool cannot be interrupted by another tool.
deactivate
in interface ITool
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void onKeyDown(int param, int param1)
keyCode specifies which key on the keyboard was pressed.
Shift indicates whether the Shift key, Ctrl key, or Alt key was pressed when the mouse button was pressed. 0 for no keys pressed. 1 for Shift key pressed. 2 for Ctrl key pressed. 4 for Alt key pressed. If both the Shift key and the Ctrl key were pressed, Shift would be 3. If all three keys were pressed, Shift would be 7.
When implementing ITool to create a custom tool, write the code that performs the action when a key on the keyboard is pressed when this tool is the active tool in the OnKeyDown method.
onKeyDown
in interface ITool
keyCode
- The keyCode (in)shift
- The shift (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public boolean onContextMenu(int param, int param1)
X is the X coordinate, in device units, where the right mouse button was pressed.
Y is the Y coordinate, in device units, where the right mouse button was pressed.
When implementing ITool to create a custom tool, write code to display a custom context menu when the right mouse button is pressed when this tool is the active tool in the OnContext method.
If your tool displays a custom context menu, it should let the application know that it handled the OnContextMenu event by returning True from the OnContext function. If you don't do this, the standard context menu will be displayed after your custom context menu.
This method does not fire in ArcGIS Engine. A context menu is implemented using IToolbarMenu in ArcGIS Engine as illustrated by the ControlsEditingSketchContextMenu command.
onContextMenu
in interface ITool
x
- The x (in)y
- The y (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public int getCursor()
When implementing ITool to create a custom tool, use the Cursor property to set the mouse pointer of the tool.
getCursor
in interface ITool
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public int getCursorFromLocation(String filename)
filename
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |