public override void Render(OxyPlot.IRenderContext rc, PlotModel model1, AxisLayer axisLayer, int pass) { #if DEBUG_MAP Console.WriteLine("render clound axis " + this.Name); #endif Render(rc, model1); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass"></param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Layer != axisLayer) { return; } var r = new MagnitudeAxisRenderer(rc, model); r.Render(this, pass); }
public override void Render(OxyPlot.IRenderContext rc, PlotModel model1, AxisLayer axisLayer, int pass) { PlotModel model = this.PlotModel; if (Theme != null) { OxyColor color = Convertor.ConvertColorToOxyColor(Theme.GetThemeColor()); TicklineColor = color; TextColor = color; TitleColor = color; } //base.Render(rc, model, axisLayer, pass); IList <IList <ScreenPoint> > points = new List <IList <ScreenPoint> >(); FeatureTextIntersector intersector = new FeatureTextIntersector(FeatureTextIntersector.SortStyle.Horizontal, 3); for (int i = 0; i < this.Labels.Count; i++) { string label = this.Labels[i]; OxySize text_size = rc.MeasureText(label, this.ActualFont, this.ActualFontSize, this.ActualFontWeight); double x = Transform(i); if (x < model.PlotArea.Left || x > model.PlotArea.Right) { continue; } double y = model.PlotArea.Bottom; double y2 = y + 5; IList <ScreenPoint> sps = new List <ScreenPoint>(); sps.Add(new ScreenPoint(x, y)); sps.Add(new ScreenPoint(x, model.PlotArea.Top)); points.Add(sps); intersector.Add(new FeatureText(label, new ScreenPoint(x, y2), text_size)); // rc.DrawText(new ScreenPoint(x, y + 7), label, TextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.Angle, HorizontalAlignment.Left, VerticalAlignment.Middle); } List <FeatureText> fearures = intersector.DiscaredIntersection(); if (fearures != null) { foreach (FeatureText ft in fearures) { rc.DrawText(ft.Position, ft.Text, this.TextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.Angle, HorizontalAlignment.Center); } } foreach (IList <ScreenPoint> line in points) { rc.DrawLine(line, this.ExtraGridlineColor, 1, LineStyle.Dash.GetDashArray()); } }
/// <summary> /// Renders the axes. /// </summary> /// <param name="rc"> /// The render context. /// </param> /// <param name="layer"> /// The layer. /// </param> private void RenderAxes(IRenderContext rc, AxisLayer layer) { for (int i = 0; i < 2; i++) { foreach (var a in this.Axes) { if (a.IsAxisVisible && a.Layer == layer) { a.Render(rc, this, layer, i); } } } }
public override void Render(OxyPlot.IRenderContext rc, PlotModel model1, AxisLayer axisLayer, int pass) { PlotModel model = this.PlotModel; if (Theme != null) { OxyColor color = Convertor.ConvertColorToOxyColor(Theme.GetThemeColor()); TicklineColor = color; TextColor = color; TitleColor = color; } base.Render(rc, model1, axisLayer, pass); }
/// <summary> /// Renders the axes. /// </summary> /// <param name="drawingContext">The drawing context.</param> /// <param name="layer">The layer.</param> private void RenderAxes(IDrawingContext drawingContext, AxisLayer layer) { var axisRenderer = new HorizontalAndVerticalAxisRenderer(this, drawingContext); // render pass 0 foreach (var axis in Axes.Where(a => a.Layer == layer)) { axisRenderer.Render(axis, 0); } // render pass 1 foreach (var axis in Axes.Where(a => a.Layer == layer)) { axisRenderer.Render(axis, 1); } }
/// <summary> /// Renders the axes. /// </summary> /// <param name="rc">The render context.</param> /// <param name="layer">The layer.</param> private void RenderAxes(IRenderContext rc, AxisLayer layer) { for (int i = 0; i < 2; i++) { foreach (var a in this.VisibleAxes) { rc.SetToolTip(a.ToolTip); if (a.Layer == layer) { a.Render(rc, this, layer, i); } } } rc.SetToolTip(null); }
/// <summary> /// Renders the axes. /// </summary> /// <param name="rc">The render context.</param> /// <param name="layer">The layer.</param> private void RenderAxes(IRenderContext rc, AxisLayer layer) { // render pass 0 foreach (var a in this.Axes.Where(a => a.IsAxisVisible && a.Layer == layer)) { rc.SetToolTip(a.ToolTip); a.Render(rc, 0); } // render pass 1 foreach (var a in this.Axes.Where(a => a.IsAxisVisible && a.Layer == layer)) { rc.SetToolTip(a.ToolTip); a.Render(rc, 1); } rc.SetToolTip(null); }
public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { base.Render(rc, model, axisLayer, pass); var points = new List<ScreenPoint>(); if (this.IsHorizontal()) { var xmax = this.Transform(this.ActualMaximum); points.Add(new ScreenPoint(xmax + 4, model.PlotArea.Bottom - 4)); points.Add(new ScreenPoint(xmax + 18, model.PlotArea.Bottom)); points.Add(new ScreenPoint(xmax + 4, model.PlotArea.Bottom + 4)); //// etc. } else { var ymax = this.Transform(this.ActualMaximum); points.Add(new ScreenPoint(model.PlotArea.Left - 4, ymax - 4)); points.Add(new ScreenPoint(model.PlotArea.Left, ymax - 18)); points.Add(new ScreenPoint(model.PlotArea.Left + 4, ymax - 4)); //// etc. } rc.DrawPolygon(points, OxyColors.Black, OxyColors.Undefined); }
public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { base.Render(rc, model, axisLayer, pass); var points = new List <ScreenPoint>(); if (this.IsHorizontal()) { var xmax = this.Transform(this.ActualMaximum); points.Add(new ScreenPoint(xmax + 4, model.PlotArea.Bottom - 4)); points.Add(new ScreenPoint(xmax + 18, model.PlotArea.Bottom)); points.Add(new ScreenPoint(xmax + 4, model.PlotArea.Bottom + 4)); //// etc. } else { var ymax = this.Transform(this.ActualMaximum); points.Add(new ScreenPoint(model.PlotArea.Left - 4, ymax - 4)); points.Add(new ScreenPoint(model.PlotArea.Left, ymax - 18)); points.Add(new ScreenPoint(model.PlotArea.Left + 4, ymax - 4)); //// etc. } rc.DrawPolygon(points, OxyColors.Black, OxyColors.Undefined); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The render pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (this.Palette == null) { throw new InvalidOperationException("No Palette defined for color axis."); } if (pass == 0) { double distance = this.AxisDistance; double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - this.PositionTierMinShift - width - distance; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + this.PositionTierMinShift + distance; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - this.PositionTierMinShift - height - distance; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + this.PositionTierMinShift + distance; break; } if (this.RenderAsImage) { var axisLength = this.Transform(this.ActualMaximum) - this.Transform(this.ActualMinimum); bool reverse = axisLength > 0; axisLength = Math.Abs(axisLength); if (this.IsHorizontal()) { var colorAxisImage = this.GenerateColorAxisImage(reverse); rc.DrawImage(colorAxisImage, left, top, axisLength, height, 1, true); } else { var colorAxisImage = this.GenerateColorAxisImage(reverse); rc.DrawImage(colorAxisImage, left, top, width, axisLength, 1, true); } } else { Action <double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh) + 0.5; rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, OxyColors.Undefined); }; int n = this.Palette.Colors.Count; for (int i = 0; i < n; i++) { double ylow = this.Transform(this.GetLowValue(i)); double yhigh = this.Transform(this.GetHighValue(i)); drawColorRect(ylow, yhigh, this.Palette.Colors[i]); } double highLowLength = 10; if (this.IsHorizontal()) { highLowLength *= -1; } if (!this.LowColor.IsUndefined()) { double ylow = this.Transform(this.ActualMinimum); drawColorRect(ylow, ylow + highLowLength, this.LowColor); } if (!this.HighColor.IsUndefined()) { double yhigh = this.Transform(this.ActualMaximum); drawColorRect(yhigh, yhigh - highLowLength, this.HighColor); } } } base.Render(rc, model, axisLayer, pass); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The render pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (this.Palette == null) { throw new InvalidOperationException("No Palette defined for color axis."); } if (pass == 0) { double distance = this.AxisDistance; double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - this.PositionTierMinShift - width - distance; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + this.PositionTierMinShift + distance; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - this.PositionTierMinShift - height - distance; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + this.PositionTierMinShift + distance; break; } if (this.RenderAsImage) { var axisLength = this.Transform(this.ActualMaximum) - this.Transform(this.ActualMinimum); bool reverse = axisLength > 0; axisLength = Math.Abs(axisLength); if (this.IsHorizontal()) { var colorAxisImage = this.GenerateColorAxisImage(reverse); rc.DrawImage(colorAxisImage, left, top, axisLength, height, 1, true); } else { var colorAxisImage = this.GenerateColorAxisImage(reverse); rc.DrawImage(colorAxisImage, left, top, width, axisLength, 1, true); } } else { Action<double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh) + 0.5; rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, OxyColors.Undefined); }; int n = this.Palette.Colors.Count; for (int i = 0; i < n; i++) { double ylow = this.Transform(this.GetLowValue(i)); double yhigh = this.Transform(this.GetHighValue(i)); drawColorRect(ylow, yhigh, this.Palette.Colors[i]); } double highLowLength = 10; if (this.IsHorizontal()) { highLowLength *= -1; } if (!this.LowColor.IsUndefined()) { double ylow = this.Transform(this.ActualMinimum); drawColorRect(ylow, ylow + highLowLength, this.LowColor); } if (!this.HighColor.IsUndefined()) { double yhigh = this.Transform(this.ActualMaximum); drawColorRect(yhigh, yhigh - highLowLength, this.HighColor); } } } base.Render(rc, model, axisLayer, pass); }
public CustomComponent() : base() { layers = new List<Layer>(); //InteractionLayer interaction1 = new InteractionLayer(); //interaction1.Control.SetOuterMargins(20, GavControl.DistanceType.Absolute); //_sampleLayers.Add(interaction1); //InteractionLayer interaction2 = new InteractionLayer(); //interaction2.Control.SetOuterMargins(30, GavControl.DistanceType.Absolute); //_sampleLayers.Add(interaction2); /* GlyphLayer glyphLayer = new GlyphLayer(); glyphLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute); layers.Add(glyphLayer);*/ this.lineLayer = new LineLayer(); this.lineLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute); this.lineLayer.XAxisSpacing = 30; this.lineLayer.YAxisSpacing = 30; layers.Add(this.lineLayer); this.axisLayer = new AxisLayer(); this.axisLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute); this.axisLayer.XAxisSpacing = 30.0f; this.axisLayer.YAxisSpacing = 30.0f; layers.Add(this.axisLayer); this.interactionLayer = new InteractionLayer(this.lineLayer,this); this.interactionLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute); this.interactionLayer.SelectionChanged += new SelectionUpdatedEventHandler(InternalSelectionUpdatedEvent); layers.Add(this.interactionLayer); /* TextLayer textLayer = new TextLayer(); textLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute); layers.Add(textLayer); */ List<int> selected = new List<int>(); selected.Add(201); selected.Add(202); selected.Add(203); // default settings this.TimeSourceAxis = Axis.Z; this.LineSourceAxis = Axis.Y; this.DataSourceAxis = Axis.X; this.DataLineXIndex = 0; this.DataLineYIndex = 1; this.DataLineThicknessIndex = -1; this.DataLineThicknessScale = 1.5f; this.ColorMap = null; this.SelectedIndexColor = Color.Red; this.AllowCustomizeXAxis = true; this.AllowCustomizeYAxis = true; this.AllowCustomizeThickness = true; this.SetSelectedIndexes(selected); foreach (Layer layer in layers) { AddLayer(layer); } }
public override void Render(IRenderContext rc, PlotModel model1, AxisLayer axisLayer, int pass) { if (pass == 1) { return; } #if DEBUG_MAP Debug.WriteLine("render mul axes " + this.Name); #endif PlotModel model = this.PlotModel; for (int i = 0; i < 2; i++) { bool render = i == 1; List <IAxis> left_axes = GetVisibleAxes(AxisPosition.Left); List <IAxis> right_axes = GetVisibleAxes(AxisPosition.Right); ////List<IAxis> bottom_axes = GetVisibleAxes(AxisPosition.Bottom); OxySize left_size = GetAxesSize(rc, left_axes); OxySize right_size = GetAxesSize(rc, right_axes); #if DEBUG_MAP Debug.WriteLine(string.Format("left size:{0},{1}", left_size.Width, left_size.Height)); Debug.WriteLine(string.Format("right size:{0},{1}", right_size.Width, right_size.Height)); #endif bool right_grid_visible = true; if (left_axes != null && left_axes.Count <IAxis>() > 0) { right_grid_visible = false; } //draw region double top = model.PlotArea.Top; double bottom = model.PlotArea.Bottom; double left_axes_right = model1.PlotAndAxisArea.Right - right_size.Width; double left_axes_left = left_size.Width; for (int k = 0; k < model.Axes.Count; k++) { IMeasureTop measure_top = model.Axes[k] as IMeasureTop; if (measure_top == null) { continue; } OxySize size = measure_top.MeasureTop(rc, model1); if (render) { measure_top.RenderTop(rc, model1, new OxyRect(left_axes_left, top, left_axes_right - left_axes_left, size.Height)); } top += size.Height; } OxyRect region_bound = new OxyRect(left_axes_left, top, left_axes_right - left_axes_left, bottom - top); OxyRect left_label_bound = new OxyRect(model.PlotAndAxisArea.Left, top, left_size.Width, bottom - top); RenderAxes(model1, rc, left_axes, region_bound, left_label_bound, RegionPadding, true, render); //assign right axes /////OxyRect right_region_bound = new OxyRect(left_axes_left, top, left_axes_right - left_axes_left, bottom - top); OxyRect right_label_bound = new OxyRect(left_axes_right, top, right_size.Width, bottom - top); RenderAxes(model1, rc, right_axes, region_bound, right_label_bound, RegionPadding, right_grid_visible, render); } }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The render pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (pass == 0) { double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - this.PositionTierMinShift - width; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + this.PositionTierMinShift; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - this.PositionTierMinShift - height; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + this.PositionTierMinShift; break; } Action <double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh); rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, null); }; int n = this.Palette.Colors.Count; for (int i = 0; i < n; i++) { double ylow = this.Transform(this.GetLowValue(i)); double yhigh = this.Transform(this.GetHighValue(i)); drawColorRect(ylow, yhigh, this.Palette.Colors[i]); } double highLowLength = 10; if (this.IsHorizontal()) { highLowLength *= -1; } if (this.LowColor != null) { double ylow = this.Transform(this.ActualMinimum); drawColorRect(ylow, ylow + highLowLength, this.LowColor); } if (this.HighColor != null) { double yhigh = this.Transform(this.ActualMaximum); drawColorRect(yhigh, yhigh - highLowLength, this.HighColor); } } base.Render(rc, model, axisLayer, pass); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The layer.</param> /// <param name="pass">The pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (pass == 0) { double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - this.PositionTierMinShift - width; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + this.PositionTierMinShift; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - this.PositionTierMinShift - height; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + this.PositionTierMinShift; break; } Action<double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh); rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, OxyColors.Undefined); }; IList<double> majorLabelValues; IList<double> majorTickValues; IList<double> minorTickValues; this.GetTickValues(out majorLabelValues, out majorTickValues, out minorTickValues); int n = this.Palette.Colors.Count; for (int i = 0; i < n; i++) { double low = this.Transform(this.GetLowValue(i, majorLabelValues)); double high = this.Transform(this.GetHighValue(i, majorLabelValues)); drawColorRect(low, high, this.Palette.Colors[i]); } } base.Render(rc, model, axisLayer, pass); }
public override void Render(IRenderContext rc, PlotModel model1, AxisLayer axisLayer, int pass) { #if DEBUG_MAP Console.WriteLine("render timecategoryaxis " + this.Name); #endif PlotModel model = this.PlotModel; OxyColor live_color = OxyColors.Red; OxyColor forecast_color = OxyColors.Red; OxyColor separator_color = OxyColors.Red; OxyColor grid_color = OxyColors.Red; //OxyColor line_color = OxyColors.Red; if (Theme != null) { AxisStyle style = Theme.GetStyle(ThemeMode) as AxisStyle; TitleColor = Helper.ConvertColorToOxyColor(style.TitleColor); TextColor = Helper.ConvertColorToOxyColor(style.LabelColor); TicklineColor = Helper.ConvertColorToOxyColor(style.LineColor); live_color = Helper.ConvertColorToOxyColor(style.LiveColor); forecast_color = Helper.ConvertColorToOxyColor(style.ForecastColor); separator_color = Helper.ConvertColorToOxyColor(style.SepatorColor); grid_color = Helper.ConvertColorToOxyColor(style.GridColor); } //找到所有的y轴 if (TimeLines != null) { //绘制线标值和线条 FeatureTextIntersector intersector = new FeatureTextIntersector(FeatureTextIntersector.SortStyle.Horizontal, 3); for (int i = 0; i < TimeLines.Count; i++) { string label = TimeLines[i].Time.ToString("dd-HH"); OxySize size = rc.MeasureText(label); double x = TransformX(TimeLines[i].Index); if (x < model.PlotArea.Left || x > model.PlotArea.Right) { continue; } double y = model.PlotArea.Bottom; double y2 = y + 5; //if (TimeLines[i].TimeStyle == TimeStyle.Seperator) // continue; intersector.Add(new FeatureText(label, new ScreenPoint(x, y + 7), size, new ScreenPoint(x, y))); } List <FeatureText> features = intersector.DiscaredIntersection(this.Angle); if (features != null) { foreach (FeatureText feature in features) { rc.DrawText(feature.Position, feature.Text, TextColor, this.ActualFont, this.ActualFontSize, 200, this.Angle, HorizontalAlignment.Left, VerticalAlignment.Middle); } } //绘制纵线 foreach (Axis axis in model.Axes) { if (axis.Position == AxisPosition.Left || axis.Position == AxisPosition.Right) { if (axis is IAxis) { IAxis y_axis = axis as IAxis; if (!y_axis.AxisVisible) { continue; } foreach (TimeLine line in TimeLines) { OxyColor color = OxyColors.Red; double thickness = 1; LineStyle style = LineStyle.Solid; switch (line.TimeStyle) { case TimeStyle.Forecast: color = forecast_color; style = LineStyle.Dash; break; case TimeStyle.Live: color = live_color; break; case TimeStyle.Seperator: color = separator_color; style = LineStyle.Dash; thickness = 2; break; } IList <ScreenPoint> sps = new List <ScreenPoint>(); double x = TransformX(line.Index); double top = y_axis.Bound.Top; sps.Add(new ScreenPoint(x, top)); sps.Add(new ScreenPoint(x, y_axis.Bound.Bottom)); rc.DrawClippedLine(y_axis.Bound, sps, 2, color, thickness, style.GetDashArray(), LineJoin.Round, false); } } } } } }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The pass.</param> public virtual void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { var r = new HorizontalAndVerticalAxisRenderer(rc, model); r.Render(this, pass); }
public override void Render(OxyPlot.IRenderContext rc, OxyPlot.PlotModel model, AxisLayer axisLayer, int pass) { base.Render(rc, model, axisLayer, pass); if (model.Series.Count == 0) { return; } var field = rc.GetType().GetField("g", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); object o = field.GetValue(rc); Graphics g = (Graphics)o; LineSeries series = model.Series.First(s => { if (s is LineSeries) { return(true); } else { return(false); } }) as LineSeries; for (int i = 0; i < series.Points.Count; i++) { ScreenPoint sp = series.Transform(series.Points[i]); int key = (int)series.Points[i].X; if (IsCloudVisble && Cloud.Count > 0 && (Cloud[key]) != "9999") { if (Cloud[key] != null) { using (Font f = new System.Drawing.Font(_PrivateFontCollection.Families[1], 12F)) { float x = (float)sp.X; float y = (float)model.Height - 50; DrawText(g, new ScreenPoint(x, y), Cloud[key], OxyColor.FromRgb(CloudColor.R, CloudColor.G, CloudColor.B), f, 0F, HorizontalAlignment.Center, VerticalAlignment.Middle); } } } if (IsWindVisible && WindSpeeds.Count > 0 && (WindSpeeds[key]) != "9999" /* && (WindSpeeds[key]) != "0"*/) { if (WindDirs[key] != null) { using (Font f = new System.Drawing.Font(_PrivateFontCollection.Families[0], 30F)) { float x = (float)sp.X; float y = (float)model.Height - 50; DrawText(g, new ScreenPoint(x, y), WindSpeeds[key], OxyColor.FromRgb(WindColor.R, WindColor.G, WindColor.B), f, float.Parse(WindDirs[key]), HorizontalAlignment.Left, VerticalAlignment.Bottom, -15, 15); } } } } }
/// <summary> /// Renders the axes. /// </summary> /// <param name="rc">The render context.</param> /// <param name="layer">The layer.</param> private void RenderAxes(IRenderContext rc, AxisLayer layer) { // render pass 0 foreach (var a in this.Axes.Where(a => a.IsAxisVisible && a.Layer == layer)) { rc.SetToolTip(a.ToolTip); a.Render(rc, 0); } // render pass 1 foreach (var a in this.Axes.Where(a => a.IsAxisVisible && a.Layer == layer)) { rc.SetToolTip(a.ToolTip); a.Render(rc, 1); } rc.SetToolTip(null); }
/// <summary> /// Renders the axes. /// </summary> /// <param name="rc"> /// The render context. /// </param> /// <param name="layer"> /// The layer. /// </param> private void RenderAxes(IRenderContext rc, AxisLayer layer) { for (int i = 0; i < 2; i++) { foreach (var a in this.Axes) { if (a.IsAxisVisible && a.Layer == layer) { a.Render(rc, this, layer, i); } } } }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The render pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (pass == 0) { double distance = this.AxisDistance; double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; const int TierShift = 0; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - TierShift - width - distance; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + TierShift + distance; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - TierShift - height - distance; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + TierShift + distance; break; } Action<double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh); rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, OxyColors.Undefined); }; foreach (ColorRange range in this.ranges) { double ylow = this.Transform(range.LowerBound); double yhigh = this.Transform(range.UpperBound); double ymax = this.Transform(ActualMaximum); double ymin = this.Transform(ActualMinimum); if (ylow < ymax) { continue; } if (yhigh > ymin) { continue; } if (ylow > ymin) { ylow = ymin; } if (yhigh < ymax) { yhigh = ymax; } drawColorRect(ylow, yhigh, range.Color); } double highLowLength = 10; if (this.IsHorizontal()) { highLowLength *= -1; } if (!this.LowColor.IsUndefined()) { double ylow = this.Transform(this.ActualMinimum); drawColorRect(ylow, ylow + highLowLength, this.LowColor); } if (!this.HighColor.IsUndefined()) { double yhigh = this.Transform(this.ActualMaximum); drawColorRect(yhigh, yhigh - highLowLength, this.HighColor); } } var r = new HorizontalAndVerticalAxisRenderer(rc, model); r.Render(this, pass); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Layer != axisLayer) { return; } var r = new AngleAxisRenderer(rc, model); r.Render(this, pass); }
/// <summary> /// Renders the axes. /// </summary> /// <param name="rc">The render context.</param> /// <param name="layer">The layer.</param> private void RenderAxes(IRenderContext rc, AxisLayer layer) { for (int i = 0; i < 2; i++) { foreach (var a in this.VisibleAxes) { rc.SetToolTip(a.ToolTip); if (a.Layer == layer) { a.Render(rc, this, layer, i); } } } rc.SetToolTip(null); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The layer.</param> /// <param name="pass">The pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (pass == 0) { double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - this.PositionTierMinShift - width; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + this.PositionTierMinShift; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - this.PositionTierMinShift - height; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + this.PositionTierMinShift; break; } Action <double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh); rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, OxyColors.Undefined); }; IList <double> majorLabelValues; IList <double> majorTickValues; IList <double> minorTickValues; this.GetTickValues(out majorLabelValues, out majorTickValues, out minorTickValues); int n = this.Palette.Colors.Count; for (int i = 0; i < n; i++) { double low = this.Transform(this.GetLowValue(i, majorLabelValues)); double high = this.Transform(this.GetHighValue(i, majorLabelValues)); drawColorRect(low, high, this.Palette.Colors[i]); } } base.Render(rc, model, axisLayer, pass); }
public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { //base.Render(rc, model, axisLayer, pass); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The render pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (pass == 0) { double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - this.PositionTierMinShift - width; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + this.PositionTierMinShift; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - this.PositionTierMinShift - height; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + this.PositionTierMinShift; break; } Action<double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh); rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, null); }; int n = this.Palette.Colors.Count; for (int i = 0; i < n; i++) { double ylow = this.Transform(this.GetLowValue(i)); double yhigh = this.Transform(this.GetHighValue(i)); drawColorRect(ylow, yhigh, this.Palette.Colors[i]); } double highLowLength = 10; if (this.IsHorizontal()) { highLowLength *= -1; } if (this.LowColor != null) { double ylow = this.Transform(this.ActualMinimum); drawColorRect(ylow, ylow + highLowLength, this.LowColor); } if (this.HighColor != null) { double yhigh = this.Transform(this.ActualMaximum); drawColorRect(yhigh, yhigh - highLowLength, this.HighColor); } } base.Render(rc, model, axisLayer, pass); }
/// <summary> /// Renders the axis on the specified render context. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <param name="axisLayer">The rendering order.</param> /// <param name="pass">The render pass.</param> public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass) { if (this.Position == AxisPosition.None) { return; } if (pass == 0) { double distance = this.AxisDistance; double left = model.PlotArea.Left; double top = model.PlotArea.Top; double width = this.MajorTickSize - 2; double height = this.MajorTickSize - 2; const int TierShift = 0; switch (this.Position) { case AxisPosition.Left: left = model.PlotArea.Left - TierShift - width - distance; top = model.PlotArea.Top; break; case AxisPosition.Right: left = model.PlotArea.Right + TierShift + distance; top = model.PlotArea.Top; break; case AxisPosition.Top: left = model.PlotArea.Left; top = model.PlotArea.Top - TierShift - height - distance; break; case AxisPosition.Bottom: left = model.PlotArea.Left; top = model.PlotArea.Bottom + TierShift + distance; break; } Action <double, double, OxyColor> drawColorRect = (ylow, yhigh, color) => { double ymin = Math.Min(ylow, yhigh); double ymax = Math.Max(ylow, yhigh); rc.DrawRectangle( this.IsHorizontal() ? new OxyRect(ymin, top, ymax - ymin, height) : new OxyRect(left, ymin, width, ymax - ymin), color, OxyColors.Undefined); }; foreach (ColorRange range in this.ranges) { double ylow = this.Transform(range.LowerBound); double yhigh = this.Transform(range.UpperBound); double ymax = this.Transform(ActualMaximum); double ymin = this.Transform(ActualMinimum); if (ylow < ymax) { continue; } if (yhigh > ymin) { continue; } if (ylow > ymin) { ylow = ymin; } if (yhigh < ymax) { yhigh = ymax; } drawColorRect(ylow, yhigh, range.Color); } double highLowLength = 10; if (this.IsHorizontal()) { highLowLength *= -1; } if (!this.LowColor.IsUndefined()) { double ylow = this.Transform(this.ActualMinimum); drawColorRect(ylow, ylow + highLowLength, this.LowColor); } if (!this.HighColor.IsUndefined()) { double yhigh = this.Transform(this.ActualMaximum); drawColorRect(yhigh, yhigh - highLowLength, this.HighColor); } } var r = new HorizontalAndVerticalAxisRenderer(rc, model); r.Render(this, pass); }