/// <summary> /// Creates an ICustomRenderSettings object which renders shape colors using quantiles /// </summary> /// <remarks> /// <para> /// QuantileCustomRenderSettings are used to render individual shape colors in a shapefile layer according to a specified range of values. For example, /// the color of the rendered shape could be green if field1 is between 0 and 100, yellow if field 1 is between 100 and 200, or red if /// it is greater than 200. /// </para> /// </remarks> /// <param name="renderSettings"></param> /// <param name="quantileColors">The colors used for each quantile. If 5 colors are used then 5 quantiles will be setup </param> /// <param name="shapeFieldName">The field name to use for the quantiles</param> /// <returns></returns> public static ICustomRenderSettings CreateQuantileCustomRenderSettings(RenderSettings renderSettings, System.Drawing.Color[] quantileColors, string shapeFieldName) { int numRecords = renderSettings.DbfReader.DbfRecordHeader.RecordCount; int fieldIndex = renderSettings.DbfReader.IndexOfFieldName(shapeFieldName); double[] samples = new double[numRecords]; //find the range of population values and obtain the quintile quantiles for (int n = 0; n < numRecords; n++) { double d = double.Parse(renderSettings.DbfReader.GetField(n, fieldIndex), System.Globalization.CultureInfo.InvariantCulture); samples[n] = d; } double[] ranges = QuantileRenderSettings.GetQuantiles(samples, quantileColors.Length-1); return new QuantileRenderSettings(renderSettings, quantileColors, ranges, shapeFieldName); }
public TestCustomRenderSettings(RenderSettings renderSettings, string fieldName, float maxValue) { this.maxValue = maxValue; this.renderSettings = renderSettings; this.fieldName = fieldName; string[] fieldNames = renderSettings.DbfReader.GetFieldNames(); int index = fieldNames.Length-1; while (index >= 0) { if (string.Compare(fieldNames[index].Trim(), fieldName, StringComparison.OrdinalIgnoreCase) == 0) { break; } index--; } fieldIndex = index; customImage = CreateCustomImage(renderSettings.GetImageSymbol()); }
/// <summary> /// Constructs a new QuantileCustomRenderSettings instance /// </summary> /// <param name="renderSettings">Reference to a ShapeFile RenderSettings</param> /// <param name="quantileColors">Array of Colors to use. The number of Color elements should be 1 more than the number of quantile elements</param> /// <param name="quantiles">Array of quantile values. Each successive element must be greater than the previous element. Example - {10, 50, 75}</param> /// <param name="shapeFieldName">The name of the shapefile dbf field used to determine what color to render a shape </param> public QuantileRenderSettings(RenderSettings renderSettings, Color[] quantileColors, double[] quantiles, string shapeFieldName) { this.renderSettings = renderSettings; this.rangeColors = quantileColors; Array.Resize<Color>(ref this.rangeColors, quantileColors.Length + 1); this.rangeColors[this.rangeColors.Length - 1] = renderSettings.FillColor; //default color SetupRangeSettings(quantiles, shapeFieldName); }
/// <summary> /// Creates an ICustomRenderSettings object which renders shapes with a random color /// </summary> /// <param name="renderSettings">The shapefile's RenderSettings object</param> /// <param name="seed">Random seed used to create the colors. By supplying a seed the same colors will be used when rendering the shapefile in successive drawing operations </param> /// <returns></returns> public static ICustomRenderSettings CreateRandomColorCustomRenderSettings(RenderSettings renderSettings, int seed) { return new RandomColorRenderSettings(renderSettings, seed); }
public RandomColorRenderSettings(RenderSettings renderSettings, int seed) { int numRecords = renderSettings.DbfReader.DbfRecordHeader.RecordCount; Random r = new Random(seed); colors = new Color[numRecords]; for (int n = numRecords - 1; n >= 0; --n) { colors[n] = Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)); } this.renderSettings = renderSettings; }
/// <summary> /// Constructs a new QuantileCustomRenderSettings instance /// </summary> /// <param name="renderSettings">Reference to a ShapeFile RenderSettings</param> /// <param name="quantileColors">Array of Colors to use. The number of Color elements should be 1 more than the number of quantile elements</param> /// <param name="quantiles">Array of quantile values. Each successive element must be greater than the previous element. Example - {10, 50, 75}</param> /// <param name="shapeFieldName">The name of the shapefile dbf field used to determine what color to render a shape </param> /// <param name="tooltipHeaderFieldList">List of TooltipHeaderFieldNamePair objects used to create a custom tooltip</param> public QuantileCustomRenderSettings(RenderSettings renderSettings, Color[] quantileColors, double[] quantiles, string shapeFieldName, System.Collections.Generic.List<TooltipHeaderFieldNamePair> tooltipHeaderFieldList) { this.renderSettings = renderSettings; this.rangeColors = quantileColors; Array.Resize<Color>(ref this.rangeColors, quantileColors.Length + 1); this.rangeColors[this.rangeColors.Length - 1] = renderSettings.FillColor; if (tooltipHeaderFieldList != null) toolTips = new System.Collections.Generic.Dictionary<int, string>(); SetupRangeSettings(quantiles, shapeFieldName, tooltipHeaderFieldList); }
/// <summary> /// Constructs a new QuantileCustomRenderSettings instance /// </summary> /// <param name="renderSettings">Reference to a ShapeFile RenderSettings</param> /// <param name="quantileColors">Array of Colors to use. The number of Color elements should be 1 more than the number of quantile elements</param> /// <param name="quantiles">Array of quantile values. Each successive element must be greater than the previous element. Example - {10, 50, 75}</param> /// <param name="shapeFieldName">The name of the shapefile dbf field used to determine what color to render a shape </param> public QuantileCustomRenderSettings(RenderSettings renderSettings, Color[] quantileColors, double[] quantiles, string shapeFieldName):this(renderSettings, quantileColors, quantiles, shapeFieldName, null) { }
/// <summary> /// Constructs a new QuantileCustomRenderSettings instance /// </summary> /// <param name="renderSettings">Reference to a ShapeFile RenderSettings</param> /// <param name="quantileColors">Array of Colors to use. The number of Color elements should be 1 more than the number of quantile elements</param> /// <param name="quantiles">Array of quantile values. Each successive element must be greater than the previous element. Example - {10, 50, 75}</param> /// <param name="quantileKey">The name of the column in the imported data used to determine what color to render a shape </param> /// <param name="importData">Data to join on the shapefile layer.</param> /// <param name="shapeJoinKey">The column in the shapefile layer's dbf file used to join to importData</param> /// <param name="importJoinKey">The column in importData used to join on the shapefile layer</param> public QuantileCustomRenderSettings(RenderSettings renderSettings, Color[] quantileColors, double[] quantiles, string quantileKey, DataTable importData, string shapeJoinKey, string importJoinKey) { this.renderSettings = renderSettings; this.rangeColors = quantileColors; Array.Resize<Color>(ref this.rangeColors, quantileColors.Length + 1); this.rangeColors[this.rangeColors.Length - 1] = renderSettings.FillColor; SetupRangeSettings(quantiles, quantileKey, importData, shapeJoinKey, importJoinKey); }
/// <summary> /// constructs a BaseCusomtRenderSettings object /// </summary> /// <param name="renderSettings">A RenderSetting object to provide default ICustomRenderSettings values</param> public BaseCustomRenderSettings(RenderSettings renderSettings) { this.renderSettings = renderSettings; }