/// <summary> /// 图例 /// </summary> public void DrawLegendColorBar() { if (TableValue == null) { return; } int cellWidth = 12; int cellHeight = 1; LineCoordConverter pixeToInputValConverter = new LineCoordConverter(SizeOfLegendColorBar.Height, this.TableValue.ValueSpan.Span); for (int i = 0; i < SizeOfLegendColorBar.Height; i++) { var val = pixeToInputValConverter.GetNew(i) + this.TableValue.ValueSpan.Start; //像素,转换到原始数据,以获取颜色 var color = ColorBuilder.Build(val); //转回平面坐标 var pt = OriginOfLengendColorBar + new Size(0, i); var scrPt = UserToScreenCoordConverter.GetScreenCoord(pt); ChartGraphics.DrawColorPoint(scrPt, cellWidth, cellHeight, color); } //绘制文字 ChartGraphics.DrawLabel(Geo.Utils.StringUtil.FillSpaceLeft(this.TableValue.ValueSpan.Start.ToString("0.00"), 6), OriginOfLengendColorBar - new Size(30, 20), 0); ChartGraphics.DrawLabel(Geo.Utils.StringUtil.FillSpaceLeft(this.TableValue.ValueSpan.End.ToString("0.00"), 6), OriginOfLengendColorBar + new Size(-30, SizeOfLegendColorBar.Height + 20), 0); }
/// <summary> /// 绘制二维颜色图 /// </summary> /// <param name="table"></param> public void DrawColorTable(TwoNumeralKeyAndValueDictionary table) { int cellWidth = ToInt(InputToContentCoordConverter.XConverter.Factor * table.IntervalA); int cellHeight = ToInt(InputToContentCoordConverter.YConverter.Factor * table.IntervalB); table.ForEach(new Action <double, double, double>(delegate(double x, double y, double val) { var xy = new XY(x, y); var scrPt = InputToScreenPt(xy); var color = ColorBuilder.Build(val); ChartGraphics.DrawColorPoint(scrPt, cellWidth, cellHeight, color, ContentBoxInScreenCoord); })); }
/// <summary> /// 绘图 /// </summary> /// <param name="geoCoords"></param> public Bitmap Draw(List <GeoCoord> geoCoords) { if (ChartSize.Width == 0 || ChartSize.Height == 0) { return(null); } Bitmap bmp = new Bitmap(ChartSize.Width, ChartSize.Height);; Graphics g = Graphics.FromImage(bmp); g.Clear(Color.White); this.UserToScreenCoordConverter = new ScreenCoordConverter(this.ChartSize); this.GeoCoords = new GeoCoords(geoCoords); this.ChartGraphics = new Geo.Draw.UserChartGraphics(UserToScreenCoordConverter, g); InputToContentCoordConverter = new PlainCoordConverter(this.GeoCoords.Size, this.ChartSize, GeoCoords.CoordFrom); //var ColorBuilder = new TwoStepColorBuilder(this.GeoCoords.HeightSpan, Color.Blue, Color.Yellow, Color.Red); var ColorBuilder = new ThreeStepColorBuilder(this.GeoCoords.HeightSpan, Color.Blue, Color.Cyan, Color.Yellow, Color.Red); int cellWidth = (int)Math.Ceiling(InputToContentCoordConverter.XConverter.Factor * GeoCoords.LonInterval); cellWidth = cellWidth < 1 ? 1 : cellWidth; int cellHeight = (int)Math.Ceiling(InputToContentCoordConverter.YConverter.Factor * GeoCoords.LatInterval); cellHeight = cellHeight < 1 ? 1 : cellHeight; foreach (var geoCoord in geoCoords) { var xy = new XY(geoCoord.Lon, geoCoord.Lat); var pt = InputToContentCoordConverter.GetNewPoint(xy); var scrPt = UserToScreenCoordConverter.GetScreenCoord(pt); var color = ColorBuilder.Build(geoCoord.Height); ChartGraphics.DrawColorPoint(scrPt, cellWidth, cellHeight, color); } return(bmp); // UserChartGraphics.DrawGrid(new Pen(new SolidBrush(Color.FromArgb(100, 100, 100))), 10, 10, Origin, this.ScreenCoordArea.RightTop); }