18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

JAVA APPLICATION PROGRAMMING INTERFACE<br />

ArrayStoreException as ArcObjects is attempting to populate an IPolyline array with<br />

an IGeometry object, attempting to place a superclass type into a subclass array.<br />

The correct way to use this method is outlined below:<br />

/* Set up the array and call the method. */<br />

IGeometry[] geoArray = {new Polyline()};<br />

tin.interpolateShape( breakline, geoArray, null );<br />

/* "Cast" the first array element as a Polyline - this is<br />

* the equivalent of calling QueryInterface on IGeometry.<br />

*/<br />

IPolyline firstPolyLine = new IPolylineProxy(geoArray[0]);<br />

Non-OLE automation-compliant types<br />

A few ArcObjects types are not OLE automation-compliant. They contain methods<br />

that do not work in the <strong>ArcGIS</strong> API for Java. The API addresses each of<br />

these situations in one of two ways:<br />

1. Supplemental interfaces have been added that have the offending methods<br />

overwritten in an automation-compliant way. These new interfaces are named<br />

by appending them with the letters “GEN”, implying that they are generic for<br />

all supported APIs. In these cases, the noncompliant interface is deprecated<br />

with a link to the appropriate GEN interface. In the following example,<br />

“somePoints” is an array of Point with two Point objects in it.<br />

/* Not automation compatible - throws exception */<br />

IEnvelope env = new Envelope();<br />

env.defineFromPoints(2, somePoints[0]);<br />

/* Automation compatible */<br />

IEnvelopeGEN envGEN = new Envelope();<br />

envGEN.defineFromPoints(somePoints);<br />

2. A singleton utility class implements bridge interfaces. Since each utility class<br />

can handle methods from multiple noncompliant interfaces, there is no naming<br />

convention for the utility classes. The bridge interfaces handle the effort of<br />

converting between noncompliant and compliant methods. In these cases, the<br />

noncompliant methods are deprecated, with a link to the appropriate bridge<br />

method in the utility class. To call the bridge method, simply pass in the<br />

noncompliant object as the first argument. In this example,<br />

myPointCollection4 is an instance of IPointCollection4, and<br />

somePointStructures is an array of WKSPointZ objects with four objects in<br />

it.<br />

/* Not automation compatible - throws exception */<br />

myPointCollection4.addWKSPointZs (4, somePointStructures[0]);<br />

/* Automation compatible */<br />

GeometryEnvironment geomEnv = new GeometryEnvironment();<br />

geomEnv.addWKSPointZs(myPointCollection4, somePointStructures);<br />

Using visual beans<br />

The <strong>ArcGIS</strong> API for Java provides a set of reusable components as prebuilt<br />

pieces of software code designed to provide graphical functions. As a visual beans<br />

developer, you only need to write code to “buddy” them into your <strong>ArcGIS</strong> En-<br />

194 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!