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;
        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

  • You've posted 2 snippets...which one throws error? Are you trying to use the second snippet for ArcGIS Desktop customization? If yes, you'd be getting problems cause Hookhelper is designed for ArcEngine and not Desktop. Read this
    – ujjwalesri
    Jul 4, 2011 at 5:40
  • The second snippet throws the error. Thanks for pointing out, that it is not for extending a desktop application.
    – user3543
    Jul 5, 2011 at 12:25
  • Is there another way to obtain reference to actual layer from layers custom property page?
    – user3543
    Jul 5, 2011 at 12:35
  • What version are you on? Did you try following this sample? Jul 5, 2011 at 19:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.