18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING APPLICATIONS WITH VISUAL JAVABEANS<br />

8. Run the application. Use the map navigation tools that you added earlier to<br />

change the extent of the focus map in the pageLayout component, and observe<br />

that the new extent is drawn on the map component as a red rectangle.<br />

Navigating around the focus map using the map<br />

navigation tools will change the extent of the<br />

focus map in the PageLayoutBean and cause<br />

the MapBean to update. Navigating around the<br />

page layout with the page layout navigation<br />

tools will change the extent of the page layout<br />

(not the extent of the focus map in the<br />

PageLayoutBean), so the MapBean will not<br />

update.<br />

Creating a custom tool<br />

You will create a custom tool that can be added to the ToolbarBean. This tool<br />

will add today’s date as a text element to the PageLayoutBean, at the location of<br />

a mouse click.<br />

The tool will be built as a generic tool so it can work with MapBean and<br />

ToolbarBean as well as the PageLayoutBean.<br />

Custom tools can be built as Java classes that implement the following two<br />

interfaces:<br />

com.esri.arcgis.systemUI.ICommand;<br />

com.esri.arcgis.systemUI.ITool;<br />

1. Create a new file called AddDateCommand.java:<br />

// AddDateCommand.java<br />

import com.esri.arcgis.systemUI.ICommand;<br />

import com.esri.arcgis.systemUI.ITool;<br />

public class AddDateCommand implements ICommand, ITool {<br />

} // end AddDateCommand class<br />

Since this class implements the ICommand and ITool interfaces, it will compile only<br />

after all methods belonging to these interfaces have been implemented.<br />

2. Add implementation for all methods defined in ICommand, as shown below.<br />

The implementation of onCreate and onClick methods will be done in the<br />

next step, so you can leave an empty implementation for now.<br />

320 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!