18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH VISUAL JAVABEANS<br />

Drawing an overview rectangle on the MapBean<br />

You will now use the map component as an overview window and draw on its<br />

display the current extent of the focus map within the pageLayout component.<br />

As you navigate around the data within the data frame of the pageLayout component,<br />

you will see the map component’s overview window update.<br />

1. Add the following imports to MapViewerFrame.java for classes used in this<br />

step:<br />

import com.esri.arcgis.beans.map.IMapControlEvents2Adapter;<br />

import com.esri.arcgis.beans.map.IMapControlEvents2OnAfterDrawEvent;<br />

import com.esri.arcgis.beans.pagelayout.<br />

IPageLayoutControlEventsOnPageLayoutReplacedEvent;<br />

import com.esri.arcgis.carto.Map;<br />

import com.esri.arcgis.carto.esriViewDrawPhase;<br />

import com.esri.arcgis.display.DisplayTransformation;<br />

import com.esri.arcgis.display.ITransformEventsAdapter;<br />

import com.esri.arcgis.display.ITransformEventsVisibleBoundsUpdatedEvent;<br />

import com.esri.arcgis.display.RgbColor;<br />

import com.esri.arcgis.display.SimpleFillSymbol;<br />

import com.esri.arcgis.display.SimpleLineSymbol;<br />

import com.esri.arcgis.geometry.IEnvelope;<br />

2. Add the following class members to MapViewerFrame:<br />

public class MapViewerFrame extends JFrame {<br />

SimpleFillSymbol fillSymbol; // The symbol used to draw the envelope<br />

IEnvelope currentExtent; // The envelope drawn on the MapBean<br />

Map focusMap;<br />

// The PageLayoutBean's focus map<br />

. . .<br />

PageLayoutBean pageLayout;<br />

3. Create a new private method called createOverviewSymbol(). This is where<br />

you will create the symbol used in the map control to represent the extent of<br />

the data in the pageLayout Bean. Add the following method:<br />

private void createOverviewSymbol() throws IOException{<br />

RgbColor color = new RgbColor();<br />

color.setRed(255);<br />

color.setGreen(0);<br />

color.setBlue(0);<br />

color.setTransparency((byte)255);<br />

SimpleLineSymbol outline = new SimpleLineSymbol();<br />

outline.setWidth(15);<br />

outline.setColor(color);<br />

fillSymbol = new SimpleFillSymbol();<br />

}<br />

color.setTransparency((byte) 0);<br />

fillSymbol.setColor(color);<br />

fillSymbol.setOutline(outline);<br />

Chapter 6 • <strong>Developer</strong> scenarios • 317

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

Saved successfully!

Ooh no, something went wrong!