|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IMxDocument
Provides access to members that control the Mx Document.
This interface is a starting point for much of the other objects in ArcMap. For example, this interface provides access to the current active view, the currently selected map, all of the maps, and the style gallery. This interface also has many properties reflected in the running application including: the text font, the text size, and the search tolerance. Almost every ArcMap customization uses IMxDocument one way or another.
Obtain a reference to this interface via IApplication::Document.
To edit the contents of a map document saved to a file (*.mxd) outside of an ArcMap session or without instantiating a new Application (ArcMap process), see IMapDocument. IMapDocument provides the ability to edit and save the contents of a map document.
Method Summary | |
---|---|
void |
addLayer(ILayer layer)
Adds a layer to the current focus map. |
void |
canInsertObject(boolean[] pEnabled)
Indicates if the document allows objects to be inserted. |
IActiveView |
getActivatedView()
The activated view. |
IActiveView |
getActiveView()
The active view. |
ICommand |
getActiveViewCommand()
The command associated with the active view. |
IContentsView |
getContentsView(int index)
The contents view at the specified index. |
int |
getContentsViewCount()
The number of contents views in the document. |
Object |
getContextItem()
The last item that was right-clicked. |
IContentsView |
getCurrentContentsView()
The current contents view of the document. |
IPoint |
getCurrentLocation()
The current mouse location in map units. |
IColor |
getDefaultColor(int type)
The default color for the given type. |
Font |
getDefaultTextFont()
The default font for text. |
IFontSize |
getDefaultTextFontSize()
The default font size for text. |
IMap |
getFocusMap()
The current focus map. |
IMaps |
getMaps()
The collection of maps in the document. |
IOperationStack |
getOperationStack()
The operation stack. |
IPageLayout |
getPageLayout()
The page layout. |
double |
getSearchTolerance()
The global search tolerance in geographic units for selection. |
int |
getSearchTolerancePixels()
The global search tolerance in pixels for selection. |
Object |
getSelectedItem()
The selected item in the layer control. |
ILayer |
getSelectedLayer()
The selected layer in the layer control. |
IStyleGallery |
getStyleGallery()
Reference to the document's Style Gallery. |
ITableProperties |
getTableProperties()
Table properties, for Layers and Tables in ArcMap. |
void |
insertObject()
Inserts an object into the document. |
boolean |
isRelativePaths()
Indicates if path names are stored relative to the document. |
void |
setActiveViewByRef(IActiveView activeView)
The active view. |
void |
setContextItem(Object item)
The last item that was right-clicked. |
void |
setCurrentContentsViewByRef(IContentsView view)
The current contents view of the document. |
void |
setCurrentLocation(IPoint mouseLoc)
The current mouse location in map units. |
void |
setDefaultColor(int type,
IColor color)
The default color for the given type. |
void |
setDefaultTextFont(Font fontDisp)
The default font for text. |
void |
setDefaultTextFontSize(IFontSize fontSize)
The default font size for text. |
void |
setDelayUpdateContents(boolean rhs1)
Indicates document update notifications should be ignored. |
void |
setPageLayoutByRef(IPageLayout pageLayout)
The page layout. |
void |
setRelativePaths(boolean relPaths)
Indicates if path names are stored relative to the document. |
void |
setSearchTolerancePixels(int tol)
The global search tolerance in pixels for selection. |
void |
updateContents()
Notifies the document that the contents have been updated. |
Method Detail |
---|
void setPageLayoutByRef(IPageLayout pageLayout) throws IOException, AutomationException
pageLayout
- A reference to a com.esri.arcgis.carto.IPageLayout (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IPageLayout getPageLayout() throws IOException, AutomationException
This method returns an IPageLayout reference to the PageLayout object. The page layout is the visual representation of a map. A typical page layout is composed of a page and many elements including data, graphics, and text.
From an object point of view, the PageLayout object has a Page object and a collection of Element objects. The page is used to manage page size and printing. Element objects include MapFrames, GraphicElements, and TextElements. Anything that can be placed on a map is a type of element.
Athough, you can programmatically create your own page layout and assign it to the map document, the general practice is to modify the existing one.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IPageLayout
IActiveView getActiveView() throws IOException, AutomationException
This method provides access to the active view. ArcMap currently supports two types of views, layout view and data view; the view with focus is the active view. If ArcMap is in layout view, this property returns an IActiveView reference to the PageLayout object. Alternatively, if ArcMap is in data view, the returned IActiveView reference is to a Map object. Both the PageLayout and Map objects implement the IActiveView interface.
Note, an ArcMap document may have multiple maps (data frames) in it. Multiple maps means multiple Map objects. Any Map in this collection may be set as the active view. There is typically only one PageLayout object per session of ArcMap.
To determine if the returned reference is to a PageLayout object or a Map, attempt a query interface (QI) to either IPageLayout or IMap. If you know you want a reference to the focus map, use IMxDocument::FocusMap instead. Similarly, if you know you want a reference to the page layout, use IMxDocument::PageLayout instead. This is often the case when you need to refresh the display. For example, if someone has panned the map and you now need to refresh it, explicitly use IMxDocument::FocusMap which returns a reference to the Map with focus, and then QI for IActiveView.
Use this property to also set the active view programmatically.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IActiveView
void setActiveViewByRef(IActiveView activeView) throws IOException, AutomationException
activeView
- A reference to a com.esri.arcgis.carto.IActiveView (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IActiveView getActivatedView() throws IOException, AutomationException
This property is primarily used when adding graphics as it conveniently gives a reference to the object set as the target graphics container.
In ArcMap's layout view, graphics can either be added to the PageLayout's graphics container or the focus Map's graphics container if the Map has been activated by double-clicking on it. In this case, IMxDocument::ActiveView differs from IMxDocument::ActivatedView in that the ActiveView property may pass a reference to the PageLayout object while the ActivatedView property may pass a reference to the focus Map object if that Map has been activated. In data view, both ActiveView and ActivatedView return a reference to the focus Map.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.com.esri.arcgis.arcmapUI.IActiveView
ICommand getActiveViewCommand() throws IOException, AutomationException
The command associated with the current active view.
In ArcMap the active view can be either a Map (corresponding to Data view in ArcMap) or a PageLayout (corresponding to Layout view in ArcMap). To switch between these different views, ArcMap has two active view commands: GeographicViewCommand and LayoutViewCommand. These commands are the tiny globe and page buttons on the scroll bar and also appear in the View menu. GeographicViewCommand sets the focus Map as the ActiveView and LayoutViewCommand sets the PageLayout as the ActiveView.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IMap getFocusMap() throws IOException, AutomationException
This property is a short-cut to IActiveView::FocusMap and is read-only. To programmatically change the FocusMap use IActiveView::FocusMap.
A user's map may comprise one or more Map objects. Each Map object typically holds layers of data as well as several MapSurround objects such as a Legend. This property returns an IMap reference to the Map object that currently has focus. In ArcMap, the focus map is the one visible in data view and the one selected in layout view.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.com.esri.arcgis.arcmapUI.IActiveView
ILayer getSelectedLayer() throws IOException, AutomationException
Returns the currently selected layer in the table of contents.
To select a layer in the table of contents, obtain an IContentsView reference via IMxDocument::ContentsView, then use either IContentsView::AddToSelectedItems or IContentsView::SelectedItem. To learn more, read the help for IContentsView.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.Object getSelectedItem() throws IOException, AutomationException
This property returns a reference to the currently selected item in the table of contents. The return is an IUnknown because there are several possbile objects the selected item can be.
When working in the Display tab, the reference could be to a Map object if you have a data frame selected, one of the Layer objects (FeatureLayer, FDOGraphicsLayer, etc) if you have a layer selected, or a LegendGroup if you have a unique value or heading selected.
In the Source tab, the reference can be to any of the above objects plus a Table, FeatureDataset, or Workspace.
In the case where more than one item is selected, the reference is to a Set object.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.Object getContextItem() throws IOException, AutomationException
This property returns the item that was last right-clicked in the table of contents. Use this property when creating a custom context menu. For example, after right-clicking on a layer in the table of contents, a context menu appears which has several commands including Copy and Remove.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setContextItem(Object item) throws IOException, AutomationException
item
- A reference to another Object (IUnknown) (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IStyleGallery getStyleGallery() throws IOException, AutomationException
The StyleGallery is an object that manages styles. Styles are a collection of predefined colors, symbols, properties of symbols, and map elements that are used to create maps. Styles help organizations follow a mapping standard and help promote consistency in mapping products.
The StyleGallery is the object underlying the Style Manager window in ArcMap. There is one StyleGallery object per application and it is global. Instantiating a new StyleGallery object really finds the one created by the application.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void addLayer(ILayer layer) throws IOException, AutomationException
This method is a shortcut to the AddLayer method on the focus map (IMap::Addlayer).
layer
- A reference to a com.esri.arcgis.carto.ILayer (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.com.esri.arcgis.arcmapUI.IMap
void updateContents() throws IOException, AutomationException
Refreshes the current view in the table of contents. UpdateContents is a shortcut - it calls Refresh on the current contents view (IContentsView::Refresh). Access to the current view is provided through IMxDocument::CurrentContentsView.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.double getSearchTolerance() throws IOException, AutomationException
The application's search tolerance is measured and set using pixel units. This property automatically converts the size of the pixels to map units. The example shows how this conversion is done.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.int getSearchTolerancePixels() throws IOException, AutomationException
This property controls the application's search tolerance. The search tolerance is measured in pixel units. Use IMxDocument::SearchTolerance to check the search tolerance in map units.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setSearchTolerancePixels(int tol) throws IOException, AutomationException
tol
- The tol (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void insertObject() throws IOException, AutomationException
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void canInsertObject(boolean[] pEnabled) throws IOException, AutomationException
pEnabled
- The pEnabled (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IMaps getMaps() throws IOException, AutomationException
The map document has a collection of Map objects which are accessible through this property. The reference IMaps is typically used to add and delete maps from the collection.
See the FocusMap property on this interface for accessing just the one map with focus.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IMaps
IOperationStack getOperationStack() throws IOException, AutomationException
The map document manages an operation stack which provides undo/redo functionality. Modifications, including those to elements and features, are typically wrapped inside an operation. Operations are added to the operation stack so the modification can be rolled out and then rolled back if desired. For example, when a graphic element is moved, the operation can be undone moving the graphic back to its original location.
Depending on your scenario, there are different methodologies for creating an operation and adding it to the OperationStack.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IOperationStack
Font getDefaultTextFont() throws IOException, AutomationException
This property conveniently stores a default font for any tool requiring one. For example, the New Text tool adds text graphics to an active view and initially uses the font stored in this property.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setDefaultTextFontSize(IFontSize fontSize) throws IOException, AutomationException
fontSize
- A reference to a com.esri.arcgis.display.IFontSize (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IFontSize getDefaultTextFontSize() throws IOException, AutomationException
This property conveniently stores a default font size for any tool requiring one. For example, the New Text tool on ArcMap's Draw toolbar, adds text graphics to an active view and initially uses the font size stored in this property.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setDefaultTextFont(Font fontDisp) throws IOException, AutomationException
fontDisp
- A reference to a com.esri.arcgis.support.ms.stdole.Font (A com.esri.arcgis.support.ms.stdole.Font COM typedef) (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IColor getDefaultColor(int type) throws IOException, AutomationException
type
- A com.esri.arcgis.arcmapui.esriMxDefaultColorTypes constant (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setDefaultColor(int type, IColor color) throws IOException, AutomationException
type
- A com.esri.arcgis.arcmapui.esriMxDefaultColorTypes constant (in)color
- A reference to a com.esri.arcgis.display.IColor (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IPoint getCurrentLocation() throws IOException, AutomationException
A lot of tools require the current mouse location in order to perform an operation. This property provides a short-cut alternative to having to manually calculate the current mouse location in map units. For example, a typical pan tool needs the current mouse location in three different places: when the mouse if first clicked, while the mouse drags, and when the button is released. Although ITool provides the mouse location for each of these events, the location is given in x,y device units. Rather than writing a function that uses something like IDisplayTransformation::ToMapPoint to calculate the location in map units, the Location property does this automatically behind the scenes.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setCurrentLocation(IPoint mouseLoc) throws IOException, AutomationException
mouseLoc
- A reference to a com.esri.arcgis.geometry.IPoint (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setDelayUpdateContents(boolean rhs1) throws IOException, AutomationException
Delays calling refresh of the current contents view. For example, after loading a layer you should call UpdateContents to refresh the contents view (table on contents). When loading several layers, there is no need to refresh the contents view after each layer is loaded; instead, delay refreshing the contents view until all the layers have been loaded.
All calls to UpdateContents are ignored when DelayUpdateContents is set to TRUE. To ensure the contents view is ultimately refreshed, UpdateContents is automatically called when DelayUpdateContents is set back to FALSE.
rhs1
- The rhs1 (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.boolean isRelativePaths() throws IOException, AutomationException
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setRelativePaths(boolean relPaths) throws IOException, AutomationException
relPaths
- The relPaths (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IContentsView getCurrentContentsView() throws IOException, AutomationException
A contents view is a tab in the table of contents. ArcMap ships with two contents views, Display and Source. The object behind Display is TOCDisplayView and TOCCatalogView is behind the Source view. Custom contents views can be created by implementing the IContentsView interface. Only one contents view can be active at a time. Use this property to set the current contents view and to get a reference to the current contents view. Setting the current contents view automatically calls IContentsView::Refresh.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.void setCurrentContentsViewByRef(IContentsView view) throws IOException, AutomationException
view
- A reference to a com.esri.arcgis.arcmapui.IContentsView (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.int getContentsViewCount() throws IOException, AutomationException
A contents view is a tab in the table of contents. ArcMap ships with two contents views: Display (TOCDisplayView) and Source (TOCCatalogView). Create custom contents views by implementing the IContentsView interface. Only one contents view can be active at a time. This property returns the number of contents views registered in the ESRI Contents Views component category. The Display contents view is not listed here as it is the default.
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.IContentsView getContentsView(int index) throws IOException, AutomationException
index
- The index (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.ITableProperties getTableProperties() throws IOException, AutomationException
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |