vbothello

Change graphic color on select (JAVA)

Discussion created by vbothello on Mar 22, 2012
For ArcGIS desktop I???m trying to highlight my selected graphic when a user clicks on it but I seem to get an error at the line graphicsContainer.updateElement(pElem), Does anyone happen to know what I might be doing wrong.

Appreciate the help.
Vik

try
{
IEnumElement enumElement = graphicsContainer.locateElements(point, LOCATE_ELEMENT_TOLARANCE);
IElement pElem = null ;
if (enumElement != null)
{
pElem = (IElement) enumElement.next();

graphicsContainerSelect.selectElement(pElem);

//Change the color of the selected graphic
IRgbColor pColor = new RgbColor();
pColor.setRGB(255); // red
ISimpleFillSymbol pFillSym = new SimpleFillSymbol();
pFillSym.setColor(pColor);
pFillSym.setStyle(com.esri.arcgis.display.esriSimpleFillStyle.esriSFSSolid);
IFillShapeElement fillShapeElement = null;
fillShapeElement = new PolygonElement();
fillShapeElement.setSymbol(pFillSym);
pElem = (IElement) fillShapeElement;

//Errors out here
graphicsContainer.updateElement(pElem);

System.out.println("Graphic Selected");

}
System.out.println(" graphicsContainerSelect.getElementSelectionCount() " + graphicsContainerSelect.getElementSelectionCount());
mxDocument.getActivatedView().partialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null);
} catch ( Exception e ) { e.printStackTrace(); }

Outcomes