64
Building ArcGIS Engine Applications with Building ArcGIS Engine Applications with Visual Visual-Java Beans Java Beans Divesh Goyal Divesh Goyal Ranjit Iyer Ranjit Iyer Developer Summit 2007 Developer Summit 2007 1

Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Building ArcGIS Engine Applications with Building ArcGIS Engine Applications with VisualVisual--Java BeansJava Beans

Divesh GoyalDivesh GoyalRanjit IyerRanjit Iyer

Developer Summit 2007Developer Summit 2007 11

Page 2: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Introductions …Introductions …

•• Who are we?Who are we?ArcGIS Engine Java Dev team membersArcGIS Engine Java Dev team members–– ArcGIS Engine Java Dev team members.ArcGIS Engine Java Dev team members.

•• Who are you?Who are you?–– ArcGIS Desktop developers?ArcGIS Desktop developers?p pp p–– MapObjects Java developers?MapObjects Java developers?–– Current ArcGIS Engine developers?Current ArcGIS Engine developers?

ff–– Target Platforms?Target Platforms?–– Preferred IDE?Preferred IDE?

Developer Summit 2007Developer Summit 2007 22

Page 3: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Our assumptionsOur assumptions

•• You are familiar with Java AWT or SwingYou are familiar with Java AWT or Swing•• You have some experience with ArcObjectsYou have some experience with ArcObjects•• You have some experience with ArcObjectsYou have some experience with ArcObjects•• You are excited to be here!You are excited to be here!

Developer Summit 2007Developer Summit 2007 33

Page 4: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

AgendaAgenda

•• Introduction Introduction •• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Customizing your applicationCustomizing your application•• Avoiding common pitfallsAvoiding common pitfalls•• Avoiding common pitfallsAvoiding common pitfalls•• Optimizing DisplayOptimizing Display•• Deploying your applicationDeploying your application•• Deploying your applicationDeploying your application

Developer Summit 2007Developer Summit 2007 44

Page 5: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Overview of ArcGIS Engine JavaOverview of ArcGIS Engine Java

•• Java SDK for developing cross platform desktop GIS Java SDK for developing cross platform desktop GIS ApplicationsApplicationsApplications.Applications.

•• Collection of object libraries called ‘arcobjects’ for Collection of object libraries called ‘arcobjects’ for mapping, visualization, data management and GIS mapping, visualization, data management and GIS pp g, , gpp g, , ganalysis.analysis.

•• Create stand alone GIS apps or Embed GIS functions in Create stand alone GIS apps or Embed GIS functions in existing applicationsexisting applications

Developer Summit 2007Developer Summit 2007 55

Page 6: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

ArcGIS Engine CapabilitiesArcGIS Engine Capabilities

•• 2D & 3D Visualization2D & 3D Visualizationwith Visualwith Visual--Java BeansJava Beans–– with Visualwith Visual--Java BeansJava Beans

•• Data creation and analysisData creation and analysis–– data formats supported by ArcGIS Desktopdata formats supported by ArcGIS Desktoppp y ppp y p

•• GeoprocessingGeoprocessing–– invoke tools and modelsinvoke tools and models

•• Map authoring Map authoring –– create and edit .mxd, .lyr filescreate and edit .mxd, .lyr files

Ad d bili i i h E iAd d bili i i h E i•• Advanced capabilities with ExtensionsAdvanced capabilities with Extensions

Developer Summit 2007Developer Summit 2007 66

Page 7: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

ArcGIS Engine ExtensionsArcGIS Engine Extensions

•• Spatial Spatial •• 3D3D•• 3D3D•• Geodatabase UpdateGeodatabase Update•• NetworkNetwork•• NetworkNetwork•• Data InteroperabilityData Interoperability•• SchematicsSchematics•• SchematicsSchematics•• MaplexMaplex•• TrackingTrackingTrackingTracking•• StreetMap USAStreetMap USA

Developer Summit 2007Developer Summit 2007 77

Page 8: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

ArchitectureArchitecture

Java Proxies & Visual JavaBeansJava Proxies & Visual JavaBeansJava Proxies & Visual JavaBeansJava Proxies & Visual JavaBeans

InteropInterop BridgeBridge

ArcObjects

Wi d / S l i / Li

Developer Summit 2007Developer Summit 2007 88

Windows / Solaris / Linux

Page 9: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

What are Visual Java Beans?What are Visual Java Beans?

•• Visual components Visual components to build GUIto build GUIto build GUI to build GUI

–– MapMap–– PageLayoutPageLayoutg yg y–– GlobeGlobe–– SceneScene–– ToolbarToolbar–– TOCTOC–– SymbologySymbology

