Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
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 '11 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 '11 at 12:25
    
Is there another way to obtain reference to actual layer from layers custom property page? –  user3543 Jul 5 '11 at 12:35
    
What version are you on? Did you try following this sample? –  Kirk Kuykendall Jul 5 '11 at 19:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.