Index: Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj
===================================================================
diff -u -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86 -rd494567cc0771ff224e920de98682a901dcfe01a
--- Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
+++ Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -42,6 +42,7 @@
+
Index: Core/Components/src/Core.Components.Charting/Data/ChartMultipleAreaData.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Charting/Data/ChartMultipleAreaData.cs (revision 0)
+++ Core/Components/src/Core.Components.Charting/Data/ChartMultipleAreaData.cs (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -0,0 +1,65 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Charting.Styles;
+
+namespace Core.Components.Charting.Data
+{
+ public class ChartMultipleAreaData : ChartData
+ {
+ public ChartMultipleAreaData(IEnumerable> areas, string name)
+ : base(name)
+ {
+ if (areas == null)
+ {
+ var message = string.Format("A collection of areas is required when creating {0}.", typeof(ChartMultipleAreaData).Name);
+ throw new ArgumentNullException("areas", message);
+ }
+ if (areas.Any(a => a == null))
+ {
+ var message = string.Format("Every area in the collection needs a value when creating {0}.", typeof(ChartMultipleAreaData).Name);
+ throw new ArgumentException(message, "areas");
+ }
+
+ Areas = areas.Select(area => area.ToList()).ToList();
+ IsVisible = true;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the is visible.
+ ///
+ public bool IsVisible { get; set; }
+
+ ///
+ /// Gets the areas that are described by the .
+ ///
+ public IEnumerable> Areas { get; private set; }
+
+ ///
+ /// The style of the .
+ ///
+ public ChartAreaStyle Style { get; set; }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleAreaDataConverter.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleAreaDataConverter.cs (revision 0)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleAreaDataConverter.cs (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -0,0 +1,64 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using Core.Components.OxyPlot.CustomSeries;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Converter
+{
+ ///
+ /// This class converts into .
+ ///
+ public class ChartMultipleAreaDataConverter : ChartDataConverter
+ {
+ protected override IList Convert(ChartMultipleAreaData data)
+ {
+ var series = new MultipleAreaSeries
+ {
+ IsVisible = data.IsVisible,
+ Tag = data
+ };
+
+ foreach (var area in data.Areas)
+ {
+ series.Areas.Add(area.Select(Point2DToDataPoint).ToArray());
+ }
+
+ CreateStyle(series, data.Style);
+
+ return new List { series };
+ }
+
+ private void CreateStyle(MultipleAreaSeries series, ChartAreaStyle style)
+ {
+ if (style != null)
+ {
+ series.Fill = ChartDataHelper.Convert(style.FillColor);
+ series.Color = ChartDataHelper.Convert(style.StrokeColor);
+ series.StrokeThickness = style.Width;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartSeriesFactory.cs
===================================================================
diff -u -r8aa11a9aa48733a5b5b72c58c71674472825b26c -rd494567cc0771ff224e920de98682a901dcfe01a
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartSeriesFactory.cs (.../ChartSeriesFactory.cs) (revision 8aa11a9aa48733a5b5b72c58c71674472825b26c)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartSeriesFactory.cs (.../ChartSeriesFactory.cs) (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -37,6 +37,7 @@
///
private readonly IEnumerable converters = new Collection
{
+ new ChartMultipleAreaDataConverter(),
new ChartAreaDataConverter(),
new ChartLineDataConverter(),
new ChartPointDataConverter(),
Index: Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rd494567cc0771ff224e920de98682a901dcfe01a
--- Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -52,9 +52,11 @@
+
+
Index: Core/Components/src/Core.Components.OxyPlot/CustomSeries/MultipleAreaSeries.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.OxyPlot/CustomSeries/MultipleAreaSeries.cs (revision 0)
+++ Core/Components/src/Core.Components.OxyPlot/CustomSeries/MultipleAreaSeries.cs (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -0,0 +1,146 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using OxyPlot;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.CustomSeries
+{
+ public class MultipleAreaSeries : XYAxisSeries
+ {
+ private readonly OxyColor defaultColor = OxyColors.Fuchsia;
+
+ public List Areas { get; private set; }
+
+ public MultipleAreaSeries()
+ {
+ Areas = new List();
+ Fill = OxyColors.Automatic;
+ Color = OxyColors.Automatic;
+ }
+
+ ///
+ /// Gets or sets the color of the curve.
+ ///
+ /// The color.
+ public OxyColor Color { get; set; }
+
+ ///
+ /// Gets the actual color.
+ ///
+ /// The actual color.
+ public OxyColor ActualColor
+ {
+ get
+ {
+ return Color.GetActualColor(defaultColor);
+ }
+ }
+
+ ///
+ /// Gets or sets the thickness of the curve.
+ ///
+ /// The stroke thickness.
+ public double StrokeThickness { get; set; }
+
+ ///
+ /// Gets or sets the area fill color.
+ ///
+ /// The fill.
+ public OxyColor Fill { get; set; }
+
+ ///
+ /// Gets the actual fill color.
+ ///
+ /// The actual fill.
+ public OxyColor ActualFill
+ {
+ get
+ {
+ return Fill.GetActualColor(defaultColor);
+ }
+ }
+
+ public override void Render(IRenderContext rc)
+ {
+ var areas = Areas;
+ int numberOfAreas = areas.Count;
+ if (numberOfAreas == 0)
+ {
+ return;
+ }
+ if (areas.TrueForAll(a => !a.Any()))
+ {
+ return;
+ }
+
+ VerifyAxes();
+
+ var clippingRect = GetClippingRect();
+ rc.SetClip(clippingRect);
+
+ // Transform all points to screen coordinates
+ foreach (var area in areas)
+ {
+ var n0 = area.Length;
+ IList pts0 = new ScreenPoint[n0];
+ TransformToScreenCoordinates(n0, pts0, area);
+
+ rc.DrawClippedPolygon(clippingRect, pts0, 1, GetSelectableFillColor(ActualFill), ActualColor, StrokeThickness);
+ }
+
+ rc.ResetClip();
+ }
+
+ protected override void UpdateMaxMin()
+ {
+ base.UpdateMaxMin();
+ var allPoints = Areas.SelectMany(a => a).ToArray();
+
+ if (!allPoints.Any())
+ {
+ return;
+ }
+
+ MinX = allPoints.Min(p => p.X);
+ MaxX = allPoints.Max(p => p.X);
+
+ MinY = allPoints.Min(p => p.Y);
+ MaxY = allPoints.Max(p => p.Y);
+
+ XAxis.Include(MinX);
+ XAxis.Include(MaxX);
+
+ YAxis.Include(MinY);
+ YAxis.Include(MaxY);
+ }
+
+ private void TransformToScreenCoordinates(int n0, IList pts0, DataPoint[] actualPoints)
+ {
+ for (int i = 0; i < n0; i++)
+ {
+ pts0[i] = XAxis.Transform(actualPoints[i].X, actualPoints[i].Y, YAxis);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj
===================================================================
diff -u -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86 -rd494567cc0771ff224e920de98682a901dcfe01a
--- Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
+++ Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -51,6 +51,7 @@
+
Index: Core/Components/test/Core.Components.Charting.Test/Data/ChartMultipleAreaDataTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Charting.Test/Data/ChartMultipleAreaDataTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Charting.Test/Data/ChartMultipleAreaDataTest.cs (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -0,0 +1,128 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using Core.Components.Charting.Data;
+using NUnit.Framework;
+
+namespace Core.Components.Charting.Test.Data
+{
+ [TestFixture]
+ public class ChartMultipleAreaDataTest
+ {
+ [Test]
+ public void Constructor_NullAreas_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new ChartMultipleAreaData(null, "test data");
+
+ // Assert
+ var expectedMessage = "A collection of areas is required when creating ChartMultipleAreaData.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ }
+
+ [Test]
+ public void Constructor_NullAreaInAreas_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new ChartMultipleAreaData(new Collection> { null }, "test data");
+
+ // Asserrt
+ var expectedMessage = "Every area in the collection needs a value when creating ChartMultipleAreaData.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ }
+
+ [Test]
+ [TestCase(null)]
+ [TestCase("")]
+ [TestCase(" ")]
+ public void Constructor_InvalidName_ThrowsArgumentException(string invalidName)
+ {
+ // Setup
+ var areas = new Collection>();
+
+ // Call
+ TestDelegate test = () => new ChartMultipleAreaData(areas, invalidName);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "A name must be set to chart data");
+ }
+
+ [Test]
+ public void Constructor_WithEmptyAreas_CreatesNewICharData()
+ {
+ // Setup
+ var areas = new Collection>();
+
+ // Call
+ var data = new ChartMultipleAreaData(areas, "test data");
+
+ // Assert
+ Assert.IsInstanceOf(data);
+ Assert.AreNotSame(areas, data.Areas);
+ Assert.IsTrue(data.IsVisible);
+ }
+
+ [Test]
+ public void Constructor_WithPoints_CreatesNewICharData()
+ {
+ // Setup
+ var areas = CreateTestAreas();
+
+ // Call
+ var data = new ChartMultipleAreaData(areas, "test data");
+
+ // Assert
+ Assert.IsInstanceOf(data);
+ Assert.AreNotSame(areas, data.Areas);
+ for (int i = 0; i < areas.Count; i++)
+ {
+ Assert.AreNotSame(areas[i], data.Areas.ElementAt(i));
+ Assert.AreEqual(areas[i], data.Areas.ElementAt(i));
+ }
+ CollectionAssert.AreEqual(areas, data.Areas);
+ }
+
+ private Collection> CreateTestAreas()
+ {
+ return new Collection>
+ {
+ new Collection
+ {
+ new Point2D(0.0, 1.1),
+ new Point2D(1.0, 2.1),
+ new Point2D(1.6, 1.6)
+ },
+ new Collection
+ {
+ new Point2D(0.4, 1.1),
+ new Point2D(1.6, 2.2),
+ new Point2D(1.2, 4.6)
+
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartMultipleAreaDataConverterTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartMultipleAreaDataConverterTest.cs (revision 0)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartMultipleAreaDataConverterTest.cs (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -0,0 +1,192 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Drawing;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using Core.Components.Charting.TestUtil;
+using Core.Components.OxyPlot.Converter;
+using Core.Components.OxyPlot.CustomSeries;
+using NUnit.Framework;
+using OxyPlot;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Test.Converter
+{
+ [TestFixture]
+ public class ChartMultipleAreaDataConverterTest
+ {
+ [Test]
+ public void DefaultConstructor_IsChartDataConverter()
+ {
+ // Call
+ var converter = new ChartMultipleAreaDataConverter();
+
+ // Assert
+ Assert.IsInstanceOf>(converter);
+ }
+
+ [Test]
+ public void CanConvertSeries_AreaData_ReturnTrue()
+ {
+ // Setup
+ var converter = new ChartMultipleAreaDataConverter();
+ var areaData = new ChartMultipleAreaData(new Collection>(), "test data");
+
+ // Call
+ var canConvert = converter.CanConvertSeries(areaData);
+
+ // Assert
+ Assert.IsTrue(canConvert);
+ }
+
+ [Test]
+ public void CanConvertSeries_ChartData_ReturnsFalse()
+ {
+ // Setup
+ var converter = new ChartMultipleAreaDataConverter();
+ var chartData = new TestChartData();
+
+ // Call
+ var canConvert = converter.CanConvertSeries(chartData);
+
+ // Assert
+ Assert.IsFalse(canConvert);
+ }
+
+ [Test]
+ public void Convert_RandomAreaData_ReturnsNewSeries()
+ {
+ // Setup
+ var converter = new ChartMultipleAreaDataConverter();
+ var random = new Random(21);
+ var randomCount = random.Next(5, 10);
+ var areas = new Collection>();
+ var points = new Collection();
+ areas.Add(points);
+
+ for (int i = 0; i < randomCount; i++)
+ {
+ points.Add(new Point2D(random.NextDouble(), random.NextDouble()));
+ }
+
+ var areaData = new ChartMultipleAreaData(areas, "test data");
+
+ // Call
+ var series = converter.Convert(areaData);
+
+ // Assert
+ Assert.IsInstanceOf>(series);
+ var areaSeries = ((MultipleAreaSeries)series[0]);
+ var expectedData = points.Select(t => new DataPoint(t.X, t.Y)).ToArray();
+ CollectionAssert.AreEqual(expectedData, areaSeries.Areas[0]);
+ }
+
+ [Test]
+ public void Convert_DataNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var testConverter = new ChartMultipleAreaDataConverter();
+
+ // Call
+ TestDelegate test = () => testConverter.Convert(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Convert_DataCannotBeConverted_ThrowsArgumentException()
+ {
+ // Setup
+ var testConverter = new ChartMultipleAreaDataConverter();
+ var testChartData = new TestChartData();
+ var expectedMessage = string.Format("The data of type {0} cannot be converted by this converter.", testChartData.GetType());
+ // Precondition
+ Assert.IsFalse(testConverter.CanConvertSeries(testChartData));
+
+ // Call
+ TestDelegate test = () => testConverter.Convert(testChartData);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ }
+
+ [Test]
+ [TestCase(KnownColor.AliceBlue)]
+ [TestCase(KnownColor.Azure)]
+ [TestCase(KnownColor.Beige)]
+ public void Convert_WithDifferentFillColors_AppliesStyleToSeries(KnownColor color)
+ {
+ // Setup
+ var converter = new ChartMultipleAreaDataConverter();
+ var expectedColor = Color.FromKnownColor(color);
+ var style = new ChartAreaStyle(expectedColor, Color.Red, 3);
+ var data = new ChartMultipleAreaData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var multipleAreaSeries = ((MultipleAreaSeries)series[0]);
+ AssertColors(style.FillColor, multipleAreaSeries.Fill);
+ }
+
+ [Test]
+ [TestCase(KnownColor.AliceBlue)]
+ [TestCase(KnownColor.Azure)]
+ [TestCase(KnownColor.Beige)]
+ public void Convert_WithDifferentStrokeColors_AppliesStyleToSeries(KnownColor color)
+ {
+ // Setup
+ var converter = new ChartMultipleAreaDataConverter();
+ var expectedColor = Color.FromKnownColor(color);
+ var style = new ChartAreaStyle(Color.Red, expectedColor, 3);
+ var data = new ChartMultipleAreaData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var multipleAreaSeries = ((MultipleAreaSeries)series[0]);
+ AssertColors(style.StrokeColor, multipleAreaSeries.Color);
+ }
+
+ [Test]
+ [TestCase(1)]
+ [TestCase(5)]
+ [TestCase(7)]
+ public void Convert_WithDifferentStrokeWidths_AppliesStyleToSeries(int width)
+ {
+ // Setup
+ var converter = new ChartMultipleAreaDataConverter();
+ var style = new ChartAreaStyle(Color.Red, Color.Red, width);
+ var data = new ChartMultipleAreaData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var multipleAreaSeries = ((MultipleAreaSeries)series[0]);
+ Assert.AreEqual(width, multipleAreaSeries.StrokeThickness);
+ }
+
+ private void AssertColors(Color color, OxyColor oxyColor)
+ {
+ OxyColor originalColor = OxyColor.FromArgb(color.A, color.R, color.G, color.B);
+ Assert.AreEqual(originalColor, oxyColor);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartSeriesFactoryTest.cs
===================================================================
diff -u -r8ca6a4ce40d75a96784c6ce8839e06e0b11052da -rd494567cc0771ff224e920de98682a901dcfe01a
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartSeriesFactoryTest.cs (.../ChartSeriesFactoryTest.cs) (revision 8ca6a4ce40d75a96784c6ce8839e06e0b11052da)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartSeriesFactoryTest.cs (.../ChartSeriesFactoryTest.cs) (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -27,6 +27,7 @@
using Core.Components.Charting.Data;
using Core.Components.Charting.TestUtil;
using Core.Components.OxyPlot.Converter;
+using Core.Components.OxyPlot.CustomSeries;
using NUnit.Framework;
using OxyPlot;
using OxyPlot.Series;
@@ -53,7 +54,6 @@
var areaSeries = ((AreaSeries)series[0]);
CollectionAssert.AreEqual(expectedData, areaSeries.Points);
CollectionAssert.AreEqual(new Collection{expectedData.First()}, areaSeries.Points2);
- Assert.AreNotSame(expectedData, areaSeries.ItemsSource);
}
[Test]
@@ -95,6 +95,27 @@
}
[Test]
+ public void Create_MultipleAreaData_ReturnsLinesSeriesWithAreaStyle()
+ {
+ // Setup
+ var factory = new ChartSeriesFactory();
+ var testAreaA = CreateTestData();
+ var testAreaB = CreateTestData();
+ var expectedDataA = CreateExpectedData(testAreaA);
+ var expectedDataB = CreateExpectedData(testAreaB);
+
+ // Call
+ IList series = factory.Create(new ChartMultipleAreaData(new [] { testAreaA, testAreaB }, "test data"));
+
+ // Assert
+ Assert.AreEqual(1, series.Count);
+ Assert.IsInstanceOf>(series);
+ var multipleAreaSeries = ((MultipleAreaSeries)series[0]);
+ CollectionAssert.AreEqual(expectedDataA, multipleAreaSeries.Areas[0]);
+ CollectionAssert.AreEqual(expectedDataB, multipleAreaSeries.Areas[1]);
+ }
+
+ [Test]
public void Create_OtherData_ThrowsNotSupportedException()
{
// Setup
Index: Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rd494567cc0771ff224e920de98682a901dcfe01a
--- Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -46,6 +46,9 @@
False..\..\..\..\packages\OxyPlot.Core.1.0.0-unstable1953\lib\net40\OxyPlot.dll
+
+ ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll
+
@@ -56,7 +59,9 @@
+
+
Index: Core/Components/test/Core.Components.OxyPlot.Test/CustomSeries/MultipleAreaSeriesTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.OxyPlot.Test/CustomSeries/MultipleAreaSeriesTest.cs (revision 0)
+++ Core/Components/test/Core.Components.OxyPlot.Test/CustomSeries/MultipleAreaSeriesTest.cs (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -0,0 +1,172 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Components.OxyPlot.CustomSeries;
+using NUnit.Framework;
+using OxyPlot;
+using Rhino.Mocks;
+
+namespace Core.Components.OxyPlot.Test.CustomSeries
+{
+ public class MultipleAreaSeriesTest
+ {
+ [Test]
+ public void DefaultConstructor_RetunsDefaultValues()
+ {
+ // Call
+ var series = new MultipleAreaSeries();
+
+ // Assert
+ Assert.AreEqual(OxyColors.Automatic, series.Fill);
+ Assert.AreEqual(OxyColors.Fuchsia, series.ActualFill);
+ Assert.AreEqual(OxyColors.Automatic, series.Color);
+ Assert.AreEqual(OxyColors.Fuchsia, series.ActualColor);
+ Assert.AreEqual(0, series.StrokeThickness);
+ Assert.IsEmpty(series.Areas);
+ }
+
+ [Test]
+ public void Render_NoAreas_NoCallForRenderArea()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ IRenderContext renderContext = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var series = new MultipleAreaSeries();
+
+ // Call
+ series.Render(renderContext);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Render_EmptyAreas_NoCallForRenderArea()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ IRenderContext renderContext = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var series = new MultipleAreaSeries
+ {
+ Areas =
+ {
+ new DataPoint[0],
+ new DataPoint[0],
+ new DataPoint[0]
+ }
+ };
+
+ // Call
+ series.Render(renderContext);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Render_NonEmptyArea_RendersThePoints()
+ {
+ // Setup
+ var random = new Random(21);
+ var pointCount = random.Next(5, 455);
+ var series = new MultipleAreaSeries();
+ var model = new PlotModel();
+ model.Series.Add(series);
+
+ var mocks = new MockRepository();
+ var renderContext = mocks.Stub();
+ renderContext.Stub(rc => rc.SetClip(OxyRect.Create(0, 0, 0, 0))).Return(true);
+ renderContext.Stub(rc => rc.ResetClip());
+ renderContext.Expect(rc => rc.DrawPolygon(
+ Arg.Matches(sp => sp.Length == pointCount),
+ Arg.Is.Equal(series.ActualFill),
+ Arg.Is.Equal(series.ActualColor),
+ Arg.Is.Equal(series.StrokeThickness),
+ Arg.Is.Anything,
+ Arg.Is.Anything,
+ Arg.Is.Anything));
+
+ mocks.ReplayAll();
+ var area = new DataPoint[pointCount];
+ series.Areas.Add(area);
+
+ for (var i = 0; i < pointCount; i++)
+ {
+ area[i] = new DataPoint(random.Next(-50,50), random.Next(-50,50));
+ }
+
+ ((IPlotModel)model).Update(false);
+
+ // Call
+ series.Render(renderContext);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Render_MultipleNonEmptyArea_RendersTheAreas()
+ {
+ // Setup
+ var random = new Random(21);
+ var areaCount = random.Next(5, 455);
+ var series = new MultipleAreaSeries();
+ var model = new PlotModel();
+ model.Series.Add(series);
+
+ var mocks = new MockRepository();
+ var renderContext = mocks.Stub();
+ renderContext.Stub(rc => rc.SetClip(OxyRect.Create(0, 0, 0, 0))).Return(true);
+ renderContext.Stub(rc => rc.ResetClip());
+ renderContext.Expect(rc => rc.DrawPolygon(
+ Arg.Matches(sp => sp.Length > 0),
+ Arg.Is.Equal(series.ActualFill),
+ Arg.Is.Equal(series.ActualColor),
+ Arg.Is.Equal(series.StrokeThickness),
+ Arg.Is.Anything,
+ Arg.Is.Anything,
+ Arg.Is.Anything)).Repeat.Times(areaCount);
+
+ mocks.ReplayAll();
+
+ for (var i = 0; i < areaCount; i++)
+ {
+ series.Areas.Add(new []
+ {
+ new DataPoint(random.Next(-50, 50), random.Next(-50, 50))
+ });
+ }
+
+ ((IPlotModel)model).Update(false);
+
+ // Call
+ series.Render(renderContext);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartLegendView.cs
===================================================================
diff -u -r170ec8698dfed095e23f4fa822fe2198b3e5f242 -rd494567cc0771ff224e920de98682a901dcfe01a
--- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartLegendView.cs (.../ChartLegendView.cs) (revision 170ec8698dfed095e23f4fa822fe2198b3e5f242)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartLegendView.cs (.../ChartLegendView.cs) (revision d494567cc0771ff224e920de98682a901dcfe01a)
@@ -108,11 +108,22 @@
OnNodeChecked = PointBasedChartDataOnNodeChecked
});
+ treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
+ {
+ Text = multipleAreaData => multipleAreaData.Name,
+ Image = multipleAreaData => OxyPlotResources.AreaIcon,
+ CanDrag = (multipleAreaData, parentData) => true,
+ CanCheck = multipleAreaData => true,
+ IsChecked = multipleAreaData => multipleAreaData.IsVisible,
+ OnNodeChecked = ChartMultipleAreaDataOnNodeChecked
+ });
+
treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
{
Text = chartControl => chartControl.Name,
Image = chartControl => GuiResources.folder,
ChildNodeObjects = chartControl => chartControl.List.Reverse().Cast