Developer Summit 2007Developer Summit 2007 99

SymbologySymbology

Page 10: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

… but what are they really?… but what are they really?

•• ArcGIS ActiveX ControlsArcGIS ActiveX Controls•• Exposed as AWT controls by the InteropExposed as AWT controls by the Interop•• Exposed as AWT controls by the InteropExposed as AWT controls by the Interop•• Wrapped in Swing for IDE design environmentWrapped in Swing for IDE design environment

SwingSwing

AWTAWT

SwingSwing

AWTAWT

Java RuntimeJava Runtime

InteropInterop

ArcGIS RuntimeArcGIS Runtime

Developer Summit 2007Developer Summit 2007 1010

ActiveXActiveX

Page 11: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

VisualVisual--JavaBean Event ListenersJavaBean Event Listeners

•• Event ListenersEvent Listenerscorrespond to Outbound interfacescorrespond to Outbound interfaces–– correspond to Outbound interfacescorrespond to Outbound interfaces

•• Respond to eventsRespond to events–– mousemouse–– keyboardkeyboard–– ArcGIS framework eventsArcGIS framework events

•• Use Adapters for convenienceUse Adapters for convenience

Developer Summit 2007Developer Summit 2007 1111

Page 12: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

AgendaAgenda

•• Introduction Introduction •• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Customizing your applicationCustomizing your application•• Avoiding common pitfallsAvoiding common pitfalls•• Avoiding common pitfallsAvoiding common pitfalls•• Optimizing DisplayOptimizing Display•• Deploying your applicationDeploying your application•• Deploying your applicationDeploying your application

Developer Summit 2007Developer Summit 2007 1212

Page 13: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Application LifecycleApplication Lifecycle

1.1. Design UIDesign UI22 InitializeInitialize2.2. InitializeInitialize

–– EngineInitializer::initializeVisualBeans()EngineInitializer::initializeVisualBeans()

3.3. LicenseLicense3.3. LicenseLicense–– AoInitialize::initialize()AoInitialize::initialize()–– AoInitialize::checkOutExtension()AoInitialize::checkOutExtension()

4.4. Display UIDisplay UI5.5. ShutdownShutdown

–– AoInitialize::checkInExtension()AoInitialize::checkInExtension()–– AoInitialize::shutDown()AoInitialize::shutDown()

Developer Summit 2007Developer Summit 2007 1313

Page 14: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

ArcGIS plugin for EclipseArcGIS plugin for Eclipse

•• Design with Visual JavaDesign with Visual Java--beansbeansDrag Drop and Property PagesDrag Drop and Property Pages–– Drag, Drop and Property PagesDrag, Drop and Property Pages

•• Use code snippets for common tasksUse code snippets for common tasks•• Explore sample projectsExplore sample projectsExplore sample projectsExplore sample projects•• Browse the integrated help systemBrowse the integrated help system

Developer Summit 2007Developer Summit 2007 1414

Page 15: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

AgendaAgenda

•• Introduction Introduction •• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Customizing your applicationCustomizing your application•• Avoiding common pitfallsAvoiding common pitfalls•• Avoiding common pitfallsAvoiding common pitfalls•• Optimizing DisplayOptimizing Display•• Deploying your applicationDeploying your application•• Deploying your applicationDeploying your application

Developer Summit 2007Developer Summit 2007 1515

Page 16: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

CommandsCommands

•• Execute GIS function at the click of a buttonExecute GIS function at the click of a button•• 150+ standard commands150+ standard commands•• 150+ standard commands150+ standard commands•• Create your own custom commandsCreate your own custom commands

–– implement ICommandimplement ICommandimplement ICommandimplement ICommand–– or, extend BaseCommandor, extend BaseCommand

Developer Summit 2007Developer Summit 2007 1616

Page 17: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Command : using BaseCommandCommand : using BaseCommandclass MyCommand extends BaseCommand{

HookHelper helper;

public void onCreate(Object hook) {

//initialize HookHelper// p

helper = new HookHelper();

helper.setHookByRef(hook);

//set properties

bl denabled = true;

caption = "MyCommand";

toolTip = "My Command";

bitmapPath = "C:/myicons/image1.bmp";p y g p

}

public void onClick() {

//use HookHelper

IM h l tF M ()IMap map = helper.getFocusMap();

IActiveView view = helper.getActiveView();

//do your thing

}

Developer Summit 2007Developer Summit 2007 1717

}

Page 18: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

IHookHelperIHookHelper

•• Helps you write generic codeHelps you write generic codeHookHelperHookHelper

