Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OxyPlot.Core to 2.1.0 #142

Merged
merged 10 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@ public App()
{
Model = new PlotModel
{
Title = "OxyPlot in Xamarin Forms.",
Title = "OxyPlot in Xamarin.Forms",
Axes =
{
new CategoryAxis {Position = AxisPosition.Bottom},
new LinearAxis {Position = AxisPosition.Left, MinimumPadding = 0}
new CategoryAxis {Position = AxisPosition.Bottom, Key = "Y" },
new LinearAxis {Position = AxisPosition.Left, Key = "X", MinimumPadding = 0}
},
Series =
{
new ColumnSeries
new BarSeries
{
XAxisKey = "X",
YAxisKey = "Y",
Items =
{
new ColumnItem {Value = 3},
new ColumnItem {Value = 14},
new ColumnItem {Value = 11},
new ColumnItem {Value = 12},
new ColumnItem {Value = 7}
new BarItem {Value = 3},
new BarItem {Value = 14},
new BarItem {Value = 11},
new BarItem {Value = 12},
new BarItem {Value = 7}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
<PackageReference Include="OxyPlot.Core" Version="2.1.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2545" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.4" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/OxyPlot.Windows/OxyPlot.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
<None Include="..\..\OxyPlot_128.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
<PackageReference Include="OxyPlot.Core" Version="2.1.0" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion Source/OxyPlot.Windows/PlotView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ private void UpdateVisuals()

if (this.ActualModel != null)
{
((IPlotModel)this.ActualModel).Render(this.renderContext, this.canvas.ActualWidth, this.canvas.ActualHeight);
OxyRect rect = new OxyRect(0, 0, canvas.ActualWidth, canvas.ActualHeight);
((IPlotModel)this.ActualModel).Render(this.renderContext, rect);
}
}

Expand Down
43 changes: 12 additions & 31 deletions Source/OxyPlot.Windows/RenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace OxyPlot.Windows
/// <summary>
/// Implements <see cref="IRenderContext" /> for <see cref="Canvas" />.
/// </summary>
public class RenderContext : IRenderContext
public class RenderContext : ClippingRenderContext
{
/// <summary>
/// The brush cache.
Expand Down Expand Up @@ -102,12 +102,6 @@ public bool PaintBackground
/// <value>The width.</value>
public double Width { get; private set; }

/// <summary>
/// Gets or sets a value indicating whether the context renders to screen.
/// </summary>
/// <value><c>true</c> if the context renders to screen; otherwise, <c>false</c>.</value>
public bool RendersToScreen { get; set; }

/// <summary>
/// Draws an ellipse.
/// </summary>
Expand Down Expand Up @@ -185,20 +179,14 @@ public void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stro
/// <param name="thickness">The stroke thickness.</param>
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
public void DrawLine(
IList<ScreenPoint> points,
OxyColor stroke,
double thickness,
double[] dashArray,
LineJoin lineJoin,
bool aliased)
public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
{
var e = new Polyline
{
CompositeMode = ElementCompositeMode.SourceOver
};

bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
this.SetStroke(e, stroke, thickness, lineJoin, dashArray, aliased);

var pc = new PointCollection();
Expand Down Expand Up @@ -270,20 +258,14 @@ public void DrawLineSegments(
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
public void DrawPolygon(
IList<ScreenPoint> points,
OxyColor fill,
OxyColor stroke,
double thickness,
double[] dashArray,
LineJoin lineJoin,
bool aliased)
public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
{
var po = new Polygon
{
CompositeMode = ElementCompositeMode.SourceOver
};

bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
this.SetStroke(po, stroke, thickness, lineJoin, dashArray, aliased);

if (fill.IsVisible())
Expand Down Expand Up @@ -434,7 +416,7 @@ public void DrawRectangles(IList<OxyRect> rectangles, OxyColor fill, OxyColor st
/// <param name="halign">The horizontal alignment.</param>
/// <param name="valign">The vertical alignment.</param>
/// <param name="maxSize">The maximum size of the text.</param>
public void DrawText(
public override void DrawText(
ScreenPoint p,
string text,
OxyColor fill,
Expand Down Expand Up @@ -532,7 +514,7 @@ public void DrawText(
/// <param name="fontSize">Size of the font.</param>
/// <param name="fontWeight">The font weight.</param>
/// <returns>The text size.</returns>
public OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
public override OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
{
if (string.IsNullOrEmpty(text))
{
Expand Down Expand Up @@ -562,7 +544,7 @@ public OxySize MeasureText(string text, string fontFamily, double fontSize, doub
/// Sets the tool tip for the following items.
/// </summary>
/// <param name="text">The text in the tooltip.</param>
public void SetToolTip(string text)
public override void SetToolTip(string text)
{
this.currentToolTip = text;
}
Expand All @@ -581,7 +563,7 @@ public void SetToolTip(string text)
/// <param name="destHeight">The height of the drawn image.</param>
/// <param name="opacity">The opacity.</param>
/// <param name="interpolate">interpolate if set to <c>true</c>.</param>
public void DrawImage(
public override void DrawImage(
OxyImage source,
double srcX,
double srcY,
Expand Down Expand Up @@ -633,17 +615,16 @@ public void DrawImage(
/// </summary>
/// <param name="clippingRect">The clipping rectangle.</param>
/// <returns>True if the clipping rectangle was set.</returns>
public bool SetClip(OxyRect clippingRect)
protected override void SetClip(OxyRect clippingRect)
{
this.clipRect = clippingRect.ToRect(false);
this.clip = true;
return true;
}

/// <summary>
/// Resets the clipping rectangle.
/// </summary>
public void ResetClip()
protected override void ResetClip()
{
this.clip = false;
}
Expand All @@ -652,7 +633,7 @@ public void ResetClip()
/// Cleans up resources not in use.
/// </summary>
/// <remarks>This method is called at the end of each rendering.</remarks>
public void CleanUp()
public override void CleanUp()
{
// Find the images in the cache that has not been used since last call to this method
var imagesToRelease = this.imageCache.Keys.Where(i => !this.imagesInUse.Contains(i)).ToList();
Expand Down
42 changes: 26 additions & 16 deletions Source/OxyPlot.Xamarin.Android/CanvasRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace OxyPlot.Xamarin.Android
/// <summary>
/// Provides a render context for Android.Graphics.Canvas.
/// </summary>
public class CanvasRenderContext : RenderContextBase
public class CanvasRenderContext : ClippingRenderContext
{
/// <summary>
/// The images in use
Expand Down Expand Up @@ -96,10 +96,11 @@ public void SetTarget(Canvas c)
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm)
{
this.paint.Reset();
{
bool aliased = this.ShouldUseAntiAliasingForEllipse(erm);
if (fill.IsVisible())
{
this.SetFill(fill);
Expand All @@ -108,7 +109,7 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d

if (stroke.IsVisible())
{
this.SetStroke(stroke, thickness);
this.SetStroke(stroke, thickness, aliased: aliased);
this.canvas.DrawOval(this.Convert(rect), this.paint);
}
}
Expand All @@ -122,10 +123,11 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness)
public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm)
{
this.paint.Reset();
{
bool aliased = this.ShouldUseAntiAliasingForEllipse(erm);
foreach (var rect in rectangles)
{
if (fill.IsVisible())
Expand All @@ -136,7 +138,7 @@ public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyC

if (stroke.IsVisible())
{
this.SetStroke(stroke, thickness);
this.SetStroke(stroke, thickness, aliased: aliased);
this.canvas.DrawOval(this.Convert(rect), this.paint);
}
}
Expand All @@ -151,13 +153,13 @@ public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyC
/// <param name="thickness">The stroke thickness.</param>
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased)
public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
{
this.paint.Reset();
{
this.path.Reset();
{
bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
this.SetPath(points, aliased);
this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased);
this.canvas.DrawPath(this.path, this.paint);
Expand All @@ -175,10 +177,11 @@ public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
public override void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased)
public override void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
{
this.paint.Reset();
{
bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased);
this.pts.Clear();
if (aliased)
Expand Down Expand Up @@ -212,12 +215,13 @@ public override void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased)
public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
{
this.paint.Reset();
{
this.path.Reset();
{
bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
this.SetPath(points, aliased);
this.path.Close();

Expand All @@ -243,20 +247,27 @@ public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyCo
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm)
{
this.paint.Reset();
{
bool aliased = this.ShouldUseAntiAliasingForRect(erm);
if (fill.IsVisible())
{
this.SetFill(fill);
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
if (aliased)
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
else
this.canvas.DrawRect(this.Convert(rect.Left), this.Convert(rect.Top), this.Convert(rect.Right), this.Convert(rect.Bottom), this.paint);
}

if (stroke.IsVisible())
{
this.SetStroke(stroke, thickness, aliased: true);
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
this.SetStroke(stroke, thickness, aliased: aliased);
if (aliased)
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
else
this.canvas.DrawRect(this.Convert(rect.Left), this.Convert(rect.Top), this.Convert(rect.Right), this.Convert(rect.Bottom), this.paint);
}
}
}
Expand Down Expand Up @@ -366,17 +377,16 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS
/// </summary>
/// <param name="rect">The clip rectangle.</param>
/// <returns>True if the clip rectangle was set.</returns>
public override bool SetClip(OxyRect rect)
protected override void SetClip(OxyRect rect)
{
this.canvas.Save();
this.canvas.ClipRect(this.Convert(rect));
return true;
}

/// <summary>
/// Resets the clip rectangle.
/// </summary>
public override void ResetClip()
protected override void ResetClip()
{
this.canvas.Restore();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="OxyPlot.Core">
<Version>2.0.0</Version>
<Version>2.1.0</Version>
</PackageReference>
<PackageReference Include="System.Collections">
<Version>4.3.0</Version>
Expand Down
5 changes: 3 additions & 2 deletions Source/OxyPlot.Xamarin.Android/PlotView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ protected override void OnDraw(Canvas canvas)
}

this.rc.SetTarget(canvas);

((IPlotModel)actualModel).Render(this.rc, Width / Scale, Height / Scale);

OxyRect rect = new OxyRect(0, 0, Width / Scale, Height / Scale);
((IPlotModel)actualModel).Render(this.rc, rect);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
<PackageReference Include="OxyPlot.Core" Version="2.1.0" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.4" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2545" />
<PackageReference Include="NuGet.Build.Packaging">
Expand All @@ -85,4 +85,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
</Project>
Loading