1 / 15

Programming ArcGIS AddIn Architecture ArcObjects Framework

Programming ArcGIS AddIn Architecture ArcObjects Framework. Code. The code that goes in the addIn is code to work with the ArcObjects framework. The running version of Arc is accessed via gatekeeper objects.

carmene
Download Presentation

Programming ArcGIS AddIn Architecture ArcObjects Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ProgrammingArcGIS AddIn Architecture ArcObjects Framework

  2. Code The code that goes in the addIn is code to work with the ArcObjects framework. The running version of Arc is accessed via gatekeeper objects. You then request objects from these, and subsequent objects from the objects you get back. Ask App for Document Ask Document for Maps Ask Maps for a Map Ask Map for Layers Ask Layers for Layer etc.

  3. init(IApplication app) Most addIns come with a init method that can be overridden. This is sent the application as an entry point for the running framework. import com.esri.arcgis.framework.*; private IApplication app; @Override public void init(IApplication app){ this.app = app; }

  4. Document You can use this to get hold of the current document. This is the current data and GUI. import com.esri.arcgis.arcmapui.*; IMxDocument mxDoc = (IMxDocument)app.getDocument();

  5. API It is then just a matter of finding how to do stuff in the API docs: http://desktop.arcgis.com/en/arcobjects/latest/java/api/arcobjects/index.html

  6. N.B. The code utilises Java Annotations. @name Used as a marker for software intending to process the code. @Override Four default annotations within java.lang (see docs).

  7. @override Java ‘annotation’. Default annotation denoted an overridden method (i.e. one also in a superclass or interface). Compiler will check (e.g. incase you’ve misspelt it or not used the same parameter types). Also flagged in documentation. You can write your own annotations.

  8. N.B.II Arc returns objects that implement multiple interfaces. You generally cast the object to a specific interface when using it. IMxDocument mxDoc = (IMxDocument)app.getDocument(); There is nothing to stop you recasting it to another interface to use different methods in it: IDocument iDoc = (IDocument) mxDoc; Infact, it is very common.

  9. The COM In Microsoft languages, this reassignment of interface labels is key. It allows chunks of code to use other chunks of code without knowing anything other than the interface names. It is used to hold together a great deal of the Component Object Model (COM) at the heart of Microsoft software. ArcGIS is built around the COM, so this is a common thing to see.

  10. Interfaces This requires some care. You might think that redefining everything as the right object would be sensible: public void init(IApplication app){ Application a = (Application)app; You could then use all the methods. However, while objects Arc gives you will match the interfaces, they may not do anything sensible.

  11. Interfaces For example, this works in ArcMap: public void init(IApplication app){ Application a = (Application)app; IGxSelection selec = a.getSelection(); JOptionPane.showMessageDialog (null, selec.toString()); } But doesn’t give you anything sensible, as IGxSelection is an ArcCatalog class, and here the Application object is the ArcMap Application object, not the ArcCatalog one.

  12. Interfaces In general, better to get the interface right and keep the object defined by its interfaces. As well as explicitly casting, just attaching the right label works if you are going to a less specific class: IMxDocument mxDoc = app.getDocument(); But generally in the examples you’ll see an explicit cast because it saves looking up the relationship. In the API Docs, in general go for the interface list at the top of the class. Interfaces generally start “I” Then “Mx” for ArcMap, “Gx” for ArcCatalog.

  13. ArcMap IApplication methods newDocument(boolean userPickTemplate?, String path) openDocument(String optionalPath) refreshWindow() saveDocument(String optionalPath) If the paths are null, the usual “new”, “open”, and “save” processes occur.

  14. ArcMap IMXDocument methods Used for getting data: getActiveView() i.e. layout view or data view data. getFocusMap() i.e. currently selected/shown map. getMaps() i.e. all maps. getSelectedItem() i.e. that the user has picked. getSelectedLayer() i.e. that the user has picked. Documents also implement IDocument, the main use of which is programmatically controlling toolbars.

  15. Next Lecture Getting, sorting, and searching data. Practical Hello World! Utilising tools in Arc Addins.

More Related