public void onCreate(Object hook) {

//getting ActiveView without HookHelper

if(hook instanceof MapControl){

((MapControl)hook).getActiveView();–– HookHelperHookHelper•• use with MapControl, PageLayoutControluse with MapControl, PageLayoutControl•• get ActiveView, Map, and PageLayout objects.get ActiveView, Map, and PageLayout objects.

(( p ) ) g ();

}else if(hook instanceof PageLayoutControl){

((PageLayoutControl)hook).getActiveView();

}else if(hook instanceof ToolbarControl){

bj l

public void onCreate(Object hook) {

//with HookHelper–– GlobeHookHelperGlobeHookHelper

•• use with GlobeControl SceneControluse with GlobeControl SceneControl•• get ActiveViewer, Camera, Globe, and GlobeDisplay objectsget ActiveViewer, Camera, Globe, and GlobeDisplay objects

Object control

=((ToolbarControl)hook).getBuddy();

if(control instanceof MapControl){

((MapControl)control).getActiveView();

helper = new HookHelper();

helper.setHookByRef(hook);

helper.getActiveView();g y jg y j

•• IHookActionsIHookActions–– available on HookHelper and GlobeHookHelperavailable on HookHelper and GlobeHookHelper

p g

}else if(control instance of PageLayoutControl){

((PageLayoutControl)control).getActiveView();

}

}

. . .

}

–– perform actions on geometriesperform actions on geometries}

. . .

}

Developer Summit 2007Developer Summit 2007 1818

Page 19: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

ToolsTools

•• Execute a GIS function after interacting with a map, Execute a GIS function after interacting with a map, globe scene or pagelayoutglobe scene or pagelayoutglobe, scene, or pagelayout.globe, scene, or pagelayout.

•• 60+ Standard Tools60+ Standard Tools•• Create your own custom toolsCreate your own custom toolsCreate your own custom toolsCreate your own custom tools

–– implement ICommand & IToolimplement ICommand & ITool–– or, extend BaseToolor, extend BaseTool

Developer Summit 2007Developer Summit 2007 1919

Page 20: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Tool : using BaseToolTool : using BaseToolclass MyTool extends BaseTool{

HookHelper helper;

public void onCreate(Object hook) {

//initialize HookHelper// p

helper = new HookHelper();

helper.setHookByRef(hook);

//set properties

bl denabled = true;

caption = "MyCommand";

toolTip = "My Command";

bitmapPath = "C:/myicons/image1.bmp";p y g p

cursorPath = “C:/myicons/foot.cur";

}

public void onMouseDown(int button, int shift, int x, int y) {

// H kH l d thi//use HookHelper, do your thing

}

}

Developer Summit 2007Developer Summit 2007 2020

Page 21: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

MenusMenus

•• Group similar items togetherGroup similar items together•• Save screen realSave screen real estateestate•• Save screen realSave screen real--estateestate•• 8 Standard menus8 Standard menus

–– all implement IMenuDefall implement IMenuDefall implement IMenuDefall implement IMenuDef

•• Create your custom menuCreate your custom menu–– implement IMenuDefimplement IMenuDef–– or, instantiate ToolbarMenuor, instantiate ToolbarMenu

Developer Summit 2007Developer Summit 2007 2121

Page 22: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Custom Menu : using IMenuDefCustom Menu : using IMenuDefclass MyMenu implements IMenuDef{

…public int getItemCount(){

return 2; //the number of menu items; //

}

public void getItemInfo(int pos, IItemDef def){

//Add standard components to the menu

i h( ){switch(pos){

case 0:

def.setID(ControlsMapRotateTool.getClsid()); break;

case 1:

def.setID(ControlsMapBookmarkMenu.getClsid()); break;

}

}

}}

…toolbarBean.addSubMenu(new MyMenu(),…); //Add to ToolbarBean

Developer Summit 2007Developer Summit 2007 2222

Page 23: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Custom Menu : using ToolbarMenuCustom Menu : using ToolbarMenu//Instantiate ToolbarMenu

ToolbarMenu myToolbarMenu = new ToolbarMenu();

