Does anyone use Java to make Add-in for Desktop Extension?

Discussion created by mbw@geus.dk on Jul 17, 2011
Latest reply on Jul 19, 2011 by mbw@geus.dk
Hello Forum

I am trying to make a custom renderer as a Java add-in. I made the following very simple code, which paints all polygons green.
The strange thing is, that each time i compile this program, it will work the first time I try it out in ArcMap.
If I close restart ArcMap, then all polygons get painted in red by this Add-in, which I guess is a sort of fall back behaviour.
No error is catched, and the printlines in the draw method are both printed to the console. I make the greenFillSymbol new each time. So I do not understand this behaviour at all.
My question is, if anyone out there is actually making Java Add-ins for Desktop extensions?
It may be, that I should revert to C++, and wait for another version of ArcGIS before changing to Java.

I have attached the sorce.

Best Regards

Marianne Wiese

package dk.geus;

import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
import com.esri.arcgis.carto.*;
import com.esri.arcgis.display.*;
import com.esri.arcgis.geodatabase.*;
import com.esri.arcgis.geometry.*;
import com.esri.arcgis.interop.AutomationException;
import com.esri.arcgis.system.*;
import com.esri.arcgis.interop.extn.ArcGISExtension;

public class LegendRenderer implements IFeatureRenderer {
 private static final long serialVersionUID = 1L;

 public LegendRenderer() { }

    public SimpleFillSymbol greenSymbol() {
     SimpleFillSymbol greenFillSymbol = null;
     try {
            greenFillSymbol = new SimpleFillSymbol();
            IColor greenColor = new RgbColor();
     } catch (Exception e) {
     return greenFillSymbol; 
 // Available only for specific geometry types
 public boolean canRender(IFeatureClass fc, IDisplay display) throws IOException, AutomationException {

  if (fc.getShapeType() == esriGeometryType.esriGeometryPolygon)
         return true;
         return false;

 // Could be used for query filter
 public void prepareFilter(IFeatureClass fc, IQueryFilter qFilter)throws IOException, AutomationException { }

 // How to render
 public void draw(IFeatureCursor featureCursor, int drawPhase, IDisplay display, ITrackCancel trackCancel) throws IOException,AutomationException {
  System.out.println("Hello, here I am");
     try {      
   IFeature feature = featureCursor.nextFeature(); 
    feature = featureCursor.nextFeature();
   }while (feature != null);

   System.out.println("Hello, here I was");
  } catch (Exception e) {

 public ISymbol getSymbolByFeature(IFeature arg0) throws IOException,AutomationException {
  return null;

 public boolean isRenderPhase(int drawPhase) throws IOException,AutomationException {
  if (drawPhase == esriDrawPhase.esriDPGeography) return true;
     else return false;

 public void setExclusionSetByRef(IFeatureIDSet featureIDSet)throws IOException, AutomationException { }

 public void writeExternal(ObjectOutput out) throws IOException { }

 public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException { }