/// <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="Span"></param> /// <param name="ColorFrom"></param> /// <param name="ColorTo"></param> public TwoStepColorBuilder(NumerialSegment Span, Color ColorFrom, Color ColorMiddle, Color ColorTo) { MidleValue = Span.Median; var segA = new NumerialSegment(Span.Start, MidleValue); var segB = new NumerialSegment(MidleValue, Span.End); ColorBuilderA = new ColorBuilder(segA, ColorFrom, ColorMiddle); ColorBuilderB = new ColorBuilder(segB, ColorMiddle, ColorTo); }
/// <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="Span"></param> /// <param name="ColorFrom"></param> /// <param name="ColorTo"></param> public ThreeStepColorBuilder(NumerialSegment Span, Color ColorFrom, Color ColorMiddle, Color ColorMiddleB, Color ColorTo) { var smallSpan = Span.Span / 3.0; FistStep = Span.Start + smallSpan; SecondStep = Span.Start + smallSpan * 2; var segA = new NumerialSegment(Span.Start, Span.Start + smallSpan); var segB = new NumerialSegment(Span.Start + smallSpan, Span.Start + smallSpan * 2); var segC = new NumerialSegment(Span.Start + smallSpan * 2, Span.End); ColorBuilderA = new ColorBuilder(segA, ColorFrom, ColorMiddle); ColorBuilderB = new ColorBuilder(segB, ColorMiddle, ColorMiddleB); ColorBuilderC = new ColorBuilder(segC, ColorMiddleB, ColorTo); }