myToolbarMenu.setCaption(“Custom Menu");

//Add standard components

myToolbarMenu.addItem(ControlsMapMeasureTool.getClsid(),…);

// dd//Add custom components

ICommand myCommand = new MyCommand();

myToolbarMenu.addItem(myCommand,…);

IMenuDef mySubMenu = new MySubMenu();y y

myToolbarMenu.addSubMenu(mySubMenu,…);

//Add to the toolbar

t lb B ddS bM ( T lb M )toolbarBean.addSubMenu(myToolbarMenu,…);

//or pop-up

myToolbarMenu.popUp(x,y,…);

Developer Summit 2007Developer Summit 2007 2323

Page 24: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Custom Menus Custom Menus

IMenuDefIMenuDef ToolbarMenuToolbarMenu•• can contain standardcan contain standard •• can contain standardcan contain standardcan contain standard can contain standard components (CLSID based)components (CLSID based)

can contain standard can contain standard components (CLSID based)components (CLSID based)•• can contain custom components can contain custom components (Object Instance based)(Object Instance based)(Object Instance based)(Object Instance based)

––ICommandICommand–– IMultiItemIMultiItem–– IMenuDefIMenuDef–– IPaletteDefIPaletteDef–– ToolbarMenuToolbarMenu–– ToolbarPaletteToolbarPalette

•• can appear on ToolbarControlcan appear on ToolbarControl •• can appear on ToolbarControlcan appear on ToolbarControl

Developer Summit 2007Developer Summit 2007 2424

•• can appear as popcan appear as pop--upup

Page 25: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

PalettesPalettes

•• Similar to MenusSimilar to Menus•• 3 standard Palettes3 standard Palettes•• 3 standard Palettes3 standard Palettes

–– all implement IPaletteDefall implement IPaletteDef

•• Create your custom paletteCreate your custom paletteCreate your custom paletteCreate your custom palette–– implement IPaletteDefimplement IPaletteDef–– or, instantiate ToolbarPaletteor, instantiate ToolbarPalette

Developer Summit 2007Developer Summit 2007 2525

Page 26: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Custom Palette : using IPaletteDefCustom Palette : using IPaletteDefclass MyPalette implements IPaletteDef{

…public int getItemCount(){

return 3; //the number of menu items; //

}

public void getItemInfo(int pos, IItemDef def){

//Add standard components to the menu

i h( ){switch(pos){

case 0:

def.setID(ControlsNewMarkerTool.getClsid()); break;

case 1:

def.setID(ControlsNewPolygonTool.getClsid()); break;

case 2:

def.setID(ControlsNewCircleTool.getClsid()); break;

}}

}

}

Developer Summit 2007Developer Summit 2007 2626

toolbarBean.addItem(new MyPalette(),…); //Add to ToolbarBean

Page 27: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Custom Palette : using ToolbarPaletteCustom Palette : using ToolbarPalette//Instantiate ToolbarPalette

ToolbarPalette myToolbarPalette = new ToolbarPalette ();

myToolbarPalette.setCaption(“Custom Palette");

//Add standard components

myToolbarPalette.addItem(ControlsMapMeasureTool.getClsid(),…);

// dd//Add custom components

ICommand myCommand = new MyCommand();

myToolbarPalette.addItem(myCommand,…);

IMenuDef mySubMenu = new MySubMenu();y y

myToolbarPalette.addSubMenu(mySubMenu,…);

//Add to the toolbar

t lb B ddIt ( T lb P l tt )toolbarBean.addItem(myToolbarPalette,…);

//or pop-up

myToolbarPalette.popUp(x,y,…);

Developer Summit 2007Developer Summit 2007 2727

Page 28: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Custom PalettesCustom Palettes

IPaletteDefIPaletteDef ToolbarPaletteToolbarPalette•• can contain standardcan contain standard •• can contain standardcan contain standard•• can contain standard can contain standard components (CLSID based)components (CLSID based)

•• can contain standard can contain standard components (CLSID based)components (CLSID based)•• can contain custom components can contain custom components (Obj t I t b d)(Obj t I t b d)(Object Instance based)(Object Instance based)

––ICommandICommand––IMenuDefIMenuDef––IPaletteDefIPaletteDef––ToolbarPaletteToolbarPalette

•• can appear on ToolbarControlcan appear on ToolbarControl •• can appear on ToolbarControlcan appear on ToolbarControlcan appear on ToolbarControlcan appear on ToolbarControl can appear on ToolbarControlcan appear on ToolbarControl•• can appear as popcan appear as pop--upup

Developer Summit 2007Developer Summit 2007 2828

Page 29: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Putting it all togetherPutting it all together

ToolbarBeanToolbarBean

IMenuDefIMenuDef

ICommandICommand

ToolbaToolbaM

enu

Men

u

e u ee u e

IPaletteDefIPaletteDef

arPalettearPaletteTo

olba

rMTo

olba

rM

IMultiItemIMultiItem eeIMultiItemIMultiItem

PP PopupPopup

Developer Summit 2007Developer Summit 2007 2929

PopupPopup PopupPopup

Page 30: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

AgendaAgenda

•• Introduction Introduction •• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Customizing your applicationCustomizing your application•• Avoiding common pitfallsAvoiding common pitfalls•• Avoiding common pitfallsAvoiding common pitfalls•• Optimizing DisplayOptimizing Display•• Deploying your applicationDeploying your application•• Deploying your applicationDeploying your application

Developer Summit 2007Developer Summit 2007 3030

Page 31: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

AWT and Swing under the hoodAWT and Swing under the hood

•• AWT components are AWT components are heavyweightheavyweightThey each get their own native screen resources (native peer)They each get their own native screen resources (native peer)–– They each get their own native screen resources (native peer)They each get their own native screen resources (native peer)

–– A “Frame” in AWT is really a “Window” created using the Win32 A “Frame” in AWT is really a “Window” created using the Win32 APIAPI

•• Swing components are Swing components are lightweightlightweight (except for the top (except for the top level windows : JFrame JDialog JWindow JApplet)level windows : JFrame JDialog JWindow JApplet)level windows : JFrame, JDialog, JWindow, JApplet)level windows : JFrame, JDialog, JWindow, JApplet)–– They do not get their own native screen resourcesThey do not get their own native screen resources–– They are simply drawn on their Parent’s canvasThey are simply drawn on their Parent’s canvas

