com.esri.arcgis.display
Class MapContext

java.lang.Object
  extended by com.esri.arcgis.display.MapContext
All Implemented Interfaces:
IMapContext, com.esri.arcgis.interop.RemoteObjRef, ISupportErrorInfo, Serializable

public class MapContext
extends Object
implements com.esri.arcgis.interop.RemoteObjRef, IMapContext, ISupportErrorInfo

The context in which geometric effects and marker placement work.

Remarks

There are three reference frames which are used for data translation between geographic, map and output display context. These frames are:

  1. Geographic Reference Frame: A feature layer represents geographic data and may be re-projected prior to drawing the features onto a map.
  2. Map Reference Frame: This is an intermediate frame introduced to define a clear context in which geometric effects and all on-the-fly processing works. This frame is similar to the map sheet frame which is used with a 72 dpi graphic resolution centered at the center of the geographic spatial reference. The advantage of having the map reference frame is to provide a stable context for geometric effects and marker placement properties as this is in a graphic frame but independent of zoom levels and pan positions. All linear attributes (distance/length) are relative to this frame. For example, a 12 point offset is a 12 unit displacement in MRF. Effects will store these attributes in MRF units and use them without any transformation.
  3. Output Reference Frame: This consists of an output device, that displays the map with a zoom level which is not equal to the reference scale and a changed center position.

MapContext CoClass relates to the Map Reference Frame. IMapContext interface manages the map context object.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

See Also:
Serialized Form

Constructor Summary
MapContext()
          Constructs a MapContext using ArcGIS Engine.
