${iServerJava6R_ThemeGridRange_Title}

${iServerJava6R_ThemeGridRange_Description}

Inheritance: Theme
        internal static ThemeGridRange FromJson(JsonObject json)
        {
            if (json == null) return null;
            ThemeGridRange themeGridRange = new ThemeGridRange();

            if (json["items"] != null && json["items"].Count > 0)
            {
                List<ThemeGridRangeItem> itemsList = new List<ThemeGridRangeItem>();
                foreach (JsonObject item in (JsonArray)json["items"])
                {
                    itemsList.Add(ThemeGridRangeItem.FromJson(item));
                }

                themeGridRange.Items = itemsList;
            }

            if (json["colorGradientType"] != null)
            {
                themeGridRange.ColorGradientType = (ColorGradientType)Enum.Parse(typeof(ColorGradientType), json["colorGradientType"], true);
            }
            else
            {
                //这里不处理为空时的情况
            }

            if (json["rangeMode"] != null)
            {
                themeGridRange.RangeMode = (RangeMode)Enum.Parse(typeof(RangeMode), json["rangeMode"], true);
            }
            else
            {
                //不处理Null的情况
            }
            themeGridRange.RangeParameter = (double)json["rangeParameter"];
            themeGridRange.ReverseColor = (Boolean)json["reverseColor"];
            return themeGridRange;
        }
        //分析成功,利用生成的插值数据制作范围分段专题图
        private void processCompleted(object sender, InterpolateAnalystArgs e)
        {
            List<ThemeGridRangeItem> themeRangeItems = new List<ThemeGridRangeItem>
                {
                     new ThemeGridRangeItem
                     {
                         Start =-5,
                         End =-3.4,
                         Color = new ServerColor(170,240,233)
                     },

                    new ThemeGridRangeItem
                    {
                        Start =-3.4,
                        End =-1.8,
                        Color =new ServerColor(176,243,196)
                    },

                     new ThemeGridRangeItem
                    {
                        Start =-1.8,
                        End =-0.2,
                        Color =new ServerColor(198,249,178)
                    },

                      new ThemeGridRangeItem
                    {
                        Start =-0.2,
                        End =1.4,
                        Color =new ServerColor(235,249,174)
                    },

                      new ThemeGridRangeItem
                    {
                        Start =1.4,
                        End =3,
                        Color =new ServerColor(188,224,123)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =3,
                        End =4.6,
                        Color =new ServerColor(88,185,63)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =4.6,
                        End =6.2,
                        Color =new ServerColor(25,147,52)
                    },

                   new ThemeGridRangeItem
                    {
                        Start =6.2,
                        End =7.8,
                        Color =new ServerColor(54,138,58)
                    },

                  new ThemeGridRangeItem
                    {
                        Start =7.8,
                        End =9.4,
                        Color =new ServerColor(131,158,47)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =9.4,
                        End =11,
                        Color =new ServerColor(201,174,28)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =11,
                        End =12.6,
                        Color =new ServerColor(232,154,7)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =12.6,
                        End =14.2,
                        Color =new ServerColor(204,91,2)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =14.2,
                        End =15.8,
                        Color =new ServerColor(174,54,1)
                    },

                     new ThemeGridRangeItem
                    {
                        Start =15.8,
                        End =17.4,
                        Color =new ServerColor(127,13,1)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =17.4,
                        End =19,
                        Color =new ServerColor(115,23,6)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =19,
                        End =20.6,
                        Color =new ServerColor(111,36,8)
                    },

                   new ThemeGridRangeItem
                    {
                        Start =20.6,
                        End =22.2,
                        Color =new ServerColor(107,47,14)
                    },

                    new ThemeGridRangeItem
                    {
                        Start =22.2,
                        End =23.8,
                        Color =new ServerColor(125,75,44)
                    },

                   new ThemeGridRangeItem
                    {
                        Start =23.8,
                        End =25.4,
                        Color =new ServerColor(146,110,88)
                    },

                     new ThemeGridRangeItem
                    {
                        Start =25.4,
                        End =27,
                        Color =new ServerColor(166,153,146)
                    },

            };

            //设置栅格分段专题图分段模式、反序显示参数和子项数组
            ThemeGridRange themeGridRange = new ThemeGridRange
            {
                RangeMode = RangeMode.EQUALINTERVAL,
                ReverseColor = false,
                Items = themeRangeItems,
            };

            //设置专题图参数
            ThemeParameters parameter = new ThemeParameters
            {
                DatasetName = e.Result.Dataset.Split('@')[0],
                DataSourceName = "Interpolation",
                Themes = new List<Theme> { themeGridRange },
            };
            //与服务器交互
            ThemeService themeService = new ThemeService(mapUrl);
            themeService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeServie_ProcessCompleted);
            themeService.Failed += new EventHandler<ServiceFailedEventArgs>(themeServie_Failed);
            themeService.ProcessAsync(parameter);
        }
        internal static string ToJson(ThemeGridRange themeGridRange)
        {
            string json = "{";
            List<string> list = new List<string>();

            if (themeGridRange.Items != null && themeGridRange.Items.Count >= 1)
            {
                List<string> tempTUI = new List<string>();
                foreach (var item in themeGridRange.Items)
                {
                    tempTUI.Add(ThemeGridRangeItem.ToJson(item));
                }

                list.Add(string.Format("\"items\":[{0}]", String.Join(",", tempTUI.ToArray())));
            }
            else
            {
                list.Add("\"items\":[]");
            }

            list.Add(string.Format("\"rangeParameter\":\"{0}\"", themeGridRange.RangeParameter.ToString(System.Globalization.CultureInfo.InvariantCulture)));

            list.Add(string.Format("\"rangeMode\":\"{0}\"", themeGridRange.RangeMode));
            list.Add(string.Format("\"colorGradientType\":\"{0}\"", themeGridRange.ColorGradientType.ToString()));

            list.Add("\"type\":\"GRIDRANGE\"");
            list.Add(string.Format("\"reverseColor\":\"{0}\"",themeGridRange.ReverseColor.ToString()));

            json += string.Join(",", list.ToArray());
            json += "}";

            return json;
        }