Make IPictureMarkerSymbol file path accessible to all users?

186
1
01-28-2020 01:31 PM
LaurenPeckman
New Contributor II

I've written a little java add-in button for ArcDesktop 10.4, in eclipse, which makes a new ArcMap layer with some points. (NOT Runtime) My goal is to assign a picture as the symbol for each of these points. I have success on my machine, but I can't figure out how to make my picture accessible to all future users.

Here's my class, part of larger program, which does work, but image currently only comes through from path on my own computer:

```

public class SymbologyChanger {
public
SymbologyChanger(ArrayList<Point> pointsForTheLayer, IMap currentMap) throws AutomationException, IOException {
      IGraphicsContainer graphContainer = (IGraphicsContainer) currentMap.getActiveGraphicsLayer();
      for (int i = 0; i < pointsForTheLayer.size(); i++) {
         Point point = (Point) pointsForTheLayer.get(i);
         double symbolSize = 15;
         IPictureMarkerSymbol picSym = new PictureMarkerSymbol();
         picSym
.setSize(symbolSize);
         // http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriDisplay/esriIPictureType.htm

         picSym
.createMarkerSymbolFromFile(1, "C:\\Users\\userName\\eclipseWorkspace\\java_project\\images\\my_image.bmp");

         IMarkerElement markerElement = new MarkerElement();
         markerElement
.setSymbol(picSym);
         IElement element = (IElement) markerElement;
         element
.setGeometry(point); g
         raphContainer
.addElement(element, 0);
         }
      }
}
```

inspiration from: 
arcgissamples\cartography\DrawSymbolMain.java—ArcObjects 10.4 Help for Java | ArcGIS for Desktop 

So it's this particular line:

```

picSym.createMarkerSymbolFromFile(1, "C:\Users\userName\eclipseWorkspace\java_project\images\my_image.bmp");

```

which is my problem. I've placed the image in the project images folder, along with the button icon. The button icon totally works, but for the points symbol, I've tried:

```

picSym.createMarkerSymbolFromFile(1, "images\my_image.bmp");

```

And this does not work. Again, I get the image I want for the point symbol, but how to set the path correctly to share with others? I need the image to work as the point symbol with all machines, not just my own.

0 Kudos
1 Reply
LaurenPeckman
New Contributor II

I have tried:
1. placing the bitmap image in the package with the java classes
2. grabbing that image via InputStream
3. Casting the inputStream to an Object
4. using the IPIctureMarkerSymbol.equals(Object object) method. 

The program does not fail or produce an error, but the image does NOT display with this attempt.
Again the image DOES display with the file path as String, but that is not a sustainable plan for deploying the add-in.  
Still stumped. 
```

public class SymbologyChanger {
  public
SymbologyChanger(ArrayList<Point> pointsForTheLayer, IMap currentMap) throws AutomationException, IOException {    
      IGraphicsContainer graphContainer = (IGraphicsContainer) currentMap.getActiveGraphicsLayer();    
      for (int i = 0; i < pointsForTheLayer.size(); i++) {       
         Point point = (Point) pointsForTheLayer.get(i);        
         double symbolSize = 15;       
         IPictureMarkerSymbol picSym = new PictureMarkerSymbol();       
         picSym
.setSize(symbolSize);       
      
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream inputStream = getClass().getResourceAsStream("my_image.bmp");
         Object inputObj = (Object) inputStream;
         picSym.equals(inputObj);
     
         IMarkerElement markerElement = new MarkerElement();       
         markerElement
.setSymbol(picSym);       
         IElement element = (IElement) markerElement;       
         element
.setGeometry(point);       
         graphContainer
.addElement(element, 0);         
         }   
      }
}
```
0 Kudos