How to create a dynamic glyph from a marker symbol


Summary Drawing dynamic content to the dynamic display is done with dynamic glyphs. Dynamic glyphs handle the necessary resources to be rendered by the dynamic symbol. This can be a resource for a line, marker, or text. This document guides you through the required steps to create glyphs for a marker symbol and draw them on the map.

Creating dynamic glyphs

Creation of dynamic glyphs must take place inside one of the dynamic drawing methods; either inside IDynamicLayer.drawDynamicLayer or one of the DynamicDisplayEvents callbacks (IDynamicMapEvents.beforeDraw and IDynamicMapEvents.afterDraw). This is because the creation of a DynamicGlyph is done through the DynamicGlyphFactory, which is a property of the DynamicDisplay where the DynamicDisplay is a parameter of these methods.
 
Obtaining DynamicGlyphFactory and DynamicSymbolProperties from the DynamicDisplay
It is highly recommended to keep the DynamicGlyphFactory and DynamicSymbolProperties as class members and only get them once from the DynamicDisplay, since they will be used many times throughout the lifetime of the application. See the following:
[Java]
if (bOnce){
    //Get the DynamicGlyphFactory from the DynamicDisplay.
    dynamicGlyphFactory = DynamicDisplay.getDynamicGlyphFactory();
    //Cast the DynamicDisplay into DynamicSymbolProperties.
    dynamicSymbolProps = (IDynamicSymbolProperties)DynamicDisplay;
    � � � 
    //Do other initializations here.
    //Call a method to create your glyph.
    CreateMarkerGlyph();

    bOnce = false;
}
Implementing the CreateMarkerGlyph method
The following goes through the required steps to implement the createMarkerGlyph() method.
  1. At the bottom of your code, add a new createMarkerGlyph() private method. See the following:
[Java]
private void createMarkerGlyph(){}
  1. Set the color that will be used as a background by the DynamicGlyph. See the following:
[Java]
//Set the background color to white.
IRgbColor color = new RgbColor();
color.setRed(255);
color.setGreen(255);
color.setBlue(255);
  1. Create the marker symbol. In this example, create a character marker symbol. For convenience, use the ToStdFont() method, which converts a .NET font into stdole.IFontDisp. See the following:
[Java]
ICharacterMarkerSymbol charMarkerSymbol = new CharacterMarkerSymbol();
StdFont font = new StdFont();
font.setName("ESRI Default Marker");
charMarkerSymbol.setFont(font);
  1. Set the font's character index, size, and background color. See the following:
[Java]
charMarkerSymbol.setCharacterIndex(96);
charMarkerSymbol.setSize(12.0);
charMarkerSymbol.setColor((IColor)color);
  1. Use the previously cached DynamicGlyphFactory to generate the glyph. See the following:
[Java]
markerGlyph = dynamicGlyphFactory.createDynamicGlyph((ISymbol)charMarkerSymbol);
The glyph is now created and you can use it to draw the marker on the map.
Drawing the marker element
Before drawing the element, set the dynamic symbol properties. This includes setting the heading, alignment, color, scale, and the glyph.
 
  1. Set the heading of the dynamic symbol. See the following:
[Java]
dynamicSymbolProps.setHeading(esriDynamicSymbolType.esriDSymbolMarker, (float)
    heading);
  1. Set the rotation alignment of the dynamic symbol. The symbol's rotation can be aligned in three positions: with the actual orientation of the element (set by the heading), with the window, or with the north direction (the element will always face north). See the following:
[Java]
//Set the symbol's alignment so that it will align with the symbol's heading.

dynamicSymbolProps.setRotationAlignment(esriDynamicSymbolType.esriDSymbolMarker,
    esriDynamicSymbolRotationAlignment.esriDSRAScreen);
  1. Scale the symbol. Scaling refers to the scale relative to the original size of the active symbol. When scaling, you can use different scaling for x- and y-axis. See the following:
[Java]
dynamicSymbolProps.setScale(esriDynamicSymbolType.esriDSymbolMarker, 1.1f, 1.1f);
  1. Assign color to the symbol. See the following:
[Java]
dynamicSymbolProps.setColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 1.0f,
    0.6f, 1.0f); // GREEN
  1. Set the dynamic glyph. See the following:
[Java]
dynamicSymbolProps.setDynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker,
    markerGlyph);
  1. Draw the marker symbol. You need a point geometry to specify where the marker will be drawn. See the following:
[Java]
dynamicDisplay.drawMarker(point);


See Also:

Dynamic Drawing APIs
Sample :Dynamic Layer WalkThrough
How to draw a bitmap element using OpenGL




Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo