${iServerJava6R_ThemeLabel_Title}
${iServerJava6R_ThemeLabel_Description}
//点击生成专题图触发事件 private void commit_Click(object sender, RoutedEventArgs e) { ThemeLabel labelTheme = new ThemeLabel { BackSetting = new ThemeLabelBackSetting { BackStyle = new ServerStyle { FillForeColor = new Color { R = 124, G = 193, B = 225 }, LineWidth = 0.1, MarkerSize = 1, }, }, Flow = new ThemeFlow { FlowEnabled = true, LeaderLineDisplayed = false, }, LabelExpression = "Capital", LabelOverLengthMode = LabelOverLengthMode.NONE, Offset = new ThemeOffset { OffsetX = "0.1", OffsetY = "0.1", OffsetFixed = false, }, Text = new ThemeLabelText { UniformStyle = new ServerTextStyle { Align = SuperMap.Web.iServerJava6R.TextAlignment.MIDDLECENTER, FontHeight = 4, FontWidth = 0, FontWeight = 10, } }, }; //专题图参数设置 ThemeParameters themeLabelParam = new ThemeParameters { //数据集名称 DatasetName = "Countries", //数据源名称 DataSourceName = "World", Themes = new List<Theme> { labelTheme } }; //与服务器交互 ThemeService themeLableService = new ThemeService(url); themeLableService.ProcessAsync(themeLabelParam); themeLableService.Failed += new EventHandler<ServiceFailedEventArgs>(themeLableService_Failed); themeLableService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeLableService_ProcessCompleted); }
private void ThemeLabelSymbolButton_Click(object sender, RoutedEventArgs e) { ThemeLabel labelTheme = new ThemeLabel { AlongLine = new ThemeLabelAlongLine { RepeatIntervalFixed = false, AlongLineDirection = AlongLineDirection.ALONG_LINE_NORMAL, AngleFixed = false, LabelRepeatInterval = 0, IsAlongLine = false, RepeatedLabelAvoided = false }, BackSetting = new ThemeLabelBackSetting { BackStyle = new ServerStyle { FillForeColor = Colors.Red }, LabelBackShape = LabelBackShape.NONE, }, Flow = new ThemeFlow { FlowEnabled = true, LeaderLineDisplayed = false, LeaderLineStyle = new ServerStyle { FillForeColor = Colors.Green }, }, Items = new List<ThemeLabelItem> { }, LabelExpression = "Cap_Pop", //LabelExpression = "Capital", LabelOverLengthMode = LabelOverLengthMode.NONE, MaxLabelLength = 0, NumericPrecision = 0, Offset = new ThemeOffset { OffsetFixed = false, OffsetX = "20", OffsetY = "0" }, OverlapAvoided = false, RangeExpression = "", SmallGeometryLabeled = false, Text = new ThemeLabelText { MaxTextHeight = 0, MaxTextWidth = 0, MinTextHeight = 0, MinTextWidth = 0, UniformMixedStyle = new LabelMixedTextStyle(), UniformStyle = new ServerTextStyle { Align = SuperMap.Web.iServerJava6R.TextAlignment.MIDDLELEFT, FontName = "黑体", FontHeight = 0, } } }; ThemeParameters themeLabelParams = new ThemeParameters { DatasetName = "Countries", DataSourceName = "World", Themes = new List<Theme> { labelTheme } }; themeLabelParams.JoinItems.Add(new JoinItem { ForeignTableName = "Capitals", JoinFilter = "Countries.Country=Capitals.Country", JoinType = JoinType.LEFTJOIN }); ThemeService themeLabelService = new ThemeService(url); themeLabelService.ProcessAsync(themeLabelParams); themeLabelService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeLabelService_ProcessCompleted); themeLabelService.Failed += new EventHandler<ServiceFailedEventArgs>(themeLabelService_Failed); }
internal static string ToJson(ThemeLabel themeLabel) { string json = "{"; List<string> list = new List<string>(); if (themeLabel.AlongLine != null) { list.Add(ThemeLabelAlongLine.ToJson(themeLabel.AlongLine)); } else { list.Add(string.Format("\"alongLineDirection\":\"{0}\"", AlongLineDirection.ALONG_LINE_NORMAL)); list.Add("\"labelRepeatInterval\":0.0"); } if (themeLabel.BackSetting != null) { list.Add(ThemeLabelBackSetting.ToJson(themeLabel.BackSetting)); } else { list.Add(string.Format("\"backStyle\":{0}", ServerStyle.ToJson(new ServerStyle()))); list.Add("\"labelBackShape\":\"ROUNDRECT\""); } if (themeLabel.Flow != null) { list.Add(ThemeFlow.ToJson(themeLabel.Flow)); } else { list.Add(string.Format("\"leaderLineStyle\":{0}", ServerStyle.ToJson(new ServerStyle()))); } if (themeLabel.Items != null && themeLabel.Items.Count > 1) { List<string> itemList = new List<string>(); foreach (var item in themeLabel.Items) { itemList.Add(ThemeLabelItem.ToJson(item)); } list.Add(string.Format("\"items\":[{0}]", string.Join(",", itemList.ToArray()))); } else { list.Add("\"items\":[]"); } if (!string.IsNullOrEmpty(themeLabel.LabelExpression)) { list.Add(string.Format("\"labelExpression\":\"{0}\"", themeLabel.LabelExpression)); } else { list.Add("\"labelExpression\":\"\""); } list.Add(string.Format("\"labelOverLengthMode\":\"{0}\"", themeLabel.LabelOverLengthMode)); list.Add(string.Format("\"maxLabelLength\":{0}", themeLabel.MaxLabelLength.ToString(System.Globalization.CultureInfo.InvariantCulture))); list.Add(string.Format("\"numericPrecision\":{0}", themeLabel.NumericPrecision.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (themeLabel.Offset != null) { list.Add(ThemeOffset.ToJson(themeLabel.Offset)); } else { list.Add("\"offsetX\":\"\""); list.Add("\"offsetY\":\"\""); } list.Add(string.Format("\"overlapAvoided\":{0}", themeLabel.OverlapAvoided.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower())); if (!string.IsNullOrEmpty(themeLabel.RangeExpression)) { list.Add(string.Format("\"rangeExpression\":\"{0}\"", themeLabel.RangeExpression)); } else { list.Add("\"rangeExpression\":\"\""); } list.Add(string.Format("\"smallGeometryLabeled\":{0}", themeLabel.SmallGeometryLabeled.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower())); if (themeLabel.Text != null) { list.Add(ThemeLabelText.ToJson(themeLabel.Text)); } else { list.Add("\"minTextHeight\":0"); list.Add("\"maxTextWidth\":0"); list.Add("\"minTextWidth\":0"); list.Add("\"maxTextHeight\":0"); list.Add(string.Format("\"uniformStyle\":{0}", ServerTextStyle.ToJson(new ServerTextStyle()))); list.Add("\"uniformMixedStyle\":null"); } if (themeLabel.MatrixCells != null) { List<string> cellList = new List<string>(); for (int column = 0; column < themeLabel.MatrixCells.GetLength(1); column++) //列 { List<string> columnList = new List<string>(); for (int row = 0; row < themeLabel.MatrixCells.GetLength(0); row++) //行 { if (themeLabel.MatrixCells[row, column] is LabelImageCell) { columnList.Add(LabelImageCell.ToJson((LabelImageCell)themeLabel.MatrixCells[row, column])); } else if (themeLabel.MatrixCells[row, column] is LabelSymbolCell) { columnList.Add(LabelSymbolCell.ToJson((LabelSymbolCell)themeLabel.MatrixCells[row, column])); } else if (themeLabel.MatrixCells[row, column] is LabelThemeCell) { columnList.Add(LabelThemeCell.ToJson((LabelThemeCell)themeLabel.MatrixCells[row, column])); } } cellList.Add(string.Format("[{0}]", string.Join(",", columnList.ToArray()))); } list.Add(string.Format("\"matrixCells\":[{0}]", string.Join(",", cellList.ToArray()))); } else { list.Add("\"matrixCells\":null"); } if (themeLabel.MemoryData != null) { list.Add("\"memoryData\":" + themeLabel.ToJson(themeLabel.MemoryData)); } else { list.Add("\"memoryData\":null"); } list.Add("\"type\":\"LABEL\""); json += string.Join(",", list.ToArray()); json += "}"; return json; }
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; }