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 />

4. Call the createOverviewSymbol from the buildAndShow() method, after the call<br />

setting label editing to manual:<br />

// Set label editing to manual.<br />

toc.setLabelEdit(esriTOCControlEdit.esriTOCControlManual);<br />

// Create symbol used to draw overview on the MapBean.<br />

createOverviewSymbol();<br />

// Add popup menu items.<br />

. . .<br />

5. In the event listener for IPageLayoutControlEvents added in the<br />

addEventListeners() method earlier, get a reference to the pageLayout<br />

component’s focus map. Store the extent of the focusMap in the<br />

currentExtent member variable. This extent will be used to draw the overview<br />

rectangle on the map component. To achieve this, add the lines of code<br />

below, after loading the map documents and setting its extent in the<br />

onPageLayoutReplaced event handler:<br />

pageLayout.addIPageLayoutControlEventsListener(<br />

new IPageLayoutControlEventsAdapter() {<br />

public void onPageLayoutReplaced(<br />

IPageLayoutControlEventsOnPageLayoutReplacedEvent evt)<br />

throws IOException{<br />

map.loadMxFile(pageLayout.getDocumentFilename(), null, null);<br />

map.setExtent(map.getFullExtent());<br />

focusMap = new Map(pageLayout.getActiveView().getFocusMap());<br />

currentExtent = focusMap.getExtent();<br />

}<br />

});<br />

6. The default events of the PageLayoutBean are the<br />

IPageLayoutControlEvents. These events do not tell you when the extent of<br />

the map within the data frame changes. To do this you will trap the<br />

ITransformEvents of the PageLayoutBean focus map. Add the following<br />

event listeners to listen to the DisplayTransformation object’s<br />

visibleBoundsUpdated event.<br />

The visibleBoundsUpdated event is triggered whenever the extent of the map<br />

is changed and is used to set the IEnvelope to the new visible bounds of the<br />

map. By refreshing the MapBean you force it to redraw the shape on its display.<br />

Modify the listener you edited in the last step, as shown below:<br />

pageLayout.addIPageLayoutControlEventsListener(<br />

new IPageLayoutControlEventsAdapter() {<br />

public void onPageLayoutReplaced(<br />

IPageLayoutControlEventsOnPageLayoutReplacedEvent evt)<br />

throws IOException{<br />

map.loadMxFile(pageLayout.getDocumentFilename(), null, null);<br />

map.setExtent(map.getFullExtent());<br />

focusMap = new Map(pageLayout.getActiveView().getFocusMap());<br />

currentExtent = focusMap.getExtent();<br />

318 • <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!