Developer Summit 2007Developer Summit 2007 3131

Page 32: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

JFrameJFrameJFrameJFrame

Swing ButtonSwing ButtonAWT ButtonAWT Button

GUI ApplicationGUI Application

Operating SystemOperating System

Frame peerFrame peer Button peerButton peer

Developer Summit 2007Developer Summit 2007 3232

ESRI Engine Controls are AWT components ESRI Engine Controls are AWT components

Page 33: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Mixing AWT and SwingMixing AWT and Swing

•• When would you mix AWT and Swing componentsWhen would you mix AWT and Swing components

–– You are in the process of migrating from AWT to SwingYou are in the process of migrating from AWT to Swing

–– You want to integrate ESRI Engine Controls in your applicationsYou want to integrate ESRI Engine Controls in your applications

ff–– You want a native look and feelYou want a native look and feel

Developer Summit 2007Developer Summit 2007 3333

Page 34: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

A sample Swing/AWT applicationA sample Swing/AWT application

Developer Summit 2007Developer Summit 2007 3434

Page 35: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Be careful though!Be careful though!

•• ZZ--order issues cause the most grieforder issues cause the most griefAWT controls can hide Swing componentsAWT controls can hide Swing components–– AWT controls can hide Swing componentsAWT controls can hide Swing components

Developer Summit 2007Developer Summit 2007 3535

Page 36: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Potential ProblemsPotential Problems

•• What can be done?What can be done?Be careful while overlapping Swing components and EngineBe careful while overlapping Swing components and Engine–– Be careful while overlapping Swing components and Engine Be careful while overlapping Swing components and Engine ControlsControls

–– Exercise caution when embedding Engine Controls inside a Exercise caution when embedding Engine Controls inside a JI t lFJI t lFJInternalFrameJInternalFrame

–– Avoid using Engine Controls inside of a JScrollPaneAvoid using Engine Controls inside of a JScrollPane–– Use Heavy Weight PopupsUse Heavy Weight Popupsy g p py g p p

•• JPopupMenu.setDefaultLightWeightPopupEnabled(false);JPopupMenu.setDefaultLightWeightPopupEnabled(false);

Developer Summit 2007Developer Summit 2007 3636

Page 37: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Anatomy of a Java GUI ApplicationAnatomy of a Java GUI Application

Java.exeJava.exe

Main ThreadMain Thread AWT Event ThreadAWT Event Thread

L b lL b l public void actionPerformed(ActioEvent e)public void actionPerformed(ActioEvent e){{

label.setText(“Feature count”);label.setText(“Feature count”);}}

LabelLabel

EventEvent HandlerHandlerHandlerHandlerEventEvent

EventEvent

EventEvent

Developer Summit 2007Developer Summit 2007 3737

EventEvent

AWT Event QueueAWT Event Queue

Page 38: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

ArcObjects Event ListenersArcObjects Event Listeners

JVM “owns” theseJVM “owns” theseJVM owns theseJVM owns thesecomponentscomponents

ArcObjects “owns”ArcObjects “owns”MapControlMapControl

JavaJava--COMCOMInterop BridgeInterop Bridge

Call Event HandlerCall Event HandlerMapControl EventsMapControl Events

Developer Summit 2007Developer Summit 2007 3838

ArcObjectsArcObjects

Page 39: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

ArcObjects Event ListenersArcObjects Event Listeners

Java.exeJava.exe

Main ThreadMain Thread AWT Event ThreadAWT Event Thread

L b lL b l

Worker ThreadWorker Thread

public void onMouseDownpublic void onMouseDown(IMapControlEvent e)(IMapControlEvent e)

{{// Count features // Count features ……

LabelLabel

// Update Swing Component// Update Swing Componentlabel.setText(featureCount);label.setText(featureCount);

}}

EventEvent

EventEvent

Developer Summit 2007Developer Summit 2007 3939

EventEvent

AWT Event QueueAWT Event Queue

Page 40: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

SwingUtilities to the rescueSwingUtilities to the rescue

•• The SwingUtilities class provides two static methodsThe SwingUtilities class provides two static methodsinvokeLater(Runnable task)invokeLater(Runnable task)–– invokeLater(Runnable task)invokeLater(Runnable task)

–– invokeAndWait(Runnable task)invokeAndWait(Runnable task)

// MapControl event listenerppublic void onMouseDown(IMapControlEvents2OnMouseDownEvent event){// Perform some ArcObjects work…

// Safely update Swing/AWT componentsSwingUtilities.invokeLater(new Runnable(){

public void run(){

label.setText(featureCount);}

})

Developer Summit 2007Developer Summit 2007 4040

});}

Page 41: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Java.exeJava.exe

Main ThreadMain Thread AWT Event ThreadAWT Event Thread Worker ThreadWorker Thread

public void onMouseDownpublic void onMouseDown(IMapControlEvent e)(IMapControlEvent e)

{{

LabelLabel

……

// Update Swing component// Update Swing componentSwingUtilities.invokeLater(new Runnable() SwingUtilities.invokeLater(new Runnable() {{{{

public void run() {public void run() {label.setText(featureCount);label.setText(featureCount);

}}});});

}}

EventEvent

EventEvent

}}

Developer Summit 2007Developer Summit 2007 4141

EventEvent

AWT Event QueueAWT Event Queue EventEvent

Page 42: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

AgendaAgenda

•• Introduction Introduction •• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Customizing your applicationCustomizing your application•• Avoiding common pitfallsAvoiding common pitfalls•• Avoiding common pitfallsAvoiding common pitfalls•• Optimizing DisplayOptimizing Display•• Deploying your applicationDeploying your application•• Deploying your applicationDeploying your application

Developer Summit 2007Developer Summit 2007 4242

Page 43: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

DisplayDisplay

•• Screen Display abstracts an Screen Display abstracts an p yp yapplication windowapplication window

•• Simple Display abstracts otherSimple Display abstracts other

DisplayDisplay

•• Simple Display abstracts other Simple Display abstracts other devices (printers, bitmaps, etc)devices (printers, bitmaps, etc)

Th A Obj t M thTh A Obj t M th S Di lS Di l•• The ArcObject Map uses the The ArcObject Map uses the Display objects to render a map Display objects to render a map and manage display cachesand manage display caches

Screen DisplayScreen Display

Simple DisplaySimple DisplaySimple DisplaySimple Display

Developer Summit 2007Developer Summit 2007 4343

MapMap

Page 44: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Display CachesDisplay Caches

•• Map uses caching techniques to avoid drawing from Map uses caching techniques to avoid drawing from diskdiskdiskdisk

•• Creates and maintains default cachesCreates and maintains default caches–– Layers cache (features)Layers cache (features)y ( )y ( )–– Graphics cache (labels, annotations, graphic elements)Graphics cache (labels, annotations, graphic elements)–– Feature Selection cacheFeature Selection cache

•• Allows creating private cachesAllows creating private caches

Developer Summit 2007Developer Summit 2007 4444

Page 45: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Display caches…Display caches…

CC

To ScreenTo Screen

Recording CacheRecording Cache

Feature Selection CacheFeature Selection Cache

Graphics CacheGraphics Cachepp

Developer Summit 2007Developer Summit 2007 4545

Layers CacheLayers Cache

Page 46: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Drawing OrderDrawing Order

ObjectObject PhasePhase CacheCache

Graphic SelectionGraphic Selection

Feature SelectionFeature Selection

esriViewForegroundesriViewForeground

esriViewGeoSelectionesriViewGeoSelection

nonenone

selectionselectionFeature SelectionFeature Selection

LabelsLabels

esriViewGeoSelectionesriViewGeoSelection

esriViewGraphicsesriViewGraphics

selectionselection

annotationannotation

GraphicsGraphics

Layer AnnotationsLayer Annotations

esriViewGraphicsesriViewGraphics

esriViewGraphicsesriViewGraphics

annotationannotation

annotationannotationLayer AnnotationsLayer Annotations

LayersLayers

pp

esriViewGeographyesriViewGeography layerlayer

Developer Summit 2007Developer Summit 2007 4646

Page 47: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Refreshing the MapRefreshing the Map

