Skip to content

Commit 87fba19

Browse files
authored
Merge pull request #142 from janusw/oxy-2.1.0
Update OxyPlot.Core to 2.1.0
2 parents 87c0ae6 + 7713177 commit 87fba19

File tree

20 files changed

+110
-111
lines changed

20 files changed

+110
-111
lines changed

Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/App.xaml.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,25 @@ public App()
2424
{
2525
Model = new PlotModel
2626
{
27-
Title = "OxyPlot in Xamarin Forms.",
27+
Title = "OxyPlot in Xamarin.Forms",
2828
Axes =
2929
{
30-
new CategoryAxis {Position = AxisPosition.Bottom},
31-
new LinearAxis {Position = AxisPosition.Left, MinimumPadding = 0}
30+
new CategoryAxis {Position = AxisPosition.Bottom, Key = "Y" },
31+
new LinearAxis {Position = AxisPosition.Left, Key = "X", MinimumPadding = 0}
3232
},
3333
Series =
3434
{
35-
new ColumnSeries
35+
new BarSeries
3636
{
37+
XAxisKey = "X",
38+
YAxisKey = "Y",
3739
Items =
3840
{
39-
new ColumnItem {Value = 3},
40-
new ColumnItem {Value = 14},
41-
new ColumnItem {Value = 11},
42-
new ColumnItem {Value = 12},
43-
new ColumnItem {Value = 7}
41+
new BarItem {Value = 3},
42+
new BarItem {Value = 14},
43+
new BarItem {Value = 11},
44+
new BarItem {Value = 12},
45+
new BarItem {Value = 7}
4446
}
4547
}
4648
}

Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/SimpleDemo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
</PropertyGroup>
55
<ItemGroup>
6-
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
6+
<PackageReference Include="OxyPlot.Core" Version="2.1.0" />
77
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2545" />
88
<PackageReference Include="Xamarin.Essentials" Version="1.7.4" />
99
</ItemGroup>

Source/OxyPlot.Windows/OxyPlot.Windows.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
<None Include="..\..\OxyPlot_128.png" Pack="true" PackagePath="\" />
1717
</ItemGroup>
1818
<ItemGroup>
19-
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
19+
<PackageReference Include="OxyPlot.Core" Version="2.1.0" />
2020
</ItemGroup>
2121
</Project>

Source/OxyPlot.Windows/PlotView.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,8 @@ private void UpdateVisuals()
914914

915915
if (this.ActualModel != null)
916916
{
917-
((IPlotModel)this.ActualModel).Render(this.renderContext, this.canvas.ActualWidth, this.canvas.ActualHeight);
917+
OxyRect rect = new OxyRect(0, 0, canvas.ActualWidth, canvas.ActualHeight);
918+
((IPlotModel)this.ActualModel).Render(this.renderContext, rect);
918919
}
919920
}
920921

Source/OxyPlot.Windows/RenderContext.cs

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace OxyPlot.Windows
2929
/// <summary>
3030
/// Implements <see cref="IRenderContext" /> for <see cref="Canvas" />.
3131
/// </summary>
32-
public class RenderContext : IRenderContext
32+
public class RenderContext : ClippingRenderContext
3333
{
3434
/// <summary>
3535
/// The brush cache.
@@ -102,12 +102,6 @@ public bool PaintBackground
102102
/// <value>The width.</value>
103103
public double Width { get; private set; }
104104

105-
/// <summary>
106-
/// Gets or sets a value indicating whether the context renders to screen.
107-
/// </summary>
108-
/// <value><c>true</c> if the context renders to screen; otherwise, <c>false</c>.</value>
109-
public bool RendersToScreen { get; set; }
110-
111105
/// <summary>
112106
/// Draws an ellipse.
113107
/// </summary>
@@ -185,20 +179,14 @@ public void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stro
185179
/// <param name="thickness">The stroke thickness.</param>
186180
/// <param name="dashArray">The dash array.</param>
187181
/// <param name="lineJoin">The line join type.</param>
188-
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
189-
public void DrawLine(
190-
IList<ScreenPoint> points,
191-
OxyColor stroke,
192-
double thickness,
193-
double[] dashArray,
194-
LineJoin lineJoin,
195-
bool aliased)
182+
public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
196183
{
197184
var e = new Polyline
198185
{
199186
CompositeMode = ElementCompositeMode.SourceOver
200187
};
201188

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

204192
var pc = new PointCollection();
@@ -270,20 +258,14 @@ public void DrawLineSegments(
270258
/// <param name="dashArray">The dash array.</param>
271259
/// <param name="lineJoin">The line join type.</param>
272260
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
273-
public void DrawPolygon(
274-
IList<ScreenPoint> points,
275-
OxyColor fill,
276-
OxyColor stroke,
277-
double thickness,
278-
double[] dashArray,
279-
LineJoin lineJoin,
280-
bool aliased)
261+
public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
281262
{
282263
var po = new Polygon
283264
{
284265
CompositeMode = ElementCompositeMode.SourceOver
285266
};
286267

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

289271
if (fill.IsVisible())
@@ -434,7 +416,7 @@ public void DrawRectangles(IList<OxyRect> rectangles, OxyColor fill, OxyColor st
434416
/// <param name="halign">The horizontal alignment.</param>
435417
/// <param name="valign">The vertical alignment.</param>
436418
/// <param name="maxSize">The maximum size of the text.</param>
437-
public void DrawText(
419+
public override void DrawText(
438420
ScreenPoint p,
439421
string text,
440422
OxyColor fill,
@@ -532,7 +514,7 @@ public void DrawText(
532514
/// <param name="fontSize">Size of the font.</param>
533515
/// <param name="fontWeight">The font weight.</param>
534516
/// <returns>The text size.</returns>
535-
public OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
517+
public override OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
536518
{
537519
if (string.IsNullOrEmpty(text))
538520
{
@@ -562,7 +544,7 @@ public OxySize MeasureText(string text, string fontFamily, double fontSize, doub
562544
/// Sets the tool tip for the following items.
563545
/// </summary>
564546
/// <param name="text">The text in the tooltip.</param>
565-
public void SetToolTip(string text)
547+
public override void SetToolTip(string text)
566548
{
567549
this.currentToolTip = text;
568550
}
@@ -581,7 +563,7 @@ public void SetToolTip(string text)
581563
/// <param name="destHeight">The height of the drawn image.</param>
582564
/// <param name="opacity">The opacity.</param>
583565
/// <param name="interpolate">interpolate if set to <c>true</c>.</param>
584-
public void DrawImage(
566+
public override void DrawImage(
585567
OxyImage source,
586568
double srcX,
587569
double srcY,
@@ -633,17 +615,16 @@ public void DrawImage(
633615
/// </summary>
634616
/// <param name="clippingRect">The clipping rectangle.</param>
635617
/// <returns>True if the clipping rectangle was set.</returns>
636-
public bool SetClip(OxyRect clippingRect)
618+
protected override void SetClip(OxyRect clippingRect)
637619
{
638620
this.clipRect = clippingRect.ToRect(false);
639621
this.clip = true;
640-
return true;
641622
}
642623

643624
/// <summary>
644625
/// Resets the clipping rectangle.
645626
/// </summary>
646-
public void ResetClip()
627+
protected override void ResetClip()
647628
{
648629
this.clip = false;
649630
}
@@ -652,7 +633,7 @@ public void ResetClip()
652633
/// Cleans up resources not in use.
653634
/// </summary>
654635
/// <remarks>This method is called at the end of each rendering.</remarks>
655-
public void CleanUp()
636+
public override void CleanUp()
656637
{
657638
// Find the images in the cache that has not been used since last call to this method
658639
var imagesToRelease = this.imageCache.Keys.Where(i => !this.imagesInUse.Contains(i)).ToList();

Source/OxyPlot.Xamarin.Android/CanvasRenderContext.cs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace OxyPlot.Xamarin.Android
1717
/// <summary>
1818
/// Provides a render context for Android.Graphics.Canvas.
1919
/// </summary>
20-
public class CanvasRenderContext : RenderContextBase
20+
public class CanvasRenderContext : ClippingRenderContext
2121
{
2222
/// <summary>
2323
/// The images in use
@@ -96,10 +96,11 @@ public void SetTarget(Canvas c)
9696
/// <param name="fill">The fill color.</param>
9797
/// <param name="stroke">The stroke color.</param>
9898
/// <param name="thickness">The thickness.</param>
99-
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
99+
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm)
100100
{
101101
this.paint.Reset();
102102
{
103+
bool aliased = this.ShouldUseAntiAliasingForEllipse(erm);
103104
if (fill.IsVisible())
104105
{
105106
this.SetFill(fill);
@@ -108,7 +109,7 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d
108109

109110
if (stroke.IsVisible())
110111
{
111-
this.SetStroke(stroke, thickness);
112+
this.SetStroke(stroke, thickness, aliased: aliased);
112113
this.canvas.DrawOval(this.Convert(rect), this.paint);
113114
}
114115
}
@@ -122,10 +123,11 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d
122123
/// <param name="fill">The fill color.</param>
123124
/// <param name="stroke">The stroke color.</param>
124125
/// <param name="thickness">The stroke thickness.</param>
125-
public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness)
126+
public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm)
126127
{
127128
this.paint.Reset();
128129
{
130+
bool aliased = this.ShouldUseAntiAliasingForEllipse(erm);
129131
foreach (var rect in rectangles)
130132
{
131133
if (fill.IsVisible())
@@ -136,7 +138,7 @@ public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyC
136138

137139
if (stroke.IsVisible())
138140
{
139-
this.SetStroke(stroke, thickness);
141+
this.SetStroke(stroke, thickness, aliased: aliased);
140142
this.canvas.DrawOval(this.Convert(rect), this.paint);
141143
}
142144
}
@@ -151,13 +153,13 @@ public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyC
151153
/// <param name="thickness">The stroke thickness.</param>
152154
/// <param name="dashArray">The dash array.</param>
153155
/// <param name="lineJoin">The line join type.</param>
154-
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
155-
public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased)
156+
public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
156157
{
157158
this.paint.Reset();
158159
{
159160
this.path.Reset();
160161
{
162+
bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
161163
this.SetPath(points, aliased);
162164
this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased);
163165
this.canvas.DrawPath(this.path, this.paint);
@@ -175,10 +177,11 @@ public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double
175177
/// <param name="dashArray">The dash array.</param>
176178
/// <param name="lineJoin">The line join type.</param>
177179
/// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
178-
public override void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased)
180+
public override void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
179181
{
180182
this.paint.Reset();
181183
{
184+
bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
182185
this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased);
183186
this.pts.Clear();
184187
if (aliased)
@@ -212,12 +215,13 @@ public override void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke
212215
/// <param name="dashArray">The dash array.</param>
213216
/// <param name="lineJoin">The line join type.</param>
214217
/// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
215-
public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased)
218+
public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin)
216219
{
217220
this.paint.Reset();
218221
{
219222
this.path.Reset();
220223
{
224+
bool aliased = this.ShouldUseAntiAliasingForLine(erm, points);
221225
this.SetPath(points, aliased);
222226
this.path.Close();
223227

@@ -243,20 +247,27 @@ public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyCo
243247
/// <param name="fill">The fill color.</param>
244248
/// <param name="stroke">The stroke color.</param>
245249
/// <param name="thickness">The stroke thickness.</param>
246-
public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
250+
public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm)
247251
{
248252
this.paint.Reset();
249253
{
254+
bool aliased = this.ShouldUseAntiAliasingForRect(erm);
250255
if (fill.IsVisible())
251256
{
252257
this.SetFill(fill);
253-
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
258+
if (aliased)
259+
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
260+
else
261+
this.canvas.DrawRect(this.Convert(rect.Left), this.Convert(rect.Top), this.Convert(rect.Right), this.Convert(rect.Bottom), this.paint);
254262
}
255263

256264
if (stroke.IsVisible())
257265
{
258-
this.SetStroke(stroke, thickness, aliased: true);
259-
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
266+
this.SetStroke(stroke, thickness, aliased: aliased);
267+
if (aliased)
268+
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
269+
else
270+
this.canvas.DrawRect(this.Convert(rect.Left), this.Convert(rect.Top), this.Convert(rect.Right), this.Convert(rect.Bottom), this.paint);
260271
}
261272
}
262273
}
@@ -366,17 +377,16 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS
366377
/// </summary>
367378
/// <param name="rect">The clip rectangle.</param>
368379
/// <returns>True if the clip rectangle was set.</returns>
369-
public override bool SetClip(OxyRect rect)
380+
protected override void SetClip(OxyRect rect)
370381
{
371382
this.canvas.Save();
372383
this.canvas.ClipRect(this.Convert(rect));
373-
return true;
374384
}
375385

376386
/// <summary>
377387
/// Resets the clip rectangle.
378388
/// </summary>
379-
public override void ResetClip()
389+
protected override void ResetClip()
380390
{
381391
this.canvas.Restore();
382392
}

Source/OxyPlot.Xamarin.Android/OxyPlot.Xamarin.Android.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<PrivateAssets>all</PrivateAssets>
7474
</PackageReference>
7575
<PackageReference Include="OxyPlot.Core">
76-
<Version>2.0.0</Version>
76+
<Version>2.1.0</Version>
7777
</PackageReference>
7878
<PackageReference Include="System.Collections">
7979
<Version>4.3.0</Version>

Source/OxyPlot.Xamarin.Android/PlotView.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,9 @@ protected override void OnDraw(Canvas canvas)
354354
}
355355

356356
this.rc.SetTarget(canvas);
357-
358-
((IPlotModel)actualModel).Render(this.rc, Width / Scale, Height / Scale);
357+
358+
OxyRect rect = new OxyRect(0, 0, Width / Scale, Height / Scale);
359+
((IPlotModel)actualModel).Render(this.rc, rect);
359360
}
360361
}
361362

Source/OxyPlot.Xamarin.Forms.Platform.Android/OxyPlot.Xamarin.Forms.Platform.Android.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<Reference Include="System.Core" />
6060
</ItemGroup>
6161
<ItemGroup>
62-
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
62+
<PackageReference Include="OxyPlot.Core" Version="2.1.0" />
6363
<PackageReference Include="Xamarin.Essentials" Version="1.7.4" />
6464
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2545" />
6565
<PackageReference Include="NuGet.Build.Packaging">
@@ -85,4 +85,4 @@
8585
</ProjectReference>
8686
</ItemGroup>
8787
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
88-
</Project>
88+
</Project>

0 commit comments

Comments
 (0)