This document is archived and information here might be outdated. Recommended version. |
Renderer used to draw the topology layer.
[Visual Basic .NET] Public Function get_Renderer ( _ ByVal Index As esriTopologyRenderer _ ) As IFeatureRenderer
[Visual Basic .NET] Public Sub set_Renderer ( _ ByVal Index As esriTopologyRenderer, _ ByVal Renderer As IFeatureRenderer _ )
[C#] public IFeatureRenderer get_Renderer ( esriTopologyRenderer Index );
[C#] public void set_Renderer ( esriTopologyRenderer Index, IFeatureRenderer Renderer );
[C++]
HRESULT get_Renderer(
esriTopologyRenderer Index,
IFeatureRenderer** Renderer
);
[C++]
HRESULT putref_Renderer(
esriTopologyRenderer Index,
IFeatureRenderer* Renderer
);
[C++] Parameters Index [in]
Index is a parameter of type esriTopologyRenderer Renderer [out, retval]
Renderer is a parameter of type IFeatureRenderer** Index [in]
Index is a parameter of type esriTopologyRenderer Renderer [in]
Renderer is a parameter of type IFeatureRenderer*
When defining a unique value renderer for a topology layer, set the symbology's field as "TopoRuleType".
The following routine sets up a unique value renderer for a topology layer.
private void BuildUniqueValRenderer()
{
IMxDocument mxDocument = (IMxDocument)m_application.Document;
ITopologyLayer topologyLayer = mxDocument.FocusMap.get_Layer(0) as ITopologyLayer;
if (topologyLayer == null)
throw new NullReferenceException();
ITopology topology = topologyLayer.Topology;
if (topology == null)
throw new NullReferenceException();
//build colorramp
IRandomColorRamp randomColorRamp = new RandomColorRampClass();
randomColorRamp.MinSaturation = 20;
randomColorRamp.MaxSaturation = 40;
randomColorRamp.MinValue = 85;
randomColorRamp.MaxValue = 100;
randomColorRamp.StartHue = 76;
randomColorRamp.EndHue = 188;
randomColorRamp.UseSeed = true;
randomColorRamp.Seed = 43;
//build unique value renderer
IUniqueValueRenderer uniqueValRenderer = new UniqueValueRendererClass();
uniqueValRenderer.FieldCount = 1;
uniqueValRenderer.set_Field(0,"TopoRuleType");
uniqueValRenderer.DefaultSymbol = null;
uniqueValRenderer.UseDefaultSymbol = false;
uniqueValRenderer.set_FieldType(0, false);
//iterate through topology rules and add value to renderer for each
ITopologyRuleContainer topoRuleContainer = (ITopologyRuleContainer)topology;
IEnumRule enumRule = topoRuleContainer.Rules;
ITopologyRule topoRule = (ITopologyRule)enumRule.Next();
while (topoRule != null)
{
uniqueValRenderer.AddValue(((int)topoRule.TopologyRuleType).ToString(),"Error",
(ISymbol)BuildErrorLineSym());
uniqueValRenderer.set_Label(((int)topoRule.TopologyRuleType).ToString(),
topoRule.Name);
topoRule = (ITopologyRule)enumRule.Next();
}
randomColorRamp.Size = uniqueValRenderer.ValueCount;
bool bCreated = false;
randomColorRamp.CreateRamp(out bCreated);
IEnumColors enumColors = randomColorRamp.Colors;
for(int i = 0; i < uniqueValRenderer.ValueCount - 1; i++)
{
string val = uniqueValRenderer.get_Value(i);
if (val == "")
continue;
ISymbol sym = uniqueValRenderer.get_Symbol(val);
((ISimpleLineSymbol)sym).Color = enumColors.Next();
uniqueValRenderer.set_Symbol(val, sym);
}
uniqueValRenderer.ColorScheme = "Custom";
topologyLayer.set_Renderer(esriTopologyRenderer.esriTRLineErrors,
(IFeatureRenderer)uniqueValRenderer);
mxDocument.UpdateContents();
mxDocument.ActiveView.Refresh();
}
private ISimpleLineSymbol BuildErrorLineSym()
{
ISimpleLineSymbol simLineSymbol = new SimpleLineSymbolClass();
simLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
simLineSymbol.Width = 2.5;
return simLineSymbol;
}