•• IActiveView::Refresh is expensive IActiveView::Refresh is expensive •• Use IActiveView::PartialRefresh when possibleUse IActiveView::PartialRefresh when possible•• Use IActiveView::PartialRefresh when possibleUse IActiveView::PartialRefresh when possible

–– Lets you specify what part of the display to redrawLets you specify what part of the display to redraw

// R f h ll L// Refresh all LayerspMap.partialRefresh(esriViewGeography, 0, 0);

// Refresh Feature Selection

// Prototype of the partialRefresh method

IActiveView::partialRefresh(int drawPhase, Obj t difi dObj t IE l f hR i )// Refresh Feature Selection

pMap.partialRefresh(esriViewGeoSelection, 0, 0);

// Refresh Annotations/Graphics

Object modifiedObject, IEnvelope refreshRegion);

ppMap.partialRefresh(esriViewGraphics, 0, 0);

// Refresh a single Element

Developer Summit 2007Developer Summit 2007 4747

pMap.partialRefresh(esriViewGraphics, pElement, 0);

Page 48: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Adding a Graphic elementAdding a Graphic element

// Creating a graphic elementCirularElement element = new CircularElement();SimpleFillSymbol symbol = new SimpleFillSymbol();…

// Adding it to the graphics containergraphicsContainer.addElement(element, 0);

// ExpensiveactiveView.refresh();

// Recommended way to refresh.activeView.partialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

Developer Summit 2007Developer Summit 2007 4848

p

Page 49: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Private cachePrivate cache

•• When do you need a private cache?When do you need a private cache?Need to redraw features on a layer at regular intervalsNeed to redraw features on a layer at regular intervals–– Need to redraw features on a layer at regular intervalsNeed to redraw features on a layer at regular intervals

–– Other layers in the Map don’t change but are expensive to Other layers in the Map don’t change but are expensive to redrawredraw

•• How do you create it?How do you create it?–– Set the cached property on the layer Set the cached property on the layer

Refresh the Map’s cachesRefresh the Map’s caches–– Refresh the Map’s cachesRefresh the Map’s caches

Developer Summit 2007Developer Summit 2007 4949

Page 50: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Creating and using a private cacheCreating and using a private cache// Set the cache property on the layerILayer cachedLayer = …;cachedLayer.setCached(true);

// Refresh the Map’s cachesMap map = (Map)mapControl.getMap();

f hC h ()map.refreshCaches();

// Refresh the layer. Other layers draw from cacheIActiveView activeView = mapControl.getActiveView();activeView.partialRefresh(esriViewDrawPhase.esriViewGeographyp ( g p y

, cachedLayer, null);

Developer Summit 2007Developer Summit 2007 5050

Page 51: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Map EventsMap Events

•• The Map generates events when its state changesThe Map generates events when its state changes•• Clients implementClients implement IActiveViewEventsIActiveViewEvents to register ato register a•• Clients implement Clients implement IActiveViewEventsIActiveViewEvents to register a to register a

listener and receive these eventslistener and receive these events•• Two kinds of eventsTwo kinds of eventsTwo kinds of eventsTwo kinds of events

–– Reports a new state Reports a new state –– itemAdded(), contentsChanged()itemAdded(), contentsChanged()

–– Allows participation during the Map’s state changeAllows participation during the Map’s state change–– afterDraw(), afterItemDraw()afterDraw(), afterItemDraw()

Developer Summit 2007Developer Summit 2007 5151

Page 52: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Demo : Refresh ExplorerDemo : Refresh Explorer

Developer Summit 2007Developer Summit 2007 5252

Page 53: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Map Events…Map Events…

•• The afterDraw() method is called at the end of each The afterDraw() method is called at the end of each draw phasedraw phasedraw phasedraw phase

•• Useful for drawing custom graphics while the Map Useful for drawing custom graphics while the Map refreshesrefreshes

•• Pick the draw phase and perform the drawing Pick the draw phase and perform the drawing •• The drawing directly goes either to a cache or to displayThe drawing directly goes either to a cache or to displayg y g p yg y g p y

Developer Summit 2007Developer Summit 2007 5353

Page 54: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

// Wiring up an event listenermap.addIActiveViewEventsListener(new IActiveViewEventsAdapter() {

public void afterDraw(IActiveViewEventsAfterDrawEvent evnt){

//// The phase after which you will drawint drawPhase = evnt.getPhase();

// The Screen Display// The Screen DisplayIDisplay display = evnt.getDisplay();

if(drawPhase == esriViewDrawPhase.esriViewGraphics)if(drawPhase esriViewDrawPhase.esriViewGraphics){// All drawings performed here go into the graphics // cache

}}

});

Developer Summit 2007Developer Summit 2007 5454

