Building Desktop Applications with Java
Eric Bader
Vishal Agarwal
Introductions…
• Who are we?
– Core Engine Java dev team members.
• Who are you?
– ArcGIS Desktop developers/users?
– MapObjects Java users?
– Current ArcGIS Engine developers?
– Target Platforms?
Agenda
• Overview
• Key Features
• Coarse grain Developer components
• Working with Swing
• Custom Commands and Tools
• What’s new in 9.2
Overview of ArcGIS Engine Java
• Java SDK for developing cross platform
desktop GIS Applications.
• Collection of numerous java objects called
‘arcobjects ’ and tools for mapping,
visualization, data management and GIS
analysis.
• Create stand alone GIS apps or Embed GIS
functions in existing J2SE applications
Some User Applications
Architecture
Java Visual Beans and utilities
Java Proxy Objects
ArcObjects
Windows / Solaris / Linux
ArcGIS Engine Functionality
• 2D and 3D visualization
• Read all supported ESRI data formats
including the geodatabases.
• Map authoring (create and edit MXD)
• ArcGIS level cartography
• Geo-coding, query, analysis.
• Simple editing (shp and pGDB)
• With Extensions:
– Multi user editing, Spatial, 3D and Network analysis
Java Beans – Drag and Drop development
• MapBean
• PageLayoutBean
• ToolbarBean
• TOCBean
• ReaderBean
• SceneBean
• GlobeBean
Tools and Commands
More than100 tools and commands included.
Utility classes to help you create own custom Tools
Things to Note
• Post Install
• Initialization
– EngineInitializer - initializeVisualBeans
• Licensing
– AoInitialize – initialize() AND checkoutExtension ()
• Shutting Down
– AoInitialize
Why use Proxy Classes?
• They are only for getting a handle to the
underlying object
Polygon polygon = new Polygon();
NOT
IPolygon polygon =
new PolygonProxy();
IEnvelope e = geom.getEnvelope();
ITopologicalOperator topo = new
ITopologicalOperatorProxy(e);
topo.buffer(4.0);
Bridge and GEN Interfaces
• Certain ArcObjects do not work properly in
Java, we create
• GEN Interfaces:
– These are created to substitute the un-compatible
interfaces
– Ex. IEnvelopeGEN replaces IEnvelope.
• BRIDGE Interfaces:
– For the more basic GIS service, to reduce the
overhead.
– Ex. IGeometryBridge
ArcObjects and Swing
Tips or Pop-ups don’t work properly?
– JPopupMenu.setLightWeightPopupEnabled
• Application Freezes?
– Use 9.1 SP1
– Use Event Dispatcher thread
javax.swing.SwingUtilities.invokeLat
er(new Runnable(){
public void run(){
//Code Here
}});
Events and Drawing
• Don’t add Java Event listeners to the Beans
• Each Bean has its own event Listener
• Don’t use the Java.awt.Graphics or
Graphics2D to draw grpahics – not supported
– Use GraphicsContainer of ActiveView
– Several Tools are available.
– You need BMP images for your graphic elements
– Use the Graphics draw phase to refresh the map –
Partial Refresh
Special to Java
• Methods take output as parameters:
IBasicMap basicmap [] = {null};
ILayer layer [] = {null};
Object other [] = {null};
int itemType [] = {0};
Object pIndex [] = {null
};
toc.hitTest(e.getX(), e.getY(),
itemType, basicmap, layer, pIndex,
other);
Custom Commands and Tools
• BaseCommand & BaseTool as helper classes
• Key Methods – onCreate() and the Constructor
• Use HookHelper
• Use isEnabled () to maintain the state
• Use Swing worker thread to invoke Swing
components.
• You cannot use JToolBar with our tools.
Summary
• Runtime Overview
• Initialization and licensing
• Coarse grained components
• Working with Swing
• Events and Animation
• Custom Commands and Tools
ArcGIS 9.2 Features
What’s new in 9.2
• Ready-to-use Out-of-the-Box
• Improve Stability
• API Improvements
• New Packages and Extensions
• File GDB
• New Visual Components
• New Help System and samples
• IDE Integration
• Support for JDK 1.5
• ArcGIS Desktop is ‘Java Enabled’
API Improvements
• Support for Casting and InstanceOf
– No QI or Proxy calls
• Hand Crafted Geo-Processing API
• Javadoc improvements
– No unnecessary constructors, methods
New Visual Beans – Shared Code!
• New Controls and Commands
– Symbology Control
– Several new tools – Identify, measure, editing…
• New Visual Beans for RAD
– Attribute Table
– Query Selection
– Selection by Location
– Symbology
– Buffer
Samples
• Reflect API improvements
• Better Structure
– Easy to navigate
– HTML Readme
• Easier to Run
– Executable Jars
– Simple Import into IDEs
Java Help System
• A central repository for all help content
– Better Structure
– Easier to get started
– Several New docs
• Scenarios
• Deployment
• Using IDEs
• FAQ
Geo-processing and Tracking
• Refined API
• Tool Generator
– Support for models written in ArcGIS Desktop
• Supporting Documents
• Samples
• Developer Scenario
– How to consume custom Routing model
– How to Track events and time windows
IDE Integration
• ArcGIS Eclipse Plug-ins
– Java Help System
– Samples
– Templates
– Code shortcuts
– Geo-Processing Tool Generator
– Local update site
Summary – ArcGIS Engine
• Better API – 100% Pure Java experience
• Performance and stability improvements
• Better user experience:
– IDE Integration + Help System + samples
• More holistic approach for solving GIS
Problems
– Out of box components and extended samples.
Developer Resources
• Engine Developer Kit includes
– Help System
– Developer Documentation
– Sample Code
– Detailed Object Model Diagrams
– Utilities and Tools
• For Additional Support:
– EDN – http://edn.esri.com
– User Forum: http://forums.esri.com
Thanks!
More Questions?
Join us for Tech Talk
2:30 PM – 3:00PM Community Center