mbw@geus.dk

Custom UVRenderer

Discussion created by mbw@geus.dk on Aug 15, 2011
Hello Forum

I try to implement a custom renderer, that will render a polygon featureclass with unique values.

To start, I simply have hardcoded som colors.

My draw method code goes like this:


 // How to render
 public void draw(IFeatureCursor featureCursor, int drawPhase, IDisplay display, ITrackCancel trackCancel) throws IOException,AutomationException {
     
     try {
      int index = featureCursor.findField("GM_LABEL");

   if (legendID == 1) {
    IFeature feature = featureCursor.nextFeature(); 
    display.setSymbol(blueSymbol());
    do{
     display.drawPolygon(feature.getShape());
     feature = featureCursor.nextFeature();
    }while (feature != null);    
   }

   if (legendID == 2) {
    renderer.setSymbolByRef(greenSymbol());
    renderer.draw(featureCursor, drawPhase, display, trackCancel);  
   }
   
   if (legendID == 3) {

    uvRenderer.setFieldCount(1);
    uvRenderer.setField(0, "GM_LABEL");
    uvRenderer.setDefaultSymbol(redSymbol());
    uvRenderer.setUseDefaultSymbol(true);

    uvRenderer.addValue("LAK", null, blueSymbol());
    uvRenderer.setLabel("LAK", "Blue");
    
    uvRenderer.draw(featureCursor, drawPhase, display, trackCancel);    
   }
   
  } catch (Exception e) {
   System.out.println(e.getMessage());
  }

  return;
 }



This is a desktop extension in java.
The first option draws directly to display as in the custom renderer example, works well.
The second option works via a simple renderer, works well too.
The third option is a try to use a Unique Value Renderer, does not render anything. The polygons are not rendered, screen becomes white.

Does anybody know, if I am missing something, or if it is not possible to reference another renderer from inside the draw method.

Any answer appreciated

Marianne B. Wiese

Outcomes