Page 55: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Drawing to the screenDrawing to the screen

•• Give instantaneous feedback without refreshing the Give instantaneous feedback without refreshing the MapMap

•• No dependency on refresh cyclesNo dependency on refresh cycles

// Start the drawing session. Draw to the screen directlyscreenDisplay.startDrawing(0, esriNoScreenCache);

// S t th b l f th t// Set the symbol for the geometryscreenDisplay.setSymbol(markerSymbol);

// Draw the geometry// Draw the geometryscreenDisplay.drawPoint(point);

// End the drawing session

Developer Summit 2007Developer Summit 2007 5555

// gscreenDisplay.finishDrawing();

Page 56: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

AgendaAgenda

•• Introduction Introduction •• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Creating an application with Visual JavaBeansCreating an application with Visual JavaBeans•• Customizing your applicationCustomizing your application•• Avoiding common pitfallsAvoiding common pitfalls•• Avoiding common pitfallsAvoiding common pitfalls•• Optimizing DisplayOptimizing Display•• Deploying your applicationDeploying your application•• Deploying your applicationDeploying your application

Developer Summit 2007Developer Summit 2007 5656

Page 57: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Java WebStartJava WebStart

•• OneOne--Click deployment solution for Java ApplicationsClick deployment solution for Java Applications•• Webstart allows java applications to be deployed over aWebstart allows java applications to be deployed over a•• Webstart allows java applications to be deployed over a Webstart allows java applications to be deployed over a

networknetwork•• Distributed like Applets Perform like ApplicationsDistributed like Applets Perform like ApplicationsDistributed like Applets, Perform like ApplicationsDistributed like Applets, Perform like Applications•• Deployment Descriptor : JNLP Deployment Descriptor : JNLP –– Java Network Launch Java Network Launch

ProtocolProtocol

Developer Summit 2007Developer Summit 2007 5757

Page 58: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Deploying your application using WebStartDeploying your application using WebStart

•• Code your applicationCode your application•• Create and Sign your application’s jarCreate and Sign your application’s jar•• Create and Sign your application’s jarCreate and Sign your application’s jar•• Create the .jnlp descriptorCreate the .jnlp descriptor

–– declare the main classdeclare the main classdeclare the main classdeclare the main class–– grant full permissionsgrant full permissions

•• Place application and descriptor on webserverPlace application and descriptor on webserver

Developer Summit 2007Developer Summit 2007 5858

Page 59: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Example .jnlp fileExample .jnlp file

<jnlp spec="1.0+" codebase="http://mytomcat:8080/devsummit/">

...

<security>

ll i i /<all-permissions/>

</security>

<resources>

...

<jar href=“application.jar" main="true"/>

/<jar href=“utilities.jar"/>

</resources>

<application-desc main-class="com.myorg.Main" />

Developer Summit 2007Developer Summit 2007 5959

pp y g /

</jnlp>

Page 60: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Presentation materialsPresentation materials

•• PowerPoint presentation and code are posted on the PowerPoint presentation and code are posted on the conference web siteconference web siteconference web siteconference web site–– http://www.esri.com/events/devsummit/index.htmlhttp://www.esri.com/events/devsummit/index.html

•• EDN EDN –– downloads and videosdownloads and videos

Developer Summit 2007Developer Summit 2007 6060

Page 61: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Demo : Launching application using WebStartDemo : Launching application using WebStart

Developer Summit 2007Developer Summit 2007 6161

Page 62: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Demo : Launching application using WebStartDemo : Launching application using WebStart

Developer Summit 2007Developer Summit 2007 6262

Page 63: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Further questions?Further questions?

•• TECHTECH--TALK AREA 6TALK AREA 6–– in the Community Center (Oasis 3)in the Community Center (Oasis 3)in the Community Center (Oasis 3)in the Community Center (Oasis 3)–– during the next 30 minutesduring the next 30 minutes

•• Meet the Java teamMeet the Java team–– Tuesday 4 PM, March 20 in Oasis 4Tuesday 4 PM, March 20 in Oasis 4

•• Java SIGJava SIG–– Wednesday 12 PM, March 21 in Primrose C/DWednesday 12 PM, March 21 in Primrose C/Dyy

•• ESRI Developers Network (EDN) websiteESRI Developers Network (EDN) website

Developer Summit 2007Developer Summit 2007 6363

–– http://edn.esri.comhttp://edn.esri.com

Page 64: Building ArcGIS Engine Applications with Visual-Java Beans · Overview of ArcGIS Engine Java • Java SDK for developing cross platform desktop GIS Applications. • Collection of

Thank you for coming!Thank you for coming!

Developer Summit 2007Developer Summit 2007 6464