${iServerJava6R_ThemeLabelBackGround_Title}

${iServerJava6R_ThemeLabelBackGround_Description}

        internal static string ToJson(ThemeLabelBackSetting labelBackSetting)
        {
            string json = "";
            System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();

            if (labelBackSetting.BackStyle != null)
            {
                list.Add(string.Format("\"backStyle\":{0}", ServerStyle.ToJson(labelBackSetting.BackStyle)));
            }
            else
            {
                list.Add(string.Format("\"backStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
            }

            list.Add(string.Format("\"labelBackShape\":\"{0}\"", labelBackSetting.LabelBackShape));
            json = string.Join(",", list.ToArray());
            return json;
        }
        internal static ThemeLabelBackSetting FromJson(JsonObject json)
        {
            if (json == null) return null;
            ThemeLabelBackSetting backSetting = new ThemeLabelBackSetting();

            if (json["backStyle"] != null)
            {
                backSetting.BackStyle = ServerStyle.FromJson((JsonObject)json["backStyle"]);
            }

            if (json["labelBackShape"] != null)
            {
                backSetting.LabelBackShape = (LabelBackShape)Enum.Parse(typeof(LabelBackShape), json["labelBackShape"], true);
            }
            else
            {
                //不处理null的情况
            }
            return backSetting;
        }
        internal static ThemeLabel FromJson(JsonObject json)
        {
            if (json == null) return null;
            ThemeLabel themeLabel = new ThemeLabel();

            ThemeLabelAlongLine alongLine = new ThemeLabelAlongLine();
            if (json["alongLineDirection"] != null)
            {
                alongLine.AlongLineDirection = (AlongLineDirection)Enum.Parse(typeof(AlongLineDirection), json["alongLineDirection"], true);
            }
            else
            {
                //不处理null的情况
            }
            alongLine.AngleFixed = (bool)json["angleFixed"];
            alongLine.IsAlongLine = (bool)json["alongLine"];
            alongLine.LabelRepeatInterval = (double)json["labelRepeatInterval"];
            alongLine.RepeatedLabelAvoided = (bool)json["repeatedLabelAvoided"];
            alongLine.RepeatIntervalFixed = (bool)json["repeatIntervalFixed"];
            themeLabel.AlongLine = alongLine;

            ThemeLabelBackSetting backSetting = new ThemeLabelBackSetting();
            if (json["backStyle"] != null)
            {
                backSetting.BackStyle = ServerStyle.FromJson((JsonObject)json["backStyle"]);
            }
            if (json["labelBackShape"] != null)
            {
                backSetting.LabelBackShape = (LabelBackShape)Enum.Parse(typeof(LabelBackShape), json["labelBackShape"], true);
            }
            else
            {
                //不处理null的情况
            }

            themeLabel.BackSetting = backSetting;

            ThemeFlow flow = new ThemeFlow();
            flow.FlowEnabled = (bool)json["flowEnabled"];
            flow.LeaderLineDisplayed = (bool)json["leaderLineDisplayed"];
            if (json["leaderLineStyle"] != null)
            {
                flow.LeaderLineStyle = ServerStyle.FromJson((JsonObject)json["leaderLineStyle"]);
            }
            themeLabel.Flow = flow;

            List<ThemeLabelItem> items = new List<ThemeLabelItem>();
            if (json["items"] != null && json["items"].Count > 0)
            {
                for (int i = 0; i < json["items"].Count; i++)
                {
                    items.Add(ThemeLabelItem.FromJson(((JsonObject)json["items"][i])));
                }
            }
            themeLabel.Items = items;

            themeLabel.LabelExpression = (string)json["labelExpression"];
            if (json["labelOverLengthMode"] != null)
            {
                themeLabel.LabelOverLengthMode = (LabelOverLengthMode)Enum.Parse(typeof(LabelOverLengthMode), json["labelOverLengthMode"], true);
            }
            else
            {
                //不处理null的情况
            }

            //themeLabel.MatrixCells
            if (json["matrixCells"] != null)
            {
                int rowCount = ((JsonArray)json["matrixCells"]).Count;
                int columnCount = ((JsonArray)((JsonArray)json["matrixCells"])[0]).Count;
                LabelMatrixCell[,] matrixCells = new LabelMatrixCell[columnCount, rowCount];

                for (int column = 0; column < ((JsonArray)json["matrixCells"]).Count; column++)
                {
                    JsonArray cells = (JsonArray)((JsonArray)json["matrixCells"])[column];
                    for (int row = 0; row < cells.Count; row++)
                    {
                        if (cells[row].ContainsKey("height") && cells[row].ContainsKey("pathField") && cells[row].ContainsKey("rotation") && cells[row].ContainsKey("sizeFixed") && cells[row].ContainsKey("width"))
                        {
                            matrixCells[row, column] = (LabelImageCell.FromJson((JsonObject)cells[row]));
                        }
                        else if (cells[row].ContainsKey("style") && cells[row].ContainsKey("symbolIDField"))
                        {
                            matrixCells[row, column] = (LabelSymbolCell.FromJson((JsonObject)cells[row]));
                        }
                        else if (cells[row].ContainsKey("themeLabel"))
                        {
                            matrixCells[row, column] = (LabelThemeCell.FromJson((JsonObject)((JsonObject)cells[row])["themeLabel"]));
                        }
                    }
                }

                themeLabel.MatrixCells = matrixCells;
            }
            themeLabel.MaxLabelLength = (int)json["maxLabelLength"];
            themeLabel.NumericPrecision = (int)json["numericPrecision"];
            themeLabel.Offset = ThemeOffset.FromJson(json);
            themeLabel.OverlapAvoided = (bool)json["overlapAvoided"];
            themeLabel.RangeExpression = (string)json["rangeExpression"];
            themeLabel.SmallGeometryLabeled = (bool)json["smallGeometryLabeled"];
            themeLabel.Text = ThemeLabelText.FromJson(json);
            return themeLabel;
        }