/// <summary> /// Gets the vector. /// </summary> /// <param name="x">The x component.</param> /// <param name="y">The y component.</param> /// <param name="model">The model.</param> /// <returns>The vector in screen coordinates.</returns> protected ScreenVector GetVector(PlotLength x, PlotLength y, PlotModel model) { var xd = double.NaN; var yd = double.NaN; if (x.Unit == PlotLengthUnit.Data || y.Unit == PlotLengthUnit.Data) { var dataX = x.Unit == PlotLengthUnit.Data ? x.Value : double.NaN; var dataY = y.Unit == PlotLengthUnit.Data ? y.Value : double.NaN; var v = this.Transform(dataX, dataY) - this.Transform(0, 0); xd = v.X; yd = v.Y; } switch (x.Unit) { case PlotLengthUnit.Data: break; case PlotLengthUnit.ScreenUnits: xd = x.Value; break; case PlotLengthUnit.RelativeToViewport: xd = model.Width * x.Value; break; case PlotLengthUnit.RelativeToPlotArea: xd = model.PlotArea.Width * x.Value; break; default: throw new ArgumentOutOfRangeException(); } switch (y.Unit) { case PlotLengthUnit.Data: break; case PlotLengthUnit.ScreenUnits: yd = y.Value; break; case PlotLengthUnit.RelativeToViewport: yd = model.Height * y.Value; break; case PlotLengthUnit.RelativeToPlotArea: yd = model.PlotArea.Height * y.Value; break; default: throw new ArgumentOutOfRangeException(); } return(new ScreenVector(xd, yd)); }
/// <summary> /// Gets the vector. /// </summary> /// <param name="x">The x component.</param> /// <param name="y">The y component.</param> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <returns>The vector in screen coordinates.</returns> protected ScreenVector GetVector(PlotLength x, PlotLength y, IRenderContext rc, PlotModel model) { double sx; double sy; switch (x.Unit) { case PlotLengthUnit.Data: sx = this.XAxis.Transform(x.Value) - this.XAxis.Transform(0); break; case PlotLengthUnit.RelativeToPlotArea: sx = model.PlotArea.Width * x.Value; break; case PlotLengthUnit.RelativeToViewport: sx = model.Width * x.Value; break; default: sx = x.Value; break; } switch (y.Unit) { case PlotLengthUnit.Data: sy = -this.YAxis.Transform(y.Value) + this.YAxis.Transform(0); break; case PlotLengthUnit.RelativeToPlotArea: sy = model.PlotArea.Height * y.Value; break; case PlotLengthUnit.RelativeToViewport: sy = model.Height * y.Value; break; default: sy = y.Value; break; } return(new ScreenVector(sx, sy)); }
/// <summary> /// Gets the point. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="rc">The render context.</param> /// <param name="model">The model.</param> /// <returns>The point in screen coordinates.</returns> protected ScreenPoint GetPoint(PlotLength x, PlotLength y, IRenderContext rc, PlotModel model) { if (x.Unit == PlotLengthUnit.Data || y.Unit == PlotLengthUnit.Data) { return(this.XAxis.Transform(x.Value, y.Value, this.YAxis)); } double sx; double sy; switch (x.Unit) { case PlotLengthUnit.RelativeToPlotArea: sx = model.PlotArea.Left + (model.PlotArea.Width * x.Value); break; case PlotLengthUnit.RelativeToViewport: sx = model.Width * x.Value; break; default: sx = x.Value; break; } switch (y.Unit) { case PlotLengthUnit.RelativeToPlotArea: sy = model.PlotArea.Top + (model.PlotArea.Height * y.Value); break; case PlotLengthUnit.RelativeToViewport: sy = model.Height * y.Value; break; default: sy = y.Value; break; } return(new ScreenPoint(sx, sy)); }
/// <summary> /// Gets the vector. /// </summary> /// <param name="x"> /// The x component. /// </param> /// <param name="y"> /// The y component. /// </param> /// <param name="rc"> /// The render context. /// </param> /// <param name="model"> /// The model. /// </param> /// <returns> /// The vector in screen coordinates. /// </returns> protected ScreenVector GetVector(PlotLength x, PlotLength y, IRenderContext rc, PlotModel model) { double sx; double sy; switch (x.Unit) { case PlotLengthUnit.Data: sx = this.XAxis.Transform(x.Value) - this.XAxis.Transform(0); break; case PlotLengthUnit.RelativeToPlotArea: sx = model.PlotArea.Width * x.Value; break; case PlotLengthUnit.RelativeToViewport: sx = model.Width * x.Value; break; default: sx = x.Value; break; } switch (y.Unit) { case PlotLengthUnit.Data: sy = this.YAxis.Transform(y.Value) - this.YAxis.Transform(0); break; case PlotLengthUnit.RelativeToPlotArea: sy = model.PlotArea.Height * y.Value; break; case PlotLengthUnit.RelativeToViewport: sy = model.Height * y.Value; break; default: sy = y.Value; break; } return new ScreenVector(sx, sy); }
/// <summary> /// Gets the point. /// </summary> /// <param name="x"> /// The x. /// </param> /// <param name="y"> /// The y. /// </param> /// <param name="rc"> /// The render context. /// </param> /// <param name="model"> /// The model. /// </param> /// <returns> /// The point in screen coordinates. /// </returns> protected ScreenPoint GetPoint(PlotLength x, PlotLength y, IRenderContext rc, PlotModel model) { if (x.Unit == PlotLengthUnit.Data || y.Unit == PlotLengthUnit.Data) { return this.XAxis.Transform(x.Value, y.Value, this.YAxis); } double sx; double sy; switch (x.Unit) { case PlotLengthUnit.RelativeToPlotArea: sx = model.PlotArea.Left + (model.PlotArea.Width * x.Value); break; case PlotLengthUnit.RelativeToViewport: sx = model.Width * x.Value; break; default: sx = x.Value; break; } switch (y.Unit) { case PlotLengthUnit.RelativeToPlotArea: sy = model.PlotArea.Top + (model.PlotArea.Height * y.Value); break; case PlotLengthUnit.RelativeToViewport: sy = model.Height * y.Value; break; default: sy = y.Value; break; } return new ScreenPoint(sx, sy); }