Drawing a point on the screen
The following code draws a point on the screen in the ActiveView where the mouse is clicked. The x,y coordinates come from a mousedown click event when the user interacts with the application.
[Java]
static void drawPoint(IActiveView activeView, int x, int y)throws Exception{
IScreenDisplay screenDisplay = activeView.getScreenDisplay();
// Constant.
screenDisplay.startDrawing(screenDisplay.getHDC(), (short)
esriScreenCache.esriNoScreenCache);
ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
ISymbol symbol = (ISymbol)simpleMarkerSymbol;
screenDisplay.setSymbol(symbol);
IDisplayTransformation displayTransformation =
screenDisplay.getDisplayTransformation();
// X and y are in device coordinates.
IPoint point = displayTransformation.toMapPoint(x, y);
screenDisplay.drawPoint(point);
screenDisplay.finishDrawing();
}
See Also:
How to draw a polyline on the screenHow to draw a polygon on the screen
How to draw a rectangle on the screen
Development licensing | Deployment licensing |
---|---|
ArcView | ArcView |
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |
Engine Developer Kit | Engine Runtime |