I am trying to implement a java add-in version of this solution: unique value symbolize layers from a lookup table. At the same time I want to start coding in Java for the ArcGIS Desktop, so I am rewriting the sample Custom renderer, which is implemented as a property page in the layers -> properties -> Symbology -> Custom Renderer tab. The above solution uses
IGeoFeatureLayer gfLayer = mxDoc.FocusMap.get_Layer(0) as IGeoFeatureLayer; gfLayer.Renderer = (IFeatureRenderer)UvrItem.MakeUVR(@"Filepath");
Now, ArcMap surely knows the featurelayer, when editing its properties. But the Custom renderer is just handed a featureCursor. So I try to get a reference to GeoFeatureLayer through the activeView like this:
public boolean canRender(IFeatureClass fc, IDisplay display) throws IOException, AutomationException {
try {
HookHelper hookhelper = new HookHelper();
IActiveView activeView = hookhelper.getActiveView();
System.out.println("The Layer Name Is: " + activeView.getFocusMap().getLayer(0).getName());
} catch (Exception e) {
System.out.println(e.getMessage() + e.getStackTrace().toString());
}
if (fc.getShapeType() == esriGeometryType.esriGeometryPolygon)
return true;
else
return false;
}
But I get Error Message: Null.
If anyone more experienced than me knows the best way to do this in java, I would very much appreciate some advice.
Best Regards, Marianne B. Wiese