MapContext(Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
MapContext theMapContext = (MapContext) obj;
 
Method Summary
 boolean equals(Object o)
          Compare this object with another
 IGeometry fromGeographyToMap(IGeometry ingeom)
          Converts geographic geometry to map context geometry.
 IGeometry fromMapToGeography(IGeometry ingeom)
          Converts map context geometry to geographic geometry.
 double fromPoints(double ptDist)
          Converts a distance expressed in points into a geographic distance.
static String getClsid()
          getClsid.
 double getReferenceScale()
          The reference scale of the map.
 ISpatialReference getSpatialReference()
          The spatial reference of the map.
 int hashCode()
          the hashcode for this object
 void init(ISpatialReference mapProj, double mapRefScale, IEnvelope mapExtent)
          Initializes the map context.
 void initFromDisplay(IDisplayTransformation displayTransform)
          Initializes the map context using a display transformation.
 void interfaceSupportsErrorInfo(GUID riid)
          interfaceSupportsErrorInfo
 double toPoints(double mapDist)
          Converts a geographic distance into a distance expressed in points.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef
getJintegraDispatch, release
 

Constructor Detail

MapContext

public MapContext()
           throws IOException,
                  UnknownHostException
Constructs a MapContext using ArcGIS Engine.

Throws:
IOException - if there are interop problems
UnknownHostException - if there are interop problems

MapContext

public MapContext(Object obj)
           throws IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
MapContext theMapContext = (MapContext) obj;

Construct a MapContext using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to MapContext.

Parameters:
obj - an object returned from ArcGIS Engine or Server
Throws:
IOException - if there are interop problems
Method Detail

getClsid

public static String getClsid()
getClsid.


equals

public boolean equals(Object o)
Compare this object with another

Overrides:
equals in class Object

hashCode

public int hashCode()
the hashcode for this object

Overrides:
hashCode in class Object

initFromDisplay

public void initFromDisplay(IDisplayTransformation displayTransform)
                     throws IOException,
                            AutomationException
Initializes the map context using a display transformation.

Remarks

Use this method when you create a reference to a new MapContext object to initialize the mapcontext using a DisplayTransformation that exists. If a reference to a DisplayTransformation does not exist, then use IMapContext::Init method to initialize the map context. It is important to initialize the map context as this will help in getting correct context for displaying and drawing geometric effects and marker placements.

Use the following code snippet to initialize a MapContext using display settings from a map document


Dim pMxDoc As IMxDocument
Dim pMap As IMap
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap

'set the MapContext object from current display settings
Dim pMapContext As IMapContext
Dim pMxApp As IMxApplication
Set pMxApp = Application 'QI
Set pMapContext = New MapContext
pMapContext.InitFromDisplay pMxApp.Display.DisplayTransformation

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
initFromDisplay in interface IMapContext
Parameters:
displayTransform - A reference to a com.esri.arcgis.display.IDisplayTransformation (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

init

public void init(ISpatialReference mapProj,
                 double mapRefScale,
                 IEnvelope mapExtent)
          throws IOException,
                 AutomationException
Initializes the map context.

Remarks

Use this method when you create a reference to a new MapContext object to initialize the mapcontext. If a reference to a DisplayTransformation exists, then use IMapContext::InitFromDisplay method to initialize the map context. It is important to initialize the map context as this will help in getting correct context for displaying and drawing geometric effects and marker placements.

'initialize new mapcontext using a feature class's spatial reference and extent

Dim pMapContext As IMapContext

Dim pGFClass As IGeoDataset

Set pMapContext = New MapContext

Set pGFClass = pFClass

pMapContext.Init pGFClass.SpatialReference, 25000, pGFClass.Extent

Set pRepresentation = pRepClass.GetRepresentation(pFeat, pMapContext)

'where pFeat is reference to a Feature object and pFClass is reference to a FeatureClass object

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
init in interface IMapContext
Parameters:
mapProj - A reference to a com.esri.arcgis.geometry.ISpatialReference (in)
mapRefScale - The mapRefScale (in)
mapExtent - A reference to a com.esri.arcgis.geometry.IEnvelope (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

fromGeographyToMap

public IGeometry fromGeographyToMap(IGeometry ingeom)
                             throws IOException,
                                    AutomationException
Converts geographic geometry to map context geometry.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
fromGeographyToMap in interface IMapContext
Parameters:
ingeom - A reference to a com.esri.arcgis.geometry.IGeometry (in)
Returns:
A reference to a com.esri.arcgis.geometry.IGeometry
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

fromMapToGeography

public IGeometry fromMapToGeography(IGeometry ingeom)
                             throws IOException,
                                    AutomationException
Converts map context geometry to geographic geometry.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
fromMapToGeography in interface IMapContext
Parameters:
ingeom - A reference to a com.esri.arcgis.geometry.IGeometry (in)
Returns:
A reference to a com.esri.arcgis.geometry.IGeometry
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getReferenceScale

public double getReferenceScale()
                         throws IOException,
                                AutomationException
The reference scale of the map.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
getReferenceScale in interface IMapContext
Returns:
The refScale
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getSpatialReference

public ISpatialReference getSpatialReference()
                                      throws IOException,
                                             AutomationException
The spatial reference of the map.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
getSpatialReference in interface IMapContext
Returns:
A reference to a com.esri.arcgis.geometry.ISpatialReference
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

fromPoints

public double fromPoints(double ptDist)
                  throws IOException,
                         AutomationException
Converts a distance expressed in points into a geographic distance.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
fromPoints in interface IMapContext
Parameters:
ptDist - The ptDist (in)
Returns:
The mapDist
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

toPoints

public double toPoints(double mapDist)
                throws IOException,
                       AutomationException
Converts a geographic distance into a distance expressed in points.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
toPoints in interface IMapContext
Parameters:
mapDist - The mapDist (in)
Returns:
The ptDist
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

interfaceSupportsErrorInfo

public void interfaceSupportsErrorInfo(GUID riid)
                                throws IOException,
                                       AutomationException
interfaceSupportsErrorInfo

Description

Indicates whether the interface supports IErrorInfo.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
interfaceSupportsErrorInfo in interface ISupportErrorInfo
Parameters:
riid - A Structure: com.esri.arcgis.support.ms.stdole.GUID (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.